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=silvermont < %s | FileCheck -check-prefixes=CHECK,REST,SLM %s
5 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=CHECK,REST,SKL %s
6 ; RUN: llc -profile-summary-huge-working-set-size-threshold=1 -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=HUGEWS %s
8 ; Verify that div32 is bypassed only for Atoms.
9 define i32 @div32(i32 %a, i32 %b) {
11 ; ATOM: # %bb.0: # %entry
12 ; ATOM-NEXT: movl %edi, %eax
13 ; ATOM-NEXT: orl %esi, %eax
14 ; ATOM-NEXT: testl $-256, %eax
15 ; ATOM-NEXT: je .LBB0_1
17 ; ATOM-NEXT: movl %edi, %eax
19 ; ATOM-NEXT: idivl %esi
22 ; ATOM-NEXT: movzbl %dil, %eax
23 ; ATOM-NEXT: divb %sil
24 ; ATOM-NEXT: movzbl %al, %eax
28 ; REST: # %bb.0: # %entry
29 ; REST-NEXT: movl %edi, %eax
31 ; REST-NEXT: idivl %esi
34 ; HUGEWS-LABEL: div32:
35 ; HUGEWS: # %bb.0: # %entry
36 ; HUGEWS-NEXT: movl %edi, %eax
38 ; HUGEWS-NEXT: idivl %esi
41 %div = sdiv i32 %a, %b
45 ; Verify that div64 is always bypassed.
46 define i64 @div64(i64 %a, i64 %b) {
48 ; ATOM: # %bb.0: # %entry
49 ; ATOM-NEXT: movq %rdi, %rcx
50 ; ATOM-NEXT: movq %rdi, %rax
51 ; ATOM-NEXT: orq %rsi, %rcx
52 ; ATOM-NEXT: shrq $32, %rcx
53 ; ATOM-NEXT: je .LBB1_1
56 ; ATOM-NEXT: idivq %rsi
59 ; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
60 ; ATOM-NEXT: xorl %edx, %edx
61 ; ATOM-NEXT: divl %esi
62 ; ATOM-NEXT: # kill: def $eax killed $eax def $rax
66 ; SLM: # %bb.0: # %entry
67 ; SLM-NEXT: movq %rdi, %rcx
68 ; SLM-NEXT: movq %rdi, %rax
69 ; SLM-NEXT: orq %rsi, %rcx
70 ; SLM-NEXT: shrq $32, %rcx
71 ; SLM-NEXT: je .LBB1_1
74 ; SLM-NEXT: idivq %rsi
77 ; SLM-NEXT: xorl %edx, %edx
78 ; SLM-NEXT: # kill: def $eax killed $eax killed $rax
80 ; SLM-NEXT: # kill: def $eax killed $eax def $rax
84 ; SKL: # %bb.0: # %entry
85 ; SKL-NEXT: movq %rdi, %rax
86 ; SKL-NEXT: movq %rdi, %rcx
87 ; SKL-NEXT: orq %rsi, %rcx
88 ; SKL-NEXT: shrq $32, %rcx
89 ; SKL-NEXT: je .LBB1_1
92 ; SKL-NEXT: idivq %rsi
95 ; SKL-NEXT: # kill: def $eax killed $eax killed $rax
96 ; SKL-NEXT: xorl %edx, %edx
98 ; SKL-NEXT: # kill: def $eax killed $eax def $rax
101 ; HUGEWS-LABEL: div64:
102 ; HUGEWS: # %bb.0: # %entry
103 ; HUGEWS-NEXT: movq %rdi, %rax
105 ; HUGEWS-NEXT: idivq %rsi
108 %div = sdiv i64 %a, %b
113 ; Verify that no extra code is generated when optimizing for size.
115 define i64 @div64_optsize(i64 %a, i64 %b) optsize {
116 ; CHECK-LABEL: div64_optsize:
118 ; CHECK-NEXT: movq %rdi, %rax
120 ; CHECK-NEXT: idivq %rsi
123 ; HUGEWS-LABEL: div64_optsize:
125 ; HUGEWS-NEXT: movq %rdi, %rax
127 ; HUGEWS-NEXT: idivq %rsi
129 %div = sdiv i64 %a, %b
133 define i64 @div64_hugews(i64 %a, i64 %b) {
134 ; ATOM-LABEL: div64_hugews:
136 ; ATOM-NEXT: movq %rdi, %rcx
137 ; ATOM-NEXT: movq %rdi, %rax
138 ; ATOM-NEXT: orq %rsi, %rcx
139 ; ATOM-NEXT: shrq $32, %rcx
140 ; ATOM-NEXT: je .LBB3_1
141 ; ATOM-NEXT: # %bb.2:
143 ; ATOM-NEXT: idivq %rsi
145 ; ATOM-NEXT: .LBB3_1:
146 ; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
147 ; ATOM-NEXT: xorl %edx, %edx
148 ; ATOM-NEXT: divl %esi
149 ; ATOM-NEXT: # kill: def $eax killed $eax def $rax
152 ; SLM-LABEL: div64_hugews:
154 ; SLM-NEXT: movq %rdi, %rcx
155 ; SLM-NEXT: movq %rdi, %rax
156 ; SLM-NEXT: orq %rsi, %rcx
157 ; SLM-NEXT: shrq $32, %rcx
158 ; SLM-NEXT: je .LBB3_1
161 ; SLM-NEXT: idivq %rsi
164 ; SLM-NEXT: xorl %edx, %edx
165 ; SLM-NEXT: # kill: def $eax killed $eax killed $rax
166 ; SLM-NEXT: divl %esi
167 ; SLM-NEXT: # kill: def $eax killed $eax def $rax
170 ; SKL-LABEL: div64_hugews:
172 ; SKL-NEXT: movq %rdi, %rax
173 ; SKL-NEXT: movq %rdi, %rcx
174 ; SKL-NEXT: orq %rsi, %rcx
175 ; SKL-NEXT: shrq $32, %rcx
176 ; SKL-NEXT: je .LBB3_1
179 ; SKL-NEXT: idivq %rsi
182 ; SKL-NEXT: # kill: def $eax killed $eax killed $rax
183 ; SKL-NEXT: xorl %edx, %edx
184 ; SKL-NEXT: divl %esi
185 ; SKL-NEXT: # kill: def $eax killed $eax def $rax
188 ; HUGEWS-LABEL: div64_hugews:
190 ; HUGEWS-NEXT: movq %rdi, %rax
192 ; HUGEWS-NEXT: idivq %rsi
194 %div = sdiv i64 %a, %b
198 define i32 @div32_optsize(i32 %a, i32 %b) optsize {
199 ; CHECK-LABEL: div32_optsize:
201 ; CHECK-NEXT: movl %edi, %eax
203 ; CHECK-NEXT: idivl %esi
206 ; HUGEWS-LABEL: div32_optsize:
208 ; HUGEWS-NEXT: movl %edi, %eax
210 ; HUGEWS-NEXT: idivl %esi
212 %div = sdiv i32 %a, %b
216 define i32 @div32_minsize(i32 %a, i32 %b) minsize {
217 ; CHECK-LABEL: div32_minsize:
219 ; CHECK-NEXT: movl %edi, %eax
221 ; CHECK-NEXT: idivl %esi
224 ; HUGEWS-LABEL: div32_minsize:
226 ; HUGEWS-NEXT: movl %edi, %eax
228 ; HUGEWS-NEXT: idivl %esi
230 %div = sdiv i32 %a, %b
234 !llvm.module.flags = !{!1}
235 !1 = !{i32 1, !"ProfileSummary", !2}
236 !2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
237 !3 = !{!"ProfileFormat", !"InstrProf"}
238 !4 = !{!"TotalCount", i64 10000}
239 !5 = !{!"MaxCount", i64 1000}
240 !6 = !{!"MaxInternalCount", i64 1}
241 !7 = !{!"MaxFunctionCount", i64 1000}
242 !8 = !{!"NumCounts", i64 3}
243 !9 = !{!"NumFunctions", i64 3}
244 !10 = !{!"DetailedSummary", !11}
245 !11 = !{!12, !13, !14}
246 !12 = !{i32 10000, i64 1000, i32 1}
247 !13 = !{i32 999000, i64 1000, i32 3}
248 !14 = !{i32 999999, i64 5, i32 3}