* don't do MovOpMov2MovOp optimization reducing bit width of the operation if symbols are involved, resolves #40269

This commit is contained in:
florian 2025-04-15 16:30:09 +02:00
parent 835375e7e0
commit 7afde9fe77
2 changed files with 13 additions and 0 deletions

View File

@ -5266,6 +5266,10 @@ unit aoptx86;
((topsize2memsize[taicpu(hp1).opsize]<= topsize2memsize[taicpu(hp2).opsize]) or
{ opsize matters for these opcodes, we could probably work around this, but it is not worth the effort }
((taicpu(hp1).opcode<>A_SHL) and (taicpu(hp1).opcode<>A_SHR) and (taicpu(hp1).opcode<>A_SAR))
) and
{ if ref contains a symbol, we cannot change its size to a smaller size }
((taicpu(p).oper[0]^.typ<>top_ref) or (taicpu(p).oper[0]^.ref^.symbol=nil) or
(topsize2memsize[taicpu(p).opsize]<=topsize2memsize[taicpu(hp2).opsize])
)
{$ifdef i386}
{ byte registers of esi, edi, ebp, esp are not available on i386 }

9
tests/webtbs/tw40269.pp Normal file
View File

@ -0,0 +1,9 @@
{ %opt=-O2 }
var
a, b: int32;
x, y: byte;
begin
x := PtrUint(@a) mod 32;
y := PtrUint(@b) mod 32;
writeln(x, ' ', y);
end.