diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-12-02 08:05:48 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-12-02 08:05:48 +0000 |
commit | 48dd644109d97a76288f0b5045f6aa6a3c075732 (patch) | |
tree | 5ed461768e1ff034f387e334478d589523b0d57f /lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | fb13f008cb2a6a51d2d590f994051586774734a1 (diff) |
Add a new SCEV representing signed division.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 30df087cef..211f013c25 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -143,6 +143,15 @@ Value *SCEVExpander::visitUDivExpr(SCEVUDivExpr *S) { return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt); } +Value *SCEVExpander::visitSDivExpr(SCEVSDivExpr *S) { + // Do not fold sdiv into ashr, unless you know that LHS is positive. On + // negative values, it rounds the wrong way. + + Value *LHS = expand(S->getLHS()); + Value *RHS = expand(S->getRHS()); + return InsertBinop(Instruction::SDiv, LHS, RHS, InsertPt); +} + Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { const Type *Ty = S->getType(); const Loop *L = S->getLoop(); |