Skip to content

Commit 8956f80

Browse files
committed
[InstCombine] add vector tests for shift-shift; NFC
D127122
1 parent 445e2b2 commit 8956f80

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

llvm/test/Transforms/InstCombine/shift-shift.ll

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,71 @@ define <2 x i6> @shl_lshr_demand5(<2 x i8> %x) {
488488
ret <2 x i6> %r
489489
}
490490

491+
define <2 x i6> @shl_lshr_demand5_undef_left(<2 x i8> %x) {
492+
; CHECK-LABEL: @shl_lshr_demand5_undef_left(
493+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i8> <i8 undef, i8 -108>, [[X:%.*]]
494+
; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i8> [[SHL]], <i8 2, i8 2>
495+
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i8> [[LSHR]] to <2 x i6>
496+
; CHECK-NEXT: ret <2 x i6> [[R]]
497+
;
498+
%shl = shl <2 x i8> <i8 undef, i8 148>, %x ; 0b1001_0100
499+
%lshr = lshr <2 x i8> %shl, <i8 2, i8 2>
500+
%r = trunc <2 x i8> %lshr to <2 x i6>
501+
ret <2 x i6> %r
502+
}
503+
504+
define <2 x i6> @shl_lshr_demand5_undef_right(<2 x i8> %x) {
505+
; CHECK-LABEL: @shl_lshr_demand5_undef_right(
506+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i8> <i8 -108, i8 -108>, [[X:%.*]]
507+
; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i8> [[SHL]], <i8 undef, i8 2>
508+
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i8> [[LSHR]] to <2 x i6>
509+
; CHECK-NEXT: ret <2 x i6> [[R]]
510+
;
511+
%shl = shl <2 x i8> <i8 148, i8 148>, %x ; 0b1001_0100
512+
%lshr = lshr <2 x i8> %shl, <i8 undef, i8 2>
513+
%r = trunc <2 x i8> %lshr to <2 x i6>
514+
ret <2 x i6> %r
515+
}
516+
517+
define <2 x i6> @shl_lshr_demand5_nonuniform_vec_left(<2 x i8> %x) {
518+
; CHECK-LABEL: @shl_lshr_demand5_nonuniform_vec_left(
519+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i8> <i8 -108, i8 -108>, [[X:%.*]]
520+
; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i8> [[SHL]], <i8 1, i8 2>
521+
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i8> [[LSHR]] to <2 x i6>
522+
; CHECK-NEXT: ret <2 x i6> [[R]]
523+
;
524+
%shl = shl <2 x i8> <i8 148, i8 148>, %x ; 0b1001_0100
525+
%lshr = lshr <2 x i8> %shl, <i8 1, i8 2>
526+
%r = trunc <2 x i8> %lshr to <2 x i6>
527+
ret <2 x i6> %r
528+
}
529+
530+
define <2 x i6> @shl_lshr_demand5_nonuniform_vec_right(<2 x i8> %x) {
531+
; CHECK-LABEL: @shl_lshr_demand5_nonuniform_vec_right(
532+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i8> <i8 -108, i8 -112>, [[X:%.*]]
533+
; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i8> [[SHL]], <i8 2, i8 2>
534+
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i8> [[LSHR]] to <2 x i6>
535+
; CHECK-NEXT: ret <2 x i6> [[R]]
536+
;
537+
%shl = shl <2 x i8> <i8 148, i8 144>, %x ; 0b1001_0100, 0b1001_0000
538+
%lshr = lshr <2 x i8> %shl, <i8 2, i8 2>
539+
%r = trunc <2 x i8> %lshr to <2 x i6>
540+
ret <2 x i6> %r
541+
}
542+
543+
define <2 x i6> @shl_lshr_demand5_nonuniform_vec_both(<2 x i8> %x) {
544+
; CHECK-LABEL: @shl_lshr_demand5_nonuniform_vec_both(
545+
; CHECK-NEXT: [[SHL:%.*]] = shl <2 x i8> <i8 -104, i8 -108>, [[X:%.*]]
546+
; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i8> [[SHL]], <i8 3, i8 2>
547+
; CHECK-NEXT: [[R:%.*]] = trunc <2 x i8> [[LSHR]] to <2 x i6>
548+
; CHECK-NEXT: ret <2 x i6> [[R]]
549+
;
550+
%shl = shl <2 x i8> <i8 152, i8 148>, %x ; 0b1001_1000, 0b1001_0100
551+
%lshr = lshr <2 x i8> %shl, <i8 3, i8 2>
552+
%r = trunc <2 x i8> %lshr to <2 x i6>
553+
ret <2 x i6> %r
554+
}
555+
491556
define i16 @shl_lshr_demand6(i16 %x) {
492557
; CHECK-LABEL: @shl_lshr_demand6(
493558
; CHECK-NEXT: [[SHL:%.*]] = shl i16 -32624, [[X:%.*]]

0 commit comments

Comments
 (0)