选项 --param=vect-alias-flexible-segment-len=n
说明
允许更短的循环进入向量化。
使用方法
使用参数--param=vect-alias-flexible-segment-len=1使能,默认为0。
注:此优化需要和-O2 -ftree-vectorize共同使用。
结果
测试用例如下:
#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]; }
测试命令:
gcc -march=armv8.2-a+sve -O2 -ftree-vectorize --param=vect-alias-flexible-segment-len=1 -S test.c -o test.s
图1 选项未打开

图2 选项已经打开

相比选项未打开时,选项打开后,生成的汇编代码指令使用了ld1w、st1w等指令。
父主题: 静态编译优化