blob: 9141d99e3014fca956f09dd7c6c836f3f28d4695 [file] [log] [blame]
Hal Finkel847e05f2015-02-20 03:05:53 +00001; RUN: opt -S -instcombine < %s | FileCheck %s
2target datalayout = "E-m:e-i64:64-n32:64"
3target triple = "powerpc64-unknown-linux-gnu"
4
5@f.a = private unnamed_addr constant [1 x i32] [i32 12], align 4
6@f.b = private unnamed_addr constant [1 x i32] [i32 55], align 4
7
8define signext i32 @test1(i32 signext %x) #0 {
9entry:
10 %idxprom = sext i32 %x to i64
11 %arrayidx = getelementptr inbounds [1 x i32]* @f.a, i64 0, i64 %idxprom
12 %0 = load i32* %arrayidx, align 4
13 ret i32 %0
14
15; CHECK-LABEL: @test1
16; CHECK: ret i32 12
17}
18
19declare void @foo(i64* %p)
20define void @test2(i32 signext %x, i64 %v) #0 {
21entry:
22 %p = alloca i64
23 %idxprom = sext i32 %x to i64
24 %arrayidx = getelementptr inbounds i64* %p, i64 %idxprom
25 store i64 %v, i64* %arrayidx
26 call void @foo(i64* %p)
27 ret void
28
29; CHECK-LABEL: @test2
30; CHECK: %p = alloca i64
31; CHECK: store i64 %v, i64* %p
32; CHECK: ret void
33}
34
35define signext i32 @test3(i32 signext %x, i1 %y) #0 {
36entry:
37 %idxprom = sext i32 %x to i64
38 %p = select i1 %y, [1 x i32]* @f.a, [1 x i32]* @f.b
39 %arrayidx = getelementptr inbounds [1 x i32]* %p, i64 0, i64 %idxprom
40 %0 = load i32* %arrayidx, align 4
41 ret i32 %0
42
43; CHECK-LABEL: @test3
44; CHECK: getelementptr inbounds [1 x i32]* %p, i64 0, i64 0
45}
46
47attributes #0 = { nounwind readnone }
48