diff options
author | Philip Reames <listmail@philipreames.com> | 2019-09-12 21:32:27 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-09-12 21:32:27 +0000 |
commit | bdf608477e9a4f5bce98b1592a968ebd9aa30285 (patch) | |
tree | 05a297a207c2229eb32678ba8b936213113ab5ee /llvm/lib/Analysis/ScalarEvolution.cpp | |
parent | efe6724b9f55b0382f97577c582306b856ff1f95 (diff) | |
download | bcm5719-llvm-bdf608477e9a4f5bce98b1592a968ebd9aa30285.tar.gz bcm5719-llvm-bdf608477e9a4f5bce98b1592a968ebd9aa30285.zip |
[SCEV] Add smin support to getRangeRef
We were failing to compute trip counts (both exact and maximum) for any loop which involved a comparison against either an umin or smin. It looks like this simply got missed when we added smin/umin to SCEV. (Note: umin was submitted separately earlier today. Turned out two folks hit this at the same time.)
Differential Revision: https://reviews.llvm.org/D67514
llvm-svn: 371776
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 3817b1142d3..2cac4a090ff 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -5596,6 +5596,14 @@ ScalarEvolution::getRangeRef(const SCEV *S, ConservativeResult.intersectWith(X, RangeType)); } + if (const SCEVSMinExpr *SMin = dyn_cast<SCEVSMinExpr>(S)) { + ConstantRange X = getRangeRef(SMin->getOperand(0), SignHint); + for (unsigned i = 1, e = SMin->getNumOperands(); i != e; ++i) + X = X.smin(getRangeRef(SMin->getOperand(i), SignHint)); + return setRange(SMin, SignHint, + ConservativeResult.intersectWith(X, RangeType)); + } + if (const SCEVUMinExpr *UMin = dyn_cast<SCEVUMinExpr>(S)) { ConstantRange X = getRangeRef(UMin->getOperand(0), SignHint); for (unsigned i = 1, e = UMin->getNumOperands(); i != e; ++i) |