[Bug tree-optimization/26939] PRE confuses loop number of iterations analysis

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Mar 30 12:22:00 GMT 2006



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-03-30 12:22 -------
Note this testcase requires the fix(es) for PR26900 to figure out the number of
iterations for the inner loop.  The failure to figure out the number of
iterations of the outer loop can be reproduced with mainline.  Basically we
have (in the working case with using j-1):


foo (i1, j1)
{
  int pretmp.20;
  int j;
  int i;
  int D.1534;

<bb 2>:
  if (j1_4 >= 0) goto <L14>; else goto <L5>;

<L14>:;
  goto <bb 8> (<L2>);

<L16>:;

  # i_14 = PHI <i_9(4), 0(9)>;
<L1>:;
  D.1534_8 = pretmp.20_10;
  bar (pretmp.20_10);
  i_9 = i_14 + 1;
  if (i1_6 >= i_9) goto <L16>; else goto <L3>;

<L3>:;
  j_7 = j_12 + 1;
  if (j1_4 >= j_7) goto <L18>; else goto <L5>;

<L18>:;

  # j_12 = PHI <j_7(7), 0(3)>;
<L2>:;
  if (i1_6 >= 0) goto <L20>; else goto <L3>;

<L20>:;
  pretmp.20_10 = j_12 - 1;
  goto <bb 5> (<L1>);

<L5>:;
  return;

}

while with using j+1 we get

foo (i1, j1)
{
  int prephitmp.21;
  int pretmp.20;
  int j;
  int i;
  int D.1534;

<bb 2>:
  if (j1_4 >= 0) goto <L14>; else goto <L5>;

<L14>:;
  goto <bb 9> (<L2>);

<L16>:;

  # i_14 = PHI <i_9(4), 0(11)>;
<L1>:;
  D.1534_8 = pretmp.20_13;
  bar (pretmp.20_13);
  i_9 = i_14 + 1;
  if (i1_6 >= i_9) goto <L16>; else goto <L17>;

  # D.1534_2 = PHI <pretmp.20_13(5)>;
<L17>:;

  # prephitmp.21_11 = PHI <D.1534_2(6), pretmp.20_1(10)>;
<L3>:;
  j_7 = prephitmp.21_11;
  if (j1_4 >= prephitmp.21_11) goto <L18>; else goto <L5>;

<L18>:;

  # j_12 = PHI <prephitmp.21_11(8), 0(3)>;
<L2>:;
  if (i1_6 >= 0) goto <L20>; else goto <L21>;

<L21>:;
  pretmp.20_1 = j_12 + 1;
  goto <bb 7> (<L3>);

<L20>:;
  pretmp.20_13 = j_12 + 1;
  goto <bb 5> (<L1>);

<L5>:;
  return;

}


-- 


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



More information about the Gcc-bugs mailing list