mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 10:09:19 +02:00
* x86: Fixed mistake in var9 optimisation under -Os; "andl $255,%eax" is not
smaller than "movzbl %al,%eax" because the immediate is sign-extended, not zero-extended, so $255 will be stored as a 32-bit value.
This commit is contained in:
parent
87044c004f
commit
dbd8259c48
@ -12290,16 +12290,9 @@ unit aoptx86;
|
||||
end;
|
||||
{$ifndef i8086} { movzbl %al,%eax cannot be encoded in 16-bit mode (the machine code is equivalent to movzbw %al,%ax }
|
||||
S_BL:
|
||||
if not IsMOVZXAcceptable then
|
||||
begin
|
||||
if (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
|
||||
(
|
||||
not IsMOVZXAcceptable
|
||||
{ and $0xff,%eax has a smaller encoding but risks a partial write penalty }
|
||||
or (
|
||||
(cs_opt_size in current_settings.optimizerswitches) and
|
||||
(taicpu(p).oper[1]^.reg = NR_EAX)
|
||||
)
|
||||
) then
|
||||
if (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) then
|
||||
{ Change "movzbl %al, %eax" to "andl $0x0ffh, %eax" }
|
||||
begin
|
||||
DebugMsg(SPeepholeOptimization + 'var9',p);
|
||||
@ -12308,8 +12301,7 @@ unit aoptx86;
|
||||
taicpu(p).loadConst(0,$ff);
|
||||
Result := True;
|
||||
end
|
||||
else if not IsMOVZXAcceptable and
|
||||
GetNextInstruction(p, hp1) and
|
||||
else if GetNextInstruction(p, hp1) and
|
||||
(tai(hp1).typ = ait_instruction) and
|
||||
(taicpu(hp1).opcode = A_AND) and
|
||||
MatchOpType(taicpu(hp1),top_const,top_reg) and
|
||||
|
Loading…
Reference in New Issue
Block a user