1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mcpu=bdver2 < %s | FileCheck %s
4 define i32 @foo(ptr nocapture readonly %arr, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8) {
7 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 1
8 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
9 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP0]], [[A1:%.*]]
10 ; CHECK-NEXT: [[ADD2:%.*]] = add i32 [[TMP0]], [[A2:%.*]]
11 ; CHECK-NEXT: [[ADD4:%.*]] = add i32 [[TMP0]], [[A3:%.*]]
12 ; CHECK-NEXT: [[ADD6:%.*]] = add i32 [[TMP0]], [[A4:%.*]]
13 ; CHECK-NEXT: [[ADD8:%.*]] = add i32 [[TMP0]], [[A5:%.*]]
14 ; CHECK-NEXT: [[ADD10:%.*]] = add i32 [[TMP0]], [[A6:%.*]]
15 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARR]], align 4
16 ; CHECK-NEXT: [[ADD12:%.*]] = add i32 [[TMP1]], [[A7:%.*]]
17 ; CHECK-NEXT: [[ADD14:%.*]] = add i32 [[TMP1]], [[A8:%.*]]
18 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[ADD]], [[ADD2]]
19 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 [[ADD2]]
20 ; CHECK-NEXT: [[CMP15:%.*]] = icmp ult i32 [[COND]], [[ADD4]]
21 ; CHECK-NEXT: [[COND19:%.*]] = select i1 [[CMP15]], i32 [[COND]], i32 [[ADD4]]
22 ; CHECK-NEXT: [[CMP20:%.*]] = icmp ult i32 [[COND19]], [[ADD6]]
23 ; CHECK-NEXT: [[COND24:%.*]] = select i1 [[CMP20]], i32 [[COND19]], i32 [[ADD6]]
24 ; CHECK-NEXT: [[CMP25:%.*]] = icmp ult i32 [[COND24]], [[ADD8]]
25 ; CHECK-NEXT: [[COND29:%.*]] = select i1 [[CMP25]], i32 [[COND24]], i32 [[ADD8]]
26 ; CHECK-NEXT: [[CMP30:%.*]] = icmp ult i32 [[COND29]], [[ADD10]]
27 ; CHECK-NEXT: [[COND34:%.*]] = select i1 [[CMP30]], i32 [[COND29]], i32 [[ADD10]]
28 ; CHECK-NEXT: [[CMP35:%.*]] = icmp ult i32 [[COND34]], [[ADD12]]
29 ; CHECK-NEXT: [[COND39:%.*]] = select i1 [[CMP35]], i32 [[COND34]], i32 [[ADD12]]
30 ; CHECK-NEXT: [[CMP40:%.*]] = icmp ult i32 [[COND39]], [[ADD14]]
31 ; CHECK-NEXT: [[COND44:%.*]] = select i1 [[CMP40]], i32 [[COND39]], i32 [[ADD14]]
32 ; CHECK-NEXT: ret i32 [[COND44]]
35 %arrayidx = getelementptr inbounds i32, ptr %arr, i64 1
36 %0 = load i32, ptr %arrayidx, align 4
37 %add = add i32 %0, %a1
38 %add2 = add i32 %0, %a2
39 %add4 = add i32 %0, %a3
40 %add6 = add i32 %0, %a4
41 %add8 = add i32 %0, %a5
42 %add10 = add i32 %0, %a6
43 %1 = load i32, ptr %arr, align 4
44 %add12 = add i32 %1, %a7
45 %add14 = add i32 %1, %a8
46 %cmp = icmp ult i32 %add, %add2
47 %cond = select i1 %cmp, i32 %add, i32 %add2
48 %cmp15 = icmp ult i32 %cond, %add4
49 %cond19 = select i1 %cmp15, i32 %cond, i32 %add4
50 %cmp20 = icmp ult i32 %cond19, %add6
51 %cond24 = select i1 %cmp20, i32 %cond19, i32 %add6
52 %cmp25 = icmp ult i32 %cond24, %add8
53 %cond29 = select i1 %cmp25, i32 %cond24, i32 %add8
54 %cmp30 = icmp ult i32 %cond29, %add10
55 %cond34 = select i1 %cmp30, i32 %cond29, i32 %add10
56 %cmp35 = icmp ult i32 %cond34, %add12
57 %cond39 = select i1 %cmp35, i32 %cond34, i32 %add12
58 %cmp40 = icmp ult i32 %cond39, %add14
59 %cond44 = select i1 %cmp40, i32 %cond39, i32 %add14
63 define i32 @foo1(ptr nocapture readonly %arr, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8) {
66 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 1
67 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
68 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP0]], [[A1:%.*]]
69 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[ARR]], i64 2
70 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4
71 ; CHECK-NEXT: [[ADD2:%.*]] = add i32 [[TMP1]], [[A2:%.*]]
72 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i32, ptr [[ARR]], i64 3
73 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX3]], align 4
74 ; CHECK-NEXT: [[ADD4:%.*]] = add i32 [[TMP2]], [[A3:%.*]]
75 ; CHECK-NEXT: [[ADD6:%.*]] = add i32 [[TMP0]], [[A4:%.*]]
76 ; CHECK-NEXT: [[ADD8:%.*]] = add i32 [[TMP0]], [[A5:%.*]]
77 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARR]], align 4
78 ; CHECK-NEXT: [[ADD10:%.*]] = add i32 [[TMP3]], [[A6:%.*]]
79 ; CHECK-NEXT: [[ADD12:%.*]] = add i32 [[TMP1]], [[A7:%.*]]
80 ; CHECK-NEXT: [[ADD14:%.*]] = add i32 [[TMP0]], [[A8:%.*]]
81 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[ADD]], [[ADD2]]
82 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 [[ADD2]]
83 ; CHECK-NEXT: [[CMP15:%.*]] = icmp ult i32 [[COND]], [[ADD4]]
84 ; CHECK-NEXT: [[COND19:%.*]] = select i1 [[CMP15]], i32 [[COND]], i32 [[ADD4]]
85 ; CHECK-NEXT: [[CMP20:%.*]] = icmp ult i32 [[COND19]], [[ADD6]]
86 ; CHECK-NEXT: [[COND24:%.*]] = select i1 [[CMP20]], i32 [[COND19]], i32 [[ADD6]]
87 ; CHECK-NEXT: [[CMP25:%.*]] = icmp ult i32 [[COND24]], [[ADD8]]
88 ; CHECK-NEXT: [[COND29:%.*]] = select i1 [[CMP25]], i32 [[COND24]], i32 [[ADD8]]
89 ; CHECK-NEXT: [[CMP30:%.*]] = icmp ult i32 [[COND29]], [[ADD10]]
90 ; CHECK-NEXT: [[COND34:%.*]] = select i1 [[CMP30]], i32 [[COND29]], i32 [[ADD10]]
91 ; CHECK-NEXT: [[CMP35:%.*]] = icmp ult i32 [[COND34]], [[ADD12]]
92 ; CHECK-NEXT: [[COND39:%.*]] = select i1 [[CMP35]], i32 [[COND34]], i32 [[ADD12]]
93 ; CHECK-NEXT: [[CMP40:%.*]] = icmp ult i32 [[COND39]], [[ADD14]]
94 ; CHECK-NEXT: [[COND44:%.*]] = select i1 [[CMP40]], i32 [[COND39]], i32 [[ADD14]]
95 ; CHECK-NEXT: ret i32 [[COND44]]
98 %arrayidx = getelementptr inbounds i32, ptr %arr, i64 1
99 %0 = load i32, ptr %arrayidx, align 4
100 %add = add i32 %0, %a1
101 %arrayidx1 = getelementptr inbounds i32, ptr %arr, i64 2
102 %1 = load i32, ptr %arrayidx1, align 4
103 %add2 = add i32 %1, %a2
104 %arrayidx3 = getelementptr inbounds i32, ptr %arr, i64 3
105 %2 = load i32, ptr %arrayidx3, align 4
106 %add4 = add i32 %2, %a3
107 %add6 = add i32 %0, %a4
108 %add8 = add i32 %0, %a5
109 %3 = load i32, ptr %arr, align 4
110 %add10 = add i32 %3, %a6
111 %add12 = add i32 %1, %a7
112 %add14 = add i32 %0, %a8
113 %cmp = icmp ult i32 %add, %add2
114 %cond = select i1 %cmp, i32 %add, i32 %add2
115 %cmp15 = icmp ult i32 %cond, %add4
116 %cond19 = select i1 %cmp15, i32 %cond, i32 %add4
117 %cmp20 = icmp ult i32 %cond19, %add6
118 %cond24 = select i1 %cmp20, i32 %cond19, i32 %add6
119 %cmp25 = icmp ult i32 %cond24, %add8
120 %cond29 = select i1 %cmp25, i32 %cond24, i32 %add8
121 %cmp30 = icmp ult i32 %cond29, %add10
122 %cond34 = select i1 %cmp30, i32 %cond29, i32 %add10
123 %cmp35 = icmp ult i32 %cond34, %add12
124 %cond39 = select i1 %cmp35, i32 %cond34, i32 %add12
125 %cmp40 = icmp ult i32 %cond39, %add14
126 %cond44 = select i1 %cmp40, i32 %cond39, i32 %add14
130 define i32 @foo2(ptr nocapture readonly %arr, i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, i32 %a6, i32 %a7, i32 %a8) {
131 ; CHECK-LABEL: @foo2(
133 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[ARR:%.*]], i64 3
134 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
135 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[TMP0]], [[A1:%.*]]
136 ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i32, ptr [[ARR]], i64 2
137 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX1]], align 4
138 ; CHECK-NEXT: [[ADD2:%.*]] = add i32 [[TMP1]], [[A2:%.*]]
139 ; CHECK-NEXT: [[ADD4:%.*]] = add i32 [[TMP0]], [[A3:%.*]]
140 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARR]], align 4
141 ; CHECK-NEXT: [[ADD6:%.*]] = add i32 [[TMP2]], [[A4:%.*]]
142 ; CHECK-NEXT: [[ARRAYIDX7:%.*]] = getelementptr inbounds i32, ptr [[ARR]], i64 1
143 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARRAYIDX7]], align 4
144 ; CHECK-NEXT: [[ADD8:%.*]] = add i32 [[TMP3]], [[A5:%.*]]
145 ; CHECK-NEXT: [[ADD10:%.*]] = add i32 [[TMP2]], [[A6:%.*]]
146 ; CHECK-NEXT: [[ADD12:%.*]] = add i32 [[TMP1]], [[A7:%.*]]
147 ; CHECK-NEXT: [[ADD14:%.*]] = add i32 [[TMP3]], [[A8:%.*]]
148 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[ADD]], [[ADD2]]
149 ; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 [[ADD]], i32 [[ADD2]]
150 ; CHECK-NEXT: [[CMP15:%.*]] = icmp ult i32 [[COND]], [[ADD4]]
151 ; CHECK-NEXT: [[COND19:%.*]] = select i1 [[CMP15]], i32 [[COND]], i32 [[ADD4]]
152 ; CHECK-NEXT: [[CMP20:%.*]] = icmp ult i32 [[COND19]], [[ADD6]]
153 ; CHECK-NEXT: [[COND24:%.*]] = select i1 [[CMP20]], i32 [[COND19]], i32 [[ADD6]]
154 ; CHECK-NEXT: [[CMP25:%.*]] = icmp ult i32 [[COND24]], [[ADD8]]
155 ; CHECK-NEXT: [[COND29:%.*]] = select i1 [[CMP25]], i32 [[COND24]], i32 [[ADD8]]
156 ; CHECK-NEXT: [[CMP30:%.*]] = icmp ult i32 [[COND29]], [[ADD10]]
157 ; CHECK-NEXT: [[COND34:%.*]] = select i1 [[CMP30]], i32 [[COND29]], i32 [[ADD10]]
158 ; CHECK-NEXT: [[CMP35:%.*]] = icmp ult i32 [[COND34]], [[ADD12]]
159 ; CHECK-NEXT: [[COND39:%.*]] = select i1 [[CMP35]], i32 [[COND34]], i32 [[ADD12]]
160 ; CHECK-NEXT: [[CMP40:%.*]] = icmp ult i32 [[COND39]], [[ADD14]]
161 ; CHECK-NEXT: [[COND44:%.*]] = select i1 [[CMP40]], i32 [[COND39]], i32 [[ADD14]]
162 ; CHECK-NEXT: ret i32 [[COND44]]
165 %arrayidx = getelementptr inbounds i32, ptr %arr, i64 3
166 %0 = load i32, ptr %arrayidx, align 4
167 %add = add i32 %0, %a1
168 %arrayidx1 = getelementptr inbounds i32, ptr %arr, i64 2
169 %1 = load i32, ptr %arrayidx1, align 4
170 %add2 = add i32 %1, %a2
171 %add4 = add i32 %0, %a3
172 %2 = load i32, ptr %arr, align 4
173 %add6 = add i32 %2, %a4
174 %arrayidx7 = getelementptr inbounds i32, ptr %arr, i64 1
175 %3 = load i32, ptr %arrayidx7, align 4
176 %add8 = add i32 %3, %a5
177 %add10 = add i32 %2, %a6
178 %add12 = add i32 %1, %a7
179 %add14 = add i32 %3, %a8
180 %cmp = icmp ult i32 %add, %add2
181 %cond = select i1 %cmp, i32 %add, i32 %add2
182 %cmp15 = icmp ult i32 %cond, %add4
183 %cond19 = select i1 %cmp15, i32 %cond, i32 %add4
184 %cmp20 = icmp ult i32 %cond19, %add6
185 %cond24 = select i1 %cmp20, i32 %cond19, i32 %add6
186 %cmp25 = icmp ult i32 %cond24, %add8
187 %cond29 = select i1 %cmp25, i32 %cond24, i32 %add8
188 %cmp30 = icmp ult i32 %cond29, %add10
189 %cond34 = select i1 %cmp30, i32 %cond29, i32 %add10
190 %cmp35 = icmp ult i32 %cond34, %add12
191 %cond39 = select i1 %cmp35, i32 %cond34, i32 %add12
192 %cmp40 = icmp ult i32 %cond39, %add14
193 %cond44 = select i1 %cmp40, i32 %cond39, i32 %add14