Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / thinlto-loop-vectorize-pm.c
blob68891506a8115a1088e3af8e4c83ff8d6e152eb2
1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -o %t.o -O2 -flto=thin -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s
3 // RUN: llvm-lto -thinlto -o %t %t.o
5 // Test to ensure the loop vectorize codegen option is passed down to the
6 // ThinLTO backend. -vectorize-loops is a cc1 option and will be added
7 // automatically when O2/O3/Os is available for clang. Also check that
8 // "-mllvm -vectorize-loops=false" will disable loop vectorization, overriding
9 // the cc1 option.
11 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-loops -mllvm -force-vector-width=2 -mllvm -force-vector-interleave=1 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O2-LPV
12 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-loops -mllvm -vectorize-loops=false -mllvm -force-vector-width=2 -mllvm -force-vector-interleave=1 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O2-NOLPV
13 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -vectorize-loops -mllvm -force-vector-width=2 -mllvm -force-vector-interleave=1 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O0-LPV
14 // O2-LPV: = !{!"llvm.loop.isvectorized", i32 1}
15 // O2-NOLPV-NOT: = !{!"llvm.loop.isvectorized", i32 1}
16 // O0-LPV-NOT: = !{!"llvm.loop.isvectorized", i32 1}
18 // Test to ensure the loop interleave codegen option is passed down to the
19 // ThinLTO backend. The internal loop interleave codegen option will be
20 // enabled automatically when O2/O3 is available for clang. Also check that
21 // "-mllvm -interleave-loops=false" will disable the interleaving, overriding
22 // the cc1 option.
24 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-loops -mllvm -force-vector-width=2 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O2-InterLeave
25 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-loops -mllvm -interleave-loops=false -mllvm -force-vector-width=2 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O2-NoInterLeave
26 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -vectorize-loops -mllvm -force-vector-width=2 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=O0-InterLeave
27 // O2-InterLeave-COUNT-2: store <2 x double>
28 // O2-InterLeave: = !{!"llvm.loop.isvectorized", i32 1}
29 // O2-NoInterLeave-COUNT-1: store <2 x double>
30 // O2-NoInterLeave-NOT: store <2 x double>
31 // O2-NoInterLeave: = !{!"llvm.loop.isvectorized", i32 1}
32 // O0-InterLeave-NOT: = !{!"llvm.loop.isvectorized", i32 1}
34 void foo(double *a) {
35 for (int i = 0; i < 1000; i++)
36 a[i] = 10;