1

我目前正在尝试将自动矢量化与 g++ 一起使用。为此,我使用以下最小示例:

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

我编译:

g++-4.7 -Wall -Wextra -std=c++11 -O3 -ftree-vectorizer-verbose=9 tests.cpp -o tests

结果是:

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.

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

编辑:结果是相同的:

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

1 回答 1

10

检查你的编译标志no vectype for stmt意味着你的架构不支持这些指令。

设置-march=native-march=corei7

于 2013-01-03T23:28:17.260 回答