使用GCC进行自动矢量化

时间:2015-04-08 20:58:03

标签: c++ gcc auto-vectorization

我想在我的代码中向量化矩阵向量产品。我尝试在GCC中使用自动矢量化,它根本不起作用,我也不知道如何使它成功。现在我尝试一个非常简单的示例代码:

#define N 200000
double a[N] __attribute__(( aligned(16) ));
double b[N] __attribute__(( aligned(16) )) ;
double c[N] __attribute__(( aligned(16) )) ;

void f()
{ 
    int i;

    for( i = 0; i < N; i++ )
    {
        a[i] = b[i] + c[i];
    }
}

int main( int argc,char** argv )
{
    f();

    return( 0 );
}

我使用gcc版本4.9.2并使用标志进行编译(完整性)

-Wall -O3 -ftree-vectorize -march=native -msse2 -fopt-info-vec-missed -ftree-vectorizer-verbose=1 -std=c++11 -fdiagnostics-color=auto

我得到以下输出(我真的不明白这些东西意味着什么,但显然底线是矢量化没有成功):

optimization2.cpp:10:2: note: misalign = 0 bytes of ref b[i_11]
optimization2.cpp:10:2: note: misalign = 0 bytes of ref c[i_11]
optimization2.cpp:10:2: note: misalign = 0 bytes of ref a[i_11]
optimization2.cpp:10:2: note: virtual phi. skip.
optimization2.cpp:10:2: note: num. args = 4 (not unary/binary/ternary op).
optimization2.cpp:10:2: note: not ssa-name.
optimization2.cpp:10:2: note: use not simple.
optimization2.cpp:10:2: note: num. args = 4 (not unary/binary/ternary op).
optimization2.cpp:10:2: note: not ssa-name.
optimization2.cpp:10:2: note: use not simple.
optimization2.cpp:6:6: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:12:13: note: not vectorized: no vectype for stmt: vect__4.6_1 = MEM[(int *)vectp_b.4_9];
 scalar_type: vector(4) int
optimization2.cpp:12:13: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:6:6: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:14:1: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:10:2: note: misalign = 0 bytes of ref b[i_12]
optimization2.cpp:10:2: note: misalign = 0 bytes of ref c[i_12]
optimization2.cpp:10:2: note: misalign = 0 bytes of ref a[i_12]
optimization2.cpp:10:2: note: virtual phi. skip.
optimization2.cpp:10:2: note: num. args = 4 (not unary/binary/ternary op).
optimization2.cpp:10:2: note: not ssa-name.
optimization2.cpp:10:2: note: use not simple.
optimization2.cpp:10:2: note: num. args = 4 (not unary/binary/ternary op).
optimization2.cpp:10:2: note: not ssa-name.
optimization2.cpp:10:2: note: use not simple.
optimization2.cpp:16:5: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:12:13: note: not vectorized: no vectype for stmt: vect__4.28_2 = MEM[(int *)vectp_b.26_9];
 scalar_type: vector(4) int
optimization2.cpp:12:13: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:16:5: note: not vectorized: not enough data-refs in basic block.
optimization2.cpp:16:5: note: not vectorized: not enough data-refs in basic block.

我尝试了许多其他的东西和其他代码,但从来没有得到任何矢量化。有什么诀窍?

0 个答案:

没有答案