Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

c - Understanding gcc 4.9.2 auto-vectorization output

I am trying to learn gcc auto-vectorization module. After reading documentation from here.

Here is what I tried (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];
  }
}

And then, I simply run:

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

As per the documentation, I would have assumed to see a clear line saying something like:

ex1.c:5: note: LOOP VECTORIZED.

but that is not the case. I have used the command line option: -fopt-info-vec-missed since the command line option: -ftree-vectorizer-verbose is now a no-op, as per report.

So my question: is how do I read the above output to extract that somehow the loop was actually vectorized ?

In case that help:

$ gcc -dumpversion
4.9.2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Actually digging in gcc online doc, I finally found out that I should use instead: -fopt-info-vec-optimized (or maybe -fopt-info-vec-all). See 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’.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...