@@ -310,7 +310,7 @@ define <2 x i31> @fshl_only_op1_demanded_vec_splat(<2 x i31> %x, <2 x i31> %y) {
310
310
311
311
define i32 @fshl_constant_shift_amount_modulo_bitwidth (i32 %x , i32 %y ) {
312
312
; CHECK-LABEL: @fshl_constant_shift_amount_modulo_bitwidth(
313
- ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[Y:%.*]], i32 33 )
313
+ ; CHECK-NEXT: [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[Y:%.*]], i32 1 )
314
314
; CHECK-NEXT: ret i32 [[R]]
315
315
;
316
316
%r = call i32 @llvm.fshl.i32 (i32 %x , i32 %y , i32 33 )
@@ -319,16 +319,28 @@ define i32 @fshl_constant_shift_amount_modulo_bitwidth(i32 %x, i32 %y) {
319
319
320
320
define i33 @fshr_constant_shift_amount_modulo_bitwidth (i33 %x , i33 %y ) {
321
321
; CHECK-LABEL: @fshr_constant_shift_amount_modulo_bitwidth(
322
- ; CHECK-NEXT: [[R:%.*]] = call i33 @llvm.fshr.i33(i33 [[X:%.*]], i33 [[Y:%.*]], i33 34 )
322
+ ; CHECK-NEXT: [[R:%.*]] = call i33 @llvm.fshr.i33(i33 [[X:%.*]], i33 [[Y:%.*]], i33 1 )
323
323
; CHECK-NEXT: ret i33 [[R]]
324
324
;
325
325
%r = call i33 @llvm.fshr.i33 (i33 %x , i33 %y , i33 34 )
326
326
ret i33 %r
327
327
}
328
328
329
+ @external_global = external global i8
330
+
331
+ define i33 @fshr_constant_shift_amount_modulo_bitwidth_constexpr (i33 %x , i33 %y ) {
332
+ ; CHECK-LABEL: @fshr_constant_shift_amount_modulo_bitwidth_constexpr(
333
+ ; CHECK-NEXT: [[R:%.*]] = call i33 @llvm.fshr.i33(i33 [[X:%.*]], i33 [[Y:%.*]], i33 ptrtoint (i8* @external_global to i33))
334
+ ; CHECK-NEXT: ret i33 [[R]]
335
+ ;
336
+ %shamt = ptrtoint i8* @external_global to i33
337
+ %r = call i33 @llvm.fshr.i33 (i33 %x , i33 %y , i33 %shamt )
338
+ ret i33 %r
339
+ }
340
+
329
341
define <2 x i32 > @fshr_constant_shift_amount_modulo_bitwidth_vec (<2 x i32 > %x , <2 x i32 > %y ) {
330
342
; CHECK-LABEL: @fshr_constant_shift_amount_modulo_bitwidth_vec(
331
- ; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]], <2 x i32> <i32 34 , i32 -1 >)
343
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i32> @llvm.fshr.v2i32(<2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]], <2 x i32> <i32 2 , i32 31 >)
332
344
; CHECK-NEXT: ret <2 x i32> [[R]]
333
345
;
334
346
%r = call <2 x i32 > @llvm.fshr.v2i32 (<2 x i32 > %x , <2 x i32 > %y , <2 x i32 > <i32 34 , i32 -1 >)
@@ -373,17 +385,28 @@ define <2 x i32> @fshr_constant_shift_amount_modulo_bitwidth_vec(<2 x i32> %x, <
373
385
374
386
define <2 x i31 > @fshl_constant_shift_amount_modulo_bitwidth_vec (<2 x i31 > %x , <2 x i31 > %y ) {
375
387
; CHECK-LABEL: @fshl_constant_shift_amount_modulo_bitwidth_vec(
376
- ; CHECK-NEXT: [[R:%.*]] = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> [[X:%.*]], <2 x i31> [[Y:%.*]], <2 x i31> <i31 34 , i31 - 1>)
388
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> [[X:%.*]], <2 x i31> [[Y:%.*]], <2 x i31> <i31 3 , i31 1>)
377
389
; CHECK-NEXT: ret <2 x i31> [[R]]
378
390
;
379
391
%r = call <2 x i31 > @llvm.fshl.v2i31 (<2 x i31 > %x , <2 x i31 > %y , <2 x i31 > <i31 34 , i31 -1 >)
380
392
ret <2 x i31 > %r
381
393
}
382
394
383
- ; The shift modulo bitwidth is the same for all vector elements, but this is not simplified yet.
395
+ define <2 x i31 > @fshl_constant_shift_amount_modulo_bitwidth_vec_const_expr (<2 x i31 > %x , <2 x i31 > %y ) {
396
+ ; CHECK-LABEL: @fshl_constant_shift_amount_modulo_bitwidth_vec_const_expr(
397
+ ; CHECK-NEXT: [[R:%.*]] = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> [[X:%.*]], <2 x i31> [[Y:%.*]], <2 x i31> <i31 34, i31 ptrtoint (i8* @external_global to i31)>)
398
+ ; CHECK-NEXT: ret <2 x i31> [[R]]
399
+ ;
400
+ %shamt = ptrtoint i8* @external_global to i31
401
+ %r = call <2 x i31 > @llvm.fshl.v2i31 (<2 x i31 > %x , <2 x i31 > %y , <2 x i31 > <i31 34 , i31 ptrtoint (i8* @external_global to i31 )>)
402
+ ret <2 x i31 > %r
403
+ }
404
+
405
+ ; The shift modulo bitwidth is the same for all vector elements.
406
+
384
407
define <2 x i31 > @fshl_only_op1_demanded_vec_nonsplat (<2 x i31 > %x , <2 x i31 > %y ) {
385
408
; CHECK-LABEL: @fshl_only_op1_demanded_vec_nonsplat(
386
- ; CHECK-NEXT: [[Z:%.*]] = call <2 x i31> @llvm.fshl.v2i31(<2 x i31> [[X:%.*]], <2 x i31> [[ Y:%.*]], <2 x i31> <i31 7 , i31 38>)
409
+ ; CHECK-NEXT: [[Z:%.*]] = lshr <2 x i31> [[ Y:%.*]], <i31 24 , i31 24>
387
410
; CHECK-NEXT: [[R:%.*]] = and <2 x i31> [[Z]], <i31 63, i31 31>
388
411
; CHECK-NEXT: ret <2 x i31> [[R]]
389
412
;
0 commit comments