1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2 target datalayout = "E-m:e-i64:64-n32:64"
3 target triple = "powerpc64-unknown-linux-gnu"
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 @f.c = linkonce unnamed_addr alias [1 x i32], [1 x i32]* @f.b
9 define signext i32 @test1(i32 signext %x) #0 {
11 %idxprom = sext i32 %x to i64
12 %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @f.a, i64 0, i64 %idxprom
13 %0 = load i32, i32* %arrayidx, align 4
20 declare void @foo(i64* %p)
21 define void @test2(i32 signext %x, i64 %v) #0 {
24 %idxprom = sext i32 %x to i64
25 %arrayidx = getelementptr inbounds i64, i64* %p, i64 %idxprom
26 store i64 %v, i64* %arrayidx
27 call void @foo(i64* %p)
31 ; CHECK: %p = alloca i64
32 ; CHECK: store i64 %v, i64* %p
36 define signext i32 @test3(i32 signext %x, i1 %y) #0 {
38 %idxprom = sext i32 %x to i64
39 %p = select i1 %y, [1 x i32]* @f.a, [1 x i32]* @f.b
40 %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 %idxprom
41 %0 = load i32, i32* %arrayidx, align 4
45 ; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 0
48 define signext i32 @test4(i32 signext %x, i1 %y) #0 {
50 %idxprom = sext i32 %x to i64
51 %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @f.c, i64 0, i64 %idxprom
52 %0 = load i32, i32* %arrayidx, align 4
56 ; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* @f.c, i64 0, i64 %idxprom
59 attributes #0 = { nounwind readnone }