blob: 104a0f989760ae06ae0c474acdff17b12a8b0d7c [file] [log] [blame]
Tanya Lattner68328372008-03-18 04:14:37 +00001; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | \
2; RUN: not grep alloca
Chris Lattnerfa8f80a2005-12-12 07:18:59 +00003
Tanya Lattner68328372008-03-18 04:14:37 +00004target datalayout = "E-p:32:32"
Chris Lattnerfa8f80a2005-12-12 07:18:59 +00005target triple = "powerpc-apple-darwin8.0.0"
6
Tanya Lattner68328372008-03-18 04:14:37 +00007define i64 @test1(i64 %X) {
8 %A = alloca i64 ; <i64*> [#uses=3]
9 store i64 %X, i64* %A
10 %B = bitcast i64* %A to i32* ; <i32*> [#uses=1]
11 %C = bitcast i32* %B to i8* ; <i8*> [#uses=1]
12 store i8 0, i8* %C
13 %Y = load i64* %A ; <i64> [#uses=1]
14 ret i64 %Y
Chris Lattnerfa8f80a2005-12-12 07:18:59 +000015}
16
Tanya Lattner68328372008-03-18 04:14:37 +000017define i8 @test2(i64 %X) {
18 %X_addr = alloca i64 ; <i64*> [#uses=2]
19 store i64 %X, i64* %X_addr
20 %tmp.0 = bitcast i64* %X_addr to i32* ; <i32*> [#uses=1]
21 %tmp.1 = getelementptr i32* %tmp.0, i32 1 ; <i32*> [#uses=1]
22 %tmp.2 = bitcast i32* %tmp.1 to i8* ; <i8*> [#uses=1]
23 %tmp.3 = getelementptr i8* %tmp.2, i32 3 ; <i8*> [#uses=1]
24 %tmp.2.upgrd.1 = load i8* %tmp.3 ; <i8> [#uses=1]
25 ret i8 %tmp.2.upgrd.1
Chris Lattnerfa8f80a2005-12-12 07:18:59 +000026}
27
Tanya Lattner68328372008-03-18 04:14:37 +000028define i16 @crafty(i64 %X) {
29 %a = alloca { i64 } ; <{ i64 }*> [#uses=2]
30 %tmp.0 = getelementptr { i64 }* %a, i32 0, i32 0 ; <i64*> [#uses=1]
31 store i64 %X, i64* %tmp.0
32 %tmp.3 = bitcast { i64 }* %a to [4 x i16]* ; <[4 x i16]*> [#uses=2]
33 %tmp.4 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 3 ; <i16*> [#uses=1]
34 %tmp.5 = load i16* %tmp.4 ; <i16> [#uses=1]
35 %tmp.8 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 2 ; <i16*> [#uses=1]
36 %tmp.9 = load i16* %tmp.8 ; <i16> [#uses=1]
37 %tmp.10 = or i16 %tmp.9, %tmp.5 ; <i16> [#uses=1]
38 ret i16 %tmp.10
Chris Lattnerfa8f80a2005-12-12 07:18:59 +000039}
40
Tanya Lattner68328372008-03-18 04:14:37 +000041define i16 @crafty2(i64 %X) {
42 %a = alloca i64 ; <i64*> [#uses=2]
43 store i64 %X, i64* %a
44 %tmp.3 = bitcast i64* %a to [4 x i16]* ; <[4 x i16]*> [#uses=2]
45 %tmp.4 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 3 ; <i16*> [#uses=1]
46 %tmp.5 = load i16* %tmp.4 ; <i16> [#uses=1]
47 %tmp.8 = getelementptr [4 x i16]* %tmp.3, i32 0, i32 2 ; <i16*> [#uses=1]
48 %tmp.9 = load i16* %tmp.8 ; <i16> [#uses=1]
49 %tmp.10 = or i16 %tmp.9, %tmp.5 ; <i16> [#uses=1]
50 ret i16 %tmp.10
Chris Lattnerfa8f80a2005-12-12 07:18:59 +000051}