了解 gcc 4.9.2 自动矢量化输出
Understanding gcc 4.9.2 auto-vectorization output
我正在尝试学习 gcc 自动矢量化模块。阅读 here.
的文档后
这是我尝试过的 (debian jessie amd64):
$ cat ex1.c
int a[256], b[256], c[256];
foo () {
int i;
for (i=0; i<256; i++){
a[i] = b[i] + c[i];
}
}
然后,我只是 运行:
$ gcc -x c -Ofast -msse2 -c -ftree-vectorize -fopt-info-vec-missed ex1.c
ex1.c:5:3: note: misalign = 0 bytes of ref b[i_11]
ex1.c:5:3: note: misalign = 0 bytes of ref c[i_11]
ex1.c:5:3: note: misalign = 0 bytes of ref a[i_11]
ex1.c:5:3: note: virtual phi. skip.
ex1.c:5:3: note: num. args = 4 (not unary/binary/ternary op).
ex1.c:5:3: note: not ssa-name.
ex1.c:5:3: note: use not simple.
ex1.c:5:3: note: num. args = 4 (not unary/binary/ternary op).
ex1.c:5:3: note: not ssa-name.
ex1.c:5:3: note: use not simple.
ex1.c:2:1: note: not vectorized: not enough data-refs in basic block.
ex1.c:6:13: note: not vectorized: no vectype for stmt: vect__4.5_1 = MEM[(int *)vectp_b.3_9];
scalar_type: vector(4) int
ex1.c:6:13: note: not vectorized: not enough data-refs in basic block.
ex1.c:2:1: note: not vectorized: not enough data-refs in basic block.
ex1.c:8:1: note: not vectorized: not enough data-refs in basic block.
根据 documentation,我会假设看到一条清晰的线,上面写着这样的话:
ex1.c:5: note: LOOP VECTORIZED.
但事实并非如此。我使用了命令行选项:-fopt-info-vec-missed
,因为命令行选项:-ftree-vectorizer-verbose
现在是空操作,因为 per report.
所以我的问题是:如何读取上面的输出以提取循环实际上以某种方式矢量化的信息?
如果有帮助:
$ gcc -dumpversion
4.9.2
实际上在 gcc 在线文档中挖掘,我终于发现我应该使用:-fopt-info-vec-optimized
(或者可能是 -fopt-info-vec-all
)。见 here and here:
optimized
:
Print information when an optimization is successfully applied. It is up to a pass to decide which information is relevant. For example, the vectorizer passes print the source location of loops which are successfully vectorized.
missed
:
Print information about missed optimizations. Individual passes control which information to include in the output.
note
:
Print verbose information about optimizations, such as certain transformations, more detailed messages about decisions etc.
all
:
Print detailed optimization information. This includes ‘optimized’, ‘missed’, and ‘note’.
我正在尝试学习 gcc 自动矢量化模块。阅读 here.
的文档后这是我尝试过的 (debian jessie amd64):
$ cat ex1.c
int a[256], b[256], c[256];
foo () {
int i;
for (i=0; i<256; i++){
a[i] = b[i] + c[i];
}
}
然后,我只是 运行:
$ gcc -x c -Ofast -msse2 -c -ftree-vectorize -fopt-info-vec-missed ex1.c
ex1.c:5:3: note: misalign = 0 bytes of ref b[i_11]
ex1.c:5:3: note: misalign = 0 bytes of ref c[i_11]
ex1.c:5:3: note: misalign = 0 bytes of ref a[i_11]
ex1.c:5:3: note: virtual phi. skip.
ex1.c:5:3: note: num. args = 4 (not unary/binary/ternary op).
ex1.c:5:3: note: not ssa-name.
ex1.c:5:3: note: use not simple.
ex1.c:5:3: note: num. args = 4 (not unary/binary/ternary op).
ex1.c:5:3: note: not ssa-name.
ex1.c:5:3: note: use not simple.
ex1.c:2:1: note: not vectorized: not enough data-refs in basic block.
ex1.c:6:13: note: not vectorized: no vectype for stmt: vect__4.5_1 = MEM[(int *)vectp_b.3_9];
scalar_type: vector(4) int
ex1.c:6:13: note: not vectorized: not enough data-refs in basic block.
ex1.c:2:1: note: not vectorized: not enough data-refs in basic block.
ex1.c:8:1: note: not vectorized: not enough data-refs in basic block.
根据 documentation,我会假设看到一条清晰的线,上面写着这样的话:
ex1.c:5: note: LOOP VECTORIZED.
但事实并非如此。我使用了命令行选项:-fopt-info-vec-missed
,因为命令行选项:-ftree-vectorizer-verbose
现在是空操作,因为 per report.
所以我的问题是:如何读取上面的输出以提取循环实际上以某种方式矢量化的信息?
如果有帮助:
$ gcc -dumpversion
4.9.2
实际上在 gcc 在线文档中挖掘,我终于发现我应该使用:-fopt-info-vec-optimized
(或者可能是 -fopt-info-vec-all
)。见 here and here:
optimized
: Print information when an optimization is successfully applied. It is up to a pass to decide which information is relevant. For example, the vectorizer passes print the source location of loops which are successfully vectorized.
missed
: Print information about missed optimizations. Individual passes control which information to include in the output.
note
: Print verbose information about optimizations, such as certain transformations, more detailed messages about decisions etc.
all
: Print detailed optimization information. This includes ‘optimized’, ‘missed’, and ‘note’.