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

            Bug ID: 108584
           Summary: wrong code at -O2 and -O3 with "-fno-tree-ccp" 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: ---

It appears to be a recent regression from 12.2. 

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

[594] % 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.1/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
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230128 (experimental) [master r12-4647-g3f861a5c8fd] (GCC)
[595] %
[595] % gcctk -O3 small.c; ./a.out
[596] %
[596] % gcctk -O3 -fno-tree-ccp small.c
[597] % ./a.out
Floating point exception
[598] %
[598] % cat small.c
char a;
volatile int b;
short c;
void d() {
  int e = 0, f;
  b = 1;
  if (!b)
    goto L;
  unsigned h = 1;
  for (f = 0; f < 2; f++) {
    char i = ~c % h;
    short j = ~(i & e & (0 || a & c));
    h && a;
    if (h < 3)
    L:
      j = h;
    e = c = h = j;
  }
}
int main() {
  d();
  return 0;
}
  • [Bug tree-optimization/108584]... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to