blob: 14964853c7c916dbeec96032e9640e5bdd1ffc30 [file] [log] [blame]
Victor Hernandez0d025422009-10-28 20:18:55 +00001; RUN: opt < %s -globalopt -S | FileCheck %s
2
3target 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-f80:128:128"
4target triple = "i386-apple-darwin10"
5
6 %struct.foo = type { i32, i32 }
7@X = internal global %struct.foo* null
8; CHECK: @X.f0
9; CHECK: @X.f1
10
11define void @bar(i32 %Size) nounwind noinline {
12entry:
13 %mallocsize = mul i32 ptrtoint (%struct.foo* getelementptr (%struct.foo* null, i32 1) to i32), %Size, ; <i32> [#uses=1]
14; CHECK: mul i32 %Size
15 %malloccall = tail call i8* @malloc(i32 %mallocsize) ; <i8*> [#uses=1]
16 %.sub = bitcast i8* %malloccall to %struct.foo* ; <%struct.foo*> [#uses=1]
17 store %struct.foo* %.sub, %struct.foo** @X, align 4
18 ret void
19}
20
21declare noalias i8* @malloc(i32)
22
23define i32 @baz() nounwind readonly noinline {
24bb1.thread:
25 %0 = load %struct.foo** @X, align 4
26 br label %bb1
27
28bb1: ; preds = %bb1, %bb1.thread
29 %i.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %indvar.next, %bb1 ]
30 %sum.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %3, %bb1 ]
31 %1 = getelementptr %struct.foo* %0, i32 %i.0.reg2mem.0, i32 0
32 %2 = load i32* %1, align 4
33 %3 = add i32 %2, %sum.0.reg2mem.0
34 %indvar.next = add i32 %i.0.reg2mem.0, 1
35 %exitcond = icmp eq i32 %indvar.next, 1200
36 br i1 %exitcond, label %bb2, label %bb1
37
38bb2: ; preds = %bb1
39 ret i32 %3
40}
41