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

--- Comment #1 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
A related test that is miscompiled at -O{s,2,3}, but not -O1.  

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

[560] % 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/15.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 15.0.0 20241102 (experimental) (GCC) 
[561] % 
[561] % gcctk -O1 small.c; ./a.out
[562] % 
[562] % gcctk -O3 small.c
[563] % ./a.out
Aborted
[564] % 
[564] % cat small.c
int a;
int main() {
  int b = -(1 | -(a < 1));
  int c = (~b & 2) / 2;
  if (b != 1)
    __builtin_abort();
  return 0;
}

Reply via email to