1 ; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic -disable-fp-elim | FileCheck %s
3 ; MachineLICM should be able to hoist loop invariant reload out of the loop.
6 %struct.FILE = type { i8*, i32, i32, i16, i16, %struct.__sbuf, i32, i8*, i32 (i8*)*, i32 (i8*, i8*, i32)*, i64 (i8*, i64, i32)*, i32 (i8*, i8*, i32)*, %struct.__sbuf, %struct.__sFILEX*, i32, [3 x i8], [1 x i8], %struct.__sbuf, i32, i64 }
7 %struct.__sFILEX = type opaque
8 %struct.__sbuf = type { i8*, i32 }
9 %struct.epoch_t = type { %struct.trans_t*, %struct.trans_t*, i32, i32, i32, i32, i32 }
10 %struct.trans_t = type { i32, i32, i32, i8* }
12 @.str12 = external constant [2 x i8], align 1 ; <[2 x i8]*> [#uses=1]
13 @.str19 = external constant [7 x i8], align 1 ; <[7 x i8]*> [#uses=1]
14 @.str24 = external constant [4 x i8], align 1 ; <[4 x i8]*> [#uses=1]
16 define i32 @main(i32 %c, i8** nocapture %v) nounwind ssp {
19 br i1 undef, label %bb, label %bb3
25 br i1 undef, label %bb.i, label %bb.nph41
30 bb.nph41: ; preds = %bb3
31 %0 = call %struct.FILE* @"\01_fopen$UNIX2003"(i8* undef, i8* getelementptr inbounds ([2 x i8]* @.str12, i32 0, i32 0)) nounwind ; <%struct.FILE*> [#uses=3]
32 br i1 undef, label %bb4, label %bb5.preheader
34 bb5.preheader: ; preds = %bb.nph41
37 bb4: ; preds = %bb.nph41
40 bb5: ; preds = %bb5, %bb5.preheader
41 br i1 undef, label %bb7, label %bb5
44 br i1 undef, label %bb9, label %bb12
50 br i1 undef, label %bb16, label %bb22
58 bb.i1: ; preds = %bb.i1, %bb22
59 %1 = icmp eq i8 undef, 69 ; <i1> [#uses=1]
60 br i1 %1, label %imix_test.exit, label %bb.i1
62 imix_test.exit: ; preds = %bb.i1
63 br i1 undef, label %bb23, label %bb26.preheader
65 bb26.preheader: ; preds = %imix_test.exit
66 br i1 undef, label %bb28, label %bb30
68 bb23: ; preds = %imix_test.exit
70 ; CHECK: %bb26.preheader.bb28_crit_edge
71 ; CHECK: movl -16(%ebp),
72 ; CHECK-NEXT: .align 4
75 bb28: ; preds = %bb28, %bb26.preheader
76 %counter.035 = phi i32 [ %3, %bb28 ], [ 0, %bb26.preheader ] ; <i32> [#uses=2]
77 %tmp56 = shl i32 %counter.035, 2 ; <i32> [#uses=0]
78 %2 = call i8* @fgets(i8* undef, i32 50, %struct.FILE* %0) nounwind ; <i8*> [#uses=0]
79 %3 = add nsw i32 %counter.035, 1 ; <i32> [#uses=1]
80 %4 = call i32 @feof(%struct.FILE* %0) nounwind ; <i32> [#uses=0]
83 bb30: ; preds = %bb26.preheader
84 %5 = call i32 @strcmp(i8* undef, i8* getelementptr inbounds ([7 x i8]* @.str19, i32 0, i32 0)) nounwind readonly ; <i32> [#uses=0]
85 br i1 undef, label %bb34, label %bb70
87 bb32.loopexit: ; preds = %bb45
88 %6 = icmp eq i32 undef, 0 ; <i1> [#uses=1]
89 %indvar.next55 = add i32 %indvar54, 1 ; <i32> [#uses=1]
90 br i1 %6, label %bb34, label %bb70
92 bb34: ; preds = %bb32.loopexit, %bb30
93 %indvar54 = phi i32 [ %indvar.next55, %bb32.loopexit ], [ 0, %bb30 ] ; <i32> [#uses=3]
94 br i1 false, label %bb35, label %bb39.preheader
99 bb39.preheader: ; preds = %bb34
100 %7 = getelementptr inbounds %struct.epoch_t* undef, i32 %indvar54, i32 3 ; <i32*> [#uses=1]
101 %8 = getelementptr inbounds %struct.epoch_t* undef, i32 %indvar54, i32 2 ; <i32*> [#uses=0]
102 br i1 false, label %bb42, label %bb45
104 bb42: ; preds = %bb39.preheader
107 bb45: ; preds = %bb39.preheader
108 %9 = call i32 @strcmp(i8* undef, i8* getelementptr inbounds ([4 x i8]* @.str24, i32 0, i32 0)) nounwind readonly ; <i32> [#uses=0]
109 br i1 false, label %bb47, label %bb32.loopexit
111 bb47: ; preds = %bb45
112 %10 = load i32* %7, align 4 ; <i32> [#uses=0]
115 bb70: ; preds = %bb32.loopexit, %bb30
116 br i1 undef, label %bb78, label %bb76
118 bb76: ; preds = %bb70
121 bb78: ; preds = %bb70
122 br i1 undef, label %bb83, label %bb79
124 bb79: ; preds = %bb78
127 bb83: ; preds = %bb78
128 call void @rewind(%struct.FILE* %0) nounwind
132 declare %struct.FILE* @"\01_fopen$UNIX2003"(i8*, i8*)
134 declare i8* @fgets(i8*, i32, %struct.FILE* nocapture) nounwind
136 declare void @rewind(%struct.FILE* nocapture) nounwind
138 declare i32 @feof(%struct.FILE* nocapture) nounwind
140 declare i32 @strcmp(i8* nocapture, i8* nocapture) nounwind readonly