[committed] i386: Fix and improve TARGET_INDIRECT_BRANCH_REGISTER handling some more

Message ID CAFULd4YuapDSp+84JAu9Hve1gMCPt5VUSCqvU1kfN6OjV00yUA@mail.gmail.com
State New
Headers
Series [committed] i386: Fix and improve TARGET_INDIRECT_BRANCH_REGISTER handling some more |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply

Commit Message

Uros Bizjak Feb. 3, 2025, 8:04 p.m. UTC
  gcc/ChangeLog:

    * config/i386/i386.md (*sibcall_pop_memory):
    Disable for TARGET_INDIRECT_BRANCH_REGISTER
    * config/i386/predicates.md (call_insn_operand): Enable when
    "satisfies_constraint_Bw (op)" is true, instead of open-coding
    constraint here.
    (sibcall_insn_operand): Ditto with "satisfies_constraint_Bs (op)".

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Uros.
  

Patch

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index d6ae3ee378a..cb37b2af50b 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -20244,7 +20244,7 @@  (define_insn "*sibcall_pop_memory"
 	(plus:SI (reg:SI SP_REG)
 		 (match_operand:SI 2 "immediate_operand" "i")))
    (unspec [(const_int 0)] UNSPEC_PEEPSIB)]
-  "!TARGET_64BIT"
+  "!TARGET_64BIT && !TARGET_INDIRECT_BRANCH_REGISTER"
   "* return ix86_output_call_insn (insn, operands[0]);"
   [(set_attr "type" "call")])
 
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 9a9101ed374..8631588f78e 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -781,22 +781,14 @@  (define_special_predicate "call_insn_operand"
   (ior (match_test "constant_call_address_operand
 		     (op, mode == VOIDmode ? mode : Pmode)")
        (match_operand 0 "call_register_operand")
-       (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (ior (and (not (match_test "TARGET_X32"))
-		      (match_operand 0 "memory_operand"))
-		 (and (match_test "TARGET_X32 && Pmode == DImode")
-		      (match_operand 0 "GOT_memory_operand"))))))
+       (match_test "satisfies_constraint_Bw (op)")))
 
 ;; Similarly, but for tail calls, in which we cannot allow memory references.
 (define_special_predicate "sibcall_insn_operand"
   (ior (match_test "constant_call_address_operand
 		     (op, mode == VOIDmode ? mode : Pmode)")
        (match_operand 0 "register_no_elim_operand")
-       (and (not (match_test "TARGET_INDIRECT_BRANCH_REGISTER"))
-	    (ior (and (not (match_test "TARGET_X32"))
-		      (match_operand 0 "sibcall_memory_operand"))
-		 (and (match_test "TARGET_X32 && Pmode == DImode")
-		      (match_operand 0 "GOT_memory_operand"))))))
+       (match_test "satisfies_constraint_Bs (op)")))
 
 ;; Return true if OP is a 32-bit GOT symbol operand.
 (define_predicate "GOT32_symbol_operand"