diff options
-rw-r--r-- | polly/lib/Support/SCEVValidator.cpp | 12 | ||||
-rw-r--r-- | polly/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll | 32 |
2 files changed, 37 insertions, 7 deletions
diff --git a/polly/lib/Support/SCEVValidator.cpp b/polly/lib/Support/SCEVValidator.cpp index 4d0087a554f..eb26424cf60 100644 --- a/polly/lib/Support/SCEVValidator.cpp +++ b/polly/lib/Support/SCEVValidator.cpp @@ -52,7 +52,9 @@ public: }; /// @brief Construct a result with a certain type and no parameters. - ValidatorResult(SCEVType::TYPE Type) : Type(Type) {}; + ValidatorResult(SCEVType::TYPE Type) : Type(Type) { + assert(Type != SCEVType::PARAM && "Did you forget to pass the parameter"); + }; /// @brief Construct a result with a certain type and a single parameter. ValidatorResult(SCEVType::TYPE Type, const SCEV *Expr) : Type(Type) { @@ -247,7 +249,7 @@ public: } class ValidatorResult visitSMaxExpr(const SCEVSMaxExpr *Expr) { - ValidatorResult Return(SCEVType::INT); + ValidatorResult Return(SCEVType::INT, Expr); for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) { ValidatorResult Op = visit(Expr->getOperand(i)); @@ -262,8 +264,6 @@ public: } class ValidatorResult visitUMaxExpr(const SCEVUMaxExpr *Expr) { - ValidatorResult Return(SCEVType::PARAM); - // We do not support unsigned 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) { @@ -271,11 +271,9 @@ public: if (!Op.isConstant()) return ValidatorResult(SCEVType::INVALID); - - Return.merge(Op); } - return Return; + return ValidatorResult(SCEVType::PARAM, Expr); } ValidatorResult visitUnknown(const SCEVUnknown *Expr) { diff --git a/polly/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll b/polly/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll new file mode 100644 index 00000000000..8f971d618db --- /dev/null +++ b/polly/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll @@ -0,0 +1,32 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s + +target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32f64:64:64-f32:32:32-a0:0-n32" +target triple = "hexagon-unknown-linux-gnu" + +@array = external global [64 x i8], align 8 + +define void @foo(i32* %A) nounwind { +entry: + br label %if.then132 + +if.then132: + %loaded = load i32* %A + %0 = icmp ugt i32 %loaded, 10 + %umax = select i1 %0, i32 %loaded, i32 10 + br label %do.body + +do.body: + %indvar = phi i32 [ %3, %do.body ], [ 0, %if.then132 ] + %1 = add i32 0, %umax + %2 = sub i32 %1, %indvar + %arrayidx = getelementptr [64 x i8]* @array, i32 0, i32 %2 + store i8 1, i8* %arrayidx, align 1 + %3 = add i32 %indvar, 1 + %exitcond = icmp eq i32 %3, 20 + br i1 %exitcond, label %for.end, label %do.body + +for.end: + ret void +} + +;CHECK: p0: (10 umax %loaded) |