On Sun, Jan 14, 2018 at 10:52 AM, Uros Bizjak <ubiz...@gmail.com> wrote: > On Sun, Jan 14, 2018 at 7:08 PM, H.J. Lu <hjl.to...@gmail.com> wrote: >> On Sun, Jan 14, 2018 at 9:51 AM, Uros Bizjak <ubiz...@gmail.com> wrote: >>> - (ior (and (not (match_test "TARGET_X32")) >>> + (ior (and (not (match_test "TARGET_X32 >>> + || ix86_indirect_branch_thunk_register")) >>> (match_operand 0 "sibcall_memory_operand")) >>> - (and (match_test "TARGET_X32 && Pmode == DImode") >>> + (and (match_test "TARGET_X32 && Pmode == DImode >>> + && !ix86_indirect_branch_thunk_register") >>> (match_operand 0 "GOT_memory_operand")))) >>> >>> Is this patch just trying to disable the predicate when >>> ix86_indirect_branch_thunk_register is set? Because this is what this >>> convoluted logic does. >> >> Yes, we want to disable all indirect branch via memory with >> -mindirect-branch-register, just like -mx32. We could do >> >> #idefine TARGET_INDIRECT_BRANCH_REGISTER \ >> (TARGER_X32 || ix86_indirect_branch_thunk_register) > > Index: predicates.md > =================================================================== > --- predicates.md (revision 256666) > +++ predicates.md (working copy) > @@ -710,11 +710,10 @@ > (ior (match_test "constant_call_address_operand > (op, mode == VOIDmode ? mode : Pmode)") > (match_operand 0 "call_register_no_elim_operand") > - (ior (and (not (match_test "TARGET_X32 > - || ix86_indirect_branch_thunk_register")) > + (and (not (match_test "ix86_indirect_branch_thunk_register")) > + (ior (and (not (match_test "TARGET_X32"))) > (match_operand 0 "memory_operand")) > - (and (match_test "TARGET_X32 && Pmode == DImode > - && !ix86_indirect_branch_thunk_register") > + (and (match_test "TARGET_X32 && Pmode == DImode") > (match_operand 0 "GOT_memory_operand"))))) > > or something like that. >
I am testing this patch. OK for trunk if there is no regression? -- H.J.
From e332a970f82439c5169e6f87c77f15123e7ec49e Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.to...@gmail.com> Date: Sun, 14 Jan 2018 13:19:37 -0800 Subject: [PATCH] x86: Rewrite ix86_indirect_branch_thunk_register logic Rewrite ix86_indirect_branch_thunk_register logic with (and (not (match_test "ix86_indirect_branch_thunk_register")) (original condition before r256662)) * config/i386/predicates.md (indirect_branch_operand): Rewrite ix86_indirect_branch_thunk_register logic. (constant_call_address_operand): Likewise. (sibcall_insn_operand): Likewise. --- gcc/config/i386/predicates.md | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 5ae443231b8..68556d8b827 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -664,10 +664,10 @@ ;; Test for a valid operand for indirect branch. (define_predicate "indirect_branch_operand" - (ior (match_operand 0 "register_operand") - (and (not (match_test "TARGET_X32 - || ix86_indirect_branch_thunk_register")) - (match_operand 0 "memory_operand")))) + (and (not (match_test "ix86_indirect_branch_thunk_register")) + (ior (match_operand 0 "register_operand") + (and (not (match_test "TARGET_X32")) + (match_operand 0 "memory_operand"))))) ;; Return true if OP is a memory operands that can be used in sibcalls. ;; Since sibcall never returns, we can only use call-clobbered register @@ -710,24 +710,22 @@ (ior (match_test "constant_call_address_operand (op, mode == VOIDmode ? mode : Pmode)") (match_operand 0 "call_register_no_elim_operand") - (ior (and (not (match_test "TARGET_X32 - || ix86_indirect_branch_thunk_register")) - (match_operand 0 "memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode - && !ix86_indirect_branch_thunk_register") - (match_operand 0 "GOT_memory_operand"))))) + (and (not (match_test "ix86_indirect_branch_thunk_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")))))) ;; 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") - (ior (and (not (match_test "TARGET_X32 - || ix86_indirect_branch_thunk_register")) - (match_operand 0 "sibcall_memory_operand")) - (and (match_test "TARGET_X32 && Pmode == DImode - && !ix86_indirect_branch_thunk_register") - (match_operand 0 "GOT_memory_operand"))))) + (and (not (match_test "ix86_indirect_branch_thunk_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")))))) ;; Return true if OP is a 32-bit GOT symbol operand. (define_predicate "GOT32_symbol_operand" -- 2.14.3