Enable post regalloc machine licm by default.
[oota-llvm.git] / test / CodeGen / X86 / postra-licm.ll
1 ; RUN: llc < %s -mtriple=i386-apple-darwin -relocation-model=pic -disable-fp-elim | FileCheck %s
2
3 ; MachineLICM should be able to hoist loop invariant reload out of the loop.
4 ; rdar://7233099
5
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* }
11
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]
15
16 define i32 @main(i32 %c, i8** nocapture %v) nounwind ssp {
17 ; CHECK: main:
18 entry:
19   br i1 undef, label %bb, label %bb3
20
21 bb:                                               ; preds = %entry
22   unreachable
23
24 bb3:                                              ; preds = %entry
25   br i1 undef, label %bb.i, label %bb.nph41
26
27 bb.i:                                             ; preds = %bb3
28   unreachable
29
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
33
34 bb5.preheader:                                    ; preds = %bb.nph41
35   br label %bb5
36
37 bb4:                                              ; preds = %bb.nph41
38   unreachable
39
40 bb5:                                              ; preds = %bb5, %bb5.preheader
41   br i1 undef, label %bb7, label %bb5
42
43 bb7:                                              ; preds = %bb5
44   br i1 undef, label %bb9, label %bb12
45
46 bb9:                                              ; preds = %bb7
47   unreachable
48
49 bb12:                                             ; preds = %bb7
50   br i1 undef, label %bb16, label %bb22
51
52 bb16:                                             ; preds = %bb12
53   unreachable
54
55 bb22:                                             ; preds = %bb12
56   br label %bb.i1
57
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
61
62 imix_test.exit:                                   ; preds = %bb.i1
63   br i1 undef, label %bb23, label %bb26.preheader
64
65 bb26.preheader:                                   ; preds = %imix_test.exit
66   br i1 undef, label %bb28, label %bb30
67
68 bb23:                                             ; preds = %imix_test.exit
69   unreachable
70 ; CHECK: %bb26.preheader.bb28_crit_edge
71 ; CHECK: movl -16(%ebp),
72 ; CHECK-NEXT: .align 4
73 ; CHECK-NEXT: %bb28
74
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]
81   br label %bb28
82
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
86
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
91
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
95
96 bb35:                                             ; preds = %bb34
97   unreachable
98
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
103
104 bb42:                                             ; preds = %bb39.preheader
105   unreachable
106
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
110
111 bb47:                                             ; preds = %bb45
112   %10 = load i32* %7, align 4                     ; <i32> [#uses=0]
113   unreachable
114
115 bb70:                                             ; preds = %bb32.loopexit, %bb30
116   br i1 undef, label %bb78, label %bb76
117
118 bb76:                                             ; preds = %bb70
119   unreachable
120
121 bb78:                                             ; preds = %bb70
122   br i1 undef, label %bb83, label %bb79
123
124 bb79:                                             ; preds = %bb78
125   unreachable
126
127 bb83:                                             ; preds = %bb78
128   call void @rewind(%struct.FILE* %0) nounwind
129   unreachable
130 }
131
132 declare %struct.FILE* @"\01_fopen$UNIX2003"(i8*, i8*)
133
134 declare i8* @fgets(i8*, i32, %struct.FILE* nocapture) nounwind
135
136 declare void @rewind(%struct.FILE* nocapture) nounwind
137
138 declare i32 @feof(%struct.FILE* nocapture) nounwind
139
140 declare i32 @strcmp(i8* nocapture, i8* nocapture) nounwind readonly