diff options
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/load-cmp.ll | 8 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/mem-gep-zidx.ll | 48 |
2 files changed, 51 insertions, 5 deletions
diff --git a/llvm/test/Transforms/InstCombine/load-cmp.ll b/llvm/test/Transforms/InstCombine/load-cmp.ll index 98100263b48..40673a72d51 100644 --- a/llvm/test/Transforms/InstCombine/load-cmp.ll +++ b/llvm/test/Transforms/InstCombine/load-cmp.ll @@ -230,7 +230,7 @@ define i1 @test10_struct(i32 %x) { ; NODL: getelementptr inbounds %Foo* @GS, i32 %x, i32 0 ; P32-LABEL: @test10_struct( -; P32: getelementptr inbounds %Foo* @GS, i32 %x, i32 0 +; P32: ret i1 false %p = getelementptr inbounds %Foo* @GS, i32 %x, i32 0 %q = load i32* %p %r = icmp eq i32 %q, 9 @@ -256,8 +256,7 @@ define i1 @test10_struct_i16(i16 %x){ ; NODL: getelementptr inbounds %Foo* @GS, i16 %x, i32 0 ; P32-LABEL: @test10_struct_i16( -; P32: %1 = sext i16 %x to i32 -; P32: getelementptr inbounds %Foo* @GS, i32 %1, i32 0 +; P32: ret i1 false %p = getelementptr inbounds %Foo* @GS, i16 %x, i32 0 %q = load i32* %p %r = icmp eq i32 %q, 0 @@ -271,8 +270,7 @@ define i1 @test10_struct_i64(i64 %x){ ; NODL: getelementptr inbounds %Foo* @GS, i64 %x, i32 0 ; P32-LABEL: @test10_struct_i64( -; P32: %1 = trunc i64 %x to i32 -; P32: getelementptr inbounds %Foo* @GS, i32 %1, i32 0 +; P32: ret i1 false %p = getelementptr inbounds %Foo* @GS, i64 %x, i32 0 %q = load i32* %p %r = icmp eq i32 %q, 0 diff --git a/llvm/test/Transforms/InstCombine/mem-gep-zidx.ll b/llvm/test/Transforms/InstCombine/mem-gep-zidx.ll new file mode 100644 index 00000000000..9141d99e301 --- /dev/null +++ b/llvm/test/Transforms/InstCombine/mem-gep-zidx.ll @@ -0,0 +1,48 @@ +; RUN: opt -S -instcombine < %s | FileCheck %s +target datalayout = "E-m:e-i64:64-n32:64" +target triple = "powerpc64-unknown-linux-gnu" + +@f.a = private unnamed_addr constant [1 x i32] [i32 12], align 4 +@f.b = private unnamed_addr constant [1 x i32] [i32 55], align 4 + +define signext i32 @test1(i32 signext %x) #0 { +entry: + %idxprom = sext i32 %x to i64 + %arrayidx = getelementptr inbounds [1 x i32]* @f.a, i64 0, i64 %idxprom + %0 = load i32* %arrayidx, align 4 + ret i32 %0 + +; CHECK-LABEL: @test1 +; CHECK: ret i32 12 +} + +declare void @foo(i64* %p) +define void @test2(i32 signext %x, i64 %v) #0 { +entry: + %p = alloca i64 + %idxprom = sext i32 %x to i64 + %arrayidx = getelementptr inbounds i64* %p, i64 %idxprom + store i64 %v, i64* %arrayidx + call void @foo(i64* %p) + ret void + +; CHECK-LABEL: @test2 +; CHECK: %p = alloca i64 +; CHECK: store i64 %v, i64* %p +; CHECK: ret void +} + +define signext i32 @test3(i32 signext %x, i1 %y) #0 { +entry: + %idxprom = sext i32 %x to i64 + %p = select i1 %y, [1 x i32]* @f.a, [1 x i32]* @f.b + %arrayidx = getelementptr inbounds [1 x i32]* %p, i64 0, i64 %idxprom + %0 = load i32* %arrayidx, align 4 + ret i32 %0 + +; CHECK-LABEL: @test3 +; CHECK: getelementptr inbounds [1 x i32]* %p, i64 0, i64 0 +} + +attributes #0 = { nounwind readnone } + |

