1; RUN: llc < %s | FileCheck -check-prefix=ENABLED %s
2; RUN: llc -disable-nvptx-load-store-vectorizer < %s | FileCheck -check-prefix=DISABLED %s
3target triple = "nvptx64-nvidia-cuda"
4
5; Check that the load-store vectorizer is enabled by default for nvptx, and
6; that it's disabled by the appropriate flag.
7
8; ENABLED: ld.v2.{{.}}32
9; DISABLED: ld.{{.}}32
10; DISABLED: ld.{{.}}32
11define i32 @f(i32* %p) {
12  %p.1 = getelementptr i32, i32* %p, i32 1
13  %v0 = load i32, i32* %p, align 8
14  %v1 = load i32, i32* %p.1, align 4
15  %sum = add i32 %v0, %v1
16  ret i32 %sum
17}
18
19define half @fh(half* %p) {
20  %p.1 = getelementptr half, half* %p, i32 1
21  %p.2 = getelementptr half, half* %p, i32 2
22  %p.3 = getelementptr half, half* %p, i32 3
23  %p.4 = getelementptr half, half* %p, i32 4
24  %v0 = load half, half* %p, align 64
25  %v1 = load half, half* %p.1, align 4
26  %v2 = load half, half* %p.2, align 4
27  %v3 = load half, half* %p.3, align 4
28  %v4 = load half, half* %p.4, align 4
29  %sum1 = fadd half %v0, %v1
30  %sum2 = fadd half %v2, %v3
31  %sum3 = fadd half %sum1, %sum2
32  %sum = fadd half %sum3, %v4
33  ret half %sum
34}
35
36define float @ff(float* %p) {
37  %p.1 = getelementptr float, float* %p, i32 1
38  %p.2 = getelementptr float, float* %p, i32 2
39  %p.3 = getelementptr float, float* %p, i32 3
40  %p.4 = getelementptr float, float* %p, i32 4
41  %v0 = load float, float* %p, align 64
42  %v1 = load float, float* %p.1, align 4
43  %v2 = load float, float* %p.2, align 4
44  %v3 = load float, float* %p.3, align 4
45  %v4 = load float, float* %p.4, align 4
46  %sum1 = fadd float %v0, %v1
47  %sum2 = fadd float %v2, %v3
48  %sum3 = fadd float %sum1, %sum2
49  %sum = fadd float %sum3, %v4
50  ret float %sum
51}
52