This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fwd: [PATCH] Scheduling result adjustment to enable macro-fusion
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Wei Mi <wmi at google dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, Alexander Monakov <amonakov at ispras dot ru>, Steven Bosscher <stevenb dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, David Li <davidxl at google dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>
- Date: Tue, 24 Sep 2013 13:41:46 -0700
- Subject: Re: Fwd: [PATCH] Scheduling result adjustment to enable macro-fusion
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOo-dc7=ax8_pA21wuxnqphLBvf_Voi2n1OHJX7ZEab=ew at mail dot gmail dot com> <CA+4CFy4fqCRvM2Luw2_p6AEZOmucSV1KemntEO3_XU5TfzA-7A at mail dot gmail dot com> <CA+4CFy6gdxREYiJa2B70RBe2aUtLY3zQ9ShK9jGEy26Hdn9QOg at mail dot gmail dot com> <CAMe9rOp1R8XACsL=v-JZkvpPzTOFiZhZPMqQXWkmPgHW5cjC6w at mail dot gmail dot com> <CA+4CFy5nM2Dw7kv0G61N5PKHoAanmAaKm+45oS4pN22TKgSAFg at mail dot gmail dot com> <20130922095726 dot GA23006 at atrey dot karlin dot mff dot cuni dot cz> <20130922101916 dot GA31130 at atrey dot karlin dot mff dot cuni dot cz> <CA+4CFy5n=rTH+fmndNXLJkJgzLd4uCmucvPf+QfGWNsvhPQ1CQ at mail dot gmail dot com> <CA+4CFy7TCbnm3irCTKYuQmsz_xPNbC3YmugHC6fjiewPcREzZA at mail dot gmail dot com>
On Tue, Sep 24, 2013 at 12:06 PM, Wei Mi <wmi@google.com> wrote:
> This is the updated patch2.
> Changed:
> 1. For cmp/test with rip-relative addressing mem operand, don't group
> insns. Bulldozer also doesn't support fusion for cmp/test with both
> displacement MEM and immediate operand, while m_CORE_ALL doesn't
> support fusion for cmp/test with MEM and immediate operand. I simplify
> choose to use the more stringent constraint here (m_CORE_ALL's
> constraint).
> 2. Add Budozer back and merge TARGET_FUSE_CMP_AND_BRANCH_64 and
> TARGET_FUSE_CMP_AND_BRANCH_32.
>
> bootstrap and regression pass. ok for trunk?
>
> 2013-09-24 Wei Mi <wmi@google.com>
>
> * gcc/config/i386/i386.c (rip_relative_addr_p): New Function.
> (ix86_macro_fusion_p): Ditto.
> (ix86_macro_fusion_pair_p): Ditto.
> * gcc/config/i386/i386.h: Add new tune features about macro-fusion.
> * gcc/config/i386/x86-tune.def (DEF_TUNE): Ditto.
> * gcc/doc/tm.texi: Generated.
> * gcc/doc/tm.texi.in: Ditto.
> * gcc/haifa-sched.c (try_group_insn): New Function.
> (group_insns_for_macro_fusion): Ditto.
> (sched_init): Call group_insns_for_macro_fusion.
> * gcc/sched-rgn.c (add_branch_dependences): Keep insns in
> a SCHED_GROUP at the end of BB to remain their location.
> * gcc/target.def: Add two hooks: macro_fusion_p and
> macro_fusion_pair_p.
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 1fd3f60..4a04778 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -24856,6 +24856,167 @@ ia32_multipass_dfa_lookahead (void)
> }
> }
>
> +/* Extracted from ix86_print_operand_address. Check whether ADDR is a
> + rip-relative address. */
> +
> +static bool
> +rip_relative_addr_p (rtx addr)
> +{
> + struct ix86_address parts;
> + rtx base, index, disp;
> + int ok;
> +
> + if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_VSIBADDR)
> + {
> + ok = ix86_decompose_address (XVECEXP (addr, 0, 0), &parts);
> + parts.index = XVECEXP (addr, 0, 1);
> + }
> + else if (GET_CODE (addr) == UNSPEC && XINT (addr, 1) == UNSPEC_LEA_ADDR)
> + ok = ix86_decompose_address (XVECEXP (addr, 0, 0), &parts);
> + else
> + ok = ix86_decompose_address (addr, &parts);
> +
> + gcc_assert (ok);
> + base = parts.base;
> + index = parts.index;
> + disp = parts.disp;
> +
> + if (TARGET_64BIT && !base && !index)
> + {
> + rtx symbol = disp;
> +
> + if (GET_CODE (disp) == CONST
> + && GET_CODE (XEXP (disp, 0)) == PLUS
> + && CONST_INT_P (XEXP (XEXP (disp, 0), 1)))
> + symbol = XEXP (XEXP (disp, 0), 0);
> +
> + if (GET_CODE (symbol) == LABEL_REF
> + || (GET_CODE (symbol) == SYMBOL_REF
> + && SYMBOL_REF_TLS_MODEL (symbol) == 0))
> + return true;
> + }
> + if (flag_pic && !base && !index)
> + {
> + if (GET_CODE (disp) == CONST
> + && GET_CODE (XEXP (disp, 0)) == UNSPEC
> + && (XINT (XEXP (disp, 0), 1) == UNSPEC_PCREL
> + || XINT (XEXP (disp, 0), 1) == UNSPEC_GOTPCREL
> + || (TARGET_64BIT
> + && XINT (XEXP (disp, 0), 1) == UNSPEC_GOTNTPOFF)))
> + return true;
> + }
> + return false;
> +}
> +
It doesn't look right. IP relative address is only possible
with TARGET_64BIT and
1. base == pc. Or
2. UUNSPEC_PCREL, UNSPEC_GOTPCREL, and
NSPEC_GOTNTPOFF.
--
H.J.