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

This commit is contained in:
florian 2025-02-03 22:18:35 +01:00
parent 83f9a94503
commit 125da5f10a
2 changed files with 41 additions and 2 deletions
compiler/x86
tests/webtbs

View File

@ -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
tests/webtbs/tw41126.pp Normal file
View File

@ -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.