AArch64 generates incorrect code for some immediate values
Original Reporter info from Mantis: CuriousKit @CuriousKit
-
Reporter name: J. Gareth Moreton
Original Reporter info from Mantis: CuriousKit @CuriousKit
- Reporter name: J. Gareth Moreton
Description:
So I've been looking at improving some of the Arm-64 code generated when assigning values to variables, and I was a bit shocked to discover that a number of said assignments produce incorrect code, usually changing the immediate value to -1.
Steps to reproduce:
Write and run the following program:
program BadValue;
begin
WriteLn($FFFFFFFBFFFFFFFF)
end.
Observe output to be -1, and the generated assembly language for the actual parameter to be something like "movn x2, #0x0, lsl 32" (this is meant to write something to the 33nd to 48th bits, but just writes all zeroes then inverts the entire register, producing $FFFFFFFFFFFFFFFF = -1)
Additional information:
I have fixed the bug and made a comprehensive test, but am waiting on the test suite to finish running. However, my fix is embedded among my general improvements to MOV commands.
This bug is present in FPC 3.0.4 and the trunk.