summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-01-19 18:56:00 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-01-19 18:56:00 +0000
commit5c901f3489e0f9ddbbaa169c598a0152fa2d61ed (patch)
tree2ad51dfaf1c59ae191ae588f54f18b774709bca3 /llvm/lib/Analysis/ScalarEvolution.cpp
parent50a414ab97b3c6b4053afaa218c1dffc6548de9a (diff)
downloadbcm5719-llvm-5c901f3489e0f9ddbbaa169c598a0152fa2d61ed.tar.gz
bcm5719-llvm-5c901f3489e0f9ddbbaa169c598a0152fa2d61ed.zip
Similarly, analyze truncate through multiply.
llvm-svn: 123842
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 7258feca6c7..424f74427be 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud