1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mattr=+sse2 | FileCheck %s --check-prefixes=CHECK,SSE
3 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mattr=+avx | FileCheck %s --check-prefixes=CHECK,AVX
4 ; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=x86_64-unknown-linux-gnu -mattr=+avx2 | FileCheck %s --check-prefixes=CHECK,AVX
6 define void @powof2mul_uniform(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, ptr noalias nocapture readonly %c){
7 ; CHECK-LABEL: @powof2mul_uniform(
9 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[B:%.*]], align 4
10 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[C:%.*]], align 4
11 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
12 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[TMP4]], splat (i32 2)
13 ; CHECK-NEXT: store <4 x i32> [[TMP5]], ptr [[A:%.*]], align 4
14 ; CHECK-NEXT: ret void
17 %0 = load i32, ptr %b, align 4
18 %1 = load i32, ptr %c, align 4
19 %add = add nsw i32 %1, %0
20 %mul = mul i32 %add, 2
21 store i32 %mul, ptr %a, align 4
22 %arrayidx3 = getelementptr inbounds i32, ptr %b, i64 1
23 %2 = load i32, ptr %arrayidx3, align 4
24 %arrayidx4 = getelementptr inbounds i32, ptr %c, i64 1
25 %3 = load i32, ptr %arrayidx4, align 4
26 %add5 = add nsw i32 %3, %2
27 %mul6 = mul i32 %add5, 2
28 %arrayidx7 = getelementptr inbounds i32, ptr %a, i64 1
29 store i32 %mul6, ptr %arrayidx7, align 4
30 %arrayidx8 = getelementptr inbounds i32, ptr %b, i64 2
31 %4 = load i32, ptr %arrayidx8, align 4
32 %arrayidx9 = getelementptr inbounds i32, ptr %c, i64 2
33 %5 = load i32, ptr %arrayidx9, align 4
34 %add10 = add nsw i32 %5, %4
35 %mul11 = mul i32 %add10, 2
36 %arrayidx12 = getelementptr inbounds i32, ptr %a, i64 2
37 store i32 %mul11, ptr %arrayidx12, align 4
38 %arrayidx13 = getelementptr inbounds i32, ptr %b, i64 3
39 %6 = load i32, ptr %arrayidx13, align 4
40 %arrayidx14 = getelementptr inbounds i32, ptr %c, i64 3
41 %7 = load i32, ptr %arrayidx14, align 4
42 %add15 = add nsw i32 %7, %6
43 %mul16 = mul i32 %add15, 2
44 %arrayidx17 = getelementptr inbounds i32, ptr %a, i64 3
45 store i32 %mul16, ptr %arrayidx17, align 4
49 define void @negpowof2mul_uniform(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, ptr noalias nocapture readonly %c){
50 ; CHECK-LABEL: @negpowof2mul_uniform(
52 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[B:%.*]], align 4
53 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[C:%.*]], align 4
54 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
55 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[TMP4]], splat (i32 -2)
56 ; CHECK-NEXT: store <4 x i32> [[TMP5]], ptr [[A:%.*]], align 4
57 ; CHECK-NEXT: ret void
60 %0 = load i32, ptr %b, align 4
61 %1 = load i32, ptr %c, align 4
62 %add = add nsw i32 %1, %0
63 %mul = mul i32 %add, -2
64 store i32 %mul, ptr %a, align 4
65 %arrayidx3 = getelementptr inbounds i32, ptr %b, i64 1
66 %2 = load i32, ptr %arrayidx3, align 4
67 %arrayidx4 = getelementptr inbounds i32, ptr %c, i64 1
68 %3 = load i32, ptr %arrayidx4, align 4
69 %add5 = add nsw i32 %3, %2
70 %mul6 = mul i32 %add5, -2
71 %arrayidx7 = getelementptr inbounds i32, ptr %a, i64 1
72 store i32 %mul6, ptr %arrayidx7, align 4
73 %arrayidx8 = getelementptr inbounds i32, ptr %b, i64 2
74 %4 = load i32, ptr %arrayidx8, align 4
75 %arrayidx9 = getelementptr inbounds i32, ptr %c, i64 2
76 %5 = load i32, ptr %arrayidx9, align 4
77 %add10 = add nsw i32 %5, %4
78 %mul11 = mul i32 %add10, -2
79 %arrayidx12 = getelementptr inbounds i32, ptr %a, i64 2
80 store i32 %mul11, ptr %arrayidx12, align 4
81 %arrayidx13 = getelementptr inbounds i32, ptr %b, i64 3
82 %6 = load i32, ptr %arrayidx13, align 4
83 %arrayidx14 = getelementptr inbounds i32, ptr %c, i64 3
84 %7 = load i32, ptr %arrayidx14, align 4
85 %add15 = add nsw i32 %7, %6
86 %mul16 = mul i32 %add15, -2
87 %arrayidx17 = getelementptr inbounds i32, ptr %a, i64 3
88 store i32 %mul16, ptr %arrayidx17, align 4
92 define void @powof2mul_nonuniform(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, ptr noalias nocapture readonly %c){
93 ; CHECK-LABEL: @powof2mul_nonuniform(
95 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[B:%.*]], align 4
96 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[C:%.*]], align 4
97 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
98 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[TMP4]], <i32 2, i32 4, i32 8, i32 16>
99 ; CHECK-NEXT: store <4 x i32> [[TMP5]], ptr [[A:%.*]], align 4
100 ; CHECK-NEXT: ret void
103 %0 = load i32, ptr %b, align 4
104 %1 = load i32, ptr %c, align 4
105 %add = add nsw i32 %1, %0
106 %mul = mul i32 %add, 2
107 store i32 %mul, ptr %a, align 4
108 %arrayidx3 = getelementptr inbounds i32, ptr %b, i64 1
109 %2 = load i32, ptr %arrayidx3, align 4
110 %arrayidx4 = getelementptr inbounds i32, ptr %c, i64 1
111 %3 = load i32, ptr %arrayidx4, align 4
112 %add5 = add nsw i32 %3, %2
113 %mul6 = mul i32 %add5, 4
114 %arrayidx7 = getelementptr inbounds i32, ptr %a, i64 1
115 store i32 %mul6, ptr %arrayidx7, align 4
116 %arrayidx8 = getelementptr inbounds i32, ptr %b, i64 2
117 %4 = load i32, ptr %arrayidx8, align 4
118 %arrayidx9 = getelementptr inbounds i32, ptr %c, i64 2
119 %5 = load i32, ptr %arrayidx9, align 4
120 %add10 = add nsw i32 %5, %4
121 %mul11 = mul i32 %add10, 8
122 %arrayidx12 = getelementptr inbounds i32, ptr %a, i64 2
123 store i32 %mul11, ptr %arrayidx12, align 4
124 %arrayidx13 = getelementptr inbounds i32, ptr %b, i64 3
125 %6 = load i32, ptr %arrayidx13, align 4
126 %arrayidx14 = getelementptr inbounds i32, ptr %c, i64 3
127 %7 = load i32, ptr %arrayidx14, align 4
128 %add15 = add nsw i32 %7, %6
129 %mul16 = mul i32 %add15, 16
130 %arrayidx17 = getelementptr inbounds i32, ptr %a, i64 3
131 store i32 %mul16, ptr %arrayidx17, align 4
135 define void @negpowof2mul_nonuniform(ptr noalias nocapture %a, ptr noalias nocapture readonly %b, ptr noalias nocapture readonly %c){
136 ; CHECK-LABEL: @negpowof2mul_nonuniform(
138 ; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[B:%.*]], align 4
139 ; CHECK-NEXT: [[TMP3:%.*]] = load <4 x i32>, ptr [[C:%.*]], align 4
140 ; CHECK-NEXT: [[TMP4:%.*]] = add nsw <4 x i32> [[TMP3]], [[TMP1]]
141 ; CHECK-NEXT: [[TMP5:%.*]] = mul <4 x i32> [[TMP4]], <i32 -2, i32 -4, i32 -8, i32 -16>
142 ; CHECK-NEXT: store <4 x i32> [[TMP5]], ptr [[A:%.*]], align 4
143 ; CHECK-NEXT: ret void
146 %0 = load i32, ptr %b, align 4
147 %1 = load i32, ptr %c, align 4
148 %add = add nsw i32 %1, %0
149 %mul = mul i32 %add, -2
150 store i32 %mul, ptr %a, align 4
151 %arrayidx3 = getelementptr inbounds i32, ptr %b, i64 1
152 %2 = load i32, ptr %arrayidx3, align 4
153 %arrayidx4 = getelementptr inbounds i32, ptr %c, i64 1
154 %3 = load i32, ptr %arrayidx4, align 4
155 %add5 = add nsw i32 %3, %2
156 %mul6 = mul i32 %add5, -4
157 %arrayidx7 = getelementptr inbounds i32, ptr %a, i64 1
158 store i32 %mul6, ptr %arrayidx7, align 4
159 %arrayidx8 = getelementptr inbounds i32, ptr %b, i64 2
160 %4 = load i32, ptr %arrayidx8, align 4
161 %arrayidx9 = getelementptr inbounds i32, ptr %c, i64 2
162 %5 = load i32, ptr %arrayidx9, align 4
163 %add10 = add nsw i32 %5, %4
164 %mul11 = mul i32 %add10, -8
165 %arrayidx12 = getelementptr inbounds i32, ptr %a, i64 2
166 store i32 %mul11, ptr %arrayidx12, align 4
167 %arrayidx13 = getelementptr inbounds i32, ptr %b, i64 3
168 %6 = load i32, ptr %arrayidx13, align 4
169 %arrayidx14 = getelementptr inbounds i32, ptr %c, i64 3
170 %7 = load i32, ptr %arrayidx14, align 4
171 %add15 = add nsw i32 %7, %6
172 %mul16 = mul i32 %add15, -16
173 %arrayidx17 = getelementptr inbounds i32, ptr %a, i64 3
174 store i32 %mul16, ptr %arrayidx17, align 4
178 define void @PR51436(ptr nocapture %a) {
179 ; SSE-LABEL: @PR51436(
181 ; SSE-NEXT: [[GEP2:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 2
182 ; SSE-NEXT: [[GEP4:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 4
183 ; SSE-NEXT: [[GEP6:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 6
184 ; SSE-NEXT: [[TMP1:%.*]] = load <2 x i64>, ptr [[A]], align 8
185 ; SSE-NEXT: [[TMP2:%.*]] = mul <2 x i64> [[TMP1]], splat (i64 -17592186044416)
186 ; SSE-NEXT: [[TMP3:%.*]] = add <2 x i64> [[TMP2]], splat (i64 -17592186044416)
187 ; SSE-NEXT: store <2 x i64> [[TMP3]], ptr [[A]], align 8
188 ; SSE-NEXT: [[TMP6:%.*]] = load <2 x i64>, ptr [[GEP2]], align 8
189 ; SSE-NEXT: [[TMP4:%.*]] = mul <2 x i64> [[TMP6]], splat (i64 -17592186044416)
190 ; SSE-NEXT: [[TMP8:%.*]] = add <2 x i64> [[TMP4]], splat (i64 -17592186044416)
191 ; SSE-NEXT: store <2 x i64> [[TMP8]], ptr [[GEP2]], align 8
192 ; SSE-NEXT: [[TMP11:%.*]] = load <2 x i64>, ptr [[GEP4]], align 8
193 ; SSE-NEXT: [[TMP7:%.*]] = mul <2 x i64> [[TMP11]], splat (i64 -17592186044416)
194 ; SSE-NEXT: [[TMP13:%.*]] = add <2 x i64> [[TMP7]], splat (i64 -17592186044416)
195 ; SSE-NEXT: store <2 x i64> [[TMP13]], ptr [[GEP4]], align 8
196 ; SSE-NEXT: [[TMP16:%.*]] = load <2 x i64>, ptr [[GEP6]], align 8
197 ; SSE-NEXT: [[TMP10:%.*]] = mul <2 x i64> [[TMP16]], splat (i64 -17592186044416)
198 ; SSE-NEXT: [[TMP18:%.*]] = add <2 x i64> [[TMP10]], splat (i64 -17592186044416)
199 ; SSE-NEXT: store <2 x i64> [[TMP18]], ptr [[GEP6]], align 8
202 ; AVX-LABEL: @PR51436(
204 ; AVX-NEXT: [[GEP4:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 4
205 ; AVX-NEXT: [[TMP1:%.*]] = load <4 x i64>, ptr [[A]], align 8
206 ; AVX-NEXT: [[TMP2:%.*]] = mul <4 x i64> [[TMP1]], splat (i64 -17592186044416)
207 ; AVX-NEXT: [[TMP3:%.*]] = add <4 x i64> [[TMP2]], splat (i64 -17592186044416)
208 ; AVX-NEXT: store <4 x i64> [[TMP3]], ptr [[A]], align 8
209 ; AVX-NEXT: [[TMP6:%.*]] = load <4 x i64>, ptr [[GEP4]], align 8
210 ; AVX-NEXT: [[TMP4:%.*]] = mul <4 x i64> [[TMP6]], splat (i64 -17592186044416)
211 ; AVX-NEXT: [[TMP8:%.*]] = add <4 x i64> [[TMP4]], splat (i64 -17592186044416)
212 ; AVX-NEXT: store <4 x i64> [[TMP8]], ptr [[GEP4]], align 8
216 %gep1 = getelementptr inbounds i64, ptr %a, i64 1
217 %gep2 = getelementptr inbounds i64, ptr %a, i64 2
218 %gep3 = getelementptr inbounds i64, ptr %a, i64 3
219 %gep4 = getelementptr inbounds i64, ptr %a, i64 4
220 %gep5 = getelementptr inbounds i64, ptr %a, i64 5
221 %gep6 = getelementptr inbounds i64, ptr %a, i64 6
222 %gep7 = getelementptr inbounds i64, ptr %a, i64 7
223 %load0 = load i64, ptr %a, align 8
224 %load1 = load i64, ptr %gep1, align 8
225 %load2 = load i64, ptr %gep2, align 8
226 %load3 = load i64, ptr %gep3, align 8
227 %load4 = load i64, ptr %gep4, align 8
228 %load5 = load i64, ptr %gep5, align 8
229 %load6 = load i64, ptr %gep6, align 8
230 %load7 = load i64, ptr %gep7, align 8
231 %mul0 = mul i64 %load0, -17592186044416
232 %mul1 = mul i64 %load1, -17592186044416
233 %mul2 = mul i64 %load2, -17592186044416
234 %mul3 = mul i64 %load3, -17592186044416
235 %mul4 = mul i64 %load4, -17592186044416
236 %mul5 = mul i64 %load5, -17592186044416
237 %mul6 = mul i64 %load6, -17592186044416
238 %mul7 = mul i64 %load7, -17592186044416
239 %add0 = add i64 %mul0, -17592186044416
240 %add1 = add i64 %mul1, -17592186044416
241 %add2 = add i64 %mul2, -17592186044416
242 %add3 = add i64 %mul3, -17592186044416
243 %add4 = add i64 %mul4, -17592186044416
244 %add5 = add i64 %mul5, -17592186044416
245 %add6 = add i64 %mul6, -17592186044416
246 %add7 = add i64 %mul7, -17592186044416
247 store i64 %add0, ptr %a, align 8
248 store i64 %add1, ptr %gep1, align 8
249 store i64 %add2, ptr %gep2, align 8
250 store i64 %add3, ptr %gep3, align 8
251 store i64 %add4, ptr %gep4, align 8
252 store i64 %add5, ptr %gep5, align 8
253 store i64 %add6, ptr %gep6, align 8
254 store i64 %add7, ptr %gep7, align 8