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

            Bug ID: 126047
           Summary: Possible Missed Optimization at O3
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: apowenq at gmail dot com
  Target Milestone: ---

cat prog.c
int src(int v0_u8, int v2_u8) {
  if (!((72 <= v0_u8) && (v0_u8 <= 162))) __builtin_unreachable();
  if (!((128 <= v2_u8) && (v2_u8 <= 129))) __builtin_unreachable();
  int i0_u8 = v0_u8 | v2_u8;
  int i1_u8 = i0_u8 / v2_u8;
  return i1_u8;
}

GCC truck at O3 cannot optimize the C program (not a regression), but Clang
truck at O3 can.
Reproducer: https://godbolt.org/z/d3vd5EnKo

GCC at O3:
"src":
        mov     eax, edi
        or      eax, esi
        cdq
        idiv    esi
        ret

LLVM at O3:
src:
        mov     eax, 1
        ret

Reply via email to