[PATCH] D84762: [InstSimplify] allow undefs in icmp with vector constant folds

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 28 12:18:11 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3fb13b8484dc: [InstSimplify] allow undefs in icmp with vector constant folds (authored by spatel).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84762/new/

https://reviews.llvm.org/D84762

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/icmp-constant.ll


Index: llvm/test/Transforms/InstSimplify/icmp-constant.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/icmp-constant.ll
+++ llvm/test/Transforms/InstSimplify/icmp-constant.ll
@@ -21,8 +21,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> <i1 true, i1 true>
 ;
   %cmp = icmp ule <2 x i8> %x, <i8 255, i8 undef>
   ret <2 x i1> %cmp
@@ -46,8 +45,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> zeroinitializer
 ;
   %cmp = icmp ugt <2 x i8> %x, <i8 undef, i8 255>
   ret <2 x i1> %cmp
@@ -74,9 +72,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> <i1 true, i1 true>
 ;
   %A = urem <2 x i32> %X, <i32 10, i32 10>
   %B = icmp ult <2 x i32> %A, <i32 undef, i32 15>
@@ -104,9 +100,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> zeroinitializer
 ;
   %A = srem <2 x i32> %X, <i32 -5, i32 -5>
   %B = icmp sgt <2 x i32> %A, <i32 5, i32 undef>
@@ -211,9 +205,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> <i1 true, i1 true>
 ;
   %sub = shl nuw <2 x i32> <i32 4, i32 4>, %X
   %cmp = icmp ugt <2 x i32> %sub, <i32 undef, i32 3>
@@ -431,9 +423,7 @@
 
 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]]
+; CHECK-NEXT:    ret <2 x i1> zeroinitializer
 ;
   %A = or <2 x i32> %X, <i32 62, i32 62>
   %B = icmp ult <2 x i32> %A, <i32 undef, i32 50>
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -2732,7 +2732,7 @@
   }
 
   const APInt *C;
-  if (!match(RHS, m_APInt(C)))
+  if (!match(RHS, m_APIntAllowUndef(C)))
     return nullptr;
 
   // Rule out tautological comparisons (eg., ult 0 or uge 0).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84762.281326.patch
Type: text/x-patch
Size: 3236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200728/a492f871/attachment.bin>


More information about the llvm-commits mailing list