[PATCH] D124426: [InstCombine] Remove the undef-related workaround code in visitSelectInst

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 03:09:14 PDT 2022


aqjune updated this revision to Diff 425460.
aqjune added a comment.

Yep, a test added


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124426

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/test/Transforms/InstCombine/select-cmp.ll


Index: llvm/test/Transforms/InstCombine/select-cmp.ll
===================================================================
--- llvm/test/Transforms/InstCombine/select-cmp.ll
+++ llvm/test/Transforms/InstCombine/select-cmp.ll
@@ -3,8 +3,7 @@
 
 define i1 @f(i1 %cond, i32 %x, i32 %x2) {
 ; CHECK-LABEL: @f(
-; CHECK-NEXT:    [[Y:%.*]] = select i1 [[COND:%.*]], i32 poison, i32 [[X:%.*]]
-; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[Y]], [[X2:%.*]]
+; CHECK-NEXT:    [[C:%.*]] = icmp eq i32 [[X:%.*]], [[X2:%.*]]
 ; CHECK-NEXT:    ret i1 [[C]]
 ;
   %y = select i1 %cond, i32 poison, i32 %x
Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -2567,22 +2567,6 @@
   Value *FalseVal = SI.getFalseValue();
   Type *SelType = SI.getType();
 
-  // FIXME: Remove this workaround when freeze related patches are done.
-  // For select with undef operand which feeds into an equality comparison,
-  // don't simplify it so loop unswitch can know the equality comparison
-  // may have an undef operand. This is a workaround for PR31652 caused by
-  // descrepancy about branch on undef between LoopUnswitch and GVN.
-  if (match(TrueVal, m_Undef()) || match(FalseVal, m_Undef())) {
-    if (llvm::any_of(SI.users(), [&](User *U) {
-          ICmpInst *CI = dyn_cast<ICmpInst>(U);
-          if (CI && CI->isEquality())
-            return true;
-          return false;
-        })) {
-      return nullptr;
-    }
-  }
-
   if (Value *V = SimplifySelectInst(CondVal, TrueVal, FalseVal,
                                     SQ.getWithInstruction(&SI)))
     return replaceInstUsesWith(SI, V);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124426.425460.patch
Type: text/x-patch
Size: 1779 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220427/33a96844/attachment.bin>


More information about the llvm-commits mailing list