xref: /llvm-project/llvm/test/CodeGen/X86/branch-hint.ll (revision e603451f3cb16792fb46ab5f2fa50b05f3e5d935)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2; RUN: llc < %s -mtriple=x86_64 -mattr=+branch-hint -enable-branch-hint | FileCheck %s
3; RUN: llc < %s -mtriple=x86_64 -mattr=+branch-hint -enable-branch-hint -branch-hint-probability-threshold=50 | FileCheck %s
4; RUN: llc < %s -mtriple=x86_64 -mattr=+branch-hint -enable-branch-hint -branch-hint-probability-threshold=60 -tail-dup-placement=false | FileCheck --check-prefix=TH60 %s
5
6
7; Design: Add DS segment override prefix for condition branch who has high
8; probability to take (which is greater than the probability threshold of
9; enabling branch hint).
10
11define void @p51(i32 %x, ptr %p) {
12; CHECK-LABEL: p51:
13; CHECK:       # %bb.0: # %entry
14; CHECK-NEXT:    testl %edi, %edi
15; CHECK-NEXT:    ds
16; CHECK-NEXT:    je .LBB0_2
17; CHECK-NEXT:  # %bb.1: # %if.then
18; CHECK-NEXT:    movl %edi, (%rsi)
19; CHECK-NEXT:  .LBB0_2: # %if.end
20; CHECK-NEXT:    retq
21;
22; TH60-LABEL: p51:
23; TH60:       # %bb.0: # %entry
24; TH60-NEXT:    testl %edi, %edi
25; TH60-NEXT:    je .LBB0_2
26; TH60-NEXT:  # %bb.1: # %if.then
27; TH60-NEXT:    movl %edi, (%rsi)
28; TH60-NEXT:  .LBB0_2: # %if.end
29; TH60-NEXT:    retq
30entry:
31  %tobool.not = icmp eq i32 %x, 0
32  br i1 %tobool.not, label %if.end, label %if.then, !prof !0
33
34if.then:
35  store i32 %x, ptr %p, align 4
36  br label %if.end
37
38if.end:
39  ret void
40}
41
42define void @p61(i32 %x, ptr %p) {
43; CHECK-LABEL: p61:
44; CHECK:       # %bb.0: # %entry
45; CHECK-NEXT:    testl %edi, %edi
46; CHECK-NEXT:    jne .LBB1_1
47; CHECK-NEXT:  # %bb.2: # %if.end
48; CHECK-NEXT:    retq
49; CHECK-NEXT:  .LBB1_1: # %if.then
50; CHECK-NEXT:    movl %edi, (%rsi)
51; CHECK-NEXT:    retq
52;
53; TH60-LABEL: p61:
54; TH60:       # %bb.0: # %entry
55; TH60-NEXT:    testl %edi, %edi
56; TH60-NEXT:    ds
57; TH60-NEXT:    je .LBB1_2
58; TH60-NEXT:  # %bb.1: # %if.then
59; TH60-NEXT:    movl %edi, (%rsi)
60; TH60-NEXT:  .LBB1_2: # %if.end
61; TH60-NEXT:    retq
62entry:
63  %tobool.not = icmp eq i32 %x, 0
64  br i1 %tobool.not, label %if.end, label %if.then, !prof !1
65
66if.then:
67  store i32 %x, ptr %p, align 4
68  br label %if.end
69
70if.end:
71  ret void
72}
73
74!0 = !{!"branch_weights", i32 51, i32 49}
75!1 = !{!"branch_weights", i32 61, i32 39}