summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorSebastian Pop <spop@codeaurora.org>2014-05-29 19:44:09 +0000
committerSebastian Pop <spop@codeaurora.org>2014-05-29 19:44:09 +0000
commit20daf3276d1a32701ed7b5da9b6c3af49af5f7e1 (patch)
tree0b77144ff82aa2bbee50ad8c670d535cc75f4e77 /llvm/lib/Analysis/ScalarEvolution.cpp
parent5352408169d6b9927bc7fffd590fe8850eb93bb6 (diff)
downloadbcm5719-llvm-20daf3276d1a32701ed7b5da9b6c3af49af5f7e1.tar.gz
bcm5719-llvm-20daf3276d1a32701ed7b5da9b6c3af49af5f7e1.zip
implement missing SCEVDivision case
without this case we would end on an infinite recursion: the remainder is zero, so Numerator - Remainder is equal to Numerator and so we would recursively ask for the division of Numerator by Denominator. llvm-svn: 209838
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 935d4158c39..bc9f45b2043 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7216,6 +7216,15 @@ public:
cast<SCEVConstant>(Zero)->getValue();
Remainder = SCEVParameterRewriter::rewrite(Numerator, SE, RewriteMap, true);
+ if (Remainder->isZero()) {
+ // The Quotient is obtained by replacing Denominator by 1 in Numerator.
+ RewriteMap[cast<SCEVUnknown>(Denominator)->getValue()] =
+ cast<SCEVConstant>(One)->getValue();
+ Quotient =
+ SCEVParameterRewriter::rewrite(Numerator, SE, RewriteMap, true);
+ return;
+ }
+
// Quotient is (Numerator - Remainder) divided by Denominator.
const SCEV *Q, *R;
const SCEV *Diff = SE.getMinusSCEV(Numerator, Remainder);
OpenPOWER on IntegriCloud