1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 -o %t.o -O2 -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. Also check that
8 // "-mllvm -vectorize-slp=false" will disable slp vectorization, overriding
9 // the cc1 option.
10 //
11 // Check both the new and old PMs.
12 //
13 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -vectorize-slp -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=SLP
14 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -vectorize-slp -mllvm -vectorize-slp=false -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=NOSLP
15 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -vectorize-slp -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=SLP
16 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O2 -vectorize-slp -mllvm -vectorize-slp=false -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck %s --check-prefix=NOSLP
17 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -vectorize-slp -o - -x ir %t.o -fthinlto-index=%t.thinlto.bc -fexperimental-new-pass-manager 2>&1 | FileCheck %s --check-prefix=NOSLP
18 // SLP: extractelement
19 // NOSLP-NOT: extractelement
20 
21 int foo(double *A, int n, int m) {
22   double sum = 0, v1 = 2, v0 = 3;
23   for (int i=0; i < n; ++i)
24     sum += 7*A[i*2] + 7*A[i*2+1];
25   return sum;
26 }
27 
28