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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> 
> void bar ();
> void foo (int *a)
> {
>   int qa = 0;
>   for (int i = 0; i < 3; i++)
>     if (a[i])
>       a[qa++] = 0;
>   if (qa > 3)
>     bar ();
> }
> 
> where we should be able to eliminate the call to bar ().

What is interesting is we can optimize away the call to bar in this slightly
modified case during vrp2:
void bar ();
bool cond;
void foo (int *a)
{
  int qa = 0;
  for (int i = 0; i < 3; i++)
    if (cond)
      a[qa++] = 0;
  if (qa > 3)
    bar ();
}

But I don't see why having the load inside the loop would make a difference
....

Reply via email to