aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LazyValueInfo.cpp
diff options
context:
space:
mode:
authorArtur Pilipenko <apilipenko@azulsystems.com>2016-08-09 10:00:22 +0000
committerArtur Pilipenko <apilipenko@azulsystems.com>2016-08-09 10:00:22 +0000
commitd97eedff403a07e9ee7e5534d5abd8eeddfdfa02 (patch)
treefab07d6c0e8665e6912f3137188186df846c8d64 /llvm/lib/Analysis/LazyValueInfo.cpp
parente01ffee570ba968c19c41fa3b44461cbe3586e5b (diff)
downloadllvm-d97eedff403a07e9ee7e5534d5abd8eeddfdfa02.zip
llvm-d97eedff403a07e9ee7e5534d5abd8eeddfdfa02.tar.gz
llvm-d97eedff403a07e9ee7e5534d5abd8eeddfdfa02.tar.bz2
Revert 278107 which causes buildbot failures and in addition has wrong commit message
llvm-svn: 278109
Diffstat (limited to 'llvm/lib/Analysis/LazyValueInfo.cpp')
-rw-r--r--llvm/lib/Analysis/LazyValueInfo.cpp52
1 files changed, 19 insertions, 33 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp
index e6c375a8..2728687 100644
--- a/llvm/lib/Analysis/LazyValueInfo.cpp
+++ b/llvm/lib/Analysis/LazyValueInfo.cpp
@@ -1197,44 +1197,30 @@ bool getValueFromCondition(Value *Val, Value *Cond, LVILatticeVal &Result,
Result = LVILatticeVal::getNot(cast<Constant>(RHS));
return true;
}
- }
-
- // Use ConstantRange::makeAllowedICmpRegion in order to determine the possible
- // range of Val guaranteed by the condition. Recognize comparisons in the from
- // of:
- // icmp <pred> Val, ...
- // icmp ult (add Val, Offset), ...
- // The latter is the range checking idiom that InstCombine produces. Subtract
- // the offset from the allowed range for RHS in this case.
-
- // Val or (add Val, Offset) can be on either hand of the comparison
- if (LHS != Val && !match(LHS, m_Add(m_Specific(Val), m_ConstantInt()))) {
- std::swap(LHS, RHS);
- Predicate = CmpInst::getSwappedPredicate(Predicate);
- }
- ConstantInt *Offset = nullptr;
- if (Predicate == ICmpInst::ICMP_ULT)
- match(LHS, m_Add(m_Specific(Val), m_ConstantInt(Offset)));
+ // Recognize the range checking idiom that InstCombine produces.
+ // (X+C1) u< C2 --> [-C1, C2-C1)
+ ConstantInt *Offset = nullptr;
+ if (Predicate == ICmpInst::ICMP_ULT)
+ match(LHS, m_Add(m_Specific(Val), m_ConstantInt(Offset)));
- if (LHS == Val || Offset) {
- // Calculate the range of values that are allowed by the comparison
- ConstantRange RHSRange(RHS->getType()->getIntegerBitWidth(),
- /*isFullSet=*/true);
- if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
- RHSRange = ConstantRange(CI->getValue());
+ ConstantInt *CI = dyn_cast<ConstantInt>(RHS);
+ if (CI && (LHS == Val || Offset)) {
+ // Calculate the range of values that are allowed by the comparison
+ ConstantRange CmpRange(CI->getValue());
- // If we're interested in the false dest, invert the condition
- CmpInst::Predicate Pred =
- isTrueDest ? Predicate : CmpInst::getInversePredicate(Predicate);
- ConstantRange TrueValues =
- ConstantRange::makeAllowedICmpRegion(Pred, RHSRange);
+ // If we're interested in the false dest, invert the condition
+ CmpInst::Predicate Pred =
+ isTrueDest ? Predicate : CmpInst::getInversePredicate(Predicate);
+ ConstantRange TrueValues =
+ ConstantRange::makeAllowedICmpRegion(Pred, CmpRange);
- if (Offset) // Apply the offset from above.
- TrueValues = TrueValues.subtract(Offset->getValue());
+ if (Offset) // Apply the offset from above.
+ TrueValues = TrueValues.subtract(Offset->getValue());
- Result = LVILatticeVal::getRange(std::move(TrueValues));
- return true;
+ Result = LVILatticeVal::getRange(std::move(TrueValues));
+ return true;
+ }
}
return false;