[llvm-commits] [polly] r143959 - /polly/trunk/lib/Analysis/ScopDetection.cpp
Tobias Grosser
grosser at fim.uni-passau.de
Mon Nov 7 04:58:46 PST 2011
Author: grosser
Date: Mon Nov 7 06:58:46 2011
New Revision: 143959
URL: http://llvm.org/viewvc/llvm-project?rev=143959&view=rev
Log:
ScopDetection: Introduce methods to check attributes of ValidatorResult
This simplifies e.g:
if (Op.type == SCEVType::INT || Op.type == SCEVType::PARAM)
to
if (Op.isConstant())
Modified:
polly/trunk/lib/Analysis/ScopDetection.cpp
Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=143959&r1=143958&r2=143959&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
+++ polly/trunk/lib/Analysis/ScopDetection.cpp Mon Nov 7 06:58:46 2011
@@ -124,6 +124,21 @@
ValidatorResult(SCEVType::TYPE type) : type(type) {};
+ bool isConstant() {
+ return type == SCEVType::INT || type == SCEVType::PARAM;
+ }
+
+ bool isValid() {
+ return type != SCEVType::INVALID;
+ }
+
+ bool isIV() {
+ return type == SCEVType::IV;
+ }
+
+ bool isINT() {
+ return type == SCEVType::INT;
+ }
};
/// Check if a SCEV is valid in a SCoP.
@@ -147,7 +162,7 @@
SCEVValidator Validator(R, SE, BaseAddress);
ValidatorResult Result = Validator.visit(Scev);
- return Result.type != SCEVType::INVALID;
+ return Result.isValid();
}
SCEVValidator(const Region *R, ScalarEvolution &SE,
@@ -164,7 +179,7 @@
// We currently do not represent a truncate expression as an affine
// expression. If it is constant during Scop execution, we treat it as a
// parameter, otherwise we bail out.
- if (Op.type == SCEVType::INT || Op.type == SCEVType::PARAM)
+ if (Op.isConstant())
return ValidatorResult(SCEVType::PARAM);
return ValidatorResult (SCEVType::INVALID);
@@ -176,7 +191,7 @@
// We currently do not represent a zero extend expression as an affine
// expression. If it is constant during Scop execution, we treat it as a
// parameter, otherwise we bail out.
- if (Op.type == SCEVType::INT || Op.type == SCEVType::PARAM)
+ if (Op.isConstant())
return ValidatorResult (SCEVType::PARAM);
return ValidatorResult(SCEVType::INVALID);
@@ -196,7 +211,7 @@
for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
ValidatorResult Op = visit(Expr->getOperand(i));
- if (Op.type == SCEVType::INVALID)
+ if (!Op.isValid())
return ValidatorResult(SCEVType::INVALID);
Return.type = std::max(Return.type, Op.type);
@@ -232,8 +247,7 @@
// We currently do not represent a unsigned devision as an affine
// expression. If the division is constant during Scop execution we treat it
// as a parameter, otherwise we bail out.
- if (LHS.type == SCEVType::INT || LHS.type == SCEVType::PARAM ||
- RHS.type == SCEVType::INT || RHS.type == SCEVType::PARAM)
+ if (LHS.isConstant() && RHS.isConstant())
return ValidatorResult(SCEVType::PARAM);
return ValidatorResult(SCEVType::INVALID);
@@ -246,20 +260,18 @@
ValidatorResult Start = visit(Expr->getStart());
ValidatorResult Recurrence = visit(Expr->getStepRecurrence(SE));
- if (Start.type == SCEVType::INVALID ||
- Recurrence.type == SCEVType::INVALID ||
- Recurrence.type == SCEVType::IV)
+ if (!Start.isValid() || !Recurrence.isValid() || Recurrence.isIV())
return ValidatorResult(SCEVType::INVALID);
if (!R->contains(Expr->getLoop())) {
- if (Start.type == SCEVType::IV)
+ if (Start.isIV())
return ValidatorResult(SCEVType::INVALID);
else
return ValidatorResult(SCEVType::PARAM);
}
- if (Recurrence.type != SCEVType::INT)
+ if (!Recurrence.isINT())
return ValidatorResult(SCEVType::INVALID);
return ValidatorResult(SCEVType::IV);
@@ -271,7 +283,7 @@
for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
ValidatorResult Op = visit(Expr->getOperand(i));
- if (Op.type == SCEVType::INVALID)
+ if (!Op.isValid())
return ValidatorResult(SCEVType::INVALID);
Return.type = std::max(Return.type, Op.type);
@@ -286,7 +298,7 @@
for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
ValidatorResult Op = visit(Expr->getOperand(i));
- if (Op.type != SCEVType::INT && Op.type != SCEVType::PARAM)
+ if (!Op.isConstant())
return ValidatorResult(SCEVType::INVALID);
}
More information about the llvm-commits
mailing list