对于最基本的示例,g ++ autovectorization失败

Vin*_*ent 1 c++ g++ vectorization compiler-optimization c++11

我目前正在尝试使用g ++进行自动向量化.为此,我使用以下最小示例:

#include <array>
int main()
{
    std::array<double, 16> x;
    for (unsigned int i = 0; i < 16; i++) x[i] = i;
    return x[15];
}
Run Code Online (Sandbox Code Playgroud)

我编译:

g++-4.7 -Wall -Wextra -std=c++11 -O3 -ftree-vectorizer-verbose=9 tests.cpp -o tests
Run Code Online (Sandbox Code Playgroud)

结果是:

Analyzing loop at tests.cpp:5

5: ===== analyze_loop_nest =====
5: === vect_analyze_loop_form ===
5: === get_loop_niters ===
5: ==> get_loop_niters:16
5: === vect_analyze_data_refs ===

5: not vectorized: no vectype for stmt: MEM[(value_type &)&x]._M_instance[i_21] = D.21296_5;
 scalar_type: value_type
5: bad data references.
tests.cpp:2: note: vectorized 0 loops in function.
Run Code Online (Sandbox Code Playgroud)

有什么问题以及如何解决?

编辑:结果是相同的:

#include <array>
int main()
{
    std::array<int, 16> x;
    for (int i = 0; i < 16; i++) x[i] = i;
    return x[15];
}
Run Code Online (Sandbox Code Playgroud)

Mik*_*ail 10

检查编译标志no vectype for stmt意味着您的体系结构不支持这些说明.

设置-march=native-march=corei7