diff options
author | Johannes Doerfert <jdoerfert@codeaurora.org> | 2014-06-18 23:08:14 +0000 |
---|---|---|
committer | Johannes Doerfert <jdoerfert@codeaurora.org> | 2014-06-18 23:08:14 +0000 |
commit | da8038670011232eabb305cd46e72aa4c1eb9f2a (patch) | |
tree | b698d512b132f86593a23fbd27dfbfa9d14cdc80 /polly | |
parent | 62aeb8b653eadc8c9f4dda2d437bff18b43b6f29 (diff) | |
download | llvm-da8038670011232eabb305cd46e72aa4c1eb9f2a.zip llvm-da8038670011232eabb305cd46e72aa4c1eb9f2a.tar.gz llvm-da8038670011232eabb305cd46e72aa4c1eb9f2a.tar.bz2 |
Missing reduction detection test cases
llvm-svn: 211235
Diffstat (limited to 'polly')
-rw-r--r-- | polly/test/ScopInfo/reduction_only_reduction_like_access.ll | 35 | ||||
-rw-r--r-- | polly/test/ScopInfo/reduction_simple_fp.ll | 64 | ||||
-rw-r--r-- | polly/test/ScopInfo/reduction_simple_w_constant.ll | 26 | ||||
-rw-r--r-- | polly/test/ScopInfo/reduction_simple_w_iv.ll | 27 |
4 files changed, 152 insertions, 0 deletions
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 +} |