On Sun, Jan 14, 2018 at 1:23 PM, H.J. Lu <hjl.to...@gmail.com> wrote: > 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? >
Here is the updated patch. Tested on i686 and x86-64. OK for trunk? -- H.J.
From b76722e4050241d0b4c0a46bd12015d3973b118b 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 (constant_call_address_operand): Rewrite ix86_indirect_branch_thunk_register logic. (sibcall_insn_operand): Likewise. --- gcc/config/i386/predicates.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md index 5ae443231b8..23bf564f58c 100644 --- a/gcc/config/i386/predicates.md +++ b/gcc/config/i386/predicates.md @@ -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