1; RUN: opt -S -march=r600 -mcpu=cayman -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine < %s | FileCheck %s
2
3; Artificial datalayout
4target datalayout = "e-p:32:32:32-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-v2048:2048:2048-n32:64"
5
6
7define void @add_ints_1_1_1(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #0 {
8; CHECK-LABEL: @add_ints_1_1_1(
9; CHECK: <4 x i32>
10; CHECK: ret
11
12entry:
13  br label %for.body
14
15for.body:                                         ; preds = %entry, %for.body
16  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
17  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %b, i64 %i.01
18  %0 = load i32, i32 addrspace(1)* %arrayidx, align 4
19  %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %c, i64 %i.01
20  %1 = load i32, i32 addrspace(1)* %arrayidx1, align 4
21  %add = add nsw i32 %0, %1
22  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %a, i64 %i.01
23  store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
24  %inc = add i64 %i.01, 1
25  %cmp = icmp ult i64 %inc, 200
26  br i1 %cmp, label %for.body, label %for.end
27
28for.end:                                          ; preds = %for.body
29  ret void
30}
31
32define void @add_ints_as_1_0_0(i32 addrspace(1)* %a, i32* %b, i32* %c) #0 {
33; CHECK-LABEL: @add_ints_as_1_0_0(
34; CHECK-NOT: <4 x i32>
35; CHECK: ret
36
37entry:
38  br label %for.body
39
40for.body:                                         ; preds = %entry, %for.body
41  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
42  %arrayidx = getelementptr inbounds i32, i32* %b, i64 %i.01
43  %0 = load i32, i32* %arrayidx, align 4
44  %arrayidx1 = getelementptr inbounds i32, i32* %c, i64 %i.01
45  %1 = load i32, i32* %arrayidx1, align 4
46  %add = add nsw i32 %0, %1
47  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %a, i64 %i.01
48  store i32 %add, i32 addrspace(1)* %arrayidx2, align 4
49  %inc = add i64 %i.01, 1
50  %cmp = icmp ult i64 %inc, 200
51  br i1 %cmp, label %for.body, label %for.end
52
53for.end:                                          ; preds = %for.body
54  ret void
55}
56
57define void @add_ints_as_0_1_0(i32* %a, i32 addrspace(1)* %b, i32* %c) #0 {
58; CHECK-LABEL: @add_ints_as_0_1_0(
59; CHECK-NOT: <4 x i32>
60; CHECK: ret
61
62entry:
63  br label %for.body
64
65for.body:                                         ; preds = %entry, %for.body
66  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
67  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %b, i64 %i.01
68  %0 = load i32, i32 addrspace(1)* %arrayidx, align 4
69  %arrayidx1 = getelementptr inbounds i32, i32* %c, i64 %i.01
70  %1 = load i32, i32* %arrayidx1, align 4
71  %add = add nsw i32 %0, %1
72  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %i.01
73  store i32 %add, i32* %arrayidx2, align 4
74  %inc = add i64 %i.01, 1
75  %cmp = icmp ult i64 %inc, 200
76  br i1 %cmp, label %for.body, label %for.end
77
78for.end:                                          ; preds = %for.body
79  ret void
80}
81
82define void @add_ints_as_0_1_1(i32* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %c) #0 {
83; CHECK-LABEL: @add_ints_as_0_1_1(
84; CHECK-NOT: <4 x i32>
85; CHECK: ret
86
87entry:
88  br label %for.body
89
90for.body:                                         ; preds = %entry, %for.body
91  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
92  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %b, i64 %i.01
93  %0 = load i32, i32 addrspace(1)* %arrayidx, align 4
94  %arrayidx1 = getelementptr inbounds i32, i32 addrspace(1)* %c, i64 %i.01
95  %1 = load i32, i32 addrspace(1)* %arrayidx1, align 4
96  %add = add nsw i32 %0, %1
97  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %i.01
98  store i32 %add, i32* %arrayidx2, align 4
99  %inc = add i64 %i.01, 1
100  %cmp = icmp ult i64 %inc, 200
101  br i1 %cmp, label %for.body, label %for.end
102
103for.end:                                          ; preds = %for.body
104  ret void
105}
106
107define void @add_ints_as_0_1_2(i32* %a, i32 addrspace(1)* %b, i32 addrspace(2)* %c) #0 {
108; CHECK-LABEL: @add_ints_as_0_1_2(
109; CHECK-NOT: <4 x i32>
110; CHECK: ret
111
112entry:
113  br label %for.body
114
115for.body:                                         ; preds = %entry, %for.body
116  %i.01 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
117  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %b, i64 %i.01
118  %0 = load i32, i32 addrspace(1)* %arrayidx, align 4
119  %arrayidx1 = getelementptr inbounds i32, i32 addrspace(2)* %c, i64 %i.01
120  %1 = load i32, i32 addrspace(2)* %arrayidx1, align 4
121  %add = add nsw i32 %0, %1
122  %arrayidx2 = getelementptr inbounds i32, i32* %a, i64 %i.01
123  store i32 %add, i32* %arrayidx2, align 4
124  %inc = add i64 %i.01, 1
125  %cmp = icmp ult i64 %inc, 200
126  br i1 %cmp, label %for.body, label %for.end
127
128for.end:                                          ; preds = %for.body
129  ret void
130}
131
132attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
133