mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-25 16:29:20 +02:00
* x86: Fixed bug in "LeaLea2Lea 2" optimisation where final offset was calculated incorrectly
This commit is contained in:
parent
9382070454
commit
44cda17674
@ -6065,24 +6065,23 @@ unit aoptx86;
|
||||
taicpu(hp1).oper[0]^.ref^.base := TempReg;
|
||||
end;
|
||||
|
||||
if (taicpu(hp1).oper[0]^.ref^.base <> taicpu(p).oper[1]^.reg) then
|
||||
begin
|
||||
{ Just to prevent miscalculations }
|
||||
if (taicpu(hp1).oper[0]^.ref^.scalefactor = 0) then
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(p).oper[0]^.ref^.scalefactor
|
||||
else
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(hp1).oper[0]^.ref^.scalefactor * max(taicpu(p).oper[0]^.ref^.scalefactor, 1);
|
||||
end
|
||||
else
|
||||
{ Change lea (reg,reg) to lea(,reg,2) }
|
||||
if (taicpu(hp1).oper[0]^.ref^.base = taicpu(p).oper[1]^.reg) then
|
||||
begin
|
||||
taicpu(hp1).oper[0]^.ref^.base := NR_NO;
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(p).oper[0]^.ref^.scalefactor * 2;
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := 2;
|
||||
end;
|
||||
|
||||
if (taicpu(p).oper[0]^.ref^.offset <> 0) then
|
||||
Inc(taicpu(hp1).oper[0]^.ref^.offset, taicpu(p).oper[0]^.ref^.offset * max(taicpu(p).oper[0]^.ref^.scalefactor, 1));
|
||||
Inc(taicpu(hp1).oper[0]^.ref^.offset, taicpu(p).oper[0]^.ref^.offset * max(taicpu(hp1).oper[0]^.ref^.scalefactor, 1));
|
||||
taicpu(hp1).oper[0]^.ref^.index := taicpu(p).oper[0]^.ref^.index;
|
||||
|
||||
{ Just to prevent miscalculations }
|
||||
if (taicpu(hp1).oper[0]^.ref^.scalefactor = 0) then
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(p).oper[0]^.ref^.scalefactor
|
||||
else
|
||||
taicpu(hp1).oper[0]^.ref^.scalefactor := taicpu(hp1).oper[0]^.ref^.scalefactor * max(taicpu(p).oper[0]^.ref^.scalefactor, 1);
|
||||
|
||||
{ Only remove the first LEA if we don't need the intermediate register's value as is }
|
||||
if IntermediateRegDiscarded then
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user