1 # REQUIRES: system-linux
3 # RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
4 # RUN: link_fdata %s %t.o %t.fdata
5 # RUN: llvm-strip --strip-unneeded %t.o
6 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib
7 # RUN: llvm-bolt %t.exe --data %t.fdata -o %t --lite=0 -v=2 \
8 # RUN: --cmov-conversion --cmov-conversion-misprediction-threshold=-1 \
9 # RUN: --cmov-conversion-bias-threshold=-1 --print-all | FileCheck %s
10 # CHECK: BOLT-INFO: CMOVConversion: CmovInHotPath, converted static 1/1
11 # CHECK: BOLT-INFO: CMOVConversion: CmovNotInHotPath, converted static 1/1
12 # CHECK: BOLT-INFO: CMOVConversion: MaxIndex, converted static 1/1
13 # CHECK: BOLT-INFO: CMOVConversion: MaxIndex_unpredictable, converted static 1/1
14 # CHECK: BOLT-INFO: CMOVConversion: MaxValue, converted static 1/1
15 # CHECK: BOLT-INFO: CMOVConversion: BinarySearch, converted static 0/0
16 # CHECK: BOLT-INFO: CMOVConversion: Transform, converted static 0/0
17 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand, converted static 0/0
18 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_unpredictable, converted static 0/0
19 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_in_group, converted static 0/0
20 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_in_group2, converted static 0/0
21 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_conflicting_dir, converted static 0/0
22 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_in_group_reuse_for_addr, converted static 0/0
23 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_in_group_reuse_for_addr2, converted static 0/0
24 # CHECK: BOLT-INFO: CMOVConversion: test_cmov_memoperand_in_group_reuse_for_addr3, converted static 0/0
25 # CHECK: BOLT-INFO: CMOVConversion: test_memoperand_loop, converted static 1/1
26 # CHECK: BOLT-INFO: CMOVConversion: CmovBackToBack, converted static 2/2
27 # CHECK: BOLT-INFO: CMOVConversion total: converted static 8/8
31 .globl CmovInHotPath # -- Begin function CmovInHotPath
33 .type CmovInHotPath,@function
34 CmovInHotPath
: # @CmovInHotPath
35 # CHECK-LABEL: Binary Function "CmovInHotPath" after CMOV conversion
36 # FDATA: 0 [unknown] 0 1 CmovInHotPath 0 1 2
41 # %bb.1: # %for.body.preheader
44 # FDATA: 0 [unknown] 0 1 CmovInHotPath #LBB0_2# 1 2
46 movl
(%rcx
,%rdi
,4), %eax
51 # CHECK: cmpl %edx, %eax
52 # CHECK-NEXT: cmovlel %r9d, %r10d
55 # FDATA: 1 CmovInHotPath #LBB0_2_br# 1 CmovInHotPath #LBB0_3# 1 2
56 # FDATA: 1 CmovInHotPath #LBB0_2_br# 1 CmovInHotPath #LBB0_4# 1 2
62 movl
%r10d
, (%rcx
,%rdi
,4)
66 LBB0_5
: # %for.cond.cleanup
69 .size CmovInHotPath, Lfunc_end0-CmovInHotPath
72 .globl CmovNotInHotPath # -- Begin function CmovNotInHotPath
74 .type CmovNotInHotPath,@function
75 CmovNotInHotPath
: # @CmovNotInHotPath
76 # CHECK-LABEL: Binary Function "CmovNotInHotPath" after CMOV conversion
77 # FDATA: 0 [unknown] 0 1 CmovNotInHotPath 0 1 2
82 # %bb.1: # %for.body.preheader
86 # FDATA: 0 [unknown] 0 1 CmovNotInHotPath #LBB1_2# 1 2
88 movl
(%rcx
,%rdi
,4), %r11d
93 # CHECK: cmpl %r9d, %eax
94 # CHECK-NEXT: cmovlel %r11d, %edx
97 # FDATA: 1 CmovNotInHotPath #LBB1_4_br# 1 CmovNotInHotPath #LBB1_3# 1 2
98 # FDATA: 1 CmovNotInHotPath #LBB1_4_br# 1 CmovNotInHotPath #LBB1_4# 1 2
103 movl
%edx
, (%rcx
,%rdi
,4)
104 movl
(%r8,%rdi
,4), %eax
107 movl
%eax
, (%r8,%rdi
,4)
111 LBB1_5
: # %for.cond.cleanup
114 .size CmovNotInHotPath, Lfunc_end1-CmovNotInHotPath
117 .globl MaxIndex # -- Begin function MaxIndex
119 .type MaxIndex,@function
120 MaxIndex
: # @MaxIndex
121 # CHECK-LABEL: Binary Function "MaxIndex" after CMOV conversion
122 # FDATA: 0 [unknown] 0 1 MaxIndex 0 1 2
128 # %bb.1: # %for.body.preheader
132 # FDATA: 0 [unknown] 0 1 MaxIndex #LBB2_2# 1 2
134 movl
(%rsi
,%rdx
,4), %r9d
137 cmpl (%rsi
,%rcx
,4), %r9d
138 # CHECK: cmpl (%rsi,%rcx,4), %r9d
139 # CHECK-NEXT: cmovlel %edi, %eax
142 # FDATA: 1 MaxIndex #LBB2_2_br# 1 MaxIndex #LBB2_3# 1 2
143 # FDATA: 1 MaxIndex #LBB2_2_br# 1 MaxIndex #LBB2_4# 1 2
152 LBB2_5
: # %for.cond.cleanup
155 .size MaxIndex, Lfunc_end2-MaxIndex
158 .globl MaxIndex_unpredictable # -- Begin function MaxIndex_unpredictable
160 .type MaxIndex_unpredictable,@function
161 MaxIndex_unpredictable
: # @MaxIndex_unpredictable
162 # CHECK-LABEL: Binary Function "MaxIndex_unpredictable" after CMOV conversion
163 # FDATA: 0 [unknown] 0 1 MaxIndex_unpredictable 0 1 2
169 # %bb.1: # %for.body.preheader
173 # FDATA: 0 [unknown] 0 1 MaxIndex_unpredictable #LBB3_2# 1 2
175 movl
(%rsi
,%rdx
,4), %r9d
178 cmpl (%rsi
,%rcx
,4), %r9d
179 # CHECK: cmpl (%rsi,%rcx,4), %r9d
180 # CHECK-NEXT: cmovlel %edi, %eax
183 # FDATA: 1 MaxIndex_unpredictable #LBB3_2_br# 1 MaxIndex_unpredictable #LBB3_3# 1 2
184 # FDATA: 1 MaxIndex_unpredictable #LBB3_2_br# 1 MaxIndex_unpredictable #LBB3_4# 1 2
193 LBB3_5
: # %for.cond.cleanup
196 .size MaxIndex_unpredictable, Lfunc_end3-MaxIndex_unpredictable
199 .globl MaxValue # -- Begin function MaxValue
201 .type MaxValue,@function
202 MaxValue
: # @MaxValue
203 # CHECK-LABEL: Binary Function "MaxValue" after CMOV conversion
204 # FDATA: 0 [unknown] 0 1 MaxValue 0 1 2
213 LBB4_2
: # %for.cond.cleanup
215 LBB4_3
: # %for.body.preheader
219 movl
(%rsi
,%rdx
,4), %eax
221 # CHECK: cmpl %ecx, %eax
222 # CHECK-NEXT: cmovlel %ecx, %eax
225 # FDATA: 1 MaxValue #LBB4_4_br# 1 MaxValue #LBB4_5# 1 2
226 # FDATA: 1 MaxValue #LBB4_4_br# 1 MaxValue #LBB4_6# 1 2
237 .size MaxValue, Lfunc_end4-MaxValue
240 .globl BinarySearch # -- Begin function BinarySearch
242 .type BinarySearch,@function
243 BinarySearch
: # @BinarySearch
244 # CHECK-LABEL: Binary Function "BinarySearch" after CMOV conversion
245 # FDATA: 0 [unknown] 0 1 BinarySearch 0 1 2
250 LBB5_1
: # %while.body
255 movq
8(%rdx
,%rcx
,8), %rdx
256 LBB5_2
: # %while.body
260 # %bb.3: # %while.end
263 .size BinarySearch, Lfunc_end5-BinarySearch
266 .globl Transform # -- Begin function Transform
268 .type Transform,@function
269 Transform
: # @Transform
270 # CHECK-LABEL: Binary Function "Transform" after CMOV conversion
271 # FDATA: 0 [unknown] 0 1 Transform 0 1 2
277 # %bb.1: # %while.body.preheader
280 LBB6_2
: # %while.body
282 movl
(%rdi
,%rsi
,4), %eax
290 # %bb.3: # %while.body
293 LBB6_4
: # %while.body
296 movl
%edx
, (%rdi
,%rsi
,4)
303 .size Transform, Lfunc_end6-Transform
306 .globl test_cmov_memoperand # -- Begin function test_cmov_memoperand
308 .type test_cmov_memoperand,@function
309 test_cmov_memoperand
: # @test_cmov_memoperand
310 # CHECK-LABEL: Binary Function "test_cmov_memoperand" after CMOV conversion
311 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand 0 1 2
322 .size test_cmov_memoperand, Lfunc_end7-test_cmov_memoperand
325 .globl test_cmov_memoperand_unpredictable # -- Begin function test_cmov_memoperand_unpredictable
327 .type test_cmov_memoperand_unpredictable,@function
328 test_cmov_memoperand_unpredictable
: # @test_cmov_memoperand_unpredictable
329 # CHECK-LABEL: Binary Function "test_cmov_memoperand_unpredictable" after CMOV conversion
330 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_unpredictable 0 1 2
341 .size test_cmov_memoperand_unpredictable, Lfunc_end8-test_cmov_memoperand_unpredictable
344 .globl test_cmov_memoperand_in_group # -- Begin function test_cmov_memoperand_in_group
346 .type test_cmov_memoperand_in_group,@function
347 test_cmov_memoperand_in_group
: # @test_cmov_memoperand_in_group
348 # CHECK-LABEL: Binary Function "test_cmov_memoperand_in_group" after CMOV conversion
349 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_in_group 0 1 2
365 .size test_cmov_memoperand_in_group, Lfunc_end9-test_cmov_memoperand_in_group
368 .globl test_cmov_memoperand_in_group2 # -- Begin function test_cmov_memoperand_in_group2
370 .type test_cmov_memoperand_in_group2,@function
371 test_cmov_memoperand_in_group2
: # @test_cmov_memoperand_in_group2
372 # CHECK-LABEL: Binary Function "test_cmov_memoperand_in_group2" after CMOV conversion
373 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_in_group2 0 1 2
389 .size test_cmov_memoperand_in_group2, Lfunc_end10-test_cmov_memoperand_in_group2
392 .globl test_cmov_memoperand_conflicting_dir # -- Begin function test_cmov_memoperand_conflicting_dir
394 .type test_cmov_memoperand_conflicting_dir,@function
395 test_cmov_memoperand_conflicting_dir
: # @test_cmov_memoperand_conflicting_dir
396 # CHECK-LABEL: Binary Function "test_cmov_memoperand_conflicting_dir" after CMOV conversion
397 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_conflicting_dir 0 1 2
407 .size test_cmov_memoperand_conflicting_dir, Lfunc_end11-test_cmov_memoperand_conflicting_dir
410 .globl test_cmov_memoperand_in_group_reuse_for_addr # -- Begin function test_cmov_memoperand_in_group_reuse_for_addr
412 .type test_cmov_memoperand_in_group_reuse_for_addr,@function
413 test_cmov_memoperand_in_group_reuse_for_addr
: # @test_cmov_memoperand_in_group_reuse_for_addr
414 # CHECK-LABEL: Binary Function "test_cmov_memoperand_in_group_reuse_for_addr" after CMOV conversion
415 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_in_group_reuse_for_addr 0 1 2
426 .size test_cmov_memoperand_in_group_reuse_for_addr, Lfunc_end12-test_cmov_memoperand_in_group_reuse_for_addr
429 .globl test_cmov_memoperand_in_group_reuse_for_addr2 # -- Begin function test_cmov_memoperand_in_group_reuse_for_addr2
431 .type test_cmov_memoperand_in_group_reuse_for_addr2,@function
432 test_cmov_memoperand_in_group_reuse_for_addr2
: # @test_cmov_memoperand_in_group_reuse_for_addr2
433 # CHECK-LABEL: Binary Function "test_cmov_memoperand_in_group_reuse_for_addr2" after CMOV conversion
434 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_in_group_reuse_for_addr2 0 1 2
446 .size test_cmov_memoperand_in_group_reuse_for_addr2, Lfunc_end13-test_cmov_memoperand_in_group_reuse_for_addr2
449 .globl test_cmov_memoperand_in_group_reuse_for_addr3 # -- Begin function test_cmov_memoperand_in_group_reuse_for_addr3
451 .type test_cmov_memoperand_in_group_reuse_for_addr3,@function
452 test_cmov_memoperand_in_group_reuse_for_addr3
: # @test_cmov_memoperand_in_group_reuse_for_addr3
453 # CHECK-LABEL: Binary Function "test_cmov_memoperand_in_group_reuse_for_addr3" after CMOV conversion
454 # FDATA: 0 [unknown] 0 1 test_cmov_memoperand_in_group_reuse_for_addr3 0 1 2
465 .size test_cmov_memoperand_in_group_reuse_for_addr3, Lfunc_end14-test_cmov_memoperand_in_group_reuse_for_addr3
468 .globl test_memoperand_loop # -- Begin function test_memoperand_loop
470 .type test_memoperand_loop,@function
471 test_memoperand_loop
: # @test_memoperand_loop
472 # CHECK-LABEL: Binary Function "test_memoperand_loop" after CMOV conversion
473 # FDATA: 0 [unknown] 0 1 test_memoperand_loop 0 1 2
476 movq begin@GOTPCREL
(%rip
), %r8
478 movq end@GOTPCREL
(%rip
), %rcx
482 LBB15_1
: # %loop.body
486 # %bb.2: # %loop.body
488 LBB15_3
: # %loop.body
492 # CHECK: movl %edi, (%rcx)
493 # CHECK-NEXT: addq $0x8, %rcx
494 # CHECK-NEXT: cmpq %rdx, %rcx
495 # CHECK-NEXT: cmovbeq %rax, %rcx
498 # FDATA: 1 test_memoperand_loop #LBB15_3_br# 1 test_memoperand_loop #LBB15_4# 1 2
499 # FDATA: 1 test_memoperand_loop #LBB15_3_br# 1 test_memoperand_loop #LBB15_5# 1 2
500 # %bb.4: # %loop.body
503 LBB15_5
: # %loop.body
506 cmpl $
1024, %esi
# imm = 0x400
511 .size test_memoperand_loop, Lfunc_end15-test_memoperand_loop
514 .globl CmovBackToBack # -- Begin function CmovBackToBack
516 .type CmovBackToBack,@function
517 CmovBackToBack
: # @CmovBackToBack
518 # CHECK-LABEL: Binary Function "CmovBackToBack" after CMOV conversion
519 # FDATA: 0 [unknown] 0 1 CmovBackToBack 0 1 2
525 # FDATA: 0 [unknown] 0 1 CmovBackToBack #LBB16_2# 1 2
527 movl
(%rcx
,%rdi
,4), %eax
532 # CHECK: cmpl %edx, %eax
533 # CHECK-NEXT: cmovlel %r9d, %r10d
536 # FDATA: 1 CmovBackToBack #LBB16_2_br# 1 CmovBackToBack #LBB16_3# 1 2
537 # FDATA: 1 CmovBackToBack #LBB16_2_br# 1 CmovBackToBack #LBB16_4# 1 2
541 # CHECK-NEXT: cmovlel %r9d, %r10d
544 # FDATA: 1 CmovBackToBack #LBB16_6_br# 1 CmovBackToBack #LBB16_7# 1 2
545 # FDATA: 1 CmovBackToBack #LBB16_6_br# 1 CmovBackToBack #LBB16_8# 1 2
550 movl
%r10d
, (%rcx
,%rdi
,4)
554 LBB16_5
: # %for.cond.cleanup
557 .size CmovBackToBack, Lfunc_end16-CmovBackToBack