diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-22 19:57:34 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2015-10-22 19:57:34 +0000 |
commit | 6e78b17b43f41fba47a7c53483604ca2fabc8d64 (patch) | |
tree | f994df4a63d79e36a9053b8c29b10621135f7936 /llvm/lib/Analysis | |
parent | 1123148d40691a9ce08879fff878a02acd0f6822 (diff) | |
download | bcm5719-llvm-6e78b17b43f41fba47a7c53483604ca2fabc8d64.tar.gz bcm5719-llvm-6e78b17b43f41fba47a7c53483604ca2fabc8d64.zip |
[SCEV] Opportunistically interpret unsigned constraints as signed
Summary:
An unsigned comparision is equivalent to is corresponding signed version
if both the operands being compared are positive. Teach SCEV to use
this fact when profitable.
Reviewers: atrick, hfinkel, reames, nlewycky
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13687
llvm-svn: 251051
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index d30e982c8d5..d784eb9ace4 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -7509,6 +7509,13 @@ bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, RHS, LHS, FoundLHS, FoundRHS); } + // Unsigned comparison is the same as signed comparison when both the operands + // are non-negative. + if (CmpInst::isUnsigned(FoundPred) && + CmpInst::getSignedPredicate(FoundPred) == Pred && + isKnownNonNegative(FoundLHS) && isKnownNonNegative(FoundRHS)) + return isImpliedCondOperands(Pred, LHS, RHS, FoundLHS, FoundRHS); + // Check if we can make progress by sharpening ranges. if (FoundPred == ICmpInst::ICMP_NE && (isa<SCEVConstant>(FoundLHS) || isa<SCEVConstant>(FoundRHS))) { |