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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 28 10:12:28 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG03bc311a16e2: [CorrelatedValuePropagation] Remove redundant if statement in processSelect() (authored by Enna1, committed by nikic).

Repository:
  rG LLVM Github Monorepo

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

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;
@@ -133,11 +133,7 @@
   ConstantInt *CI = dyn_cast<ConstantInt>(C);
   if (!CI) return false;
 
-  Value *ReplaceWith = S->getTrueValue();
-  Value *Other = S->getFalseValue();
-  if (!CI->isOne()) std::swap(ReplaceWith, Other);
-  if (ReplaceWith == S) ReplaceWith = UndefValue::get(S->getType());
-
+  Value *ReplaceWith = CI->isOne() ? S->getTrueValue() : S->getFalseValue();
   S->replaceAllUsesWith(ReplaceWith);
   S->eraseFromParent();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76753.253358.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200328/e0969973/attachment-0001.bin>


More information about the llvm-commits mailing list