Home | History | Annotate | Download | only in InstCombine
      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"
      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 
      8 define signext i32 @test1(i32 signext %x) #0 {
      9 entry:
     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
     13   ret i32 %0
     14 
     15 ; CHECK-LABEL: @test1
     16 ; CHECK: ret i32 12
     17 }
     18 
     19 declare void @foo(i64* %p)
     20 define void @test2(i32 signext %x, i64 %v) #0 {
     21 entry:
     22   %p = alloca i64
     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)
     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 
     35 define signext i32 @test3(i32 signext %x, i1 %y) #0 {
     36 entry:
     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
     41   ret i32 %0
     42 
     43 ; CHECK-LABEL: @test3
     44 ; CHECK: getelementptr inbounds [1 x i32], [1 x i32]* %p, i64 0, i64 0
     45 }
     46 
     47 attributes #0 = { nounwind readnone }
     48 
     49