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

            Bug ID: 121686
           Summary: wrong code at -O3 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/h3GGe5fM4

Note:
- works: 15.2 and earlier
- fails: trunk
- -fno-tree-slsr and -fno-ivopts do not make it disappear

[555] % 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 20250826 (experimental) (GCC) 
[556] % 
[556] % gcctk -O2 small.c; ./a.out
[557] % gcctk -O3 small.c
[558] % ./a.out
Aborted
[559] % cat small.c
char a, b, c, f;
int d, e, g, h;
int main() {
  int j, k;
  char m;
  while (f < 4) {
    k = b = 3;
    for (; b >= 0; b--) {
      j = a < 0 ? a : a >> h;
      g = k;
      e = j;
      k = 0;
      while (1) {
        if (j)
          break;
        k = f == 0;
        break;
      }
    }
    m = g * 87;
    if (m < 70)
      __builtin_abort();
    return 0;
  }
}

Reply via email to