blob: a2d717a2422df2d726497c4ce43e2849fac163d0 [file] [log] [blame]
Tyler Nowicki020dd792015-08-10 22:17:40 +00001// RUN: %clang -O1 -fvectorize -target x86_64-unknown-unknown -Rpass-analysis=loop-vectorize -emit-llvm -S %s -o - 2>&1 | FileCheck %s
Tyler Nowicki8a0925c2015-08-10 19:56:40 +00002
Tyler Nowicki8cb274e2015-08-27 18:58:34 +00003// CHECK: {{.*}}:9:11: remark: loop not vectorized: cannot prove it is safe to reorder floating-point operations; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop or by providing the compiler option '-ffast-math'.
Tyler Nowicki8a0925c2015-08-10 19:56:40 +00004
5double foo(int N) {
6 double v = 0.0;
7
8 for (int i = 0; i < N; i++)
9 v = v + 1.0;
10
11 return v;
12}
Tyler Nowicki034baf62015-08-10 23:05:16 +000013
Hal Finkelc07e19b2016-05-25 21:53:24 +000014// CHECK: {{.*}}:17:3: remark: loop not vectorized: cannot prove it is safe to reorder memory operations; allow reordering by specifying '#pragma clang loop vectorize(enable)' before the loop. If the arrays will always be independent specify '#pragma clang loop vectorize(assume_safety)' before the loop or provide the '__restrict__' qualifier with the independent array arguments. Erroneous results will occur if these options are incorrectly applied!
Tyler Nowicki034baf62015-08-10 23:05:16 +000015
16void foo2(int *dw, int *uw, int *A, int *B, int *C, int *D, int N) {
17 for (int i = 0; i < N; i++) {
18 dw[i] = A[i] + B[i - 1] + C[i - 2] + D[i - 3];
19 uw[i] = A[i] + B[i + 1] + C[i + 2] + D[i + 3];
20 }
21}