[llvm] r252333 - [ValueTracking] Add parameters to isImpliedCondition; NFC
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 11:01:08 PST 2015
Author: sanjoy
Date: Fri Nov 6 13:01:08 2015
New Revision: 252333
URL: http://llvm.org/viewvc/llvm-project?rev=252333&view=rev
Log:
[ValueTracking] Add parameters to isImpliedCondition; NFC
Summary:
This change makes the `isImpliedCondition` interface similar to the rest
of the functions in ValueTracking (in that it takes a DataLayout,
AssumptionCache etc.). This is an NFC, intended to make a later diff
less noisy.
Depends on D14369
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D14391
Modified:
llvm/trunk/include/llvm/Analysis/ValueTracking.h
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/lib/Analysis/ValueTracking.cpp
llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/include/llvm/Analysis/ValueTracking.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=252333&r1=252332&r2=252333&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ValueTracking.h (original)
+++ llvm/trunk/include/llvm/Analysis/ValueTracking.h Fri Nov 6 13:01:08 2015
@@ -444,7 +444,10 @@ namespace llvm {
/// T | T | F
/// F | T | T
/// (A)
- bool isImpliedCondition(Value *LHS, Value *RHS);
+ bool isImpliedCondition(Value *LHS, Value *RHS, const DataLayout &DL,
+ unsigned Depth = 0, AssumptionCache *AC = nullptr,
+ const Instruction *CxtI = nullptr,
+ const DominatorTree *DT = nullptr);
} // end namespace llvm
#endif
Modified: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstructionSimplify.cpp?rev=252333&r1=252332&r2=252333&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp (original)
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp Fri Nov 6 13:01:08 2015
@@ -2176,7 +2176,7 @@ static Value *SimplifyICmpInst(unsigned
// X >=u 1 -> X
if (match(RHS, m_One()))
return LHS;
- if (isImpliedCondition(RHS, LHS))
+ if (isImpliedCondition(RHS, LHS, Q.DL))
return getTrue(ITy);
break;
case ICmpInst::ICMP_SGE:
@@ -2187,7 +2187,7 @@ static Value *SimplifyICmpInst(unsigned
/// 0 | 1 | 1 (0 >= -1) | 1
/// 1 | 0 | 0 (-1 >= 0) | 0
/// 1 | 1 | 1 (-1 >= -1) | 1
- if (isImpliedCondition(LHS, RHS))
+ if (isImpliedCondition(LHS, RHS, Q.DL))
return getTrue(ITy);
break;
case ICmpInst::ICMP_SLT:
@@ -2201,7 +2201,7 @@ static Value *SimplifyICmpInst(unsigned
return LHS;
break;
case ICmpInst::ICMP_ULE:
- if (isImpliedCondition(LHS, RHS))
+ if (isImpliedCondition(LHS, RHS, Q.DL))
return getTrue(ITy);
break;
}
Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=252333&r1=252332&r2=252333&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Nov 6 13:01:08 2015
@@ -4083,7 +4083,10 @@ ConstantRange llvm::getConstantRangeFrom
}
/// Return true if "icmp Pred LHS RHS" is always true.
-static bool isTruePredicate(CmpInst::Predicate Pred, Value *LHS, Value *RHS) {
+static bool isTruePredicate(CmpInst::Predicate Pred, Value *LHS, Value *RHS,
+ const DataLayout &DL, unsigned Depth,
+ AssumptionCache *AC, const Instruction *CxtI,
+ const DominatorTree *DT) {
if (ICmpInst::isTrueWhenEqual(Pred) && LHS == RHS)
return true;
@@ -4124,24 +4127,34 @@ static bool isTruePredicate(CmpInst::Pre
/// Return true if "icmp Pred BLHS BRHS" is true whenever "icmp Pred
/// ALHS ARHS" is true.
static bool isImpliedCondOperands(CmpInst::Predicate Pred, Value *ALHS,
- Value *ARHS, Value *BLHS, Value *BRHS) {
+ Value *ARHS, Value *BLHS, Value *BRHS,
+ const DataLayout &DL, unsigned Depth,
+ AssumptionCache *AC, const Instruction *CxtI,
+ const DominatorTree *DT) {
switch (Pred) {
default:
return false;
case CmpInst::ICMP_SLT:
case CmpInst::ICMP_SLE:
- return isTruePredicate(CmpInst::ICMP_SLE, BLHS, ALHS) &&
- isTruePredicate(CmpInst::ICMP_SLE, ARHS, BRHS);
+ return isTruePredicate(CmpInst::ICMP_SLE, BLHS, ALHS, DL, Depth, AC, CxtI,
+ DT) &&
+ isTruePredicate(CmpInst::ICMP_SLE, ARHS, BRHS, DL, Depth, AC, CxtI,
+ DT);
case CmpInst::ICMP_ULT:
case CmpInst::ICMP_ULE:
- return isTruePredicate(CmpInst::ICMP_ULE, BLHS, ALHS) &&
- isTruePredicate(CmpInst::ICMP_ULE, ARHS, BRHS);
+ return isTruePredicate(CmpInst::ICMP_ULE, BLHS, ALHS, DL, Depth, AC, CxtI,
+ DT) &&
+ isTruePredicate(CmpInst::ICMP_ULE, ARHS, BRHS, DL, Depth, AC, CxtI,
+ DT);
}
}
-bool llvm::isImpliedCondition(Value *LHS, Value *RHS) {
+bool llvm::isImpliedCondition(Value *LHS, Value *RHS, const DataLayout &DL,
+ unsigned Depth, AssumptionCache *AC,
+ const Instruction *CxtI,
+ const DominatorTree *DT) {
assert(LHS->getType() == RHS->getType() && "mismatched type");
Type *OpTy = LHS->getType();
assert(OpTy->getScalarType()->isIntegerTy(1));
@@ -4163,7 +4176,8 @@ bool llvm::isImpliedCondition(Value *LHS
return false;
if (APred == BPred)
- return isImpliedCondOperands(APred, ALHS, ARHS, BLHS, BRHS);
+ return isImpliedCondOperands(APred, ALHS, ARHS, BLHS, BRHS, DL, Depth, AC,
+ CxtI, DT);
return false;
}
Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=252333&r1=252332&r2=252333&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Fri Nov 6 13:01:08 2015
@@ -895,12 +895,14 @@ bool JumpThreading::ProcessImpliedCondit
BasicBlock *CurrentPred = BB->getSinglePredecessor();
unsigned Iter = 0;
+ auto &DL = BB->getModule()->getDataLayout();
+
while (CurrentPred && Iter++ < ImplicationSearchThreshold) {
auto *PBI = dyn_cast<BranchInst>(CurrentPred->getTerminator());
if (!PBI || !PBI->isConditional() || PBI->getSuccessor(0) != CurrentBB)
return false;
- if (isImpliedCondition(PBI->getCondition(), Cond)) {
+ if (isImpliedCondition(PBI->getCondition(), Cond, DL)) {
BI->getSuccessor(1)->removePredecessor(BB);
BranchInst::Create(BI->getSuccessor(0), BI);
BI->eraseFromParent();
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=252333&r1=252332&r2=252333&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Nov 6 13:01:08 2015
@@ -2686,7 +2686,7 @@ static bool SimplifyCondBranchToCondBran
// If BI is reached from the true path of PBI and PBI's condition implies
// BI's condition, we know the direction of the BI branch.
if (PBI->getSuccessor(0) == BI->getParent() &&
- isImpliedCondition(PBI->getCondition(), BI->getCondition()) &&
+ isImpliedCondition(PBI->getCondition(), BI->getCondition(), DL) &&
PBI->getSuccessor(0) != PBI->getSuccessor(1) &&
BB->getSinglePredecessor()) {
// Turn this into a branch on constant.
More information about the llvm-commits
mailing list