extern bool PollyUseRuntimeAliasChecks;
extern bool PollyProcessUnprofitable;
extern bool PollyInvariantLoadHoisting;
+extern bool PollyAllowUnsignedOperations;
/// A function attribute which will cause Polly to skip the function
extern llvm::StringRef PollySkipFnAttr;
cl::Hidden, cl::init(false), cl::ZeroOrMore,
cl::cat(PollyCategory));
+bool polly::PollyAllowUnsignedOperations;
+static cl::opt<bool, true> XPollyAllowUnsignedOperations(
+ "polly-allow-unsigned-operations",
+ cl::desc("Allow unsigned operations such as comparisons or zero-extends."),
+ cl::location(PollyAllowUnsignedOperations), cl::Hidden, cl::ZeroOrMore,
+ cl::init(true), cl::cat(PollyCategory));
+
bool polly::PollyUseRuntimeAliasChecks;
static cl::opt<bool, true> XPollyUseRuntimeAliasChecks(
"polly-use-runtime-alias-checks",
const SCEV *LHS = SE->getSCEVAtScope(ICmp->getOperand(0), L);
const SCEV *RHS = SE->getSCEVAtScope(ICmp->getOperand(1), L);
+ // If unsigned operations are not allowed try to approximate the region.
+ if (ICmp->isUnsigned() && !PollyAllowUnsignedOperations)
+ return !IsLoopBranch && AllowNonAffineSubRegions &&
+ addOverApproximatedRegion(RI->getRegionFor(&BB), Context);
+
// Check for invalid usage of different pointers in one expression.
if (ICmp->isEquality() && involvesMultiplePtrs(LHS, nullptr, L) &&
involvesMultiplePtrs(RHS, nullptr, L))
return ValidatorResult(SCEVType::INT);
}
+ class ValidatorResult visitZeroExtendOrTruncateExpr(const SCEV *Expr,
+ const SCEV *Operand) {
+ ValidatorResult Op = visit(Operand);
+ auto Type = Op.getType();
+
+ // If unsigned operations are allowed return the operand, otherwise
+ // check if we can model the expression without unsigned assumptions.
+ if (PollyAllowUnsignedOperations || Type == SCEVType::INVALID)
+ return Op;
+
+ if (Type == SCEVType::IV)
+ return ValidatorResult(SCEVType::INVALID);
+ return ValidatorResult(SCEVType::PARAM, Expr);
+ }
+
class ValidatorResult visitTruncateExpr(const SCEVTruncateExpr *Expr) {
- return visit(Expr->getOperand());
+ return visitZeroExtendOrTruncateExpr(Expr, Expr->getOperand());
}
class ValidatorResult visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) {
- return visit(Expr->getOperand());
+ return visitZeroExtendOrTruncateExpr(Expr, Expr->getOperand());
}
class ValidatorResult visitSignExtendExpr(const SCEVSignExtendExpr *Expr) {
}
ValidatorResult visitUDivExpr(const SCEVUDivExpr *Expr) {
+ if (!PollyAllowUnsignedOperations)
+ return ValidatorResult(SCEVType::INVALID);
+
auto *Dividend = Expr->getLHS();
auto *Divisor = Expr->getRHS();
return visitDivision(Dividend, Divisor, Expr);