[PATCH] D76753: [CorrelatedValuePropagation] Remove redundant if statement in processSelect()

Enna1 via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 20:56:42 PDT 2020


Enna1 created this revision.
Enna1 added reviewers: resistor, nikic.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

[CorrelatedValuePropagation] Remove redundant if statement in processSelect()

This statement `if (ReplaceWith == S) ReplaceWith = UndefValue::get(S->getType());` is introduced in "https://reviews.llvm.org/rG35609d97ae89b8e13f40f4e6b9b056954f8baa83" to fix a case where unreachable code can cause select instruction simplification to fail.
In "https://reviews.llvm.org/rGd10480657527ffb44ea213460fb3676a6b1300aa", we begin to perform a depth-first walk of basic blocks. This means we will not visit unreachable blocks.
So we do not need this the special check any more.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76753

Files:
  llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp


Index: llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -125,7 +125,7 @@
 
 static bool processSelect(SelectInst *S, LazyValueInfo *LVI) {
   if (S->getType()->isVectorTy()) return false;
-  if (isa<Constant>(S->getOperand(0))) return false;
+  if (isa<Constant>(S->getCondition())) return false;
 
   Constant *C = LVI->getConstant(S->getCondition(), S->getParent(), S);
   if (!C) return false;
@@ -136,7 +136,6 @@
   Value *ReplaceWith = S->getTrueValue();
   Value *Other = S->getFalseValue();
   if (!CI->isOne()) std::swap(ReplaceWith, Other);
-  if (ReplaceWith == S) ReplaceWith = UndefValue::get(S->getType());
 
   S->replaceAllUsesWith(ReplaceWith);
   S->eraseFromParent();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76753.252487.patch
Type: text/x-patch
Size: 890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200325/ab9d50b5/attachment.bin>


More information about the llvm-commits mailing list