我要评分
获取效率
正确性
完整性
易理解

--param=vect-alias-flexible-segment-len=n

Description

Shorter loops can be vectorized.

Usage

Enable this function by setting --param=vect-alias-flexible-segment-len=1. The default value is 0.

Note: This optimization must be used together with -O2 -ftree-vectorize.

Result

The test case is as follows:

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];
}

Test command:

1
gcc -march=armv8.2-a+sve -O2 -ftree-vectorize --param=vect-alias-flexible-segment-len=1 -S test.c -o test.s
Figure 1 Option disabled
Figure 2 Option enabled

After this option is enabled, the generated assembly code uses instructions such as ld1w and st1w.