summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/SCEVValidator.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-03-29 20:45:09 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2015-03-29 20:45:09 +0000
commitbe40996cfe7a8ae40e065120a40a15ead80ea393 (patch)
tree71dcb44b5d07e6f00544019893282ce98444ff2c /polly/lib/Support/SCEVValidator.cpp
parent9de151ee5d6b6c7311e6e497cfb8507902652da4 (diff)
downloadbcm5719-llvm-be40996cfe7a8ae40e065120a40a15ead80ea393.tar.gz
bcm5719-llvm-be40996cfe7a8ae40e065120a40a15ead80ea393.zip
Strip constant factors from SCoP parameters
This will strip the constant factor of a parameter befor we add it to the SCoP. As a result the access functions are simplified, e.g., for the attached test case. llvm-svn: 233501
Diffstat (limited to 'polly/lib/Support/SCEVValidator.cpp')
-rw-r--r--polly/lib/Support/SCEVValidator.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index 5a3706b2fac..048fdc32aa1 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -562,4 +562,23 @@ std::vector<const SCEV *> getParamsInAffineExpr(const Region *R,
return Result.getParameters();
}
+
+std::pair<const SCEV *, const SCEV *>
+extractConstantFactor(const SCEV *S, ScalarEvolution &SE) {
+
+ const SCEV *LeftOver = SE.getConstant(S->getType(), 1);
+ const SCEV *ConstPart = SE.getConstant(S->getType(), 1);
+
+ const SCEVMulExpr *M = dyn_cast<SCEVMulExpr>(S);
+ if (!M)
+ return std::make_pair(ConstPart, S);
+
+ for (const SCEV *Op : M->operands())
+ if (isa<SCEVConstant>(Op))
+ ConstPart = SE.getMulExpr(ConstPart, Op);
+ else
+ LeftOver = SE.getMulExpr(LeftOver, Op);
+
+ return std::make_pair(ConstPart, LeftOver);
+}
}
OpenPOWER on IntegriCloud