summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeno Fischer <keno@alumni.harvard.edu>2019-05-08 10:36:04 +0000
committerKeno Fischer <keno@alumni.harvard.edu>2019-05-08 10:36:04 +0000
commitaa1b6f1cfb35576bf5468e3d5d558ac7ee34dc88 (patch)
tree4fbc23308fb641be8d930c9600679f4ee4250a7a
parent69b8b17945f0892e68f3e0ca46d00b2c50966114 (diff)
downloadbcm5719-llvm-aa1b6f1cfb35576bf5468e3d5d558ac7ee34dc88.tar.gz
bcm5719-llvm-aa1b6f1cfb35576bf5468e3d5d558ac7ee34dc88.zip
[polly][SCEV] Expand SCEV matcher cases for new smin/umin ops
These were added in rL360159, but I neglected to update polly at the same time. llvm-svn: 360238
-rw-r--r--polly/include/polly/Support/SCEVAffinator.h2
-rw-r--r--polly/lib/Support/SCEVAffinator.cpp16
-rw-r--r--polly/lib/Support/SCEVValidator.cpp30
-rw-r--r--polly/lib/Support/ScopHelper.cpp12
-rw-r--r--polly/test/ScopInfo/smax.ll2
5 files changed, 61 insertions, 1 deletions
diff --git a/polly/include/polly/Support/SCEVAffinator.h b/polly/include/polly/Support/SCEVAffinator.h
index 4aad9a6e679..39a25d4001d 100644
--- a/polly/include/polly/Support/SCEVAffinator.h
+++ b/polly/include/polly/Support/SCEVAffinator.h
@@ -103,7 +103,9 @@ private:
PWACtx visitUDivExpr(const llvm::SCEVUDivExpr *E);
PWACtx visitAddRecExpr(const llvm::SCEVAddRecExpr *E);
PWACtx visitSMaxExpr(const llvm::SCEVSMaxExpr *E);
+ PWACtx visitSMinExpr(const llvm::SCEVSMinExpr *E);
PWACtx visitUMaxExpr(const llvm::SCEVUMaxExpr *E);
+ PWACtx visitUMinExpr(const llvm::SCEVUMinExpr *E);
PWACtx visitUnknown(const llvm::SCEVUnknown *E);
PWACtx visitSDivInstruction(llvm::Instruction *SDiv);
PWACtx visitSRemInstruction(llvm::Instruction *SRem);
diff --git a/polly/lib/Support/SCEVAffinator.cpp b/polly/lib/Support/SCEVAffinator.cpp
index 85e39e3d5b9..fc6e29ce519 100644
--- a/polly/lib/Support/SCEVAffinator.cpp
+++ b/polly/lib/Support/SCEVAffinator.cpp
@@ -435,10 +435,26 @@ PWACtx SCEVAffinator::visitSMaxExpr(const SCEVSMaxExpr *Expr) {
return Max;
}
+PWACtx SCEVAffinator::visitSMinExpr(const SCEVSMinExpr *Expr) {
+ PWACtx Min = visit(Expr->getOperand(0));
+
+ for (int i = 1, e = Expr->getNumOperands(); i < e; ++i) {
+ Min = combine(Min, visit(Expr->getOperand(i)), isl_pw_aff_min);
+ if (isTooComplex(Min))
+ return complexityBailout();
+ }
+
+ return Min;
+}
+
PWACtx SCEVAffinator::visitUMaxExpr(const SCEVUMaxExpr *Expr) {
llvm_unreachable("SCEVUMaxExpr not yet supported");
}
+PWACtx SCEVAffinator::visitUMinExpr(const SCEVUMinExpr *Expr) {
+ llvm_unreachable("SCEVUMinExpr not yet supported");
+}
+
PWACtx SCEVAffinator::visitUDivExpr(const SCEVUDivExpr *Expr) {
// The handling of unsigned division is basically the same as for signed
// division, except the interpretation of the operands. As the divisor
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp
index 84e9b87a328..501d7645831 100644
--- a/polly/lib/Support/SCEVValidator.cpp
+++ b/polly/lib/Support/SCEVValidator.cpp
@@ -294,6 +294,21 @@ public:
return Return;
}
+ class ValidatorResult visitSMinExpr(const SCEVSMinExpr *Expr) {
+ ValidatorResult Return(SCEVType::INT);
+
+ for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
+ ValidatorResult Op = visit(Expr->getOperand(i));
+
+ if (!Op.isValid())
+ return Op;
+
+ Return.merge(Op);
+ }
+
+ return Return;
+ }
+
class ValidatorResult visitUMaxExpr(const SCEVUMaxExpr *Expr) {
// We do not support unsigned max operations. If 'Expr' is constant during
// Scop execution we treat this as a parameter, otherwise we bail out.
@@ -309,6 +324,21 @@ public:
return ValidatorResult(SCEVType::PARAM, Expr);
}
+ class ValidatorResult visitUMinExpr(const SCEVUMinExpr *Expr) {
+ // We do not support unsigned min operations. If 'Expr' is constant during
+ // Scop execution we treat this as a parameter, otherwise we bail out.
+ for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
+ ValidatorResult Op = visit(Expr->getOperand(i));
+
+ if (!Op.isConstant()) {
+ LLVM_DEBUG(dbgs() << "INVALID: UMinExpr has a non-constant operand");
+ return ValidatorResult(SCEVType::INVALID);
+ }
+ }
+
+ return ValidatorResult(SCEVType::PARAM, Expr);
+ }
+
ValidatorResult visitGenericInst(Instruction *I, const SCEV *S) {
if (R->contains(I)) {
LLVM_DEBUG(dbgs() << "INVALID: UnknownExpr references an instruction "
diff --git a/polly/lib/Support/ScopHelper.cpp b/polly/lib/Support/ScopHelper.cpp
index 8c730c4c40f..e65c47298ed 100644
--- a/polly/lib/Support/ScopHelper.cpp
+++ b/polly/lib/Support/ScopHelper.cpp
@@ -370,6 +370,18 @@ private:
NewOps.push_back(visit(Op));
return SE.getSMaxExpr(NewOps);
}
+ const SCEV *visitUMinExpr(const SCEVUMinExpr *E) {
+ SmallVector<const SCEV *, 4> NewOps;
+ for (const SCEV *Op : E->operands())
+ NewOps.push_back(visit(Op));
+ return SE.getUMinExpr(NewOps);
+ }
+ const SCEV *visitSMinExpr(const SCEVSMinExpr *E) {
+ SmallVector<const SCEV *, 4> NewOps;
+ for (const SCEV *Op : E->operands())
+ NewOps.push_back(visit(Op));
+ return SE.getSMinExpr(NewOps);
+ }
const SCEV *visitAddRecExpr(const SCEVAddRecExpr *E) {
SmallVector<const SCEV *, 4> NewOps;
for (const SCEV *Op : E->operands())
diff --git a/polly/test/ScopInfo/smax.ll b/polly/test/ScopInfo/smax.ll
index be7ca3c6b9f..7662b46162b 100644
--- a/polly/test/ScopInfo/smax.ll
+++ b/polly/test/ScopInfo/smax.ll
@@ -22,4 +22,4 @@ for.end:
; We check that there are only two parameters, but not a third one that
; represents the smax() expression. This test case comes from PR 18155.
-; CHECK: [w, x_pos]
+; CHECK: [x_pos, w]
OpenPOWER on IntegriCloud