xref: /llvm-project/clang/test/CodeGen/thinlto-loop-vectorize-pm.c (revision 7e59223ac4b045178c287a56154113d5989572f4)
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
4 
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.
10 //
11 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -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 -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 -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}
17 
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.
23 //
24 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -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 -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 -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}
33 
foo(double * a)34 void foo(double *a) {
35   for (int i = 0; i < 1000; i++)
36     a[i] = 10;
37 }
38