允许更短的循环进入向量化。
使用参数--param=vect-alias-flexible-segment-len=1使能,默认为0。
注:此优化需要和-O2 -ftree-vectorize共同使用。
测试用例如下:
1 2 3 4 5 6 7 8 | #define TYPE int #define SIZE 257 void __attribute__ ((weak)) f (TYPE *x, TYPE *y, unsigned short n, long m __attribute__((unused))) { for (int i = 0; i < SIZE; ++i) x[i * n] += y[i * n]; } |
测试命令:
1 | gcc -march=armv8.2-a+sve -O2 -ftree-vectorize --param=vect-alias-flexible-segment-len=1 -S test.c -o test.s |
相比选项未打开时,选项打开后,生成的汇编代码指令使用了ld1w、st1w等指令。