summaryrefslogtreecommitdiffstats
path: root/polly/lib/Support/SCEVValidator.cpp
diff options
context:
space:
mode:
authorJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-04-08 10:25:58 +0000
committerJohannes Doerfert <doerfert@cs.uni-saarland.de>2016-04-08 10:25:58 +0000
commit7b8110358912c296a52fed7fdb50f883a74414e0 (patch)
treec67c7670cfccaa66e1cf48dea96f01d80a0bc9f2 /polly/lib/Support/SCEVValidator.cpp
parent477e5d8d3160367e03edc1343900e87267b22fac (diff)
downloadbcm5719-llvm-7b8110358912c296a52fed7fdb50f883a74414e0.tar.gz
bcm5719-llvm-7b8110358912c296a52fed7fdb50f883a74414e0.zip
[FIX] Look through div & srem instructions in SCEVs
The findValues() function did not look through div & srem instructions that were part of the argument SCEV. However, in different other places we already look through it. This mismatch caused us to preload values in the wrong order. llvm-svn: 265775
Diffstat (limited to 'polly/lib/Support/SCEVValidator.cpp')
-rw-r--r--polly/lib/Support/SCEVValidator.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index 0bece55de0a..4b91025fd0e 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -560,21 +560,45 @@ void findLoops(const SCEV *Expr, SetVector<const Loop *> &Loops) {
/// Find all values referenced in SCEVUnknowns.
class SCEVFindValues {
+ ScalarEvolution &SE;
SetVector<Value *> &Values;
public:
- SCEVFindValues(SetVector<Value *> &Values) : Values(Values) {}
+ SCEVFindValues(ScalarEvolution &SE, SetVector<Value *> &Values)
+ : SE(SE), Values(Values) {}
bool follow(const SCEV *S) {
- if (const SCEVUnknown *Unknown = dyn_cast<SCEVUnknown>(S))
+ const SCEVUnknown *Unknown = dyn_cast<SCEVUnknown>(S);
+ if (!Unknown)
+ return true;
+
+ Instruction *Inst = dyn_cast<Instruction>(Unknown->getValue());
+ if (!Inst || (Inst->getOpcode() != Instruction::SRem &&
+ Inst->getOpcode() != Instruction::SDiv)) {
Values.insert(Unknown->getValue());
- return true;
+ return false;
+ }
+
+ auto *Dividend = SE.getSCEV(Inst->getOperand(1));
+ if (!isa<SCEVConstant>(Dividend)) {
+ Values.insert(Unknown->getValue());
+ return false;
+ }
+
+ auto *Divisor = SE.getSCEV(Inst->getOperand(0));
+ SCEVFindValues FindValues(SE, Values);
+ SCEVTraversal<SCEVFindValues> ST(FindValues);
+ ST.visitAll(Dividend);
+ ST.visitAll(Divisor);
+
+ return false;
}
bool isDone() { return false; }
};
-void findValues(const SCEV *Expr, SetVector<Value *> &Values) {
- SCEVFindValues FindValues(Values);
+void findValues(const SCEV *Expr, ScalarEvolution &SE,
+ SetVector<Value *> &Values) {
+ SCEVFindValues FindValues(SE, Values);
SCEVTraversal<SCEVFindValues> ST(FindValues);
ST.visitAll(Expr);
}
OpenPOWER on IntegriCloud