This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Remove dead labels to increase superblock scope
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: Tom de Vries <Tom_deVries at mentor dot com>
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, Steven Bosscher <stevenb dot gcc at gmail dot com>, Michael Matz <matz at suse dot de>, "gcc-patches\ at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 02 Dec 2011 10:40:02 +0000
- Subject: Re: [PATCH] Remove dead labels to increase superblock scope
- References: <4EC65977.4020501@mentor.com> <Pine.LNX.4.64.1111251402230.26507@wotan.suse.de> <CABu31nPTh1+nDeytzvHPEVz8gWpvWPZMKK6+FpUW+HEwCg_gZg@mail.gmail.com> <201111272359.39297.ebotcazou@adacore.com> <4ED7364D.2070108@mentor.com>
Tom de Vries <Tom_deVries@mentor.com> writes:
> On 27/11/11 23:59, Eric Botcazou wrote:
>>> No, DELETED_LABEL notes still work just fine. It depends on how you
>>> remove the label and replace it with a note, and Tom isn't showing
>>> what he did, so...
>>
>> I agree that there is no obvious reason why just calling delete_insn would not
>> work, so this should be investigated first.
>>
>
> The reason it didn't work, is because after turning a label into a
> NOTE_INSN_DELETED_LABEL, one needs to move it to after the NOTE_INSN_BASIC_BLOCK
> as in cfgcleanup.c:try_optimize_cfg():
> ...
> delete_insn_chain (label, label, false);
> /* If the case label is undeletable, move it after the
> BASIC_BLOCK note. */
> if (NOTE_KIND (BB_HEAD (b)) == NOTE_INSN_DELETED_LABEL)
> {
> rtx bb_note = NEXT_INSN (BB_HEAD (b));
>
> reorder_insns_nobb (label, label, bb_note);
> BB_HEAD (b) = bb_note;
> if (BB_END (b) == bb_note)
> BB_END (b) = label;
> }
> ...
>
> Attached patch factors out this piece of code and reuses it in fixup_reorder_chain.
But isn't...
> @@ -2637,15 +2658,7 @@ try_optimize_cfg (int mode)
> delete_insn_chain (label, label, false);
> /* If the case label is undeletable, move it after the
> BASIC_BLOCK note. */
> - if (NOTE_KIND (BB_HEAD (b)) == NOTE_INSN_DELETED_LABEL)
> - {
> - rtx bb_note = NEXT_INSN (BB_HEAD (b));
> -
> - reorder_insns_nobb (label, label, bb_note);
> - BB_HEAD (b) = bb_note;
> - if (BB_END (b) == bb_note)
> - BB_END (b) = label;
> - }
> + fixup_deleted_label (b);
...this "delete_insn_chain (label, label, false);" call equivalent
to "delete_insn (label)"? Splitting the operation in two here and:
> Index: gcc/cfglayout.c
> ===================================================================
> --- gcc/cfglayout.c (revision 181652)
> +++ gcc/cfglayout.c (working copy)
> @@ -857,6 +857,12 @@ fixup_reorder_chain (void)
> (e_taken->src, e_taken->dest));
> e_taken->flags |= EDGE_FALLTHRU;
> update_br_prob_note (bb);
> + if (LABEL_NUSES (ret_label) == 0
> + && single_pred_p (e_taken->dest))
> + {
> + delete_insn (ret_label);
> + fixup_deleted_label (e_taken->dest);
> + }
...here seems a little odd.
Richard