1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "e-p:32:32"
4 target triple = "i686-pc-linux-gnu"
8 ; CHECK: %[[call:.*]] = call i8* @ctime(i32* null)
9 ; CHECK: %[[cast:.*]] = ptrtoint i8* %[[call]] to i32
10 ; CHECK: ret i32 %[[cast]]
12 %tmp = call i32 bitcast (i8* (i32*)* @ctime to i32 (i32*)*)( i32* null ) ; <i32> [#uses=1]
16 declare i8* @ctime(i32*)
18 define internal { i8 } @foo(i32*) {
23 define void @test_struct_ret() {
24 ; CHECK-LABEL: @test_struct_ret
27 %0 = call { i8 } bitcast ({ i8 } (i32*)* @foo to { i8 } (i16*)*)(i16* null)
33 define i32 @test1(i32* %a) {
35 ; CHECK: %[[cast:.*]] = ptrtoint i32* %a to i32
36 ; CHECK-NEXT: %[[call:.*]] = tail call i32 @fn1(i32 %[[cast]])
37 ; CHECK-NEXT: ret i32 %[[call]]
39 %call = tail call i32 bitcast (i32 (i32)* @fn1 to i32 (i32*)*)(i32* %a)
45 define i32 @test2(i32* %a) {
47 ; CHECK: %[[call:.*]] = tail call i32 bitcast (i32 (i16)* @fn2 to i32 (i32*)*)(i32* %a)
48 ; CHECK-NEXT: ret i32 %[[call]]
50 %call = tail call i32 bitcast (i32 (i16)* @fn2 to i32 (i32*)*)(i32* %a)
56 define i32 @test3(i32* %a) {
58 ; CHECK: %[[call:.*]] = tail call i32 bitcast (i32 (i64)* @fn3 to i32 (i32*)*)(i32* %a)
59 ; CHECK-NEXT: ret i32 %[[call]]
61 %call = tail call i32 bitcast (i32 (i64)* @fn3 to i32 (i32*)*)(i32* %a)
65 declare i32 @fn4(i32) "thunk"
67 define i32 @test4(i32* %a) {
69 ; CHECK: %[[call:.*]] = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
70 ; CHECK-NEXT: ret i32 %[[call]]
72 %call = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
76 declare i1 @fn5({ i32, i32 }* byval align 4 %r)
80 ; CHECK: %[[call:.*]] = call i1 bitcast (i1 ({ i32, i32 }*)* @fn5 to i1 (i32, i32)*)(i32 {{.*}}, i32 {{.*}})
81 ; CHECK-NEXT: ret i1 %[[call]]
82 %1 = alloca { i32, i32 }, align 4
83 %2 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %1, i32 0, i32 0
84 %3 = load i32, i32* %2, align 4
85 %4 = getelementptr inbounds { i32, i32 }, { i32, i32 }* %1, i32 0, i32 1
86 %5 = load i32, i32* %4, align 4
87 %6 = call i1 bitcast (i1 ({ i32, i32 }*)* @fn5 to i1 (i32, i32)*)(i32 %3, i32 %5)