Testcase: int f1(int a, int b) { return a == b; } ------ We produce right now: _f1: xor r4,r3,r4 cntlzw r4,r4 <--- sign never 1 srwi r4,r4,5 <--- upper bits defined as 0 extsw r3,r4 blr
The sign extend is incorrect as r4's sign will never be 1 and all the upper bits will always be zero because of srwi. we have the same issue if the return value is unsigned int also in that there is an extra zero extend. This is even with -fsee. -- Summary: Extra sign/zero extend with word comparison result Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: pinskia at gcc dot gnu dot org GCC target triplet: powerpc64-apple-darwin http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30967