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

            Bug ID: 120488
           Summary: wrong code at -O1 and above on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/WhvvdbbfE

It affects 12.* and later, and is a regression from 11.*. 

[524] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20250530 (experimental) (GCC) 
[525] % 
[525] % gcctk -O1 small.c
[526] % ./a.out
Aborted
[527] % cat small.c
int a, ac, b, c;
int d(int e) {
  do {
    a = -999 * c - 999 * e - 483647;
    if (-a - 4 >= 0 || -999 * e + c - 2147483367)
      ac = e = -2147483647;
  } while (b * a);
  return ac;
}
int main() {
  if (d(-2149633))
    __builtin_abort();
}

Reply via email to