This is the mail archive of the gcc-patches@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]

Re: [autovect] [patch] vectorize in cases when number of iterations may be zero


Hello,

> > have you tried this patch with some loop for that the number of
> > iterations is zero (because niter_desc.may_be_zero is true)?
> > I do not know how you handle this case in vectorizer, but just
> > ignoring the niter_desc.may_be_zero condition looks a bit suspicious.
> 
> We don't ignore niter_desc.may_be_zero when it can be proved to be true,
> we ignore it when it is an expression consisting from symbols.
> consider the following example:
> 
>       1 int a[1000];
>       2 int b[1000];
>       3
>       4 int
>       5 foo (int n, int m)
>       6 {
>       7   int i = 0;
>       8
>       9   if (n)
>      10     do {
>      11       a[i] = b[i];
>      12       i++;
>      13     } while (i < m);
>      14
>      15   return 1;
>      16 }
> 
> niter_desc.may_be_zero for this example will be < n != 0 >,
> thus both integer_nonzerop (niter_desc.may_be_zero) and
> integer_zerop (niter_desc.may_be_zero) will return false,
> and without this patch the return value of number_of_iterations_in_loop
> will be chrec_dont_know, hence loop will not be vectorized.

and what if n happed to be zero, will the produced code be correct then?

Zdenek


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