https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110362

            Bug ID: 110362
           Summary: Range information on lower bytes of __uint128_t
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: antoshkka at gmail dot com
  Target Milestone: ---

Consider the following example:

int test (__uint128_t a, __uint128_t b) {
  __uint128_t __a = b | (a << 32);
  return __a & 0xffffffff;
}

At the moment GCC-14 with -O2 generates the following assembly:

test(unsigned __int128, unsigned __int128):
        mov     rsi, rdi
        mov     rax, rdx
        sal     rsi, 32
        or      rax, rsi
        ret


Which could be simplified to just:

test(unsigned __int128, unsigned __int128):
        mov     rax, rdx
        ret

Godbolt playground: https://godbolt.org/z/K9x5vnhxq

Reply via email to