1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Check that a division is bypassed when appropriate only.
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=atom < %s | FileCheck -check-prefixes=CHECK,ATOM %s
4 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=x86-64 < %s | FileCheck -check-prefixes=CHECK,REST,X64 %s
5 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=silvermont < %s | FileCheck -check-prefixes=CHECK,REST,SLM %s
6 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=CHECK,REST,SKL %s
7 ; RUN: llc -profile-summary-huge-working-set-size-threshold=1 -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=HUGEWS %s
9 ; Verify that div32 is bypassed only for Atoms.
10 define i32 @div32(i32 %a, i32 %b) {
12 ; ATOM: # %bb.0: # %entry
13 ; ATOM-NEXT: movl %edi, %eax
14 ; ATOM-NEXT: orl %esi, %eax
15 ; ATOM-NEXT: testl $-256, %eax
16 ; ATOM-NEXT: je .LBB0_1
18 ; ATOM-NEXT: movl %edi, %eax
20 ; ATOM-NEXT: idivl %esi
23 ; ATOM-NEXT: movzbl %dil, %eax
24 ; ATOM-NEXT: divb %sil
25 ; ATOM-NEXT: movzbl %al, %eax
29 ; REST: # %bb.0: # %entry
30 ; REST-NEXT: movl %edi, %eax
32 ; REST-NEXT: idivl %esi
35 ; HUGEWS-LABEL: div32:
36 ; HUGEWS: # %bb.0: # %entry
37 ; HUGEWS-NEXT: movl %edi, %eax
39 ; HUGEWS-NEXT: idivl %esi
42 %div = sdiv i32 %a, %b
46 ; Verify that div64 is always bypassed.
47 define i64 @div64(i64 %a, i64 %b) {
49 ; ATOM: # %bb.0: # %entry
50 ; ATOM-NEXT: movq %rdi, %rcx
51 ; ATOM-NEXT: movq %rdi, %rax
52 ; ATOM-NEXT: orq %rsi, %rcx
53 ; ATOM-NEXT: shrq $32, %rcx
54 ; ATOM-NEXT: je .LBB1_1
57 ; ATOM-NEXT: idivq %rsi
60 ; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
61 ; ATOM-NEXT: xorl %edx, %edx
62 ; ATOM-NEXT: divl %esi
63 ; ATOM-NEXT: # kill: def $eax killed $eax def $rax
67 ; X64: # %bb.0: # %entry
68 ; X64-NEXT: movq %rdi, %rax
69 ; X64-NEXT: movq %rdi, %rcx
70 ; X64-NEXT: orq %rsi, %rcx
71 ; X64-NEXT: shrq $32, %rcx
72 ; X64-NEXT: je .LBB1_1
75 ; X64-NEXT: idivq %rsi
78 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
79 ; X64-NEXT: xorl %edx, %edx
81 ; X64-NEXT: # kill: def $eax killed $eax def $rax
85 ; SLM: # %bb.0: # %entry
86 ; SLM-NEXT: movq %rdi, %rcx
87 ; SLM-NEXT: movq %rdi, %rax
88 ; SLM-NEXT: orq %rsi, %rcx
89 ; SLM-NEXT: shrq $32, %rcx
90 ; SLM-NEXT: je .LBB1_1
93 ; SLM-NEXT: idivq %rsi
96 ; SLM-NEXT: xorl %edx, %edx
97 ; SLM-NEXT: # kill: def $eax killed $eax killed $rax
99 ; SLM-NEXT: # kill: def $eax killed $eax def $rax
103 ; SKL: # %bb.0: # %entry
104 ; SKL-NEXT: movq %rdi, %rax
105 ; SKL-NEXT: movq %rdi, %rcx
106 ; SKL-NEXT: orq %rsi, %rcx
107 ; SKL-NEXT: shrq $32, %rcx
108 ; SKL-NEXT: je .LBB1_1
111 ; SKL-NEXT: idivq %rsi
114 ; SKL-NEXT: # kill: def $eax killed $eax killed $rax
115 ; SKL-NEXT: xorl %edx, %edx
116 ; SKL-NEXT: divl %esi
117 ; SKL-NEXT: # kill: def $eax killed $eax def $rax
120 ; HUGEWS-LABEL: div64:
121 ; HUGEWS: # %bb.0: # %entry
122 ; HUGEWS-NEXT: movq %rdi, %rax
124 ; HUGEWS-NEXT: idivq %rsi
127 %div = sdiv i64 %a, %b
132 ; Verify that no extra code is generated when optimizing for size.
134 define i64 @div64_optsize(i64 %a, i64 %b) optsize {
135 ; CHECK-LABEL: div64_optsize:
137 ; CHECK-NEXT: movq %rdi, %rax
139 ; CHECK-NEXT: idivq %rsi
142 ; HUGEWS-LABEL: div64_optsize:
144 ; HUGEWS-NEXT: movq %rdi, %rax
146 ; HUGEWS-NEXT: idivq %rsi
148 %div = sdiv i64 %a, %b
152 define i64 @div64_pgso(i64 %a, i64 %b) !prof !15 {
153 ; CHECK-LABEL: div64_pgso:
155 ; CHECK-NEXT: movq %rdi, %rax
157 ; CHECK-NEXT: idivq %rsi
160 ; HUGEWS-LABEL: div64_pgso:
162 ; HUGEWS-NEXT: movq %rdi, %rax
164 ; HUGEWS-NEXT: idivq %rsi
166 %div = sdiv i64 %a, %b
170 define i64 @div64_hugews(i64 %a, i64 %b) {
171 ; ATOM-LABEL: div64_hugews:
173 ; ATOM-NEXT: movq %rdi, %rcx
174 ; ATOM-NEXT: movq %rdi, %rax
175 ; ATOM-NEXT: orq %rsi, %rcx
176 ; ATOM-NEXT: shrq $32, %rcx
177 ; ATOM-NEXT: je .LBB4_1
178 ; ATOM-NEXT: # %bb.2:
180 ; ATOM-NEXT: idivq %rsi
182 ; ATOM-NEXT: .LBB4_1:
183 ; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
184 ; ATOM-NEXT: xorl %edx, %edx
185 ; ATOM-NEXT: divl %esi
186 ; ATOM-NEXT: # kill: def $eax killed $eax def $rax
189 ; X64-LABEL: div64_hugews:
191 ; X64-NEXT: movq %rdi, %rax
192 ; X64-NEXT: movq %rdi, %rcx
193 ; X64-NEXT: orq %rsi, %rcx
194 ; X64-NEXT: shrq $32, %rcx
195 ; X64-NEXT: je .LBB4_1
198 ; X64-NEXT: idivq %rsi
201 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
202 ; X64-NEXT: xorl %edx, %edx
203 ; X64-NEXT: divl %esi
204 ; X64-NEXT: # kill: def $eax killed $eax def $rax
207 ; SLM-LABEL: div64_hugews:
209 ; SLM-NEXT: movq %rdi, %rcx
210 ; SLM-NEXT: movq %rdi, %rax
211 ; SLM-NEXT: orq %rsi, %rcx
212 ; SLM-NEXT: shrq $32, %rcx
213 ; SLM-NEXT: je .LBB4_1
216 ; SLM-NEXT: idivq %rsi
219 ; SLM-NEXT: xorl %edx, %edx
220 ; SLM-NEXT: # kill: def $eax killed $eax killed $rax
221 ; SLM-NEXT: divl %esi
222 ; SLM-NEXT: # kill: def $eax killed $eax def $rax
225 ; SKL-LABEL: div64_hugews:
227 ; SKL-NEXT: movq %rdi, %rax
228 ; SKL-NEXT: movq %rdi, %rcx
229 ; SKL-NEXT: orq %rsi, %rcx
230 ; SKL-NEXT: shrq $32, %rcx
231 ; SKL-NEXT: je .LBB4_1
234 ; SKL-NEXT: idivq %rsi
237 ; SKL-NEXT: # kill: def $eax killed $eax killed $rax
238 ; SKL-NEXT: xorl %edx, %edx
239 ; SKL-NEXT: divl %esi
240 ; SKL-NEXT: # kill: def $eax killed $eax def $rax
243 ; HUGEWS-LABEL: div64_hugews:
245 ; HUGEWS-NEXT: movq %rdi, %rax
247 ; HUGEWS-NEXT: idivq %rsi
249 %div = sdiv i64 %a, %b
253 define i32 @div32_optsize(i32 %a, i32 %b) optsize {
254 ; CHECK-LABEL: div32_optsize:
256 ; CHECK-NEXT: movl %edi, %eax
258 ; CHECK-NEXT: idivl %esi
261 ; HUGEWS-LABEL: div32_optsize:
263 ; HUGEWS-NEXT: movl %edi, %eax
265 ; HUGEWS-NEXT: idivl %esi
267 %div = sdiv i32 %a, %b
271 define i32 @div32_pgso(i32 %a, i32 %b) !prof !15 {
272 ; CHECK-LABEL: div32_pgso:
274 ; CHECK-NEXT: movl %edi, %eax
276 ; CHECK-NEXT: idivl %esi
279 ; HUGEWS-LABEL: div32_pgso:
281 ; HUGEWS-NEXT: movl %edi, %eax
283 ; HUGEWS-NEXT: idivl %esi
285 %div = sdiv i32 %a, %b
289 define i32 @div32_minsize(i32 %a, i32 %b) minsize {
290 ; CHECK-LABEL: div32_minsize:
292 ; CHECK-NEXT: movl %edi, %eax
294 ; CHECK-NEXT: idivl %esi
297 ; HUGEWS-LABEL: div32_minsize:
299 ; HUGEWS-NEXT: movl %edi, %eax
301 ; HUGEWS-NEXT: idivl %esi
303 %div = sdiv i32 %a, %b
307 !llvm.module.flags = !{!1}
308 !1 = !{i32 1, !"ProfileSummary", !2}
309 !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
310 !3 = !{!"ProfileFormat", !"InstrProf"}
311 !4 = !{!"TotalCount", i64 10000}
312 !5 = !{!"MaxCount", i64 1000}
313 !6 = !{!"MaxInternalCount", i64 1}
314 !7 = !{!"MaxFunctionCount", i64 1000}
315 !8 = !{!"NumCounts", i64 3}
316 !9 = !{!"NumFunctions", i64 3}
317 !10 = !{!"DetailedSummary", !11}
318 !11 = !{!12, !13, !14}
319 !12 = !{i32 10000, i64 1000, i32 1}
320 !13 = !{i32 999000, i64 1000, i32 3}
321 !14 = !{i32 999999, i64 5, i32 3}
322 !15 = !{!"function_entry_count", i64 0}