On Tue, Apr 14, 2020 at 4:39 PM Shubham Narlawar via Gcc
<gcc@gcc.gnu.org> wrote:
>
> Hello,
>
> I am working on gcc-4.9.4 and encountered different results of loop
> vectorization on array arr0, arr1 and arr2.
>
> Testcase -
>
> int main()
>   {
>     int i;
>     for (i=0; i<64; i++)
>       {
>         arr2[i]=(arr1[i]|arr0[i]);
>       }
>   }
>
> Using -O2 -ftree-vectorize, Above loop is vectorized if arr0, arr1,
> arr2 are global arrays whereas if they are local, loop is not getting
> vectorized.
>
> 1. Is there any flag which will enable vectorization of loop which
> will operate on local array as well?

Generally vectorization does not care about this difference.  It might be
that alignment of local arrays is not sufficient (you do not say which
target you are working with).  Maybe you are restricted by the
vectorizers default cost model at -O2 which is "cheap", try
-fvect-cost-model=dynamic or -O3.

> 2. Which part of code I need to tweak so that I would get
> vectorization on loops operating on local arrays or at least know why
> vectorization is not suggested for such loops?

You can look at the vectorizer debugging dumps output by
-fdump-tree-vect-details (in a file, source.1xxt.vect).  It can
be a bit overwhelming though.

I also strongly recomment to update to a newer version of GCC,
GCC 4.9 is more than 5 years old and no longer maintained.

Richard.

> Thanks and Regards
> Shubham

Reply via email to