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

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 18:07:32 PDT 2022


aqjune created this revision.
aqjune added reviewers: fhahn, wmi, spatel, nikic, davidxl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aqjune requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch removes an old hack in visitSelectInst that was written to avoid miscompilation bugs in loop unswitch.
(Added via https://reviews.llvm.org/D35811)

The legacy loop unswitch pass will be removed after D124376 <https://reviews.llvm.org/D124376>, and the new simple loop unswitch pass correctly uses freeze to avoid introducing UB after D124252 <https://reviews.llvm.org/D124252>.

Since the hack is not necessary anymore, this patch removes it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124426

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp


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.425087.patch
Type: text/x-patch
Size: 1192 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220426/4764c489/attachment.bin>


More information about the llvm-commits mailing list