@@ -212,3 +212,59 @@ define void @multi_use_vec_sub(<2 x i32> %X, <2 x i32> %Y) {
212
212
call <2 x i32 > @use64_vec (<2 x i64 > %A2 )
213
213
ret void
214
214
}
215
+
216
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
217
+ ;; These tests check cases where expression dag post-dominated by TruncInst
218
+ ;; contains TruncInst leaf or ZEXT/SEXT leafs which turn into TruncInst leaves.
219
+ ;; Check that both expressions are reduced and no TruncInst remains or (was
220
+ ;; generated).
221
+ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
222
+
223
+ ; Notice that there are two expression patterns below:
224
+ ; 1. %T2->%C2->(%B2->(%T1, 15), %B2->(%T1, 15))
225
+ ; 2. %T1`->%C1->(%B1->(%A1, 15), %B1->(%A1, 15))
226
+ ; (where %T1` is the reduced node of %T1 into trunc instruction)
227
+ define void @trunc_as_a_leaf (i32 %X ) {
228
+ ; CHECK-LABEL: @trunc_as_a_leaf(
229
+ ; CHECK-NEXT: [[B1:%.*]] = add i32 [[X:%.*]], 15
230
+ ; CHECK-NEXT: [[C1:%.*]] = mul i32 [[B1]], [[B1]]
231
+ ; CHECK-NEXT: [[B2:%.*]] = add i32 [[C1]], 15
232
+ ; CHECK-NEXT: [[C2:%.*]] = mul i32 [[B2]], [[B2]]
233
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use32(i32 [[C2]])
234
+ ; CHECK-NEXT: ret void
235
+ ;
236
+ %A1 = zext i32 %X to i64
237
+ %B1 = add i64 %A1 , 15
238
+ %C1 = mul i64 %B1 , %B1
239
+ %T1 = trunc i64 %C1 to i48 ; leaf trunc
240
+ %B2 = add i48 %T1 , 15
241
+ %C2 = mul i48 %B2 , %B2
242
+ %T2 = trunc i48 %C2 to i32
243
+ call i32 @use32 (i32 %T2 )
244
+ ret void
245
+ }
246
+
247
+ ; Notice that there are two expression patterns below:
248
+ ; 1. %T2->%C2->(%B2->(%T1, 15), %B2->(%T1, 15))
249
+ ; 2. %T1`->%C1->(%B1->(%A1, 15), %B1->(%A1, 15))
250
+ ; (where %T1` is the reduced node of %T1 into trunc instruction)
251
+ define void @zext_as_a_leaf (i16 %X ) {
252
+ ; CHECK-LABEL: @zext_as_a_leaf(
253
+ ; CHECK-NEXT: [[A1:%.*]] = zext i16 [[X:%.*]] to i32
254
+ ; CHECK-NEXT: [[B1:%.*]] = add i32 [[A1]], 15
255
+ ; CHECK-NEXT: [[C1:%.*]] = mul i32 [[B1]], [[B1]]
256
+ ; CHECK-NEXT: [[B2:%.*]] = add i32 [[C1]], 15
257
+ ; CHECK-NEXT: [[C2:%.*]] = mul i32 [[B2]], [[B2]]
258
+ ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @use32(i32 [[C2]])
259
+ ; CHECK-NEXT: ret void
260
+ ;
261
+ %A1 = zext i16 %X to i48
262
+ %B1 = add i48 %A1 , 15
263
+ %C1 = mul i48 %B1 , %B1
264
+ %T1 = zext i48 %C1 to i64 ; leaf zext, which will turn into trunc
265
+ %B2 = add i64 %T1 , 15
266
+ %C2 = mul i64 %B2 , %B2
267
+ %T2 = trunc i64 %C2 to i32
268
+ call i32 @use32 (i32 %T2 )
269
+ ret void
270
+ }
0 commit comments