summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-11-29 14:41:21 +0000
committerSanjay Patel <spatel@rotateright.com>2018-11-29 14:41:21 +0000
commit8242c82de4c0544c33e809a2b42e7885f2b7f48e (patch)
treed732b5b7eb571ed470c2ab62802bb1eeddb01516 /llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
parentbfd1d275857f0d548fdb76b29e38e8ad2eddb8ac (diff)
downloadbcm5719-llvm-8242c82de4c0544c33e809a2b42e7885f2b7f48e.tar.gz
bcm5719-llvm-8242c82de4c0544c33e809a2b42e7885f2b7f48e.zip
[CVP] tidy processCmp(); NFC
1. The variables were confusing: 'C' typically refers to a constant, but here it was the Cmp. 2. Formatting violations. 3. Simplify code to return true/false constant. llvm-svn: 347868
Diffstat (limited to 'llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
index 826df6c6ab9..d0105701c73 100644
--- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
+++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
@@ -273,10 +273,11 @@ static bool processMemAccess(Instruction *I, LazyValueInfo *LVI) {
/// information is sufficient to prove this comparison. Even for local
/// conditions, this can sometimes prove conditions instcombine can't by
/// exploiting range information.
-static bool processCmp(CmpInst *C, LazyValueInfo *LVI) {
- Value *Op0 = C->getOperand(0);
- Constant *Op1 = dyn_cast<Constant>(C->getOperand(1));
- if (!Op1) return false;
+static bool processCmp(CmpInst *Cmp, LazyValueInfo *LVI) {
+ Value *Op0 = Cmp->getOperand(0);
+ auto *C = dyn_cast<Constant>(Cmp->getOperand(1));
+ if (!C)
+ return false;
// As a policy choice, we choose not to waste compile time on anything where
// the comparison is testing local values. While LVI can sometimes reason
@@ -284,20 +285,18 @@ static bool processCmp(CmpInst *C, LazyValueInfo *LVI) {
// the block local query for uses from terminator instructions, but that's
// handled in the code for each terminator.
auto *I = dyn_cast<Instruction>(Op0);
- if (I && I->getParent() == C->getParent())
+ if (I && I->getParent() == Cmp->getParent())
return false;
LazyValueInfo::Tristate Result =
- LVI->getPredicateAt(C->getPredicate(), Op0, Op1, C);
- if (Result == LazyValueInfo::Unknown) return false;
+ LVI->getPredicateAt(Cmp->getPredicate(), Op0, C, Cmp);
+ if (Result == LazyValueInfo::Unknown)
+ return false;
++NumCmps;
- if (Result == LazyValueInfo::True)
- C->replaceAllUsesWith(ConstantInt::getTrue(C->getContext()));
- else
- C->replaceAllUsesWith(ConstantInt::getFalse(C->getContext()));
- C->eraseFromParent();
-
+ Constant *TorF = ConstantInt::get(Type::getInt1Ty(Cmp->getContext()), Result);
+ Cmp->replaceAllUsesWith(TorF);
+ Cmp->eraseFromParent();
return true;
}
@@ -308,7 +307,8 @@ static bool processCmp(CmpInst *C, LazyValueInfo *LVI) {
/// that cannot fire no matter what the incoming edge can safely be removed. If
/// a case fires on every incoming edge then the entire switch can be removed
/// and replaced with a branch to the case destination.
-static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI, DominatorTree *DT) {
+static bool processSwitch(SwitchInst *SI, LazyValueInfo *LVI,
+ DominatorTree *DT) {
DomTreeUpdater DTU(*DT, DomTreeUpdater::UpdateStrategy::Lazy);
Value *Cond = SI->getCondition();
BasicBlock *BB = SI->getParent();
OpenPOWER on IntegriCloud