bypass-slow-division-tune.ll
7.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; Check that a division is bypassed when appropriate only.
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=atom < %s | FileCheck -check-prefixes=CHECK,ATOM %s
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=silvermont < %s | FileCheck -check-prefixes=CHECK,REST,SLM %s
; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=CHECK,REST,SKL %s
; RUN: llc -profile-summary-huge-working-set-size-threshold=1 -mtriple=x86_64-unknown-linux-gnu -mcpu=skylake < %s | FileCheck -check-prefixes=HUGEWS %s
; Verify that div32 is bypassed only for Atoms.
define i32 @div32(i32 %a, i32 %b) {
; ATOM-LABEL: div32:
; ATOM: # %bb.0: # %entry
; ATOM-NEXT: movl %edi, %eax
; ATOM-NEXT: orl %esi, %eax
; ATOM-NEXT: testl $-256, %eax
; ATOM-NEXT: je .LBB0_1
; ATOM-NEXT: # %bb.2:
; ATOM-NEXT: movl %edi, %eax
; ATOM-NEXT: cltd
; ATOM-NEXT: idivl %esi
; ATOM-NEXT: retq
; ATOM-NEXT: .LBB0_1:
; ATOM-NEXT: movzbl %dil, %eax
; ATOM-NEXT: divb %sil
; ATOM-NEXT: movzbl %al, %eax
; ATOM-NEXT: retq
;
; REST-LABEL: div32:
; REST: # %bb.0: # %entry
; REST-NEXT: movl %edi, %eax
; REST-NEXT: cltd
; REST-NEXT: idivl %esi
; REST-NEXT: retq
;
; HUGEWS-LABEL: div32:
; HUGEWS: # %bb.0: # %entry
; HUGEWS-NEXT: movl %edi, %eax
; HUGEWS-NEXT: cltd
; HUGEWS-NEXT: idivl %esi
; HUGEWS-NEXT: retq
entry:
%div = sdiv i32 %a, %b
ret i32 %div
}
; Verify that div64 is always bypassed.
define i64 @div64(i64 %a, i64 %b) {
; ATOM-LABEL: div64:
; ATOM: # %bb.0: # %entry
; ATOM-NEXT: movq %rdi, %rcx
; ATOM-NEXT: movq %rdi, %rax
; ATOM-NEXT: orq %rsi, %rcx
; ATOM-NEXT: shrq $32, %rcx
; ATOM-NEXT: je .LBB1_1
; ATOM-NEXT: # %bb.2:
; ATOM-NEXT: cqto
; ATOM-NEXT: idivq %rsi
; ATOM-NEXT: retq
; ATOM-NEXT: .LBB1_1:
; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
; ATOM-NEXT: xorl %edx, %edx
; ATOM-NEXT: divl %esi
; ATOM-NEXT: # kill: def $eax killed $eax def $rax
; ATOM-NEXT: retq
;
; SLM-LABEL: div64:
; SLM: # %bb.0: # %entry
; SLM-NEXT: movq %rdi, %rcx
; SLM-NEXT: movq %rdi, %rax
; SLM-NEXT: orq %rsi, %rcx
; SLM-NEXT: shrq $32, %rcx
; SLM-NEXT: je .LBB1_1
; SLM-NEXT: # %bb.2:
; SLM-NEXT: cqto
; SLM-NEXT: idivq %rsi
; SLM-NEXT: retq
; SLM-NEXT: .LBB1_1:
; SLM-NEXT: xorl %edx, %edx
; SLM-NEXT: # kill: def $eax killed $eax killed $rax
; SLM-NEXT: divl %esi
; SLM-NEXT: # kill: def $eax killed $eax def $rax
; SLM-NEXT: retq
;
; SKL-LABEL: div64:
; SKL: # %bb.0: # %entry
; SKL-NEXT: movq %rdi, %rax
; SKL-NEXT: movq %rdi, %rcx
; SKL-NEXT: orq %rsi, %rcx
; SKL-NEXT: shrq $32, %rcx
; SKL-NEXT: je .LBB1_1
; SKL-NEXT: # %bb.2:
; SKL-NEXT: cqto
; SKL-NEXT: idivq %rsi
; SKL-NEXT: retq
; SKL-NEXT: .LBB1_1:
; SKL-NEXT: # kill: def $eax killed $eax killed $rax
; SKL-NEXT: xorl %edx, %edx
; SKL-NEXT: divl %esi
; SKL-NEXT: # kill: def $eax killed $eax def $rax
; SKL-NEXT: retq
;
; HUGEWS-LABEL: div64:
; HUGEWS: # %bb.0: # %entry
; HUGEWS-NEXT: movq %rdi, %rax
; HUGEWS-NEXT: cqto
; HUGEWS-NEXT: idivq %rsi
; HUGEWS-NEXT: retq
entry:
%div = sdiv i64 %a, %b
ret i64 %div
}
; Verify that no extra code is generated when optimizing for size.
define i64 @div64_optsize(i64 %a, i64 %b) optsize {
; CHECK-LABEL: div64_optsize:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdi, %rax
; CHECK-NEXT: cqto
; CHECK-NEXT: idivq %rsi
; CHECK-NEXT: retq
;
; HUGEWS-LABEL: div64_optsize:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movq %rdi, %rax
; HUGEWS-NEXT: cqto
; HUGEWS-NEXT: idivq %rsi
; HUGEWS-NEXT: retq
%div = sdiv i64 %a, %b
ret i64 %div
}
define i64 @div64_pgso(i64 %a, i64 %b) !prof !15 {
; CHECK-LABEL: div64_pgso:
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdi, %rax
; CHECK-NEXT: cqto
; CHECK-NEXT: idivq %rsi
; CHECK-NEXT: retq
;
; HUGEWS-LABEL: div64_pgso:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movq %rdi, %rax
; HUGEWS-NEXT: cqto
; HUGEWS-NEXT: idivq %rsi
; HUGEWS-NEXT: retq
%div = sdiv i64 %a, %b
ret i64 %div
}
define i64 @div64_hugews(i64 %a, i64 %b) {
; ATOM-LABEL: div64_hugews:
; ATOM: # %bb.0:
; ATOM-NEXT: movq %rdi, %rcx
; ATOM-NEXT: movq %rdi, %rax
; ATOM-NEXT: orq %rsi, %rcx
; ATOM-NEXT: shrq $32, %rcx
; ATOM-NEXT: je .LBB4_1
; ATOM-NEXT: # %bb.2:
; ATOM-NEXT: cqto
; ATOM-NEXT: idivq %rsi
; ATOM-NEXT: retq
; ATOM-NEXT: .LBB4_1:
; ATOM-NEXT: # kill: def $eax killed $eax killed $rax
; ATOM-NEXT: xorl %edx, %edx
; ATOM-NEXT: divl %esi
; ATOM-NEXT: # kill: def $eax killed $eax def $rax
; ATOM-NEXT: retq
;
; SLM-LABEL: div64_hugews:
; SLM: # %bb.0:
; SLM-NEXT: movq %rdi, %rcx
; SLM-NEXT: movq %rdi, %rax
; SLM-NEXT: orq %rsi, %rcx
; SLM-NEXT: shrq $32, %rcx
; SLM-NEXT: je .LBB4_1
; SLM-NEXT: # %bb.2:
; SLM-NEXT: cqto
; SLM-NEXT: idivq %rsi
; SLM-NEXT: retq
; SLM-NEXT: .LBB4_1:
; SLM-NEXT: xorl %edx, %edx
; SLM-NEXT: # kill: def $eax killed $eax killed $rax
; SLM-NEXT: divl %esi
; SLM-NEXT: # kill: def $eax killed $eax def $rax
; SLM-NEXT: retq
;
; SKL-LABEL: div64_hugews:
; SKL: # %bb.0:
; SKL-NEXT: movq %rdi, %rax
; SKL-NEXT: movq %rdi, %rcx
; SKL-NEXT: orq %rsi, %rcx
; SKL-NEXT: shrq $32, %rcx
; SKL-NEXT: je .LBB4_1
; SKL-NEXT: # %bb.2:
; SKL-NEXT: cqto
; SKL-NEXT: idivq %rsi
; SKL-NEXT: retq
; SKL-NEXT: .LBB4_1:
; SKL-NEXT: # kill: def $eax killed $eax killed $rax
; SKL-NEXT: xorl %edx, %edx
; SKL-NEXT: divl %esi
; SKL-NEXT: # kill: def $eax killed $eax def $rax
; SKL-NEXT: retq
;
; HUGEWS-LABEL: div64_hugews:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movq %rdi, %rax
; HUGEWS-NEXT: cqto
; HUGEWS-NEXT: idivq %rsi
; HUGEWS-NEXT: retq
%div = sdiv i64 %a, %b
ret i64 %div
}
define i32 @div32_optsize(i32 %a, i32 %b) optsize {
; CHECK-LABEL: div32_optsize:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: cltd
; CHECK-NEXT: idivl %esi
; CHECK-NEXT: retq
;
; HUGEWS-LABEL: div32_optsize:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movl %edi, %eax
; HUGEWS-NEXT: cltd
; HUGEWS-NEXT: idivl %esi
; HUGEWS-NEXT: retq
%div = sdiv i32 %a, %b
ret i32 %div
}
define i32 @div32_pgso(i32 %a, i32 %b) !prof !15 {
; CHECK-LABEL: div32_pgso:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: cltd
; CHECK-NEXT: idivl %esi
; CHECK-NEXT: retq
;
; HUGEWS-LABEL: div32_pgso:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movl %edi, %eax
; HUGEWS-NEXT: cltd
; HUGEWS-NEXT: idivl %esi
; HUGEWS-NEXT: retq
%div = sdiv i32 %a, %b
ret i32 %div
}
define i32 @div32_minsize(i32 %a, i32 %b) minsize {
; CHECK-LABEL: div32_minsize:
; CHECK: # %bb.0:
; CHECK-NEXT: movl %edi, %eax
; CHECK-NEXT: cltd
; CHECK-NEXT: idivl %esi
; CHECK-NEXT: retq
;
; HUGEWS-LABEL: div32_minsize:
; HUGEWS: # %bb.0:
; HUGEWS-NEXT: movl %edi, %eax
; HUGEWS-NEXT: cltd
; HUGEWS-NEXT: idivl %esi
; HUGEWS-NEXT: retq
%div = sdiv i32 %a, %b
ret i32 %div
}
!llvm.module.flags = !{!1}
!1 = !{i32 1, !"ProfileSummary", !2}
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
!3 = !{!"ProfileFormat", !"InstrProf"}
!4 = !{!"TotalCount", i64 10000}
!5 = !{!"MaxCount", i64 1000}
!6 = !{!"MaxInternalCount", i64 1}
!7 = !{!"MaxFunctionCount", i64 1000}
!8 = !{!"NumCounts", i64 3}
!9 = !{!"NumFunctions", i64 3}
!10 = !{!"DetailedSummary", !11}
!11 = !{!12, !13, !14}
!12 = !{i32 10000, i64 1000, i32 1}
!13 = !{i32 999000, i64 1000, i32 3}
!14 = !{i32 999999, i64 5, i32 3}
!15 = !{!"function_entry_count", i64 0}