[Bug tree-optimization/107273] wrong code at -O3 on x86_64-linux-gnu

zhendong.su at inf dot ethz.ch gcc-bugzilla@gcc.gnu.org
Sat Oct 15 21:00:31 GMT 2022


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

--- Comment #2 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
Another likely related instance that is miscompiled at -O1 and above.

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

[570] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.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
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20221015 (experimental) [master r13-3311-gbaeec7cc83b] (GCC) 
[571] % 
[571] % gcctk -O0 small.c; ./a.out
[572] % 
[572] % gcctk -O1 small.c
[573] % timeout -s 9 5 ./a.out
Killed
[574] % cat small.c
int a = 1, b, c;
int main() {
  unsigned d = 1;
  char e = 1, f = 150;
  if (f > 0)
    goto L2;
 L1:
  d = -(d << a || f);
  if (a)
  L2:
    f = ~e;
  char i = 1 ^ d;
  if (b) {
    e = d | c;
    goto L2;
  }
  if (a < 1)
    goto L1;
  while (!d)
    ;
  return 0;
}


More information about the Gcc-bugs mailing list