[llvm] 95b6f62 - [InstSimplify] Add some vector shift tests to show lack of DemandedElts support

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 19 15:10:07 PDT 2020


Author: Simon Pilgrim
Date: 2020-03-19T22:09:51Z
New Revision: 95b6f62efb14bae16958a13f85cf64216f6257e9

URL: https://github.com/llvm/llvm-project/commit/95b6f62efb14bae16958a13f85cf64216f6257e9
DIFF: https://github.com/llvm/llvm-project/commit/95b6f62efb14bae16958a13f85cf64216f6257e9.diff

LOG: [InstSimplify] Add some vector shift tests to show lack of DemandedElts support

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/compare.ll
    llvm/test/Transforms/InstSimplify/shift-knownbits.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 3f095cd34e3d..494968c6e81c 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -377,6 +377,25 @@ define i1 @add(i32 %x, i32 %y) {
   ret i1 %c
 }
 
+define i1 @addv(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @addv(
+; CHECK-NEXT:    [[L:%.*]] = lshr <2 x i32> [[X:%.*]], <i32 1, i32 0>
+; CHECK-NEXT:    [[Q:%.*]] = lshr <2 x i32> [[Y:%.*]], <i32 1, i32 0>
+; CHECK-NEXT:    [[R:%.*]] = or <2 x i32> [[Q]], <i32 1, i32 0>
+; CHECK-NEXT:    [[S:%.*]] = add <2 x i32> [[L]], [[R]]
+; CHECK-NEXT:    [[E:%.*]] = extractelement <2 x i32> [[S]], i32 0
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[E]], 0
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %l = lshr <2 x i32> %x, <i32 1, i32 0>
+  %q = lshr <2 x i32> %y, <i32 1, i32 0>
+  %r = or <2 x i32> %q, <i32 1, i32 0>
+  %s = add <2 x i32> %l, %r
+  %e = extractelement <2 x i32> %s, i32 0
+  %c = icmp eq i32 %e, 0
+  ret i1 %c
+}
+
 define i1 @add2(i8 %x, i8 %y) {
 ; CHECK-LABEL: @add2(
 ; CHECK-NEXT:    ret i1 false
@@ -388,6 +407,23 @@ define i1 @add2(i8 %x, i8 %y) {
   ret i1 %c
 }
 
+define i1 @add2v(<2 x i8> %x, <2 x i8> %y) {
+; CHECK-LABEL: @add2v(
+; CHECK-NEXT:    [[L:%.*]] = or <2 x i8> [[X:%.*]], <i8 0, i8 -128>
+; CHECK-NEXT:    [[R:%.*]] = or <2 x i8> [[Y:%.*]], <i8 0, i8 -127>
+; CHECK-NEXT:    [[S:%.*]] = add <2 x i8> [[L]], [[R]]
+; CHECK-NEXT:    [[E:%.*]] = extractelement <2 x i8> [[S]], i32 1
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i8 [[E]], 0
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %l = or <2 x i8> %x, <i8 0, i8 128>
+  %r = or <2 x i8> %y, <i8 0, i8 129>
+  %s = add <2 x i8> %l, %r
+  %e = extractelement <2 x i8> %s, i32 1
+  %c = icmp eq i8 %e, 0
+  ret i1 %c
+}
+
 define i1 @add3(i8 %x, i8 %y) {
 ; CHECK-LABEL: @add3(
 ; CHECK-NEXT:    [[L:%.*]] = zext i8 [[X:%.*]] to i32
@@ -446,6 +482,23 @@ define i1 @addpowtwo(i32 %x, i32 %y) {
   ret i1 %c
 }
 
+define i1 @addpowtwov(<2 x i32> %x, <2 x i32> %y) {
+; CHECK-LABEL: @addpowtwov(
+; CHECK-NEXT:    [[L:%.*]] = lshr <2 x i32> [[X:%.*]], <i32 1, i32 0>
+; CHECK-NEXT:    [[R:%.*]] = shl <2 x i32> <i32 1, i32 0>, [[Y:%.*]]
+; CHECK-NEXT:    [[S:%.*]] = add <2 x i32> [[L]], [[R]]
+; CHECK-NEXT:    [[E:%.*]] = extractelement <2 x i32> [[S]], i32 0
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[E]], 0
+; CHECK-NEXT:    ret i1 [[C]]
+;
+  %l = lshr <2 x i32> %x, <i32 1, i32 0>
+  %r = shl <2 x i32> <i32 1, i32 0>, %y
+  %s = add <2 x i32> %l, %r
+  %e = extractelement <2 x i32> %s, i32 0
+  %c = icmp eq i32 %e, 0
+  ret i1 %c
+}
+
 define i1 @or(i32 %x) {
 ; CHECK-LABEL: @or(
 ; CHECK-NEXT:    ret i1 false

diff  --git a/llvm/test/Transforms/InstSimplify/shift-knownbits.ll b/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
index 63b9b76fd22f..f4b10a348f84 100644
--- a/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
+++ b/llvm/test/Transforms/InstSimplify/shift-knownbits.ll
@@ -40,7 +40,7 @@ define i33 @ashr_amount_is_known_bogus(i33 %a, i33 %b) {
 
 define i16 @ashr_amount_is_zero(i16 %a, i16 %b) {
 ; CHECK-LABEL: @ashr_amount_is_zero(
-; CHECK-NEXT:    ret i16 %a
+; CHECK-NEXT:    ret i16 [[A:%.*]]
 ;
   %and = and i16 %b, 65520 ; 0xfff0
   %shr = ashr i16 %a, %and
@@ -49,7 +49,7 @@ define i16 @ashr_amount_is_zero(i16 %a, i16 %b) {
 
 define i300 @lshr_amount_is_zero(i300 %a, i300 %b) {
 ; CHECK-LABEL: @lshr_amount_is_zero(
-; CHECK-NEXT:    ret i300 %a
+; CHECK-NEXT:    ret i300 [[A:%.*]]
 ;
   %and = and i300 %b, 2048
   %shr = lshr i300 %a, %and
@@ -58,7 +58,7 @@ define i300 @lshr_amount_is_zero(i300 %a, i300 %b) {
 
 define i9 @shl_amount_is_zero(i9 %a, i9 %b) {
 ; CHECK-LABEL: @shl_amount_is_zero(
-; CHECK-NEXT:    ret i9 %a
+; CHECK-NEXT:    ret i9 [[A:%.*]]
 ;
   %and = and i9 %b, 496 ; 0x1f0
   %shl = shl i9 %a, %and
@@ -70,8 +70,8 @@ define i9 @shl_amount_is_zero(i9 %a, i9 %b) {
 
 define i9 @shl_amount_is_not_known_zero(i9 %a, i9 %b) {
 ; CHECK-LABEL: @shl_amount_is_not_known_zero(
-; CHECK-NEXT:    [[AND:%.*]] = and i9 %b, -8
-; CHECK-NEXT:    [[SHL:%.*]] = shl i9 %a, [[AND]]
+; CHECK-NEXT:    [[AND:%.*]] = and i9 [[B:%.*]], -8
+; CHECK-NEXT:    [[SHL:%.*]] = shl i9 [[A:%.*]], [[AND]]
 ; CHECK-NEXT:    ret i9 [[SHL]]
 ;
   %and = and i9 %b, 504 ; 0x1f8
@@ -94,8 +94,8 @@ define <2 x i32> @ashr_vector_bogus(<2 x i32> %a, <2 x i32> %b) {
 ; FIXME: This is undef, but computeKnownBits doesn't handle the union.
 define <2 x i32> @shl_vector_bogus(<2 x i32> %a, <2 x i32> %b) {
 ; CHECK-LABEL: @shl_vector_bogus(
-; CHECK-NEXT:    [[OR:%.*]] = or <2 x i32> %b, <i32 32, i32 64>
-; CHECK-NEXT:    [[SHL:%.*]] = shl <2 x i32> %a, [[OR]]
+; CHECK-NEXT:    [[OR:%.*]] = or <2 x i32> [[B:%.*]], <i32 32, i32 64>
+; CHECK-NEXT:    [[SHL:%.*]] = shl <2 x i32> [[A:%.*]], [[OR]]
 ; CHECK-NEXT:    ret <2 x i32> [[SHL]]
 ;
   %or = or <2 x i32> %b, <i32 32, i32 64>
@@ -105,7 +105,7 @@ define <2 x i32> @shl_vector_bogus(<2 x i32> %a, <2 x i32> %b) {
 
 define <2 x i32> @lshr_vector_zero(<2 x i32> %a, <2 x i32> %b) {
 ; CHECK-LABEL: @lshr_vector_zero(
-; CHECK-NEXT:    ret <2 x i32> %a
+; CHECK-NEXT:    ret <2 x i32> [[A:%.*]]
 ;
   %and = and <2 x i32> %b, <i32 64, i32 256>
   %shr = lshr <2 x i32> %a, %and
@@ -115,7 +115,7 @@ define <2 x i32> @lshr_vector_zero(<2 x i32> %a, <2 x i32> %b) {
 ; Make sure that weird vector types work too.
 define <2 x i15> @shl_vector_zero(<2 x i15> %a, <2 x i15> %b) {
 ; CHECK-LABEL: @shl_vector_zero(
-; CHECK-NEXT:    ret <2 x i15> %a
+; CHECK-NEXT:    ret <2 x i15> [[A:%.*]]
 ;
   %and = and <2 x i15> %b, <i15 1024, i15 1024>
   %shl = shl <2 x i15> %a, %and
@@ -124,8 +124,8 @@ define <2 x i15> @shl_vector_zero(<2 x i15> %a, <2 x i15> %b) {
 
 define <2 x i32> @shl_vector_for_real(<2 x i32> %a, <2 x i32> %b) {
 ; CHECK-LABEL: @shl_vector_for_real(
-; CHECK-NEXT:    [[AND:%.*]] = and <2 x i32> %b, <i32 3, i32 3>
-; CHECK-NEXT:    [[SHL:%.*]] = shl <2 x i32> %a, [[AND]]
+; CHECK-NEXT:    [[AND:%.*]] = and <2 x i32> [[B:%.*]], <i32 3, i32 3>
+; CHECK-NEXT:    [[SHL:%.*]] = shl <2 x i32> [[A:%.*]], [[AND]]
 ; CHECK-NEXT:    ret <2 x i32> [[SHL]]
 ;
   %and = and <2 x i32> %b, <i32 3, i32 3> ; a necessary mask op
@@ -139,7 +139,7 @@ define <2 x i32> @shl_vector_for_real(<2 x i32> %a, <2 x i32> %b) {
 
 define i1 @shl_i1(i1 %a, i1 %b) {
 ; CHECK-LABEL: @shl_i1(
-; CHECK-NEXT:    ret i1 %a
+; CHECK-NEXT:    ret i1 [[A:%.*]]
 ;
   %shl = shl i1 %a, %b
   ret i1 %shl
@@ -179,6 +179,19 @@ define <2 x i8> @lshr_ctlz_zero_is_undef_splat_vec(<2 x i8> %x) {
   ret <2 x i8> %sh
 }
 
+define i8 @lshr_ctlz_zero_is_undef_vec(<2 x i8> %x) {
+; CHECK-LABEL: @lshr_ctlz_zero_is_undef_vec(
+; CHECK-NEXT:    [[CT:%.*]] = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> [[X:%.*]], i1 true)
+; CHECK-NEXT:    [[SH:%.*]] = lshr <2 x i8> [[CT]], <i8 3, i8 0>
+; CHECK-NEXT:    [[EX:%.*]] = extractelement <2 x i8> [[SH]], i32 0
+; CHECK-NEXT:    ret i8 [[EX]]
+;
+  %ct = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> %x, i1 true)
+  %sh = lshr <2 x i8> %ct, <i8 3, i8 0>
+  %ex = extractelement <2 x i8> %sh, i32 0
+  ret i8 %ex
+}
+
 define <2 x i8> @lshr_cttz_zero_is_undef_splat_vec(<2 x i8> %x) {
 ; CHECK-LABEL: @lshr_cttz_zero_is_undef_splat_vec(
 ; CHECK-NEXT:    ret <2 x i8> zeroinitializer
@@ -188,3 +201,16 @@ define <2 x i8> @lshr_cttz_zero_is_undef_splat_vec(<2 x i8> %x) {
   ret <2 x i8> %sh
 }
 
+define i8 @lshr_cttz_zero_is_undef_vec(<2 x i8> %x) {
+; CHECK-LABEL: @lshr_cttz_zero_is_undef_vec(
+; CHECK-NEXT:    [[CT:%.*]] = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> [[X:%.*]], i1 true)
+; CHECK-NEXT:    [[SH:%.*]] = lshr <2 x i8> [[CT]], <i8 3, i8 0>
+; CHECK-NEXT:    [[EX:%.*]] = extractelement <2 x i8> [[SH]], i32 0
+; CHECK-NEXT:    ret i8 [[EX]]
+;
+  %ct = call <2 x i8> @llvm.cttz.v2i8(<2 x i8> %x, i1 true)
+  %sh = lshr <2 x i8> %ct, <i8 3, i8 0>
+  %ex = extractelement <2 x i8> %sh, i32 0
+  ret i8 %ex
+}
+


        


More information about the llvm-commits mailing list