1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -o %t.o -flto=thin -fexperimental-new-pass-manager -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s
3 // RUN: llvm-lto -thinlto -o %t %t.o
4 
5 // Test to ensure the slp vectorize codegen option is passed down to the
6 // ThinLTO backend. -vectorize-slp is a cc1 option and will be added
7 // automatically when O2/O3/Os/Oz is available for clang. Once -vectorize-slp
8 // is enabled, "-mllvm -vectorize-slp=false" won't disable slp vectorization
9 // currently. "-mllvm -vectorize-slp=false" is added here in the test to
10 // ensure the slp vectorization is executed because the -vectorize-slp cc1
11 // flag is passed down, not because "-mllvm -vectorize-slp" is enabled
12 // by default.
13 //
14 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-slp -mllvm -vectorize-slp=false -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O2-SLP
15 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -vectorize-slp -mllvm -vectorize-slp=false -o %t2.o -x ir %t.o -fthinlto-index=%t.thinlto.bc -fdebug-pass-manager -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O0-SLP
16 // O2-SLP: Running pass: SLPVectorizerPass
17 // O0-SLP-NOT: Running pass: SLPVectorizerPass
18 
19 // Test to ensure the loop vectorize codegen option is passed down to the
20 // ThinLTO backend. -vectorize-loops is a cc1 option and will be added
21 // automatically when O2/O3/Os is available for clang. Once -vectorize-loops is
22 // enabled, "-mllvm -vectorize-loops=false" won't disable loop vectorization
23 // currently. "-mllvm -vectorize-loops=false" is added here in the test to
24 // ensure the loop vectorization is executed because the -vectorize-loops cc1
25 // flag is passed down, not because "-mllvm -vectorize-loops" is enabled
26 // by default.
27 //
28 // 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 -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O2-LPV
29 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -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 -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O0-LPV
30 // O2-LPV: = !{!"llvm.loop.isvectorized", i32 1}
31 // O0-LPV-NOT: = !{!"llvm.loop.isvectorized", i32 1}
32 
33 // Test to ensure the loop interleave codegen option is passed down to the
34 // ThinLTO backend. The internal loop interleave codegen option will be
35 // enabled automatically when O2/O3 is available for clang. Once the loop
36 // interleave option is enabled, "-mllvm -interleave-loops=false" won't disable
37 // the interleave. currently. "-mllvm -interleave-loops=false" is added here
38 // in the test to ensure the loop interleave is executed because the interleave
39 // codegen flag is passed down, not because "-mllvm -interleave-loops" is
40 // enabled by default.
41 //
42 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O2 -vectorize-loops -mllvm -interleave-loops=false -mllvm -force-vector-width=1 -mllvm -force-vector-interleave=2 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O2-InterLeave
43 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-obj -O0 -vectorize-loops -mllvm -interleave-loops=false -mllvm -force-vector-width=1 -mllvm -force-vector-interleave=2 -emit-llvm -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=O0-InterLeave
44 // O2-InterLeave: = !{!"llvm.loop.isvectorized", i32 1}
45 // O0-InterLeave-NOT: = !{!"llvm.loop.isvectorized", i32 1}
46 
47 void foo(double *a) {
48   for (int i = 0; i < 1000; i++)
49     a[i] = 10;
50 }
51