public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Uros Bizjak <ubizjak@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] i386: Clear REG_UNUSED and REG_DEAD notes from the IL at the end of vzeroupper pass [PR113059]
Date: Mon, 5 Feb 2024 09:08:26 +0100	[thread overview]
Message-ID: <CAFULd4ZA_ZY2JokdURCJv4cXp-J4Wv11Hg2jqRNUvxHmh2RabQ@mail.gmail.com> (raw)
In-Reply-To: <ZboDcnP7ipBvjcaD@tucnak>

On Wed, Jan 31, 2024 at 9:23 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> The move of the vzeroupper pass from after reload pass to after
> postreload_cse helped only partially, CSE-like passes can still invalidate
> those notes (especially REG_UNUSED) if they use some earlier register
> holding some value later on in the IL.
>
> So, either we could try to move it one pass further after gcse2 and hope
> no later pass invalidates the notes, or the following patch attempts to
> restore the REG_DEAD/REG_UNUSED state from GCC 13 and earlier, where
> the LRA or reload passes remove all REG_DEAD/REG_UNUSED notes and the notes
> reappear only at the start of dse2 pass when it calls
>   df_note_add_problem ();
>   df_analyze ();
> So, effectively
>           NEXT_PASS (pass_postreload_cse);
>           NEXT_PASS (pass_gcse2);
>           NEXT_PASS (pass_split_after_reload);
>           NEXT_PASS (pass_ree);
>           NEXT_PASS (pass_compare_elim_after_reload);
>           NEXT_PASS (pass_thread_prologue_and_epilogue);
> passes operate without those notes in the IL.
> While in GCC 14 mode switching computes the notes problem at the start of
> vzeroupper, the patch below removes them at the end of the pass again, so
> that the above passes continue to operate without them.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2024-01-31  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/113059
>         * config/i386/i386-features.cc (rest_of_handle_insert_vzeroupper):
>         Remove REG_DEAD/REG_UNUSED notes at the end of the pass before
>         df_analyze call.

Not really a review, but let's rubber stamp this workaround OK.

Thanks,
Uros.

>
> --- gcc/config/i386/i386-features.cc.jj 2024-01-08 12:15:13.611477047 +0100
> +++ gcc/config/i386/i386-features.cc    2024-01-30 12:36:27.834515803 +0100
> @@ -2664,6 +2664,32 @@ rest_of_handle_insert_vzeroupper (void)
>    /* Call optimize_mode_switching.  */
>    g->get_passes ()->execute_pass_mode_switching ();
>
> +  /* LRA removes all REG_DEAD/REG_UNUSED notes and normally they
> +     reappear in the IL only at the start of pass_rtl_dse2, which does
> +     df_note_add_problem (); df_analyze ();
> +     The vzeroupper is scheduled after postreload_cse pass and mode
> +     switching computes the notes as well, the problem is that e.g.
> +     pass_gcse2 doesn't maintain the notes, see PR113059 and
> +     PR112760.  Remove the notes now to restore status quo ante
> +     until we figure out how to maintain the notes or what else
> +     to do.  */
> +  basic_block bb;
> +  rtx_insn *insn;
> +  FOR_EACH_BB_FN (bb, cfun)
> +    FOR_BB_INSNS (bb, insn)
> +      if (NONDEBUG_INSN_P (insn))
> +       {
> +         rtx *pnote = &REG_NOTES (insn);
> +         while (*pnote != 0)
> +           {
> +             if (REG_NOTE_KIND (*pnote) == REG_DEAD
> +                 || REG_NOTE_KIND (*pnote) == REG_UNUSED)
> +               *pnote = XEXP (*pnote, 1);
> +             else
> +               pnote = &XEXP (*pnote, 1);
> +           }
> +       }
> +
>    df_analyze ();
>    return 0;
>  }
>
>         Jakub
>

      reply	other threads:[~2024-02-05  8:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-31  8:23 Jakub Jelinek
2024-02-05  8:08 ` Uros Bizjak [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFULd4ZA_ZY2JokdURCJv4cXp-J4Wv11Hg2jqRNUvxHmh2RabQ@mail.gmail.com \
    --to=ubizjak@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).