rearrange how SRoA handles promotion of allocas to vectors.
[oota-llvm.git] / test / Transforms / ScalarRepl / memset-aggregate.ll
1 ; PR1226
2 ; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | grep {ret i32 16843009}
3 ; RUN: llvm-as < %s | opt -scalarrepl | llvm-dis | not grep alloca
4
5 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64"
6 target triple = "i686-apple-darwin8"
7         %struct.bar = type { %struct.foo, i64, double }
8         %struct.foo = type { i32, i32 }
9
10
11 define i32 @test1(%struct.foo* %P) {
12 entry:
13         %L = alloca %struct.foo, align 8                ; <%struct.foo*> [#uses=2]
14         %L2 = bitcast %struct.foo* %L to i8*            ; <i8*> [#uses=1]
15         %tmp13 = bitcast %struct.foo* %P to i8*         ; <i8*> [#uses=1]
16         call void @llvm.memcpy.i32( i8* %L2, i8* %tmp13, i32 8, i32 4 )
17         %tmp4 = getelementptr %struct.foo* %L, i32 0, i32 0             ; <i32*> [#uses=1]
18         %tmp5 = load i32* %tmp4         ; <i32> [#uses=1]
19         ret i32 %tmp5
20 }
21
22 declare void @llvm.memcpy.i32(i8*, i8*, i32, i32)
23
24 define i32 @test2() {
25 entry:
26         %L = alloca [4 x %struct.foo], align 16         ; <[4 x %struct.foo]*> [#uses=2]
27         %L12 = bitcast [4 x %struct.foo]* %L to i8*             ; <i8*> [#uses=1]
28         call void @llvm.memset.i32( i8* %L12, i8 0, i32 32, i32 16 )
29         %tmp4 = getelementptr [4 x %struct.foo]* %L, i32 0, i32 0, i32 0                ; <i32*> [#uses=1]
30         %tmp5 = load i32* %tmp4         ; <i32> [#uses=1]
31         ret i32 %tmp5
32 }
33
34 declare void @llvm.memset.i32(i8*, i8, i32, i32)
35
36 define i32 @test3() {
37 entry:
38         %B = alloca %struct.bar, align 16               ; <%struct.bar*> [#uses=4]
39         %B1 = bitcast %struct.bar* %B to i8*            ; <i8*> [#uses=1]
40         call void @llvm.memset.i32( i8* %B1, i8 1, i32 24, i32 16 )
41         %tmp3 = getelementptr %struct.bar* %B, i32 0, i32 0, i32 0              ; <i32*> [#uses=1]
42         store i32 1, i32* %tmp3
43         %tmp4 = getelementptr %struct.bar* %B, i32 0, i32 2             ; <double*> [#uses=1]
44         store double 1.000000e+01, double* %tmp4
45         %tmp6 = getelementptr %struct.bar* %B, i32 0, i32 0, i32 1              ; <i32*> [#uses=1]
46         %tmp7 = load i32* %tmp6         ; <i32> [#uses=1]
47         ret i32 %tmp7
48 }