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
8 define signext i32 @test1(i32 signext %x) #0 {
10 %idxprom = sext i32 %x to i64
11 %arrayidx = getelementptr inbounds [1 x i32], [1 x i32]* @f.a, i64 0, i64 %idxprom
12 %0 = load i32, i32* %arrayidx, align 4
19 declare void @foo(i64* %p)
20 define void @test2(i32 signext %x, i64 %v) #0 {
23 %idxprom = sext i32 %x to i64
24 %arrayidx = getelementptr inbounds i64, i64* %p, i64 %idxprom
25 store i64 %v, i64* %arrayidx
26 call void @foo(i64* %p)
30 ; CHECK: %p = alloca i64
31 ; CHECK: store i64 %v, i64* %p
35 define signext i32 @test3(i32 signext %x, i1 %y) #0 {
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], [1 x i32]* %p, i64 0, i64 %idxprom
40 %0 = load i32, i32* %arrayidx, align 4
44 ; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 0
47 attributes #0 = { nounwind readnone }