Browse Source

* another patch to fix #40223

florian 2 years ago
parent
commit
e40f997a40
2 changed files with 17 additions and 0 deletions
  1. 1 0
      compiler/x86/aoptx86.pas
  2. 16 0
      tests/webtbs/tw40223.pp

+ 1 - 0
compiler/x86/aoptx86.pas

@@ -6068,6 +6068,7 @@ unit aoptx86;
                       (
                         (
                           (taicpu(hp1).oper[0]^.ref^.index = taicpu(p).oper[1]^.reg) and
+                          (getsupreg(taicpu(p).oper[0]^.ref^.base)<>RS_ESP) and
                           (taicpu(p).oper[0]^.ref^.index = NR_NO)
                         ) or (
                           (taicpu(hp1).oper[0]^.ref^.base = taicpu(p).oper[1]^.reg) and

+ 16 - 0
tests/webtbs/tw40223.pp

@@ -1,6 +1,22 @@
 { %opt=-O2 }
 { %norun }
+
+procedure Analyze(buf: pByte);
+var
+	i: SizeInt;
+begin
+	for i := 0 to 9 do write(buf[i], ' ');
+end;
+
 procedure DoSomething(index, cellSize: SizeUint);
+var
+	buf: array[0 .. 127] of byte;
+begin
+	(pByte(buf) + index * cellSize)^ := 5;
+	Analyze(buf);
+end;
+
+procedure DoSomething2(index, cellSize: SizeUint);
 var
 	buf: array[0 .. 127] of byte;
 begin