[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(){
return 0;
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:




(See attached file: llvm_fsel_ret.patch)

llvm_fsel_ret.patch (4.23 KB)