diff options
author | Sebastian Pop <spop@codeaurora.org> | 2014-05-29 19:44:09 +0000 |
---|---|---|
committer | Sebastian Pop <spop@codeaurora.org> | 2014-05-29 19:44:09 +0000 |
commit | 20b6ed3c9c58104d76c523bdd7a5b7b6c1feb729 (patch) | |
tree | e4e7b3c2065e257855c252ab4d66b258c642f26b /lib/Analysis | |
parent | e741924230245250448a41d54adc7238e0eac716 (diff) | |
download | llvm-20b6ed3c9c58104d76c523bdd7a5b7b6c1feb729.tar.gz llvm-20b6ed3c9c58104d76c523bdd7a5b7b6c1feb729.tar.bz2 llvm-20b6ed3c9c58104d76c523bdd7a5b7b6c1feb729.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 935d4158c3..bc9f45b204 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/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); |