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

            Bug ID: 123079
           Summary: wrong code at -O{2,3} with "-fno-tree-fre
                    -fselective-scheduling -fno-tree-dce
                    -fno-tree-tail-merge -fschedule-insns -fno-ssa-phiopt"
                    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/n1bz3brEe

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


[614] % 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 20251209 (experimental) (GCC) 
[615] % 
[615] % gcctk -O3 small.c; ./a.out
1
[616] % gcctk -O3 -fno-tree-fre -fselective-scheduling -fno-tree-dce
-fno-tree-tail-merge -fschedule-insns -fno-ssa-phiopt small.c
[617] % ./a.out
0
[618] % cat small.c
int printf(const char *, ...);
int a, b, c;
char d, e;
static int f() {
  if (!b)
    goto g;
  for (; e; e++) {
  g:
    for (; d >= 0; d--)
      a = d != ++c || c;
  }
  return 0;
}
int main() {
  f();
  printf("%d\n", a);
  return 0;
}

Reply via email to