mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-02 05:34:01 +02:00
* x86: PostPeepholeOptMov attempts to convert mov $0,%reg to
xor %reg,%reg and mov $-1,%reg to or $-1,%reg under -Os even if the flags are in use by looking ahead.
This commit is contained in:
parent
63879e74cd
commit
1f178d381f
@ -15249,6 +15249,7 @@ unit aoptx86;
|
|||||||
function TX86AsmOptimizer.PostPeepholeOptMov(var p : tai) : Boolean;
|
function TX86AsmOptimizer.PostPeepholeOptMov(var p : tai) : Boolean;
|
||||||
var
|
var
|
||||||
Value, RegName: string;
|
Value, RegName: string;
|
||||||
|
hp1: tai;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
if (taicpu(p).oper[1]^.typ = top_reg) and (taicpu(p).oper[0]^.typ = top_const) then
|
if (taicpu(p).oper[1]^.typ = top_reg) and (taicpu(p).oper[0]^.typ = top_const) then
|
||||||
@ -15257,7 +15258,12 @@ unit aoptx86;
|
|||||||
case taicpu(p).oper[0]^.val of
|
case taicpu(p).oper[0]^.val of
|
||||||
0:
|
0:
|
||||||
{ Don't make this optimisation if the CPU flags are required, since XOR scrambles them }
|
{ Don't make this optimisation if the CPU flags are required, since XOR scrambles them }
|
||||||
if not (RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
if not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs) or
|
||||||
|
(
|
||||||
|
{ See if we can still convert the instruction }
|
||||||
|
GetNextInstructionUsingReg(p, hp1, NR_DEFAULTFLAGS) and
|
||||||
|
RegLoadedWithNewValue(NR_DEFAULTFLAGS, hp1)
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
{ change "mov $0,%reg" into "xor %reg,%reg" }
|
{ change "mov $0,%reg" into "xor %reg,%reg" }
|
||||||
taicpu(p).opcode := A_XOR;
|
taicpu(p).opcode := A_XOR;
|
||||||
@ -15302,7 +15308,14 @@ unit aoptx86;
|
|||||||
{ Don't make this optimisation if the CPU flags are required, since OR scrambles them }
|
{ Don't make this optimisation if the CPU flags are required, since OR scrambles them }
|
||||||
if (cs_opt_size in current_settings.optimizerswitches) and
|
if (cs_opt_size in current_settings.optimizerswitches) and
|
||||||
(taicpu(p).opsize <> S_B) and
|
(taicpu(p).opsize <> S_B) and
|
||||||
not (RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs)) then
|
(
|
||||||
|
not RegInUsedRegs(NR_DEFAULTFLAGS,UsedRegs) or
|
||||||
|
(
|
||||||
|
{ See if we can still convert the instruction }
|
||||||
|
GetNextInstructionUsingReg(p, hp1, NR_DEFAULTFLAGS) and
|
||||||
|
RegLoadedWithNewValue(NR_DEFAULTFLAGS, hp1)
|
||||||
|
)
|
||||||
|
) then
|
||||||
begin
|
begin
|
||||||
{ change "mov $-1,%reg" into "or $-1,%reg" }
|
{ change "mov $-1,%reg" into "or $-1,%reg" }
|
||||||
{ NOTES:
|
{ NOTES:
|
||||||
|
Loading…
Reference in New Issue
Block a user