[polly] r179485 - SCEVValidator: Correctly store 'k * p' as a parameter
Tobias Grosser
grosser at fim.uni-passau.de
Sun Apr 14 06:15:59 PDT 2013
Author: grosser
Date: Sun Apr 14 08:15:59 2013
New Revision: 179485
URL: http://llvm.org/viewvc/llvm-project?rev=179485&view=rev
Log:
SCEVValidator: Correctly store 'k * p' as a parameter
We do not only need to understand that 'k * p' is a parameter expression, but
also need to store this expression in the set of parameters. Before this patch
we wrongly stored the two individual parameters %k and %p.
Reported by: Sebastian Pop <spop at codeaurora.org>
Added:
polly/trunk/test/ScopInfo/parameter_product.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=179485&r1=179484&r2=179485&view=diff
==============================================================================
--- polly/trunk/lib/Support/SCEVValidator.cpp (original)
+++ polly/trunk/lib/Support/SCEVValidator.cpp Sun Apr 14 08:15:59 2013
@@ -202,6 +202,8 @@ public:
class ValidatorResult visitMulExpr(const SCEVMulExpr *Expr) {
ValidatorResult Return(SCEVType::INT);
+ bool HasMultipleParams = false;
+
for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) {
ValidatorResult Op = visit(Expr->getOperand(i));
@@ -209,7 +211,7 @@ public:
continue;
if (Op.isPARAM() && Return.isPARAM()) {
- Return.merge(Op);
+ HasMultipleParams = true;
continue;
}
@@ -226,6 +228,9 @@ public:
Return.merge(Op);
}
+ if (HasMultipleParams)
+ return ValidatorResult(SCEVType::PARAM, Expr);
+
// TODO: Check for NSW and NUW.
return Return;
}
Added: polly/trunk/test/ScopInfo/parameter_product.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/parameter_product.ll?rev=179485&view=auto
==============================================================================
--- polly/trunk/test/ScopInfo/parameter_product.ll (added)
+++ polly/trunk/test/ScopInfo/parameter_product.ll Sun Apr 14 08:15:59 2013
@@ -0,0 +1,31 @@
+; RUN: opt %loadPolly -polly-scops -analyze -S < %s | FileCheck %s
+;
+; int n, m;
+; void foo(char* __restrict a)
+; {
+; for (int i = 0; i < n*m; ++i)
+; a[i]=2;
+; }
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @foo(i8* noalias %a, i32 %param_n, i32 %param_m) {
+entry:
+ %mul = mul nsw i32 %param_m, %param_n
+ %cmp1 = icmp sgt i32 %mul, 0
+ br i1 %cmp1, label %for.body, label %for.end
+
+for.body:
+ %i.02 = phi i32 [ %add, %for.body ], [ 0, %entry ]
+ %arrayidx = getelementptr inbounds i8* %a, i64 0
+ store i8 2, i8* %arrayidx, align 1
+ %add = add nsw i32 %i.02, 1
+ %cmp = icmp slt i32 %add, %mul
+ br i1 %cmp, label %for.body, label %for.end
+
+for.end:
+ ret void
+}
+
+; CHECK: p0: (%param_n * %param_m)
+
More information about the llvm-commits
mailing list