GCC: vectorization difference between two similar loops

前端 未结 4 2121
误落风尘
误落风尘 2020-12-24 06:18

When compiling with gcc -O3, why does the following loop not vectorize (automatically):

#define SIZE (65536)

int a[SIZE], b[SIZE], c[SIZE];

in         


        
4条回答
  •  北海茫月
    2020-12-24 06:46

    First one just trivially changing a[] many times(temporary). Second one uses the last value of a[] each time(not temporary).

    Until a version of patch, you could use "volatile" variable to vectorize.

    Use

    int * c=malloc(sizeof(int));
    

    to make it aligned;

    v.c:9: note: Unknown alignment for access: c
    

    Shows "c" having different storage area than b and a.

    I assume "movaps"-like instructions for being "vectorized" (from SSE-AVX instruction list)

    Here: http://gcc.gnu.org/projects/tree-ssa/vectorization.html#using

    the 6th and 7th examples show similar difficulties.

提交回复
热议问题