https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93123
Bug ID: 93123 Summary: Lacking basic optimization around __int128 bitwise operations against constants Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jens.seifert at de dot ibm.com Target Milestone: --- unsigned __int128 and128WithConst(unsigned __int128 a) { unsigned __int128 c128 = (((unsigned __int128)(~0ULL)) << 64) | ((unsigned __int128)(~0xFULL)); return a & c128; } gcc -O2 -maix64 -save-temps int128.C Output: ._Z12andWithConsto: LFB..0: li 10,-1 li 11,-16 and 3,3,10 and 4,4,11 blr Expected result: Single instruction: rldicr on low part (register 4). Bitwise and with 0xFF..FF is a no-op. Bitwise and with 0xFF..F0 can be done using rldicr.