Browse Source

+ testcse1.pp

Jonas Maebe 25 years ago
parent
commit
c3ac962fd5
2 changed files with 24 additions and 1 deletions
  1. 3 1
      tests/testopt/readme.txt
  2. 21 0
      tests/testopt/testcse1.pp

+ 3 - 1
tests/testopt/readme.txt

@@ -1,4 +1,6 @@
 This directory contains some tests which test the optimizer
 This directory contains some tests which test the optimizer
 Register variables:
 Register variables:
   Enumerations .......................... testreg1.pp
   Enumerations .......................... testreg1.pp
-  Readln ................................ testreg2.pp
+  Readln ................................ testreg2.pp
+Common subexpression elimination (assembler)
+  Multidimensional array index operation. testcse1.pp 

+ 21 - 0
tests/testopt/testcse1.pp

@@ -0,0 +1,21 @@
+procedure t;
+var
+  a: array[1..10,1..10] of string[31];
+  i, j: longint;
+  c: char;
+
+begin
+  i := 5;
+  j := 7;
+  a[i,j] := '123456789';
+  c := '0';
+{ clear the optimizer state }
+  asm
+  end;
+  a[i,j] := a[i,j] + c;
+  writeln(a[i,j]);
+end;
+
+begin
+  t;
+end.