diff options
| author | Jingyue Wu <jingyue@google.com> | 2015-07-01 03:38:49 +0000 |
|---|---|---|
| committer | Jingyue Wu <jingyue@google.com> | 2015-07-01 03:38:49 +0000 |
| commit | cf02ef315fe650f026c3e2cd85c956fad6acd08f (patch) | |
| tree | f48be3010c1dfffcbfd407ee170b9cc7b8849018 /llvm/test | |
| parent | fa31f9f89f32dd24402212277ce3a2537f7de371 (diff) | |
| download | bcm5719-llvm-cf02ef315fe650f026c3e2cd85c956fad6acd08f.tar.gz bcm5719-llvm-cf02ef315fe650f026c3e2cd85c956fad6acd08f.zip | |
[NaryReassociate] enhances nsw by leveraging @llvm.assume
Summary:
nsw are flaky and can often be removed by optimizations. This patch enhances
nsw by leveraging @llvm.assume in the IR. Specifically, NaryReassociate now
understands that
assume(a + b >= 0) && assume(a >= 0) ==> a +nsw b
As a result, it can split more sext(a + b) into sext(a) + sext(b) for CSE.
Test Plan: nary-gep.ll
Reviewers: broune, meheff
Subscribers: jholewinski, llvm-commits
Differential Revision: http://reviews.llvm.org/D10822
llvm-svn: 241139
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/NaryReassociate/NVPTX/nary-gep.ll | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/test/Transforms/NaryReassociate/NVPTX/nary-gep.ll b/llvm/test/Transforms/NaryReassociate/NVPTX/nary-gep.ll index d08c6f60c04..92fbd20d298 100644 --- a/llvm/test/Transforms/NaryReassociate/NVPTX/nary-gep.ll +++ b/llvm/test/Transforms/NaryReassociate/NVPTX/nary-gep.ll @@ -61,6 +61,40 @@ define void @reassociate_gep_nsw(float* %a, i32 %i, i32 %j) { ret void } +; assume(j >= 0); +; foo(&a[zext(j)]); +; assume(i + j >= 0); +; foo(&a[zext(i + j)]); +; => +; t1 = &a[zext(j)]; +; foo(t1); +; t2 = t1 + sext(i); +; foo(t2); +define void @reassociate_gep_assume(float* %a, i32 %i, i32 %j) { +; CHECK-LABEL: @reassociate_gep_assume( + ; assume(j >= 0) + %cmp = icmp sgt i32 %j, -1 + call void @llvm.assume(i1 %cmp) + %1 = add i32 %i, %j + %cmp2 = icmp sgt i32 %1, -1 + call void @llvm.assume(i1 %cmp2) + + %idxprom.j = zext i32 %j to i64 + %2 = getelementptr float, float* %a, i64 %idxprom.j +; CHECK: [[t1:[^ ]+]] = getelementptr float, float* %a, i64 %idxprom.j + call void @foo(float* %2) +; CHECK: call void @foo(float* [[t1]]) + + %idxprom.1 = zext i32 %1 to i64 + %3 = getelementptr float, float* %a, i64 %idxprom.1 +; CHECK: [[sexti:[^ ]+]] = sext i32 %i to i64 +; CHECK: [[t2:[^ ]+]] = getelementptr float, float* [[t1]], i64 [[sexti]] + call void @foo(float* %3) +; CHECK: call void @foo(float* [[t2]]) + + ret void +} + ; Do not split the second GEP because sext(i + j) != sext(i) + sext(j). define void @reassociate_gep_no_nsw(float* %a, i32 %i, i32 %j) { ; CHECK-LABEL: @reassociate_gep_no_nsw( @@ -88,3 +122,5 @@ define void @reassociate_gep_128(float* %a, i128 %i, i128 %j) { ; CHECK: call void @foo(float* [[t2]]) ret void } + +declare void @llvm.assume(i1) |

