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

            Bug ID: 128658
           Summary: wrong code at -O{2,3} with "-fno-tree-forwprop
                    -fno-tree-vrp -fno-vect-cost-model" on
                    x86_64-linux-gnu
           Product: gcc
           Version: 16.0
            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/r3WPM9zsP

Note:
- fails: 15.1 till trunk
- works: 14.4 and earlier


[524] % 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/17.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++,lto --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20261111 (experimental) [master r17-1628-gd1c12591336] (GCC) 
[525] % 
[525] % gcctk -O3 small.c; ./a.out
[526] % 
[526] % gcctk -O3 -fno-tree-forwprop -fno-tree-vrp -fno-vect-cost-model small.c
[527] % timeout -s 9 5 ./a.out
Killed
[528] % 
[528] % cat small.c
long *a, b, l;
int k = 5, m;
int n(long o) {
  long e, f, g, i, j, c, d;
  a = &e;
  e = (536870911 - 1 / o) ^ 7804438717590242691 ^ 5121363712956983201;
  g = e & 5121363712956983201;
  j = ~g;
  d = ~e;
  b = ~5121363712956983201;
  i = d & b;
  c = ~i;
  e = (c & j) ^ 7804438717590242691;
  f = 2147483647 / e;
  unsigned h = f & 5;
  return h;
}
int main() {
  do {
    if (k <= 0)
      m = n(l);
    k = m;
    l = 809516896;
  } while (!m);
  return 0;
}
  • [Bug tree-optimization/128658]... zhendong.su at inf dot ethz.ch via Gcc-bugs

Reply via email to