https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103743
Bug ID: 103743 Summary: PPC: Inefficient equality compare for large 64-bit constants having only 16-bit relevant bits in high part Product: gcc Version: 8.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: jens.seifert at de dot ibm.com Target Milestone: --- int overflow(); int negOverflow(long long in) { if (in == 0x8000000000000000LL) { return overflow(); } return 0; } Generates: negOverflow(long long): .quad .L.negOverflow(long long),.TOC.@tocbase,0 .L.negOverflow(long long): li 9,-1 rldicr 9,9,0,0 cmpd 0,3,9 beq 0,.L10 li 3,0 blr .L10: mflr 0 std 0,16(1) stdu 1,-112(1) bl overflow() nop addi 1,1,112 ld 0,16(1) mtlr 0 blr .long 0 .byte 0,9,0,1,128,0,0,0 Instead of: li 9,-1 rldicr 9,9,0,0 cmpd 0,3,9 Expected output: rotldi 3,3,1 cmpdi 0,3,1 This should be only applied if constant fits into 16-bit and if those 16-bit are in the first 32-bit.