-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[ARM32][compiler-rt] movle Condition Fails After __aeabi_cdcmple Due to Inconsistent CPSR Flags Across libgcc/libunwind #134663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The "Z" and "C" values are consistent between clang and gcc. The ABI rules say the the other values you're printing are arbitrary, including the other flags and r0-r3. (https://github.com/ARM-software/abi-aa/blob/main/rtabi32/rtabi32.rst#the-floating-point-helper-functions). Not sure what you're expecting. |
Thank you for your reply. From the assembly code of LuaJIT, it uses the __aeabi_cdcmple call to determine whether the movle instruction’s condition is satisfied. The condition code for movle is Z=1 || (N≠V). While both libgcc and libunwind implementations return the same Z flag value, they differ in the N (Negative) and V (Overflow) flags. N≠V implies either: Here is the dasc file link: https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/vm_arm.dasc#L1705 and its disassembly code:
|
The ABI is specified in a way that they expect you to use unsigned comparisons (e.g. movls). So the LuaJIT code is depending on behavior that isn't specified. Code using routines specified in the ABI should respect the rules in the ABI document. Currently compiler-rt always sets the N and V bits to 0. It might be possible to change the compiler-rt code so that signed comparisons "work", I guess, since it's not specified in the first place. Not sure. (Ignore the bit about r0-r3; there's a specific carveout for the 3-way compares I missed my first time scanning through the spec.) |
Yes
because movpl is depanding on N == V, behavior also isn't specified. movhi condition code is C=1 && Z=0, it meets expectations ; ) |
Luajit fixed at LuaJIT/LuaJIT@51d4c26 |
Hi, I compiled the Luajit with clang, and found the __aeabi_cdcmple fails to set CPSR Flags correctly for movle insn.
https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/vm_arm.dasc#L1705
gcc with libgcc:
After movle:
r0 = 0x00000000, r1 = 0x40000000
Flags: N=1, Z=0, C=0, V=0
clang with compiler-rt:
After movle:
r0 = 0x00000000, r1 = 0xBFF00000
Flags: N=0, Z=0, C=0, V=0
Is this a compatibility issue between Clang and GCC?
The text was updated successfully, but these errors were encountered: