diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2011-01-19 18:56:00 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2011-01-19 18:56:00 +0000 |
commit | 5c6fc1cab774244fba2746b84f2b86d71b897733 (patch) | |
tree | 215890b99cd0bc0c52f195876e8da5fd70629efb /lib/Analysis/ScalarEvolution.cpp | |
parent | 30aa8b13c93211f68bb4efddd1e47817a1d107f1 (diff) |
Similarly, analyze truncate through multiply.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 7258feca6c..424f74427b 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -833,6 +833,20 @@ const SCEV *ScalarEvolution::getTruncateExpr(const SCEV *Op, return getAddExpr(Operands, false, false); } + // trunc(x1*x2*...*xN) --> trunc(x1)*trunc(x2)*...*trunc(xN) if we can + // eliminate all the truncates. + if (const SCEVMulExpr *SM = dyn_cast<SCEVMulExpr>(Op)) { + SmallVector<const SCEV *, 4> Operands; + bool hasTrunc = false; + for (unsigned i = 0, e = SM->getNumOperands(); i != e && !hasTrunc; ++i) { + const SCEV *S = getTruncateExpr(SM->getOperand(i), Ty); + hasTrunc = isa<SCEVTruncateExpr>(S); + Operands.push_back(S); + } + if (!hasTrunc) + return getMulExpr(Operands, false, false); + } + // If the input value is a chrec scev, truncate the chrec's operands. if (const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(Op)) { SmallVector<const SCEV *, 4> Operands; |