[PATCH] Adjust nb_iterations_upper_bound in loop header copying

Richard Sandiford rdsandiford@googlemail.com
Fri Nov 22 14:32:00 GMT 2013


Richard Biener <rguenther@suse.de> writes:
> This patch decrements nb_iterations_upper_bound by one after we copied
> the loop header.  This allows niter + 1 to more often not overflow.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, installed to trunk.
>
> Richard.
>
> 2013-11-21  Richard Biener  <rguenther@suse.de>
>
> 	* tree-ssa-loop-ch.c (copy_loop_headers): Decrement
> 	nb_iterations_upper_bound by one.

This seems to regress the following testcase, compiled at -O2 on
x86_64-linux-gnu.

Thanks,
Richard


void __attribute__ ((noinline))
f (long *s, long *t, int len1, int len2)
{
  int i, j;

  j = 2;
  for (i = len1 - 1; i >= 0; i--)
    {
      s[j--] = (i < len2 ? t[i] : t[len2 - 1] < 0 ? -1 : 0);
      if (j < 0)
	break;
    }
}

long s[3];
long t[3];

int
main (void)
{
  t[0] = 1;
  t[1] = 2;
  t[2] = 3;
  f (s, t, 3, 3);
  if (memcmp (s, t, sizeof (s)) != 0)
    abort ();
  return 0;
}



More information about the Gcc-patches mailing list