public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/112282] New: wrong code (generated code hangs) at -O3 on x86_64-linux-gnu
@ 2023-10-29 22:39 zhendong.su at inf dot ethz.ch
  2023-10-29 22:41 ` [Bug tree-optimization/112282] [14 Regression] " pinskia at gcc dot gnu.org
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2023-10-29 22:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112282
           Summary: wrong code (generated code hangs) at -O3 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: ---

The code is very tough to reduce, but it appears to be a recent regression. 

Although the reduced code is still quite hairy, it does seem valid.

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


[621] % 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/14.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 14.0.0 20231029 (experimental) (GCC) 
[622] % 
[622] % gcctk -O2 small.c; ./a.out
[623] % 
[623] % gcctk -O3 small.c
[624] % timeout -s 9 10 ./a.out
Killed
[625] % cat small.c
int printf(const char *, ...);
void __assert_fail();
int a, g, h, i, v, w = 2, x, y, ab, ac, ad, ae, af, ag;
static int f, j, m, n, p, r, u, aa;
struct b {
  int c : 20;
  int d : 20;
  int e : 10;
};
static struct b l, o, q = {3, 3, 5};
int s(int z) {
  struct b ah;
  int ai = 1, aj[7] = {1, 1, 1, 1, 1, 1, 1};
ak:
  for (u = -22; u < 2; ++u) {
    struct b al[8] = {{2, 7, 9}, {8, 7, 1}, {2, 7, 9}, {8, 7, 1}, {2, 7, 9},
{8, 7, 1}, {2, 7, 9}};
    y = z = 0;
    for (; z < 2; z++) {
      int am[18], k;
      ab = ac = 0;
      for (; ac < 1; ac++)
        for (k = 0; k < 9; k++)
          am[k] = 0;
      n = 0;
      while (1) {
        v = u < 0 || a;
        h = z < ~u && 4 & q.c;
        if ((aa <= l.c) > q.d && p)
          return o.c;
        if (w)
          break;
        return q.e;
      }
      a = j;
    }
  }
  for (x = 0; x < 2; x++) {
    struct b an = {1, 8, 4};
    int ao[28] = {5, 0, 0, 9, 0, 3, 0, 5, 0, 0, 9, 0, 3, 0, 5, 0, 0, 9, 0, 3,
0, 5, 0, 0, 9, 0, 3, 0};
    if (q.e) {
      int ap = ai || l.c + q.c, aq = q.d, ar = p & f;
      q.d = q.d || ar || ap;
      p = 0;
      if (!j && ai)
        goto as;
      if (q.d) {
        printf("", l);
        q.d = f >> j;
      }
      p = l.c = aq;
      an = q;
    } else {
      int at[12][1] = {{9}, {9}, {5}, {9}, {9}, {5}, {9}, {9}, {5}, {9}, {9},
{5}};
      struct b au;
      if (o.c)
        aa = ah.e;
      if (an.d)
        ah.e = (j & (aa * m)) ^ au.d;
      o.c = m + aa;
      int av = o.c || 0, aw = ai || q.c & l.c, ax = n;
      if (q.e < ai)
        q = an;
      if (r)
        break;
      ai = aw - av;
      an.e = 0;
      if (ai) {
        an.e = l.c || 0;
        f = q.c;
        ah.e = l.c % q.d;
        q.c = au.e;
        if ((q.d && q.c) || ah.e)
          __assert_fail();
        q.c = 0;
        if (au.d > m || ah.e)
          w = au.c | (n & ah.c);
      as:
        ae = af = ah.c;
        int ay = au.d & q.e & au.c || o.c, az = 0 || o.c, ba = m & ah.d;
        if (n)
          au.c = au.e = (q.e || ah.d) ^ (o.c + (az / au.e));
        n = au.c || au.e;
        if (ba) {
          printf("", ax);
          x = q.e | m;
          continue;
        }
        m = ay;
        n = printf("", au);
      }
      if (ah.d)
        o.c = l.c & o.c & q.c;
      if (q.d)
        __assert_fail();
      printf("", an);
      printf("", q);
      printf("", au);
      if (ah.e)
        while (u++) {
          struct b al[7] = {{7, 9, 8}, {7, 1, 2}, {7, 9, 8}, {7, 1, 2}, {7, 9,
8}, {7, 1, 2}, {7, 9, 0}};
          if (an.d) {
            int d[8] = {0, 1, 0, 1, 0, 1, 0, 1};
            if (ad)
              goto ak;
            while (ag)
              g = an.d = i = m;
            f = j;
          }
          n++;
        }
      f = q.d;
    }
    if (l.c && m) {
      int d[7] = {1, 0, 1, 0, 1, 0, 1};
      if (x)
        h = an.d;
      else
        g = 0;
    }
  }
  int bb = (q.d ^ ah.c) | aa | (q.e & q.c) | (f & ah.d);
  if (bb)
    return x;
  return 0;
}
int main() {
  j = 1;
  s(0);
  return 0;
}

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-11-16  7:05 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-29 22:39 [Bug tree-optimization/112282] New: wrong code (generated code hangs) at -O3 on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2023-10-29 22:41 ` [Bug tree-optimization/112282] [14 Regression] " pinskia at gcc dot gnu.org
2023-10-29 22:51 ` pinskia at gcc dot gnu.org
2023-10-30  0:40 ` sjames at gcc dot gnu.org
2023-10-30  0:41 ` sjames at gcc dot gnu.org
2023-10-30  1:28 ` sjames at gcc dot gnu.org
2023-10-30  1:48 ` pinskia at gcc dot gnu.org
2023-10-30  1:53 ` pinskia at gcc dot gnu.org
2023-10-30  3:49 ` [Bug tree-optimization/112282] [14 Regression] wrong code (generated code hangs) at -O3 on x86_64-linux-gnu since r14-4777-g88c27070c25309 sjames at gcc dot gnu.org
2023-10-30  9:13 ` tnfchris at gcc dot gnu.org
2023-10-30 14:21 ` rguenth at gcc dot gnu.org
2023-10-30 20:21 ` avieira at gcc dot gnu.org
2023-10-31  9:12 ` avieira at gcc dot gnu.org
2023-10-31  9:12 ` avieira at gcc dot gnu.org
2023-11-14 14:48 ` rguenth at gcc dot gnu.org
2023-11-15 10:36 ` rguenth at gcc dot gnu.org
2023-11-15 10:56 ` rguenth at gcc dot gnu.org
2023-11-15 12:12 ` cvs-commit at gcc dot gnu.org
2023-11-15 12:12 ` rguenth at gcc dot gnu.org
2023-11-16  7:05 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).