On Thu, Dec 17, 2009 at 1:07 PM, Revital1 Eres <e...@il.ibm.com> wrote:
>
> Hello,
>
> Is there a way to pass to the unroller the maximum number of iterations
> of the loop such that it can decide to avoid unrolling if
> the maximum number  is small.
>
> To be more specific, I am referring to the following case:
> After the vectorizer decides to peel for alignment
> it creates three loops:
> [1] scalar loop - the prologue to align
>    memory access.
> [2] the vecorized loop
> [3] scalar loop - the remaining scalar computations.
>
> If the unroller does not know the number of  iterations at compile time
> it unrolls loops with run-time checks in the following way
> (taken from loop-unroll.c):
>
>   for (i = 0; i < n; i++)
>     body;
>
>   ==>
>
>   i = 0;
>   mod = n % 4;
>
>   switch (mod)
>     {
>       case 3:
>         body; i++;
>       case 2:
>         body; i++;
>       case 1:
>         body; i++;
>       case 0: ;
>     }
>
>   while (i < n)
>     {
>       body; i++;
>       body; i++;
>       body; i++;
>       body; i++;
>     }
>
>
> The vectorizer knowns at compile time the maximum number of iterations
> that will be needed for the prologue and the epilogue. In some cases
> seems there is no need to unroll and create redundant loops.

You can set niter_max in the niter_desc of simple loops.  There is
also nb_iter_bound for all loops.  Of course the
issue is that loop information is destroyed sometimes.  It also looks
like that RTL loop analysis may not re-use this information.

Maybe Zdenek knows a better answer.

Richard.

> Thanks,
> Revital
>
>

Reply via email to