i386 record field access wrong Peephole Optimization
Original Reporter info from Mantis: ajax16384
-
Reporter name:
Original Reporter info from Mantis: ajax16384
- Reporter name:
Description:
3.3.1 for i386 introduces wrong Peephole Optimization
TPack1 = record
P1: Cardinal;
P2: Integer;
end;
function IsZero2(const aVal: TPack1): Boolean;
begin
Result := (0 = aVal.P1)
and (0 = aVal.P2); // Hint: Mixing signed expressions and longwords gives a 64bit result
end;
.section .text.n_p$fpc_bug_$$_iszero2$tpack1$$boolean,"ax" .balign 16,0x90 .globl P$FPC_BUG_$$_ISZERO2$TPACK1$$BOOLEAN P$FPC_BUG_$$_ISZERO2$TPACK1$$BOOLEAN: # [26] begin pushl %ebx # Var aVal located in register eax # [27] Result := (0 = aVal.P1) movl (%eax),%ebx xorl %ecx,%ecx # [28] and (0 = aVal.P2); movl 4(%eax),%eax # Peephole Optimization: MovSar2Cltd cltd orl %eax,%ebx orl %edx,%ecx jne .Lj8 testl %ebx,%ebx jne .Lj8 # Var $result located in register al movb $1,%al jmp .Lj9 .Lj8: xorb %al,%al .Lj9: # [29] end; popl %ebx
ret
Steps to reproduce:
bin\i386-win32\fpc.exe -vh -al fpc_bug.dpr
Mantis conversion info:
- Mantis ID: 38066
- Build: 3.3.1 [20201110] for i386
- Platform: windows
- Version: 3.3.1
- Fixed in version: 3.3.1
- Fixed in revision: 47423 (#98eab07a)