了解gcc 4.9.2自动矢量化输出

mal*_*lat 5 c gcc auto-vectorization

我正在尝试学习gcc自动矢量化模块.从这里阅读文档后.

这是我尝试过的(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];
  }
}
Run Code Online (Sandbox Code Playgroud)

然后,我只是运行:

$ 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.
Run Code Online (Sandbox Code Playgroud)

根据文档,我会假设看到一个明确的界限,如:

ex1.c:5: note: LOOP VECTORIZED.
Run Code Online (Sandbox Code Playgroud)

但事实并非如此.我使用了命令行选项:-fopt-info-vec-missed因为命令行选项:-ftree-vectorizer-verbose现在是一个no-op,根据报告.

所以我的问题是:我如何阅读上面的输出来提取循环实际上是否被矢量化了?

如果有帮助:

$ gcc -dumpversion
4.9.2
Run Code Online (Sandbox Code Playgroud)

mal*_*lat 7

实际上挖掘gcc在线文档,我终于发现我应该使用:( -fopt-info-vec-optimized或者也许-fopt-info-vec-all).看到这里这里:

optimized:成功应用优化后打印信息.决定哪些信息是相关的由通行证决定.例如,矢量化器传递打印成功矢量化的循环的源位置.

missed:打印有关错过的优化的信息.单个传递控制将哪些信息包含在输出中.

note:打印有关优化的详细信息,例如某些转换,有关决策的更详细消息等.

all:打印详细的优化信息.这包括"优化","遗漏"和"注释".