[llvm] 496fc3f - [InstSimplify] add tests for icmp with partial undef constant; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 12:00:43 PDT 2020


Author: Sanjay Patel
Date: 2020-07-28T15:00:33-04:00
New Revision: 496fc3f196bca77d48804ab4bc9343c3d82b97bf

URL: https://github.com/llvm/llvm-project/commit/496fc3f196bca77d48804ab4bc9343c3d82b97bf
DIFF: https://github.com/llvm/llvm-project/commit/496fc3f196bca77d48804ab4bc9343c3d82b97bf.diff

LOG: [InstSimplify] add tests for icmp with partial undef constant; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/icmp-constant.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/icmp-constant.ll b/llvm/test/Transforms/InstSimplify/icmp-constant.ll
index 3ebaca7c8aaf..8f51ba3c4c0e 100644
--- a/llvm/test/Transforms/InstSimplify/icmp-constant.ll
+++ b/llvm/test/Transforms/InstSimplify/icmp-constant.ll
@@ -19,6 +19,15 @@ define <2 x i1> @tautological_ule_vec(<2 x i8> %x) {
   ret <2 x i1> %cmp
 }
 
+define <2 x i1> @tautological_ule_vec_partial_undef(<2 x i8> %x) {
+; CHECK-LABEL: @tautological_ule_vec_partial_undef(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ule <2 x i8> [[X:%.*]], <i8 -1, i8 undef>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %cmp = icmp ule <2 x i8> %x, <i8 255, i8 undef>
+  ret <2 x i1> %cmp
+}
+
 define i1 @tautological_ugt(i8 %x) {
 ; CHECK-LABEL: @tautological_ugt(
 ; CHECK-NEXT:    ret i1 false
@@ -35,6 +44,15 @@ define <2 x i1> @tautological_ugt_vec(<2 x i8> %x) {
   ret <2 x i1> %cmp
 }
 
+define <2 x i1> @tautological_ugt_vec_partial_undef(<2 x i8> %x) {
+; CHECK-LABEL: @tautological_ugt_vec_partial_undef(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt <2 x i8> [[X:%.*]], <i8 undef, i8 -1>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %cmp = icmp ugt <2 x i8> %x, <i8 undef, i8 255>
+  ret <2 x i1> %cmp
+}
+
 ; 'urem x, C2' produces [0, C2)
 define i1 @urem3(i32 %X) {
 ; CHECK-LABEL: @urem3(
@@ -54,6 +72,17 @@ define <2 x i1> @urem3_vec(<2 x i32> %X) {
   ret <2 x i1> %B
 }
 
+define <2 x i1> @urem3_vec_partial_undef(<2 x i32> %X) {
+; CHECK-LABEL: @urem3_vec_partial_undef(
+; CHECK-NEXT:    [[A:%.*]] = urem <2 x i32> [[X:%.*]], <i32 10, i32 10>
+; CHECK-NEXT:    [[B:%.*]] = icmp ult <2 x i32> [[A]], <i32 undef, i32 15>
+; CHECK-NEXT:    ret <2 x i1> [[B]]
+;
+  %A = urem <2 x i32> %X, <i32 10, i32 10>
+  %B = icmp ult <2 x i32> %A, <i32 undef, i32 15>
+  ret <2 x i1> %B
+}
+
 ;'srem x, C2' produces (-|C2|, |C2|)
 define i1 @srem1(i32 %X) {
 ; CHECK-LABEL: @srem1(
@@ -73,6 +102,17 @@ define <2 x i1> @srem1_vec(<2 x i32> %X) {
   ret <2 x i1> %B
 }
 
+define <2 x i1> @srem1_vec_partial_undef(<2 x i32> %X) {
+; CHECK-LABEL: @srem1_vec_partial_undef(
+; CHECK-NEXT:    [[A:%.*]] = srem <2 x i32> [[X:%.*]], <i32 -5, i32 -5>
+; CHECK-NEXT:    [[B:%.*]] = icmp sgt <2 x i32> [[A]], <i32 5, i32 undef>
+; CHECK-NEXT:    ret <2 x i1> [[B]]
+;
+  %A = srem <2 x i32> %X, <i32 -5, i32 -5>
+  %B = icmp sgt <2 x i32> %A, <i32 5, i32 undef>
+  ret <2 x i1> %B
+}
+
 ;'udiv C2, x' produces [0, C2]
 define i1 @udiv5(i32 %X) {
 ; CHECK-LABEL: @udiv5(
@@ -169,6 +209,17 @@ define <2 x i1> @shl5_vec(<2 x i32> %X) {
   ret <2 x i1> %cmp
 }
 
+define <2 x i1> @shl5_vec_partial_undef(<2 x i32> %X) {
+; CHECK-LABEL: @shl5_vec_partial_undef(
+; CHECK-NEXT:    [[SUB:%.*]] = shl nuw <2 x i32> <i32 4, i32 4>, [[X:%.*]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt <2 x i32> [[SUB]], <i32 undef, i32 3>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %sub = shl nuw <2 x i32> <i32 4, i32 4>, %X
+  %cmp = icmp ugt <2 x i32> %sub, <i32 undef, i32 3>
+  ret <2 x i1> %cmp
+}
+
 ; 'shl nsw C2, x' produces [C2 << CLO(C2)-1, C2]
 define i1 @shl2(i32 %X) {
 ; CHECK-LABEL: @shl2(
@@ -378,6 +429,17 @@ define <2 x i1> @or1_vec(<2 x i32> %X) {
   ret <2 x i1> %B
 }
 
+define <2 x i1> @or1_vec_partial_undef(<2 x i32> %X) {
+; CHECK-LABEL: @or1_vec_partial_undef(
+; CHECK-NEXT:    [[A:%.*]] = or <2 x i32> [[X:%.*]], <i32 62, i32 62>
+; CHECK-NEXT:    [[B:%.*]] = icmp ult <2 x i32> [[A]], <i32 undef, i32 50>
+; CHECK-NEXT:    ret <2 x i1> [[B]]
+;
+  %A = or <2 x i32> %X, <i32 62, i32 62>
+  %B = icmp ult <2 x i32> %A, <i32 undef, i32 50>
+  ret <2 x i1> %B
+}
+
 ; Single bit OR.
 define i1 @or2_true(i8 %x) {
 ; CHECK-LABEL: @or2_true(


        


More information about the llvm-commits mailing list