This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

number_of_iterations_in_loop and a non-constant loop bound start


While working on a loop pass I found that number_of_iterations_in_loop reported
that a loop with a non constant start as being undetermined which is wrong for
this case as we know that the initializer will always before the end.


Take for an example:


void g(int init, int max, char *a) { int i; for (i = init; i < max; i++) a[i] = 0; }

in the loop we know that init < max as the tree looks like:
g (init, max, array)
{
  int i;
  char * T.2;
  char * i.1;
  unsigned int i.0;

<bb 0>:
  if (init_2 < max_4) goto <L4>; else goto <L5>;

<L5>:;
  goto <bb 2> (<L2>);

<L4>:;

  # i_15 = PHI <init_2(3), i_9(6)>;
<L0>:;
  i.0_5 = (unsigned int)i_15;
  i.1_6 = (char *)i.0_5;
  T.2_8 = i.1_6 + array_7;
  *T.2_8 = 0;
  i_9 = i_15 + 1;
  if (max_4 > i_9) goto <L7>; else goto <L6>;

<L7>:;
  goto <bb 1> (<L0>);

<L6>:;

<L2>:;
  return;

}

Is there someway to get this fixed as this looks very wrong. It looks like
it will also hurt the vectorizer also.


Note I tried the LNO branch also and found to have the same problem there
as the mainline.


Thanks,
Andrew Pinski


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]