diff mbox series

[APX,EGPR] Fix indirect call prefix

Message ID 20241108140730.1844187-2-gregorykanter1@gmail.com
State New
Headers show
Series [APX,EGPR] Fix indirect call prefix | expand

Commit Message

Gregory Kanter Nov. 8, 2024, 2:07 p.m. UTC
Fix indirect branch CS prefix for EGPR registers. Because of a mistake,
they are not prefixed with CS when the indirect-branch-cs-prefix flag is
specified.

gcc/ChangeLog:
	* config/i386/i386.cc (ix86_output_indirect_branch_via_reg): fix 
	  wrong condition for REX2 registers.
	* config/i386/i386.opt: Clarify that -mindirect-branch-cs-prefix
	  also applies to EGPR registers when enabled.

Signed-off-by: Gregory Kanter <gregorykanter1@gmail.com>

---
 gcc/config/i386/i386.cc  | 2 +-
 gcc/config/i386/i386.opt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 6ac3a5d55f..5728ba4408 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -16798,7 +16798,7 @@  ix86_output_indirect_branch_via_reg (rtx call_op, bool sibcall_p)
     {
       if (thunk_name != NULL)
 	{
-	  if ((REX_INT_REGNO_P (regno) || REX_INT_REGNO_P (regno))
+	  if ((REX_INT_REGNO_P (regno) || REX2_INT_REGNO_P (regno))
 	      && ix86_indirect_branch_cs_prefix)
 	    fprintf (asm_out_file, "\tcs\n");
 	  fprintf (asm_out_file, "\tcall\t");
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 99e86f545e..b0f92cbc0f 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -1097,7 +1097,7 @@  Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
 
 mindirect-branch-cs-prefix
 Target Var(ix86_indirect_branch_cs_prefix) Init(0)
-Add CS prefix to call and jmp to indirect thunk with branch target in r8-r15 registers.
+Add CS prefix to call and jmp to indirect thunk with branch target in r8-r15 registers (and r16-r31 when EGPR registers are in use).
 
 mindirect-branch-register
 Target Var(ix86_indirect_branch_register) Init(0)