[Bug tree-optimization/34017] [4.2/4.3 Regression] ICE in lambda_loopnest_to_gcc_loopnest with -O2 -ftree-loop-linear

jakub at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Nov 22 15:19:00 GMT 2007



------- Comment #2 from jakub at gcc dot gnu dot org  2007-11-22 15:19 -------
On the simplified:
extern int s;

void
foo (int *x, int y, int z)
{
  int m, n;
  int o;
  int p = x[0];
  o = s;
  for (m = 0; m < s; m++)
    for (n = 0; n < s; n++)
      {
        if (x[n] != p)
          continue;
        if (m > z)
          z = m;
        if (n < o)
          o = n;
      }
  for (m = y; m <= z; m++)
    {
    }
}

at -O2 -ftree-loop-linear, it fails everywhere I tried, on x86_64-linux with
both -m{32,64}, on i686-linux, on sparc64-linux with -m{32,64} and on
ppc64-linux
with -m{32,64}.

<bb 5>:
  # o_42 = PHI <o_8(4), o_1(12)>
  # n_40 = PHI <n_25(4), 0(12)>
  # z_35 = PHI <z_2(4), z_34(12)>
  D.1559_19 = (long unsigned int) n_40;
  D.1560_20 = D.1559_19 * 4;
  D.1561_21 = x_11(D) + D.1560_20;
  D.1562_22 = *D.1561_21;
  if (D.1562_22 != p_12)
    goto <bb 8>;
  else
    goto <bb 6>;

<bb 6>:
  z_17 = MAX_EXPR <z_35, m_38>;
  if (n_40 < o_42)
    goto <bb 8>;
  else
    goto <bb 7>;

<bb 7>:

<bb 8>:
  # o_8 = PHI <o_42(5), o_42(7), n_40(6)>
  # z_2 = PHI <z_35(5), z_17(7), z_17(6)>
  n_25 = n_40 + 1;
  if (o_13 > n_25)
    goto <bb 4>;
  else
    goto <bb 9>;

This is with IV n_40, oldiv_stmt is # n_40 = PHI <n_25(4), 0(12)> and one
of the immediate uses is # o_8 = PHI <o_42(5), o_42(7), n_40(6)>
That could have been perhaps transformed into a MIN_EXPR, but unlike the
MAX_EXPR phiopt1 has not done that, because there weren't just 2 incoming
edges, but 3 (where two used one value and the third different one).
I don't see justification for the assert that none of the immediate uses of
the IV is a PHI_NODE - it can certainly happen and while it can be harder to
fix up, perhaps involving adding some statements on edges, it is nothing
that should prevent the transformations.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34017



More information about the Gcc-bugs mailing list