| Issue |
179119
|
| Summary |
Miscompilation when using 32-bit ucmp on 64-bit PowerPC #178979
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
SiliconA-Z
|
Rust team found an issue when compiling one of their packages where their sort function broke entirely.
Now, after reading the backtrace, and studying the assembler, and running tests, I realized that there was a mistake due to the quirks of 64-bit PowerPC and an incorrect assumption I made about the backend.
You see: PowerPC on 64 bits in the backend, i32 appears to be legal because i guess one of the instructions can check the bottom 32 bits, but there are no 32 bit subregisters. Now, while we can definitely deal with that as an issue after talking with maintainers another time, for now what matters is that because of how this lowering of ucmp relies on the carry register, which unlike ARM64, you cannot use subregisters directly. It has to be manually cleared. So:
; CHECK-NEXT: subc 6, 4, 3
; CHECK-NEXT: sub 5, 3, 4
; CHECK-NEXT: subfe 3, 4, 3
; CHECK-NEXT: subfe 3, 3, 5
; CHECK-NEXT: blr
works great assuming zeroext to 64 bits, but nope. It is 32 bits.
While I can definitely look into alternative ways to fix this in the long term, in the short term, to prevent miscompiles when the input is 32 bit, I need to manually clear these bits.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs