File: thinlto-loop-vectorize-pm.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (37 lines) | stat: -rw-r--r-- 2,739 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -o %t.o -O2 -flto=thin -triple x86_64-unknown-linux-gnu -emit-llvm-bc %s
// RUN: llvm-lto -thinlto -o %t %t.o

// Test to ensure the loop vectorize codegen option is passed down to the
// ThinLTO backend. -vectorize-loops is a cc1 option and will be added
// automatically when O2/O3/Os is available for clang. Also check that
// "-mllvm -vectorize-loops=false" will disable loop vectorization, overriding
// the cc1 option.
//
// 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
// 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
// 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
// O2-LPV: = !{!"llvm.loop.isvectorized", i32 1}
// O2-NOLPV-NOT: = !{!"llvm.loop.isvectorized", i32 1}
// O0-LPV-NOT: = !{!"llvm.loop.isvectorized", i32 1}

// Test to ensure the loop interleave codegen option is passed down to the
// ThinLTO backend. The internal loop interleave codegen option will be
// enabled automatically when O2/O3 is available for clang. Also check that
// "-mllvm -interleave-loops=false" will disable the interleaving, overriding
// the cc1 option.
//
// 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
// 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
// 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
// O2-InterLeave-COUNT-2: store <2 x double>
// O2-InterLeave: = !{!"llvm.loop.isvectorized", i32 1}
// O2-NoInterLeave-COUNT-1: store <2 x double>
// O2-NoInterLeave-NOT: store <2 x double>
// O2-NoInterLeave: = !{!"llvm.loop.isvectorized", i32 1}
// O0-InterLeave-NOT: = !{!"llvm.loop.isvectorized", i32 1}

void foo(double *a) {
  for (int i = 0; i < 1000; i++)
    a[i] = 10;
}