Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:zhmars:arch
gcc13
_service:download_url:x86-always-generate-branc...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:download_url:x86-always-generate-branch-hint.patch of Package gcc13
From ecb8284b8bec4f9e025d21177efbe13f64f6f11b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Tue, 26 Apr 2022 11:08:55 -0700 Subject: [PATCH] x86: Always generate branch hint For -mtune-ctrl=branch_prediction_hints, always generate branch hint for conditional branches. gcc/ * config/i386/i386.cc (ix86_print_operand): Always generate branch hint for conditional branches. gcc/testsuite/ * gcc.target/i386/branch-hint-1.c: New test. --- gcc/config/i386/i386.cc | 26 +++++-------------- gcc/testsuite/gcc.target/i386/branch-hint-1.c | 16 ++++++++++++ 2 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/branch-hint-1.c diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc index 52040da8c47f..8246576f7b82 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -13555,25 +13555,13 @@ ix86_print_operand (FILE *file, rtx x, int code) int pred_val = profile_probability::from_reg_br_prob_note (XINT (x, 0)).to_reg_br_prob_base (); - if (pred_val < REG_BR_PROB_BASE * 45 / 100 - || pred_val > REG_BR_PROB_BASE * 55 / 100) - { - bool taken = pred_val > REG_BR_PROB_BASE / 2; - bool cputaken - = final_forward_branch_p (current_output_insn) == 0; - - /* Emit hints only in the case default branch prediction - heuristics would fail. */ - if (taken != cputaken) - { - /* We use 3e (DS) prefix for taken branches and - 2e (CS) prefix for not taken branches. */ - if (taken) - fputs ("ds ; ", file); - else - fputs ("cs ; ", file); - } - } + bool taken = pred_val > REG_BR_PROB_BASE / 2; + /* We use 3e (DS) prefix for taken branches and + 2e (CS) prefix for not taken branches. */ + if (taken) + fputs ("ds ; ", file); + else + fputs ("cs ; ", file); } return; } diff --git a/gcc/testsuite/gcc.target/i386/branch-hint-1.c b/gcc/testsuite/gcc.target/i386/branch-hint-1.c new file mode 100644 index 000000000000..03dd83b05af0 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/branch-hint-1.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -dp -mtune-ctrl=branch_prediction_hints" } */ + +int +main (int argc, char** argv) +{ + if (argc == 1) + return 1; + + if (argc == 2) + return 2; + + return 3; +} + +/* { dg-final { scan-assembler-not "\tj\[a-z\]\+\[ \\t\]+.* \\*jcc" } } */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor