1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -globalopt -S | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker; CHECK: tmp.f1 = phi i32* 3*9880d681SAndroid Build Coastguard Worker; CHECK: tmp.f0 = phi i32* 4*9880d681SAndroid Build Coastguard Workertarget datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker %struct.foo = type { i32, i32 } 7*9880d681SAndroid Build Coastguard Worker@X = internal global %struct.foo* null ; <%struct.foo**> [#uses=2] 8*9880d681SAndroid Build Coastguard Worker 9*9880d681SAndroid Build Coastguard Workerdefine void @bar(i32 %Size) nounwind noinline { 10*9880d681SAndroid Build Coastguard Workerentry: 11*9880d681SAndroid Build Coastguard Worker %malloccall = tail call i8* @malloc(i64 8000000) ; <i8*> [#uses=1] 12*9880d681SAndroid Build Coastguard Worker %tmp = bitcast i8* %malloccall to [1000000 x %struct.foo]* ; <[1000000 x %struct.foo]*> [#uses=1] 13*9880d681SAndroid Build Coastguard Worker %.sub = getelementptr [1000000 x %struct.foo], [1000000 x %struct.foo]* %tmp, i32 0, i32 0 ; <%struct.foo*> [#uses=1] 14*9880d681SAndroid Build Coastguard Worker store %struct.foo* %.sub, %struct.foo** @X, align 4 15*9880d681SAndroid Build Coastguard Worker ret void 16*9880d681SAndroid Build Coastguard Worker} 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerdeclare noalias i8* @malloc(i64) 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Workerdefine i32 @baz() nounwind readonly noinline { 21*9880d681SAndroid Build Coastguard Workerbb1.thread: 22*9880d681SAndroid Build Coastguard Worker %tmpLD1 = load %struct.foo*, %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] 23*9880d681SAndroid Build Coastguard Worker br label %bb1 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Workerbb1: ; preds = %bb1, %bb1.thread 26*9880d681SAndroid Build Coastguard Worker %tmp = phi %struct.foo* [%tmpLD1, %bb1.thread ], [ %tmpLD2, %bb1 ] ; <i32> [#uses=2] 27*9880d681SAndroid Build Coastguard Worker %i.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %indvar.next, %bb1 ] ; <i32> [#uses=2] 28*9880d681SAndroid Build Coastguard Worker %sum.0.reg2mem.0 = phi i32 [ 0, %bb1.thread ], [ %tmp3, %bb1 ] ; <i32> [#uses=1] 29*9880d681SAndroid Build Coastguard Worker %tmp1 = getelementptr %struct.foo, %struct.foo* %tmp, i32 %i.0.reg2mem.0, i32 0 ; <i32*> [#uses=1] 30*9880d681SAndroid Build Coastguard Worker %tmp2 = load i32, i32* %tmp1, align 4 ; <i32> [#uses=1] 31*9880d681SAndroid Build Coastguard Worker %tmp6 = add i32 %tmp2, %sum.0.reg2mem.0 ; <i32> [#uses=2] 32*9880d681SAndroid Build Coastguard Worker %tmp4 = getelementptr %struct.foo, %struct.foo* %tmp, i32 %i.0.reg2mem.0, i32 1 ; <i32*> [#uses=1] 33*9880d681SAndroid Build Coastguard Worker %tmp5 = load i32 , i32 * %tmp4 34*9880d681SAndroid Build Coastguard Worker %tmp3 = add i32 %tmp5, %tmp6 35*9880d681SAndroid Build Coastguard Worker %indvar.next = add i32 %i.0.reg2mem.0, 1 ; <i32> [#uses=2] 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Worker %tmpLD2 = load %struct.foo*, %struct.foo** @X, align 4 ; <%struct.foo*> [#uses=1] 38*9880d681SAndroid Build Coastguard Worker 39*9880d681SAndroid Build Coastguard Worker %exitcond = icmp eq i32 %indvar.next, 1200 ; <i1> [#uses=1] 40*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %bb2, label %bb1 41*9880d681SAndroid Build Coastguard Worker 42*9880d681SAndroid Build Coastguard Workerbb2: ; preds = %bb1 43*9880d681SAndroid Build Coastguard Worker ret i32 %tmp3 44*9880d681SAndroid Build Coastguard Worker} 45