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

Zhendong Su <zhendong.su at inf dot ethz.ch> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|wrong code at -O{2,3} with  |wrong code at -O{2,3} with
                   |"on x86_64-linux-gnu        |"-fno-inline
                   |                            |-fno-compare-elim" on
                   |                            |x86_64-linux-gnu

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Compiler Explorer: https://godbolt.org/z/dME5cfY6c

Note:
- fails: 16.1 and trunk
- works: 15.2 and earlier

[512] % 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/17.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 17.0.0 20260518 (experimental) (GCC) 
[513] % 
[513] % gcctk -O2 small.c; ./a.out
[514] % gcctk -O2 -fno-inline -fno-compare-elim small.c
[515] % ./a.out
Aborted
[516] % cat small.c
int a, c = 1;
short b = 1, e;
volatile unsigned short d;
static int f() {
  unsigned g = 2;
  if (c >= a)
    if ((c || b) && b) {
      unsigned h = c && d;
      int i = e = d;
      if (d)
        i = d = 0;
      g = c ^ g * i;
      c = ~c;
      b = b * (g | 9) & ((1 && a) - i);
      h && i && d;
      a = c ^ e ^ (g && a) * h;
      d = e;
      if (a)
        return g;
    }
}
int main() {
  if (f() != 1)
    __builtin_abort();
  return 0;
}

Reply via email to