[llvm-commits] [polly] r152913 - in /polly/trunk: lib/Support/SCEVValidator.cpp test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll

Tobias Grosser grosser at fim.uni-passau.de
Fri Mar 16 03:16:28 PDT 2012


Author: grosser
Date: Fri Mar 16 05:16:28 2012
New Revision: 152913

URL: http://llvm.org/viewvc/llvm-project?rev=152913&view=rev
Log:
SCEVValidator: Ensure that parameters are recorded correctly

This also fixes UMax where we did not correctly keep track of the parameters.
Fixes PR12275.

Reported-By: Sebastian Pop  <sebpop at gmail.com>

Added:
    polly/trunk/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll
Modified:
    polly/trunk/lib/Support/SCEVValidator.cpp

Modified: polly/trunk/lib/Support/SCEVValidator.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/SCEVValidator.cpp?rev=152913&r1=152912&r2=152913&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVValidator.cpp (original)
+++ polly/trunk/lib/Support/SCEVValidator.cpp Fri Mar 16 05:16:28 2012
@@ -52,7 +52,9 @@
   };
 
   /// @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 @@
   }
 
   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 @@
   }
 
   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 @@
 
       if (!Op.isConstant())
         return ValidatorResult(SCEVType::INVALID);
-
-      Return.merge(Op);
     }
 
-    return Return;
+    return ValidatorResult(SCEVType::PARAM, Expr);
   }
 
   ValidatorResult visitUnknown(const SCEVUnknown *Expr) {

Added: polly/trunk/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll?rev=152913&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll (added)
+++ polly/trunk/test/ScopInfo/2012-03-16-Crash-because-of-unsigned-in-scev.ll Fri Mar 16 05:16:28 2012
@@ -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"
+
+ at 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)





More information about the llvm-commits mailing list