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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.3.1, 11.1.1, 12.0
      Known to work|                            |9.3.1

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
We manage to do one more CSE of 'a' which in turn triggers loop distribution
which, when I disable it, fixes the testcase.  The disambiguation in question
only triggers in FRE{1,3,5}, DOM2, PRE and CUNROLL.  That points to a
latent issue in loop distribution.

The following modified testcase also is miscompiled on the GCC 10 and 11
branch,
-O2 -ftree-loop-distribution is enough to trigger that.

int printf (const char *, ...);
char a, c;
int b, d, *e = &d, g;
static char f;
int main() {
  int h = 0;
  int a_ = a;
  for (; a_ < 1; a = ++a_) {
    int *i[5], **j = &i[4], ***k[3][2] = {{&j}}, ****l = &k[2][1], *****m = &l;
    char *n = &c;
    f = *e = g = 0;
    for (; g < 2; g++) {
      for (b = 0; b < 3; b++)
        h = (h && (*n = 0)) == 0;
      if (g)
        break;
    }
  }
  printf("%d\n", f);
  return 0;
}

Specifically we distribute f = 0 from the rest.

What is odd is that we have a loop with multiple latches at the start of loop
distribution.

in .optimized we have

  <bb 9> [local count: 955630225]:
  goto <bb 9>; [100.00%]

which results from the tail partition which ends up "canonicalizing" not
included GIMPLE_CONDs in a way that forms the endless loop.

Reply via email to