diff options
| author | Jingyue Wu <jingyue@google.com> | 2015-08-14 02:02:05 +0000 |
|---|---|---|
| committer | Jingyue Wu <jingyue@google.com> | 2015-08-14 02:02:05 +0000 |
| commit | 1238f341bab1541d1160f156319d993be20489ac (patch) | |
| tree | e8fc54357fc4a7368bf5f6013e056e8fee779316 /llvm/test/Transforms/SeparateConstOffsetFromGEP | |
| parent | 45cf0bf117416c1782462ae31c6f7b2a544e9b1f (diff) | |
| download | bcm5719-llvm-1238f341bab1541d1160f156319d993be20489ac.tar.gz bcm5719-llvm-1238f341bab1541d1160f156319d993be20489ac.zip | |
[SeparateConstOffsetFromGEP] sext(a)+sext(b) => sext(a+b) when a+b can't sign-overflow.
Summary:
This patch implements my promised optimization to reunites certain sexts from
operands after we extract the constant offset. See the header comment of
reuniteExts for its motivation.
One key building block that enables this optimization is Bjarke's poison value
analysis (D11212). That helps to prove "a +nsw b" can't overflow.
Reviewers: broune
Subscribers: jholewinski, sanjoy, llvm-commits
Differential Revision: http://reviews.llvm.org/D12016
llvm-svn: 245003
Diffstat (limited to 'llvm/test/Transforms/SeparateConstOffsetFromGEP')
| -rw-r--r-- | llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep-and-gvn.ll | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep-and-gvn.ll b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep-and-gvn.ll index a0410024f6e..e7b3545839c 100644 --- a/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep-and-gvn.ll +++ b/llvm/test/Transforms/SeparateConstOffsetFromGEP/NVPTX/split-gep-and-gvn.ll @@ -194,3 +194,41 @@ define void @sum_of_array4(i32 %x, i32 %y, float* nocapture %output) { ; IR: getelementptr inbounds float, float addrspace(3)* [[BASE_PTR]], i64 1 ; IR: getelementptr inbounds float, float addrspace(3)* [[BASE_PTR]], i64 32 ; IR: getelementptr inbounds float, float addrspace(3)* [[BASE_PTR]], i64 33 + + +; The source code is: +; p0 = &input[sext(x + y)]; +; p1 = &input[sext(x + (y + 5))]; +; +; Without reuniting extensions, SeparateConstOffsetFromGEP would emit +; p0 = &input[sext(x + y)]; +; t1 = &input[sext(x) + sext(y)]; +; p1 = &t1[5]; +; +; With reuniting extensions, it merges p0 and t1 and thus emits +; p0 = &input[sext(x + y)]; +; p1 = &p0[5]; +define void @reunion(i32 %x, i32 %y, float* %input) { +; IR-LABEL: @reunion( +; PTX-LABEL: reunion( +entry: + %xy = add nsw i32 %x, %y + %0 = sext i32 %xy to i64 + %p0 = getelementptr inbounds float, float* %input, i64 %0 + %v0 = load float, float* %p0, align 4 +; PTX: ld.f32 %f{{[0-9]+}}, {{\[}}[[p0:%rd[0-9]+]]{{\]}} + call void @use(float %v0) + + %y5 = add nsw i32 %y, 5 + %xy5 = add nsw i32 %x, %y5 + %1 = sext i32 %xy5 to i64 + %p1 = getelementptr inbounds float, float* %input, i64 %1 +; IR: getelementptr inbounds float, float* %p0, i64 5 + %v1 = load float, float* %p1, align 4 +; PTX: ld.f32 %f{{[0-9]+}}, {{\[}}[[p0]]+20{{\]}} + call void @use(float %v1) + + ret void +} + +declare void @use(float) |

