From: Johannes Doerfert Date: Wed, 18 Jun 2014 23:08:14 +0000 (+0000) Subject: Missing reduction detection test cases X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=da8038670011232eabb305cd46e72aa4c1eb9f2a;p=platform%2Fupstream%2Fllvm.git Missing reduction detection test cases llvm-svn: 211235 --- diff --git a/polly/test/ScopInfo/reduction_only_reduction_like_access.ll b/polly/test/ScopInfo/reduction_only_reduction_like_access.ll new file mode 100644 index 0000000..54c9fde --- /dev/null +++ b/polly/test/ScopInfo/reduction_only_reduction_like_access.ll @@ -0,0 +1,35 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s +; +; CHECK: Reduction like: 0 +; +; void f(int *sum) { +; for (int i = 0; i < 100; i++) +; sum[i] = sum[99-i] + i; +; } +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" + +define void @f(i32* %sum) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %exitcond = icmp ne i32 %i.0, 100 + br i1 %exitcond, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %sub = sub nsw i32 99, %i.0 + %arrayidx = getelementptr inbounds i32* %sum, i32 %sub + %tmp = load i32* %arrayidx, align 4 + %add = add nsw i32 %tmp, %i.0 + %arrayidx1 = getelementptr inbounds i32* %sum, i32 %i.0 + store i32 %add, i32* %arrayidx1, align 4 + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} diff --git a/polly/test/ScopInfo/reduction_simple_fp.ll b/polly/test/ScopInfo/reduction_simple_fp.ll new file mode 100644 index 0000000..83ae7c6 --- /dev/null +++ b/polly/test/ScopInfo/reduction_simple_fp.ll @@ -0,0 +1,64 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s +; +; CHECK: Function: f_no_fast_math +; CHECK: Reduction like: 0 +; CHECK: Function: f_fast_math +; CHECK: Reduction like: 1 +; +; void f(float *sum) { +; for (int i = 0; i < 100; i++) +; *sum += 3.41 * i; +; } +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" + +define void @f_no_fast_math(float* %sum) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %exitcond = icmp ne i32 %i.0, 100 + br i1 %exitcond, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %conv = sitofp i32 %i.0 to float + %pi = fptrunc double 3.41 to float + %mul = fmul float %conv, %pi + %tmp = load float* %sum, align 4 + %add = fadd float %tmp, %mul + store float %add, float* %sum, align 4 + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} + +define void @f_fast_math(float* %sum) { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ] + %exitcond = icmp ne i32 %i.0, 100 + br i1 %exitcond, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %conv = sitofp i32 %i.0 to float + %pi = fptrunc double 3.41 to float + %mul = fmul fast float %conv, %pi + %tmp = load float* %sum, align 4 + %add = fadd fast float %tmp, %mul + store float %add, float* %sum, align 4 + br label %for.inc + +for.inc: ; preds = %for.body + %inc = add nsw i32 %i.0, 1 + br label %for.cond + +for.end: ; preds = %for.cond + ret void +} diff --git a/polly/test/ScopInfo/reduction_simple_w_constant.ll b/polly/test/ScopInfo/reduction_simple_w_constant.ll new file mode 100644 index 0000000..c01eabb --- /dev/null +++ b/polly/test/ScopInfo/reduction_simple_w_constant.ll @@ -0,0 +1,26 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s +; +; CHECK: Reduction like: 1 +; +; void f(int *sum) { +; for (int i = 0; i <= 100; i++) +; sum += 3; +; } +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" + +define void @f(i32* %sum) { +entry: + br label %for.cond + +for.cond: ; preds = %for.cond, %entry + %i1.0 = phi i32 [ 0, %entry ], [ %inc, %for.cond ] + %sum.reload = load i32* %sum + %add = add nsw i32 %sum.reload, 3 + %inc = add nsw i32 %i1.0, 1 + store i32 %add, i32* %sum + %cmp = icmp slt i32 %i1.0, 100 + br i1 %cmp, label %for.cond, label %for.end + +for.end: ; preds = %for.cond + ret void +} diff --git a/polly/test/ScopInfo/reduction_simple_w_iv.ll b/polly/test/ScopInfo/reduction_simple_w_iv.ll new file mode 100644 index 0000000..4e8750d --- /dev/null +++ b/polly/test/ScopInfo/reduction_simple_w_iv.ll @@ -0,0 +1,27 @@ +; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s +; +; CHECK: Reduction like: 1 +; +; void f(int* sum) { +; for (int i = 0; i <= 100; i++) +; sum += i * 3; +; } +target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64" + +define void @f(i32* %sum) { +entry: + br label %for.cond + +for.cond: ; preds = %for.cond, %entr + %i1.0 = phi i32 [ 0, %entry ], [ %inc, %for.cond ] + %sum.reload = load i32* %sum + %mul = mul nsw i32 %i1.0, 3 + %add = add nsw i32 %sum.reload, %mul + %inc = add nsw i32 %i1.0, 1 + store i32 %add, i32* %sum + %cmp = icmp slt i32 %i1.0, 100 + br i1 %cmp, label %for.cond, label %for.end + +for.end: ; preds = %for.cond + ret void +}