1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39440.
3 ; RUN: llc %s -O2 -mtriple=i386-unknown-linux-gnu -o - -verify-machineinstrs=0 | FileCheck %s
4 @.str = external dso_local unnamed_addr constant [6 x i8], align 1
5 @a = external dso_local local_unnamed_addr global i32, align 4
6 @h = external dso_local local_unnamed_addr global i32, align 4
7 @g = external dso_local local_unnamed_addr global i8, align 1
9 define dso_local void @fn() {
11 ; CHECK: # %bb.0: # %entry
12 ; CHECK-NEXT: pushl %ebp
13 ; CHECK-NEXT: .cfi_def_cfa_offset 8
14 ; CHECK-NEXT: pushl %ebx
15 ; CHECK-NEXT: .cfi_def_cfa_offset 12
16 ; CHECK-NEXT: pushl %edi
17 ; CHECK-NEXT: .cfi_def_cfa_offset 16
18 ; CHECK-NEXT: pushl %esi
19 ; CHECK-NEXT: .cfi_def_cfa_offset 20
20 ; CHECK-NEXT: subl $28, %esp
21 ; CHECK-NEXT: .cfi_def_cfa_offset 48
22 ; CHECK-NEXT: .cfi_offset %esi, -20
23 ; CHECK-NEXT: .cfi_offset %edi, -16
24 ; CHECK-NEXT: .cfi_offset %ebx, -12
25 ; CHECK-NEXT: .cfi_offset %ebp, -8
26 ; CHECK-NEXT: xorl %ebx, %ebx
27 ; CHECK-NEXT: # implicit-def: $ecx
28 ; CHECK-NEXT: # implicit-def: $edi
29 ; CHECK-NEXT: # implicit-def: $al
30 ; CHECK-NEXT: # kill: killed $al
31 ; CHECK-NEXT: # implicit-def: $dl
32 ; CHECK-NEXT: # implicit-def: $ebp
33 ; CHECK-NEXT: jmp .LBB0_1
34 ; CHECK-NEXT: .p2align 4, 0x90
35 ; CHECK-NEXT: .LBB0_16: # %for.inc
36 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
37 ; CHECK-NEXT: movb %dl, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
38 ; CHECK-NEXT: movb %dh, %dl
39 ; CHECK-NEXT: .LBB0_1: # %for.cond
40 ; CHECK-NEXT: # =>This Loop Header: Depth=1
41 ; CHECK-NEXT: # Child Loop BB0_20 Depth 2
42 ; CHECK-NEXT: cmpb $8, %dl
43 ; CHECK-NEXT: movb %dl, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
44 ; CHECK-NEXT: ja .LBB0_3
45 ; CHECK-NEXT: # %bb.2: # %for.cond
46 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
47 ; CHECK-NEXT: testb %bl, %bl
48 ; CHECK-NEXT: je .LBB0_3
49 ; CHECK-NEXT: # %bb.4: # %if.end
50 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
51 ; CHECK-NEXT: movl %ecx, %eax
54 ; CHECK-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %dl # 1-byte Reload
55 ; CHECK-NEXT: movb %cl, %dh
56 ; CHECK-NEXT: movl $0, h
57 ; CHECK-NEXT: cmpb $8, %dl
58 ; CHECK-NEXT: jg .LBB0_8
59 ; CHECK-NEXT: # %bb.5: # %if.then13
60 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
61 ; CHECK-NEXT: movl %eax, %esi
62 ; CHECK-NEXT: movl $.str, (%esp)
63 ; CHECK-NEXT: movb %dh, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
64 ; CHECK-NEXT: calll printf
65 ; CHECK-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %dh # 1-byte Reload
66 ; CHECK-NEXT: testb %bl, %bl
67 ; CHECK-NEXT: movl %esi, %ecx
68 ; CHECK-NEXT: # implicit-def: $eax
69 ; CHECK-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %dl # 1-byte Reload
70 ; CHECK-NEXT: movb %dl, {{[-0-9]+}}(%e{{[sb]}}p) # 1-byte Spill
71 ; CHECK-NEXT: movb %dh, %dl
72 ; CHECK-NEXT: jne .LBB0_16
73 ; CHECK-NEXT: .p2align 4, 0x90
74 ; CHECK-NEXT: # %bb.6: # %for.cond35
75 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
76 ; CHECK-NEXT: testl %edi, %edi
77 ; CHECK-NEXT: je .LBB0_7
78 ; CHECK-NEXT: .LBB0_11: # %af
79 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
80 ; CHECK-NEXT: testb %bl, %bl
81 ; CHECK-NEXT: jne .LBB0_12
82 ; CHECK-NEXT: .LBB0_17: # %if.end39
83 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
84 ; CHECK-NEXT: testl %eax, %eax
85 ; CHECK-NEXT: je .LBB0_19
86 ; CHECK-NEXT: # %bb.18: # %if.then41
87 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
88 ; CHECK-NEXT: movl $0, {{[0-9]+}}(%esp)
89 ; CHECK-NEXT: movl $fn, {{[0-9]+}}(%esp)
90 ; CHECK-NEXT: movl $.str, (%esp)
91 ; CHECK-NEXT: calll printf
92 ; CHECK-NEXT: .LBB0_19: # %for.end46
93 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
94 ; CHECK-NEXT: # implicit-def: $dl
95 ; CHECK-NEXT: # implicit-def: $dh
96 ; CHECK-NEXT: # implicit-def: $ebp
97 ; CHECK-NEXT: jmp .LBB0_20
98 ; CHECK-NEXT: .p2align 4, 0x90
99 ; CHECK-NEXT: .LBB0_3: # %if.then
100 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
101 ; CHECK-NEXT: movl $.str, (%esp)
102 ; CHECK-NEXT: calll printf
103 ; CHECK-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %dl # 1-byte Reload
104 ; CHECK-NEXT: # implicit-def: $eax
105 ; CHECK-NEXT: testl %edi, %edi
106 ; CHECK-NEXT: jne .LBB0_11
107 ; CHECK-NEXT: jmp .LBB0_7
108 ; CHECK-NEXT: .p2align 4, 0x90
109 ; CHECK-NEXT: .LBB0_8: # %if.end21
110 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
111 ; CHECK-NEXT: # implicit-def: $ebp
112 ; CHECK-NEXT: testb %bl, %bl
113 ; CHECK-NEXT: je .LBB0_13
114 ; CHECK-NEXT: jmp .LBB0_10
115 ; CHECK-NEXT: .p2align 4, 0x90
116 ; CHECK-NEXT: .LBB0_7: # in Loop: Header=BB0_1 Depth=1
117 ; CHECK-NEXT: xorl %edi, %edi
118 ; CHECK-NEXT: movb %dl, %dh
119 ; CHECK-NEXT: movb {{[-0-9]+}}(%e{{[sb]}}p), %dl # 1-byte Reload
120 ; CHECK-NEXT: .p2align 4, 0x90
121 ; CHECK-NEXT: .LBB0_20: # %for.cond47
122 ; CHECK-NEXT: # Parent Loop BB0_1 Depth=1
123 ; CHECK-NEXT: # => This Inner Loop Header: Depth=2
124 ; CHECK-NEXT: testb %bl, %bl
125 ; CHECK-NEXT: jne .LBB0_20
126 ; CHECK-NEXT: # %bb.21: # %for.cond47
127 ; CHECK-NEXT: # in Loop: Header=BB0_20 Depth=2
128 ; CHECK-NEXT: testb %bl, %bl
129 ; CHECK-NEXT: jne .LBB0_20
130 ; CHECK-NEXT: # %bb.9: # %ae
131 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
132 ; CHECK-NEXT: testb %bl, %bl
133 ; CHECK-NEXT: jne .LBB0_10
134 ; CHECK-NEXT: .LBB0_13: # %if.end26
135 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
136 ; CHECK-NEXT: xorl %ecx, %ecx
137 ; CHECK-NEXT: testb %dl, %dl
138 ; CHECK-NEXT: je .LBB0_16
139 ; CHECK-NEXT: # %bb.14: # %if.end26
140 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
141 ; CHECK-NEXT: testl %ebp, %ebp
142 ; CHECK-NEXT: jne .LBB0_16
143 ; CHECK-NEXT: # %bb.15: # %if.then31
144 ; CHECK-NEXT: # in Loop: Header=BB0_1 Depth=1
145 ; CHECK-NEXT: xorl %ecx, %ecx
146 ; CHECK-NEXT: xorl %ebp, %ebp
147 ; CHECK-NEXT: jmp .LBB0_16
148 ; CHECK-NEXT: .p2align 4, 0x90
149 ; CHECK-NEXT: .LBB0_10: # in Loop: Header=BB0_1 Depth=1
150 ; CHECK-NEXT: # implicit-def: $eax
151 ; CHECK-NEXT: testb %bl, %bl
152 ; CHECK-NEXT: je .LBB0_17
153 ; CHECK-NEXT: .LBB0_12: # in Loop: Header=BB0_1 Depth=1
154 ; CHECK-NEXT: # implicit-def: $edi
155 ; CHECK-NEXT: # implicit-def: $cl
156 ; CHECK-NEXT: # kill: killed $cl
157 ; CHECK-NEXT: # implicit-def: $dl
158 ; CHECK-NEXT: # implicit-def: $ebp
159 ; CHECK-NEXT: testl %edi, %edi
160 ; CHECK-NEXT: jne .LBB0_11
161 ; CHECK-NEXT: jmp .LBB0_7
165 for.cond: ; preds = %for.inc, %entry
166 %l.0 = phi i16 [ undef, %entry ], [ 0, %for.inc ]
167 %m.0 = phi i32 [ undef, %entry ], [ %m.2, %for.inc ]
168 %i.0 = phi i32 [ undef, %entry ], [ %i.2, %for.inc ]
169 %p.0 = phi i8 [ undef, %entry ], [ %p.2, %for.inc ]
170 %k.0 = phi i8 [ undef, %entry ], [ %k.2, %for.inc ]
171 %q.0 = phi i32 [ undef, %entry ], [ %q.2, %for.inc ]
172 %cmp = icmp ugt i8 %k.0, 8
173 %or.cond61 = or i1 %cmp, undef
174 br i1 %or.cond61, label %if.then, label %if.end
176 if.then: ; preds = %for.cond
177 tail call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 undef)
180 if.end: ; preds = %for.cond
181 %0 = load i32, i32* @a, align 4
182 %div = sdiv i32 %m.0, %0
185 ac: ; preds = %ac, %if.end
186 br i1 undef, label %if.end9, label %ac
188 if.end9: ; preds = %ac
189 %conv3 = trunc i32 %m.0 to i8
190 %conv5 = sext i16 %l.0 to i32
191 store i32 %conv5, i32* @h, align 4
192 %cmp11 = icmp slt i8 %k.0, 9
193 br i1 %cmp11, label %if.then13, label %if.end21
195 if.then13: ; preds = %if.end9
196 tail call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 undef)
197 br i1 undef, label %for.inc, label %for.cond35
199 if.end21: ; preds = %if.end9
200 %1 = load i8, i8* @g, align 1
203 ae: ; preds = %for.cond47, %if.end21
204 %l.2 = phi i16 [ undef, %if.end21 ], [ 0, %for.cond47 ]
205 %i.1 = phi i32 [ %i.0, %if.end21 ], [ %i.5, %for.cond47 ]
206 %p.1 = phi i8 [ %k.0, %if.end21 ], [ %p.6, %for.cond47 ]
207 %k.1 = phi i8 [ %conv3, %if.end21 ], [ %k.6, %for.cond47 ]
208 %q.1 = phi i32 [ undef, %if.end21 ], [ %q.5, %for.cond47 ]
209 br i1 undef, label %if.end26, label %af
211 if.end26: ; preds = %ae
212 %tobool27 = icmp eq i32 %q.1, 0
213 %tobool30 = icmp ne i8 %p.1, 0
214 %or.cond = and i1 %tobool30, %tobool27
215 br i1 %or.cond, label %if.then31, label %for.inc
217 if.then31: ; preds = %if.end26
220 for.inc: ; preds = %if.then31, %if.end26, %if.then13
221 %m.2 = phi i32 [ 0, %if.then31 ], [ 0, %if.end26 ], [ %div, %if.then13 ]
222 %i.2 = phi i32 [ %i.1, %if.then31 ], [ %i.1, %if.end26 ], [ %i.0, %if.then13 ]
223 %p.2 = phi i8 [ %p.1, %if.then31 ], [ %p.1, %if.end26 ], [ undef, %if.then13 ]
224 %k.2 = phi i8 [ %k.1, %if.then31 ], [ %k.1, %if.end26 ], [ %conv3, %if.then13 ]
225 %q.2 = phi i32 [ 0, %if.then31 ], [ %q.1, %if.end26 ], [ %q.0, %if.then13 ]
226 %2 = load i32, i32* @h, align 4
229 for.cond35: ; preds = %for.inc44, %if.then13, %if.then
230 %i.3 = phi i32 [ undef, %for.inc44 ], [ %i.0, %if.then ], [ %i.0, %if.then13 ]
231 %o.2 = phi i32 [ %o.3, %for.inc44 ], [ undef, %if.then ], [ undef, %if.then13 ]
232 %p.4 = phi i8 [ undef, %for.inc44 ], [ %p.0, %if.then ], [ %k.0, %if.then13 ]
233 %k.4 = phi i8 [ undef, %for.inc44 ], [ %k.0, %if.then ], [ %conv3, %if.then13 ]
234 %q.3 = phi i32 [ undef, %for.inc44 ], [ %q.0, %if.then ], [ %q.0, %if.then13 ]
235 %tobool36 = icmp eq i32 %i.3, 0
236 br i1 %tobool36, label %for.end46, label %af
238 af: ; preds = %for.cond35, %ae
239 %i.4 = phi i32 [ %i.3, %for.cond35 ], [ %i.1, %ae ]
240 %o.3 = phi i32 [ %o.2, %for.cond35 ], [ undef, %ae ]
241 br i1 undef, label %if.end39, label %for.inc44
243 if.end39: ; preds = %af
244 %tobool40 = icmp eq i32 %o.3, 0
245 br i1 %tobool40, label %for.end46, label %if.then41
247 if.then41: ; preds = %if.end39
248 tail call void (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i32 0, i32 0), i64 ptrtoint (void ()* @fn to i64))
251 for.inc44: ; preds = %af
254 for.end46: ; preds = %if.then41, %if.end39, %for.cond35
255 %i.5 = phi i32 [ %i.4, %if.then41 ], [ %i.4, %if.end39 ], [ 0, %for.cond35 ]
256 %p.6 = phi i8 [ undef, %if.then41 ], [ undef, %if.end39 ], [ %p.4, %for.cond35 ]
257 %k.6 = phi i8 [ undef, %if.then41 ], [ undef, %if.end39 ], [ %k.4, %for.cond35 ]
258 %q.5 = phi i32 [ undef, %if.then41 ], [ undef, %if.end39 ], [ %q.3, %for.cond35 ]
261 for.cond47: ; preds = %for.cond47, %for.end46
262 %brmerge = or i1 false, undef
263 br i1 %brmerge, label %for.cond47, label %ae
266 declare dso_local void @printf(i8* nocapture readonly, ...) local_unnamed_addr