[PATCH] D76753: [CorrelatedValuePropagation] Remove redundant if statement in processSelect()
Enna1 via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 02:40:48 PDT 2020
Enna1 updated this revision to Diff 252520.
Enna1 added a comment.
update code as suggestion
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.252520.patch
Type: text/x-patch
Size: 1046 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200325/0b006b17/attachment.bin>
More information about the llvm-commits
mailing list