SCEVValidator: Correctly store 'k * p' as a parameter
We do not only need to understand that 'k * p' is a parameter expression, but
also need to store this expression in the set of parameters. Before this patch
we wrongly stored the two individual parameters %k and %p.
Reported by: Sebastian Pop <spop@codeaurora.org>
llvm-svn: 179485
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index a739f3b..80b8a08 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -202,6 +202,8 @@
class ValidatorResult visitMulExpr(const SCEVMulExpr *Expr) {
ValidatorResult Return(SCEVType::INT);
+ bool HasMultipleParams = false;
+
for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
ValidatorResult Op = visit(Expr->getOperand(i));
@@ -209,7 +211,7 @@
continue;
if (Op.isPARAM() && Return.isPARAM()) {
- Return.merge(Op);
+ HasMultipleParams = true;
continue;
}
@@ -226,6 +228,9 @@
Return.merge(Op);
}
+ if (HasMultipleParams)
+ return ValidatorResult(SCEVType::PARAM, Expr);
+
// TODO: Check for NSW and NUW.
return Return;
}