1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=slp-vectorizer < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Make sure we do not generate malformed phis not in the beginning of block.
8 define void @test() #0 {
11 ; CHECK-NEXT: br label [[BB1:%.*]]
13 ; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ undef, [[BB1]] ], [ undef, [[BB:%.*]] ]
14 ; CHECK-NEXT: [[TMP2:%.*]] = phi i32 [ [[TMP18:%.*]], [[BB1]] ], [ undef, [[BB]] ]
15 ; CHECK-NEXT: [[TMP3:%.*]] = mul i32 undef, [[TMP]]
16 ; CHECK-NEXT: [[TMP4:%.*]] = mul i32 [[TMP3]], [[TMP]]
17 ; CHECK-NEXT: [[TMP5:%.*]] = mul i32 [[TMP4]], [[TMP]]
18 ; CHECK-NEXT: [[TMP6:%.*]] = mul i32 [[TMP5]], [[TMP]]
19 ; CHECK-NEXT: [[TMP7:%.*]] = mul i32 [[TMP6]], [[TMP]]
20 ; CHECK-NEXT: [[TMP8:%.*]] = mul i32 [[TMP7]], [[TMP]]
21 ; CHECK-NEXT: [[TMP9:%.*]] = mul i32 [[TMP8]], [[TMP]]
22 ; CHECK-NEXT: [[TMP10:%.*]] = mul i32 [[TMP9]], [[TMP]]
23 ; CHECK-NEXT: [[TMP11:%.*]] = mul i32 [[TMP10]], [[TMP]]
24 ; CHECK-NEXT: [[TMP12:%.*]] = mul i32 [[TMP11]], [[TMP]]
25 ; CHECK-NEXT: [[TMP13:%.*]] = mul i32 [[TMP12]], [[TMP]]
26 ; CHECK-NEXT: [[TMP14:%.*]] = mul i32 [[TMP13]], [[TMP]]
27 ; CHECK-NEXT: [[TMP15:%.*]] = mul i32 [[TMP14]], [[TMP]]
28 ; CHECK-NEXT: [[TMP16:%.*]] = mul i32 [[TMP15]], [[TMP]]
29 ; CHECK-NEXT: [[TMP17:%.*]] = mul i32 [[TMP16]], [[TMP]]
30 ; CHECK-NEXT: [[TMP18]] = mul i32 [[TMP17]], [[TMP]]
31 ; CHECK-NEXT: br label [[BB1]]
36 bb1: ; preds = %bb1, %bb
37 %tmp = phi i32 [ undef, %bb1 ], [ undef, %bb ]
38 %tmp2 = phi i32 [ %tmp18, %bb1 ], [ undef, %bb ]
39 %tmp3 = mul i32 undef, %tmp
40 %tmp4 = mul i32 %tmp3, %tmp
41 %tmp5 = mul i32 %tmp4, %tmp
42 %tmp6 = mul i32 %tmp5, %tmp
43 %tmp7 = mul i32 %tmp6, %tmp
44 %tmp8 = mul i32 %tmp7, %tmp
45 %tmp9 = mul i32 %tmp8, %tmp
46 %tmp10 = mul i32 %tmp9, %tmp
47 %tmp11 = mul i32 %tmp10, %tmp
48 %tmp12 = mul i32 %tmp11, %tmp
49 %tmp13 = mul i32 %tmp12, %tmp
50 %tmp14 = mul i32 %tmp13, %tmp
51 %tmp15 = mul i32 %tmp14, %tmp
52 %tmp16 = mul i32 %tmp15, %tmp
53 %tmp17 = mul i32 %tmp16, %tmp
54 %tmp18 = mul i32 %tmp17, %tmp
58 define void @test_2(ptr addrspace(1) %arg, i32 %arg1) #0 {
59 ; CHECK-LABEL: @test_2(
61 ; CHECK-NEXT: br label [[BB2:%.*]]
63 ; CHECK-NEXT: [[TMP:%.*]] = phi i32 [ undef, [[BB:%.*]] ], [ undef, [[BB2]] ]
64 ; CHECK-NEXT: [[TMP3:%.*]] = phi i32 [ 0, [[BB]] ], [ undef, [[BB2]] ]
65 ; CHECK-NEXT: [[TMP0:%.*]] = mul i32 [[TMP]], 8
66 ; CHECK-NEXT: [[OP_RDX:%.*]] = add i32 undef, [[TMP0]]
67 ; CHECK-NEXT: call void @use(i32 [[OP_RDX]])
68 ; CHECK-NEXT: br label [[BB2]]
73 bb2: ; preds = %bb2, %bb
74 %tmp = phi i32 [ undef, %bb ], [ undef, %bb2 ]
75 %tmp3 = phi i32 [ 0, %bb ], [ undef, %bb2 ]
76 %tmp4 = add i32 %tmp, undef
77 %tmp5 = add i32 undef, %tmp4
78 %tmp6 = add i32 %tmp, %tmp5
79 %tmp7 = add i32 undef, %tmp6
80 %tmp8 = add i32 %tmp, %tmp7
81 %tmp9 = add i32 undef, %tmp8
82 %tmp10 = add i32 %tmp, %tmp9
83 %tmp11 = add i32 undef, %tmp10
84 %tmp12 = add i32 %tmp, %tmp11
85 %tmp13 = add i32 undef, %tmp12
86 %tmp14 = add i32 %tmp, %tmp13
87 %tmp15 = add i32 undef, %tmp14
88 %tmp16 = add i32 %tmp, %tmp15
89 %tmp17 = add i32 undef, %tmp16
90 %tmp18 = add i32 %tmp, %tmp17
91 %tmp19 = add i32 undef, %tmp18
92 call void @use(i32 %tmp19)
96 ; Make sure we don't crash.
97 define i64 @test_3() #0 {
98 ; CHECK-LABEL: @test_3(
100 ; CHECK-NEXT: br label [[BB1:%.*]]
102 ; CHECK-NEXT: br label [[BB3:%.*]]
104 ; CHECK-NEXT: br label [[BB3]]
106 ; CHECK-NEXT: [[VAL:%.*]] = phi i32 [ undef, [[BB1]] ], [ undef, [[BB2:%.*]] ]
107 ; CHECK-NEXT: [[VAL4:%.*]] = phi i32 [ undef, [[BB1]] ], [ undef, [[BB2]] ]
108 ; CHECK-NEXT: [[TMP0:%.*]] = insertelement <32 x i32> poison, i32 [[VAL4]], i32 0
109 ; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <32 x i32> [[TMP0]], <32 x i32> poison, <32 x i32> zeroinitializer
110 ; CHECK-NEXT: [[TMP2:%.*]] = call i32 @llvm.vector.reduce.mul.v32i32(<32 x i32> [[TMP1]])
111 ; CHECK-NEXT: [[OP_RDX:%.*]] = mul i32 [[TMP2]], [[VAL4]]
112 ; CHECK-NEXT: [[OP_RDX1:%.*]] = mul i32 [[VAL4]], [[VAL4]]
113 ; CHECK-NEXT: [[OP_RDX2:%.*]] = mul i32 [[VAL4]], [[VAL4]]
114 ; CHECK-NEXT: [[OP_RDX3:%.*]] = mul i32 [[VAL4]], [[VAL4]]
115 ; CHECK-NEXT: [[OP_RDX4:%.*]] = mul i32 [[VAL4]], [[VAL4]]
116 ; CHECK-NEXT: [[OP_RDX5:%.*]] = mul i32 [[VAL4]], [[VAL4]]
117 ; CHECK-NEXT: [[OP_RDX6:%.*]] = mul i32 [[VAL4]], [[VAL4]]
118 ; CHECK-NEXT: [[OP_RDX7:%.*]] = mul i32 [[VAL4]], [[VAL4]]
119 ; CHECK-NEXT: [[OP_RDX8:%.*]] = mul i32 [[VAL4]], [[VAL4]]
120 ; CHECK-NEXT: [[OP_RDX9:%.*]] = mul i32 [[VAL4]], [[VAL4]]
121 ; CHECK-NEXT: [[OP_RDX10:%.*]] = mul i32 [[VAL4]], [[VAL4]]
122 ; CHECK-NEXT: [[OP_RDX11:%.*]] = mul i32 [[VAL4]], [[VAL4]]
123 ; CHECK-NEXT: [[OP_RDX12:%.*]] = mul i32 [[VAL4]], [[VAL4]]
124 ; CHECK-NEXT: [[OP_RDX13:%.*]] = mul i32 [[VAL4]], [[VAL4]]
125 ; CHECK-NEXT: [[OP_RDX14:%.*]] = mul i32 [[OP_RDX]], [[OP_RDX1]]
126 ; CHECK-NEXT: [[OP_RDX15:%.*]] = mul i32 [[OP_RDX2]], [[OP_RDX3]]
127 ; CHECK-NEXT: [[OP_RDX16:%.*]] = mul i32 [[OP_RDX4]], [[OP_RDX5]]
128 ; CHECK-NEXT: [[OP_RDX17:%.*]] = mul i32 [[OP_RDX6]], [[OP_RDX7]]
129 ; CHECK-NEXT: [[OP_RDX18:%.*]] = mul i32 [[OP_RDX8]], [[OP_RDX9]]
130 ; CHECK-NEXT: [[OP_RDX19:%.*]] = mul i32 [[OP_RDX10]], [[OP_RDX11]]
131 ; CHECK-NEXT: [[OP_RDX20:%.*]] = mul i32 [[OP_RDX12]], [[OP_RDX13]]
132 ; CHECK-NEXT: [[OP_RDX21:%.*]] = mul i32 [[OP_RDX14]], [[OP_RDX15]]
133 ; CHECK-NEXT: [[OP_RDX22:%.*]] = mul i32 [[OP_RDX16]], [[OP_RDX17]]
134 ; CHECK-NEXT: [[OP_RDX23:%.*]] = mul i32 [[OP_RDX18]], [[OP_RDX19]]
135 ; CHECK-NEXT: [[OP_RDX24:%.*]] = mul i32 [[OP_RDX20]], [[VAL]]
136 ; CHECK-NEXT: [[OP_RDX25:%.*]] = mul i32 [[OP_RDX21]], [[OP_RDX22]]
137 ; CHECK-NEXT: [[OP_RDX26:%.*]] = mul i32 [[OP_RDX23]], [[OP_RDX24]]
138 ; CHECK-NEXT: [[OP_RDX27:%.*]] = mul i32 [[OP_RDX25]], [[OP_RDX26]]
139 ; CHECK-NEXT: [[VAL64:%.*]] = add i32 undef, [[OP_RDX27]]
140 ; CHECK-NEXT: [[VAL65:%.*]] = sext i32 [[VAL64]] to i64
141 ; CHECK-NEXT: ret i64 [[VAL65]]
149 bb2: ; No predecessors!
152 bb3: ; preds = %bb2, %bb1
153 %val = phi i32 [ undef, %bb1 ], [ undef, %bb2 ]
154 %val4 = phi i32 [ undef, %bb1 ], [ undef, %bb2 ]
155 %val5 = mul i32 %val, %val4
156 %val6 = mul i32 %val5, %val4
157 %val7 = mul i32 %val6, %val4
158 %val8 = mul i32 %val7, %val4
159 %val9 = mul i32 %val8, %val4
160 %val10 = mul i32 %val9, %val4
161 %val11 = mul i32 %val10, %val4
162 %val12 = mul i32 %val11, %val4
163 %val13 = mul i32 %val12, %val4
164 %val14 = mul i32 %val13, %val4
165 %val15 = mul i32 %val14, %val4
166 %val16 = mul i32 %val15, %val4
167 %val17 = mul i32 %val16, %val4
168 %val18 = mul i32 %val17, %val4
169 %val19 = mul i32 %val18, %val4
170 %val20 = mul i32 %val19, %val4
171 %val21 = mul i32 %val20, %val4
172 %val22 = mul i32 %val21, %val4
173 %val23 = mul i32 %val22, %val4
174 %val24 = mul i32 %val23, %val4
175 %val25 = mul i32 %val24, %val4
176 %val26 = mul i32 %val25, %val4
177 %val27 = mul i32 %val26, %val4
178 %val28 = mul i32 %val27, %val4
179 %val29 = mul i32 %val28, %val4
180 %val30 = mul i32 %val29, %val4
181 %val31 = mul i32 %val30, %val4
182 %val32 = mul i32 %val31, %val4
183 %val33 = mul i32 %val32, %val4
184 %val34 = mul i32 %val33, %val4
185 %val35 = mul i32 %val34, %val4
186 %val36 = mul i32 %val35, %val4
187 %val37 = mul i32 %val36, %val4
188 %val38 = mul i32 %val37, %val4
189 %val39 = mul i32 %val38, %val4
190 %val40 = mul i32 %val39, %val4
191 %val41 = mul i32 %val40, %val4
192 %val42 = mul i32 %val41, %val4
193 %val43 = mul i32 %val42, %val4
194 %val44 = mul i32 %val43, %val4
195 %val45 = mul i32 %val44, %val4
196 %val46 = mul i32 %val45, %val4
197 %val47 = mul i32 %val46, %val4
198 %val48 = mul i32 %val47, %val4
199 %val49 = mul i32 %val48, %val4
200 %val50 = mul i32 %val49, %val4
201 %val51 = mul i32 %val50, %val4
202 %val52 = mul i32 %val51, %val4
203 %val53 = mul i32 %val52, %val4
204 %val54 = mul i32 %val53, %val4
205 %val55 = mul i32 %val54, %val4
206 %val56 = mul i32 %val55, %val4
207 %val57 = mul i32 %val56, %val4
208 %val58 = mul i32 %val57, %val4
209 %val59 = mul i32 %val58, %val4
210 %val60 = mul i32 %val59, %val4
211 %val61 = mul i32 %val60, %val4
212 %val62 = mul i32 %val61, %val4
213 %val63 = mul i32 %val62, %val4
214 %val64 = add i32 undef, %val63
215 %val65 = sext i32 %val64 to i64
219 declare void @use(i32) #0
221 attributes #0 = { "target-features"="+sse4.1" }