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

            Bug ID: 107172
           Summary: wrong code with "-O1 -ftree-vrp" 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: ---

This seems to be a recent regression.

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

[596] % 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 20221006 (experimental) [master r13-3101-g966010b2eb4] (GCC) 
[597] % 
[597] % gcctk -O1 small.c; ./a.out
[598] % 
[598] % gcctk -O1 -ftree-vrp small.c
[599] % ./a.out
Segmentation fault
[600] % 
[600] % cat small.c
int a, *b, c, d;
int main() {
  long e = 1;
  int f = a = 1;
 L1:
  if (a)
    a = 2;
  int h = e = ~e;
  c = -1;
  if (e >= a)
    goto L2;
  if (c > a)
    goto L1;
  if (a)
    f = -1;
 L2:
  d = (-f + d) & h;
  if (d)
    (*b)++;
  return 0;
}

Reply via email to