[PATCH] Add XINSN macro and use it within NEXT_INSN/PREV_INSN (was Re: [PATCH] Force rtl templates to be inlined)

David Malcolm dmalcolm@redhat.com
Thu Sep 4 20:07:00 GMT 2014

On Tue, 2014-09-02 at 19:50 +0200, Andi Kleen wrote:
> > I suspect the bulk of them currently are coming from the safe_as_a
> > <rtx_insn *> calls within NEXT_INSN and PREV_INSN; do you happen to have
> > information handy on that?
> Yes that's right:
> -   1.03%  lto1                    [.] bool is_a_helper<rtx_insn*>::test<rtx_def>(rtx_def*)                                                     â–’
>    - bool is_a_helper<rtx_insn*>::test<rtx_def>(rtx_def*)                                                                                       â–’
>       - 92.20% bool is_a<rtx_insn*, rtx_def>(rtx_def*)                                                                                          â–’
>          - 98.53% rtx_insn* safe_as_a<rtx_insn*, rtx_def>(rtx_def*)                                                                             â–’
>             - 73.28% NEXT_INSN(rtx_insn const*)                                                                                                 â–’

The is_a_helper for rtx_insn * is non-trivial, so it may be worth
avoiding it, even when inlined.

The attached patch rewrites the inline NEXT_INSN/PREV_INSN to avoid
doing the safe_as_a, instead tightening up the interface so that one can
only set them to an insn, and introducing a new XINSN access macro and
corresponding rt_insn member of the union.

Bootstrapped on x86_64-unknown-linux-gnu (Fedora 20), and has been
rebuilt as part of a config-list.mk build for all working configurations
(albeit with other patches for the latter case).

OK for trunk?

	* rtl.h (union rtunion): Add new member "rt_insn", of type
	rtx_insn *.
	(XINSN): New accessor macro, accessing as an rtx_insn *,
	requiring code "u".
	(PREV_INSN, NEXT_INSN): Eliminate the checked cast to rtx_insn *
	and instead directly use XINSN.
	(SET_PREV_INSN, SET_NEXT_INSN): Strengthen the return type from
	rtx & to rtx_insn *&, using XINSN internally.
	(NEXT_INSN): Eliminate the checked cast and instead directly use

	* cfgrtl.c (fixup_abnormal_edges): Use NULL rather than NULL_RTX
	when assigning to SET_PREV_INSN/SET_NEXT_INSN.
	* haifa-sched.c (remove_notes): Likewise.
	* sel-sched-ir.c (sel_remove_insn): Likewise.
	(get_bb_note_from_pool): Likewise.
	* config/ia64/ia64.c (ia64_init_dfa_pre_cycle_insn): Likewise.
	(ia64_reorg): Likewise.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-XINSN-macro-and-use-it-within-NEXT_INSN-PREV_INS.patch
Type: text/x-patch
Size: 5879 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20140904/b4e15aa0/attachment.bin>

More information about the Gcc-patches mailing list