理解gcc 4.9.2自动向量化输出

9

我正在尝试学习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];
  }
}

然后,我只需运行:

$ 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.

根据文档,我本以为会看到明确的一行文字,比如说:
ex1.c:5: note: LOOP VECTORIZED.

但情况并非如此。我使用了命令行选项:-fopt-info-vec-missed,因为命令行选项:-ftree-vectorizer-verbose 现在是一个空操作,正如报告所述。
那么我的问题是:我如何阅读上面的输出以提取循环实际上是向量化的某种方式?
如果有帮助的话:
$ gcc -dumpversion
4.9.2
1个回答

17
实际上,在查阅gcc在线文档后,我最终发现我应该使用-fopt-info-vec-optimized (或者可能是-fopt-info-vec-all)而不是-ftree-vectorizer-verbose=2。请参见这里这里:

优化: 在成功应用优化时打印信息。决定哪些信息相关取决于传递。例如,向量化器传递会打印成功向量化的循环的源位置。

未应用: 打印有关未应用优化的信息。每个传递控制输出中包含的信息。

注释: 打印有关优化的详细信息,例如某些变换,更详细的决策消息等。

全部: 打印详细的优化信息。 这包括“优化”,“未应用”和“注释”。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接