[llvm] 5a82dc6 - [InstCombine] add tests for select-of-select-shuffle; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 10:26:33 PDT 2020


Author: Sanjay Patel
Date: 2020-06-02T13:26:21-04:00
New Revision: 5a82dc62d2335b9b4da8bacfc5eaf5c534e46a3e

URL: https://github.com/llvm/llvm-project/commit/5a82dc62d2335b9b4da8bacfc5eaf5c534e46a3e
DIFF: https://github.com/llvm/llvm-project/commit/5a82dc62d2335b9b4da8bacfc5eaf5c534e46a3e.diff

LOG: [InstCombine] add tests for select-of-select-shuffle; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/select-select.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/select-select.ll b/llvm/test/Transforms/InstCombine/select-select.ll
index ad7b5dbd4e25..bbe6b767ae9a 100644
--- a/llvm/test/Transforms/InstCombine/select-select.ll
+++ b/llvm/test/Transforms/InstCombine/select-select.ll
@@ -43,3 +43,95 @@ define <2 x i32> @foo3(<2 x i1> %vec_bool, i1 %bool, <2 x i32> %V) {
   %sel1 = select i1 %bool, <2 x i32> %sel0, <2 x i32> %V
   ret <2 x i32> %sel1
 }
+
+define <4 x i8> @sel_shuf_commute0(<4 x i8> %x, <4 x i8> %y, <4 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_commute0(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x i8> [[BLEND]], <4 x i8> [[X]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %blend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+  %r = select <4 x i1> %cmp, <4 x i8> %blend, <4 x i8> %x
+  ret <4 x i8> %r
+}
+
+define <5 x i9> @sel_shuf_commute1(<5 x i9> %x, <5 x i9> %y, <5 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_commute1(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <5 x i9> [[X:%.*]], <5 x i9> [[Y:%.*]], <5 x i32> <i32 0, i32 6, i32 2, i32 8, i32 9>
+; CHECK-NEXT:    [[R:%.*]] = select <5 x i1> [[CMP:%.*]], <5 x i9> [[BLEND]], <5 x i9> [[Y]]
+; CHECK-NEXT:    ret <5 x i9> [[R]]
+;
+  %blend = shufflevector <5 x i9> %x, <5 x i9> %y, <5 x i32> <i32 0, i32 6, i32 2, i32 8, i32 9>
+  %r = select <5 x i1> %cmp, <5 x i9> %blend, <5 x i9> %y
+  ret <5 x i9> %r
+}
+
+define <4 x float> @sel_shuf_commute2(<4 x float> %x, <4 x float> %y, <4 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_commute2(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> [[Y:%.*]], <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x float> [[X]], <4 x float> [[BLEND]]
+; CHECK-NEXT:    ret <4 x float> [[R]]
+;
+  %blend = shufflevector <4 x float> %x, <4 x float> %y, <4 x i32> <i32 0, i32 1, i32 2, i32 7>
+  %r = select <4 x i1> %cmp, <4 x float> %x, <4 x float> %blend
+  ret <4 x float> %r
+}
+
+define <4 x i8> @sel_shuf_commute3(<4 x i8> %x, <4 x i8> %y, i1 %cmp) {
+; CHECK-LABEL: @sel_shuf_commute3(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 3>
+; CHECK-NEXT:    [[R:%.*]] = select i1 [[CMP:%.*]], <4 x i8> [[Y]], <4 x i8> [[BLEND]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %blend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
+  %r = select i1 %cmp, <4 x i8> %y, <4 x i8> %blend
+  ret <4 x i8> %r
+}
+
+declare void @use(<4 x i8>)
+
+define <4 x i8> @sel_shuf_use(<4 x i8> %x, <4 x i8> %y, <4 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_use(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+; CHECK-NEXT:    call void @use(<4 x i8> [[BLEND]])
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x i8> [[BLEND]], <4 x i8> [[X]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %blend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+  call void @use(<4 x i8> %blend)
+  %r = select <4 x i1> %cmp, <4 x i8> %blend, <4 x i8> %x
+  ret <4 x i8> %r
+}
+
+define <4 x i8> @sel_shuf_undef(<4 x i8> %x, <4 x i8> %y, <4 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_undef(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 undef>
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x i8> [[BLEND]], <4 x i8> [[Y]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %blend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 undef>
+  %r = select <4 x i1> %cmp, <4 x i8> %blend, <4 x i8> %y
+  ret <4 x i8> %r
+}
+
+define <4 x i8> @sel_shuf_not(<4 x i8> %x, <4 x i8> %y, <4 x i1> %cmp) {
+; CHECK-LABEL: @sel_shuf_not(
+; CHECK-NEXT:    [[NOTBLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 6>
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x i8> [[NOTBLEND]], <4 x i8> [[Y]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %notblend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 6>
+  %r = select <4 x i1> %cmp, <4 x i8> %notblend, <4 x i8> %y
+  ret <4 x i8> %r
+}
+
+define <4 x i8> @sel_shuf_no_common_operand(<4 x i8> %x, <4 x i8> %y, <4 x i1> %cmp, <4 x i8> %z) {
+; CHECK-LABEL: @sel_shuf_no_common_operand(
+; CHECK-NEXT:    [[BLEND:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> [[Y:%.*]], <4 x i32> <i32 0, i32 5, i32 2, i32 3>
+; CHECK-NEXT:    [[R:%.*]] = select <4 x i1> [[CMP:%.*]], <4 x i8> [[Z:%.*]], <4 x i8> [[BLEND]]
+; CHECK-NEXT:    ret <4 x i8> [[R]]
+;
+  %blend = shufflevector <4 x i8> %x, <4 x i8> %y, <4 x i32> <i32 0, i32 5, i32 2, i32 3>
+  %r = select <4 x i1> %cmp, <4 x i8> %z, <4 x i8> %blend
+  ret <4 x i8> %r
+}


        


More information about the llvm-commits mailing list