Samuel F Antao
2014-Sep-10 23:11 UTC
[LLVMdev] [PATCH] Fix FastISel bug in boolean returns for PowerPC
Hi all, For PPC targets, FastISel does not take the sign extension information into account when selecting return instructions whose operands are constants. A consequence of this is that the return of boolean values is not correct. E.g. the following program would (erroneously) return 0: bool T(){ return true; } bool F(){ return !T(); } inr main(){ if(F()) return 0; else return 1; } The reason the output of this program is wrong is that ‘true’ sign is sign to 64-bit (0xfff..fff) and the negation only flips the least significant bit. This code pattern is used in some Clang’s unit tests, and this is the reason they are failing for PowerPC when building clang with the latest clang. This patches fixes the problem by evaluating the sign extension information also for constants, forwarding this information to PPCMaterializeInt which takes this information to drive the sign extension during the materialization. The modified files are the following: lib/Target/PowerPC/PPCFastISel.cpp test/CodeGen/PowerPC/fast-isel-ret.ll Thanks, Sam (See attached file: llvm_fsel_ret.patch) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/f78c7388/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm_fsel_ret.patch Type: application/octet-stream Size: 4336 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140910/f78c7388/attachment.obj>