Răsfoiți Sursa

* SubLea2Lea has to check both times for equal super registers, resolves the second part of #41126

florian 6 luni în urmă
părinte
comite
125da5f10a
2 a modificat fișierele cu 41 adăugiri și 2 ștergeri
  1. 2 2
      compiler/x86/aoptx86.pas
  2. 39 0
      tests/webtbs/tw41126.pp

+ 2 - 2
compiler/x86/aoptx86.pas

@@ -7174,9 +7174,9 @@ unit aoptx86;
               begin
                 OldOffset := taicpu(hp1).oper[0]^.ref^.offset;
 
-                if ActiveReg=taicpu(hp1).oper[0]^.ref^.base then
+                if SuperRegistersEqual(ActiveReg,taicpu(hp1).oper[0]^.ref^.base) then
                   Dec(taicpu(hp1).oper[0]^.ref^.offset,taicpu(p).oper[0]^.val);
-                if ActiveReg=taicpu(hp1).oper[0]^.ref^.index then
+                if SuperRegistersEqual(ActiveReg,taicpu(hp1).oper[0]^.ref^.index) then
                   Dec(taicpu(hp1).oper[0]^.ref^.offset,taicpu(p).oper[0]^.val*max(taicpu(hp1).oper[0]^.ref^.scalefactor,1));
 
 {$ifdef x86_64}

+ 39 - 0
tests/webtbs/tw41126.pp

@@ -0,0 +1,39 @@
+{ %opt=-O3 }
+program project2;
+
+{$mode delphi}
+
+{$OPTIMIZATION DFA}
+{$OPTIMIZATION FORLOOP}
+
+type
+  TRec = record
+    EntryCount : sizeuint; { see TInterfaceTable.EntryCount }
+  end;
+  PRec = ^TRec;
+
+const
+  ANYCONST = 2;
+
+function TestLoopUnsigned(Rec: PRec): Integer;
+var
+  i: Integer;
+begin
+  Result := 0;
+  for i := 0 to Rec^.EntryCount - ANYCONST do
+    Inc(Result);
+end;
+
+var
+  Rec: TRec;
+  N: SizeInt;
+begin
+  Rec.EntryCount := ANYCONST;
+  N := TestLoopUnsigned(@Rec);
+  if N <> 1 then
+  begin
+    WriteLn('ERROR! N=', N);
+    Halt(1);
+  end;
+  WriteLn('OK');
+end.