2 ; RUN: opt < %s -scalarrepl -S | FileCheck %s
5 target datalayout = "e-p:32:32-p1:16:16-n8:16:32"
6 target triple = "i686-apple-darwin8.7.2"
8 %struct.Val = type { i32*, i32 }
10 define i8* @test(i16* %X) {
14 %X_addr = alloca i16* ; <i16**> [#uses=2]
15 store i16* %X, i16** %X_addr
16 %X_addr.upgrd.1 = bitcast i16** %X_addr to i8** ; <i8**> [#uses=1]
17 %tmp = load i8** %X_addr.upgrd.1 ; <i8*> [#uses=1]
21 define i8 addrspace(1)* @test_as1(i16 addrspace(1)* %x) {
22 ; CHECK-LABEL: @test_as1(
23 ; CHECK-NEXT: %1 = ptrtoint i16 addrspace(1)* %x to i16
24 ; CHECK-NEXT: %2 = inttoptr i16 %1 to i8 addrspace(1)*
25 ; CHECK-NEXT: ret i8 addrspace(1)* %2
26 %x_addr = alloca i16 addrspace(1)*
27 store i16 addrspace(1)* %x, i16 addrspace(1)** %x_addr
28 %x_addr.upgrd.1 = bitcast i16 addrspace(1)** %x_addr to i8 addrspace(1)**
29 %tmp = load i8 addrspace(1)** %x_addr.upgrd.1
30 ret i8 addrspace(1)* %tmp
33 define i8 addrspace(1)* @test_as1_array(i16 addrspace(1)* %x) {
34 ; CHECK-LABEL: @test_as1_array(
35 ; CHECK-NEXT: %1 = ptrtoint i16 addrspace(1)* %x to i16
36 ; CHECK-NEXT: %2 = inttoptr i16 %1 to i8 addrspace(1)*
37 ; CHECK-NEXT: ret i8 addrspace(1)* %2
38 %as_ptr_array = alloca [4 x i16 addrspace(1)*]
39 %elem1 = getelementptr [4 x i16 addrspace(1)*]* %as_ptr_array, i32 0, i32 1
40 store i16 addrspace(1)* %x, i16 addrspace(1)** %elem1
41 %elem1.cast = bitcast i16 addrspace(1)** %elem1 to i8 addrspace(1)**
42 %tmp = load i8 addrspace(1)** %elem1.cast
43 ret i8 addrspace(1)* %tmp
47 define void @test2(i64 %Op.0) {
48 ; CHECK-LABEL: @test2(
52 %tmp = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
53 %tmp1 = alloca %struct.Val, align 8 ; <%struct.Val*> [#uses=3]
54 %tmp.upgrd.2 = call i64 @_Z3foov( ) ; <i64> [#uses=1]
55 %tmp1.upgrd.3 = bitcast %struct.Val* %tmp1 to i64* ; <i64*> [#uses=1]
56 store i64 %tmp.upgrd.2, i64* %tmp1.upgrd.3
57 %tmp.upgrd.4 = getelementptr %struct.Val* %tmp, i32 0, i32 0 ; <i32**> [#uses=1]
58 %tmp2 = getelementptr %struct.Val* %tmp1, i32 0, i32 0 ; <i32**> [#uses=1]
59 %tmp.upgrd.5 = load i32** %tmp2 ; <i32*> [#uses=1]
60 store i32* %tmp.upgrd.5, i32** %tmp.upgrd.4
61 %tmp3 = getelementptr %struct.Val* %tmp, i32 0, i32 1 ; <i32*> [#uses=1]
62 %tmp4 = getelementptr %struct.Val* %tmp1, i32 0, i32 1 ; <i32*> [#uses=1]
63 %tmp.upgrd.6 = load i32* %tmp4 ; <i32> [#uses=1]
64 store i32 %tmp.upgrd.6, i32* %tmp3
65 %tmp7 = bitcast %struct.Val* %tmp to { i64 }* ; <{ i64 }*> [#uses=1]
66 %tmp8 = getelementptr { i64 }* %tmp7, i32 0, i32 0 ; <i64*> [#uses=1]
67 %tmp9 = load i64* %tmp8 ; <i64> [#uses=1]
68 call void @_Z3bar3ValS_( i64 %Op.0, i64 %tmp9 )
72 declare i64 @_Z3foov()
74 declare void @_Z3bar3ValS_(i64, i64)