1; RUN: llc < %s -mtriple=thumbv7-apple-darwin -O3 -relocation-model=pic -arm-atomic-cfg-tidy=0 | FileCheck %s
2; rdar://8115404
3; Tail merging must not split an IT block.
4
5%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 }
6%struct._RuneCharClass = type { [14 x i8], i32 }
7%struct._RuneEntry = type { i32, i32, i32, i32* }
8%struct._RuneLocale = type { [8 x i8], [32 x i8], i32 (i8*, i32, i8**)*, i32 (i32, i8*, i32, i8**)*, i32, [256 x i32], [256 x i32], [256 x i32], %struct._RuneRange, %struct._RuneRange, %struct._RuneRange, i8*, i32, i32, %struct._RuneCharClass* }
9%struct._RuneRange = type { i32, %struct._RuneEntry* }
10%struct.__sFILEX = type opaque
11%struct.__sbuf = type { i8*, i32 }
12
13@finput = external global %struct.FILE*           ; <%struct.FILE**> [#uses=1]
14@_DefaultRuneLocale = external global %struct._RuneLocale ; <%struct._RuneLocale*> [#uses=0]
15@token_buffer = external global [1025 x i8], align 4 ; <[1025 x i8]*> [#uses=1]
16@.str73 = external constant [6 x i8], align 4     ; <[6 x i8]*> [#uses=0]
17@.str174 = external constant [5 x i8], align 4    ; <[5 x i8]*> [#uses=0]
18@.str275 = external constant [6 x i8], align 4    ; <[6 x i8]*> [#uses=0]
19@.str376 = external constant [5 x i8], align 4    ; <[5 x i8]*> [#uses=0]
20@.str477 = external constant [6 x i8], align 4    ; <[6 x i8]*> [#uses=0]
21@.str578 = external constant [6 x i8], align 4    ; <[6 x i8]*> [#uses=0]
22@.str679 = external constant [7 x i8], align 4    ; <[7 x i8]*> [#uses=0]
23@.str780 = external constant [6 x i8], align 4    ; <[6 x i8]*> [#uses=0]
24@.str881 = external constant [5 x i8], align 4    ; <[5 x i8]*> [#uses=0]
25@.str982 = external constant [6 x i8], align 4    ; <[6 x i8]*> [#uses=0]
26@.str1083 = external constant [9 x i8], align 4   ; <[9 x i8]*> [#uses=0]
27@.str1184 = external constant [7 x i8], align 4   ; <[7 x i8]*> [#uses=0]
28@.str1285 = external constant [16 x i8], align 4  ; <[16 x i8]*> [#uses=0]
29@.str1386 = external constant [12 x i8], align 4  ; <[12 x i8]*> [#uses=0]
30@.str1487 = external constant [5 x i8], align 4   ; <[5 x i8]*> [#uses=0]
31@llvm.used = external global [1 x i8*]            ; <[1 x i8*]*> [#uses=0]
32
33define fastcc i32 @parse_percent_token() nounwind {
34entry:
35; CHECK: pop
36; CHECK: pop
37; CHECK: pop
38; CHECK: pop
39; CHECK: pop
40; CHECK: pop
41; CHECK: pop
42; Do not convert into single stream code. BranchProbability Analysis assumes
43; that branches which goes to "ret" instruction have lower probabilities.
44  switch i32 undef, label %bb7 [
45    i32 37, label %bb43
46    i32 48, label %bb5
47    i32 50, label %bb4
48    i32 60, label %bb2
49    i32 61, label %bb6
50    i32 62, label %bb3
51    i32 123, label %bb1
52  ]
53
54bb1:                                              ; preds = %entry
55  ret i32 8
56
57bb2:                                              ; preds = %entry
58  ret i32 15
59
60bb3:                                              ; preds = %entry
61  ret i32 16
62
63bb4:                                              ; preds = %entry
64  ret i32 17
65
66bb5:                                              ; preds = %entry
67  ret i32 9
68
69bb6:                                              ; preds = %entry
70  ret i32 18
71
72bb7:                                              ; preds = %entry
73  br i1 undef, label %bb.i.i, label %bb1.i.i
74
75bb.i.i:                                           ; preds = %bb7
76  br i1 undef, label %bb43, label %bb12
77
78bb1.i.i:                                          ; preds = %bb7
79  unreachable
80
81bb9:                                              ; preds = %bb.i.i2
82  br i1 undef, label %bb10, label %bb11
83
84bb10:                                             ; preds = %bb9
85  br label %bb11
86
87bb11:                                             ; preds = %bb10, %bb9
88  %p.0 = phi i8* [ undef, %bb10 ], [ %p.1, %bb9 ] ; <i8*> [#uses=1]
89  %0 = load %struct.FILE** @finput, align 4       ; <%struct.FILE*> [#uses=1]
90  %1 = tail call i32 @getc(%struct.FILE* %0) nounwind ; <i32> [#uses=0]
91  br label %bb12
92
93bb12:                                             ; preds = %bb11, %bb.i.i
94  %p.1 = phi i8* [ %p.0, %bb11 ], [ getelementptr inbounds ([1025 x i8]* @token_buffer, i32 0, i32 0), %bb.i.i ] ; <i8*> [#uses=2]
95  %2 = icmp ult i32 undef, 128                    ; <i1> [#uses=1]
96  br i1 %2, label %bb.i.i2, label %bb1.i.i3
97
98bb.i.i2:                                          ; preds = %bb12
99  %3 = load i32* null, align 4                    ; <i32> [#uses=1]
100  %4 = lshr i32 %3, 8                             ; <i32> [#uses=1]
101  %.lobit.i1 = and i32 %4, 1                      ; <i32> [#uses=1]
102  %.not = icmp ne i32 %.lobit.i1, 0               ; <i1> [#uses=1]
103  %or.cond = or i1 %.not, undef                   ; <i1> [#uses=1]
104  br i1 %or.cond, label %bb9, label %bb14
105
106bb1.i.i3:                                         ; preds = %bb12
107  unreachable
108
109bb14:                                             ; preds = %bb.i.i2
110  store i8 0, i8* %p.1, align 1
111  br i1 undef, label %bb43, label %bb15
112
113bb15:                                             ; preds = %bb14
114  unreachable
115
116bb43:                                             ; preds = %bb14, %bb.i.i, %entry
117  %.0 = phi i32 [ 7, %entry ], [ 24, %bb.i.i ], [ 9, %bb14 ] ; <i32> [#uses=1]
118  ret i32 %.0
119}
120
121declare i32 @getc(%struct.FILE* nocapture) nounwind
122
123declare i32 @strcmp(i8* nocapture, i8* nocapture) nounwind readonly
124
125declare i32 @__maskrune(i32, i32)
126
127declare i32 @ungetc(i32, %struct.FILE* nocapture) nounwind
128