public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Alex Coplan <alex.coplan@arm.com>
Cc: gcc-patches@gcc.gnu.org,
	 Richard Earnshaw <richard.earnshaw@arm.com>,
	 Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Subject: Re: [PATCH] aarch64: Don't record hazards against paired insns [PR113356]
Date: Mon, 22 Jan 2024 16:05:59 +0000	[thread overview]
Message-ID: <mptwms1nyjc.fsf@arm.com> (raw)
In-Reply-To: <ZaVAeoKV0dHc6Wk1@arm.com> (Alex Coplan's message of "Mon, 15 Jan 2024 14:26:02 +0000")

Alex Coplan <alex.coplan@arm.com> writes:
> Hi,
>
> For the testcase in the PR, we try to pair insns where the first has
> writeback and the second uses the updated base register.  This causes us
> to record a hazard against the second insn, thus narrowing the move
> range away from the end of the BB.
>
> However, it isn't meaningful to record hazards against the other insn
> in the pair, as this doesn't change which pairs can be formed, and also
> doesn't change where the pair is formed (from the perspective of
> nondebug insns).
>
> To see why this is the case, consider the two cases:
>
>  - Suppoe we are finding hazards for insns[0].  If we record a hazard
>    against insns[1], then range.last becomes
>    insns[1]->prev_nondebug_insn (), but note that this is equivalent to
>    inserting after insns[1] (since insns[1] is being changed).
>  - Now consider finding hazards for insns[1].  Suppose we record
>    insns[0] as a hazard.  Then we set range.first = insns[0], which is a
>    no-op.
>
> As such, it seems better to never record hazards against the other insn
> in the pair, as we check whether the insns themselves are suitable for
> combination separately (e.g. for ldp checking that they use distinct
> transfer registers).  Avoiding unnecessarily narrowing the move range
> avoids unnecessarily re-ordering over debug insns.
>
> This should also mean that we can only narrow the move range away from
> the end of the BB in the case that we record a hazard for insns[0]
> against insns[1]->prev_nondebug_insn () or earlier.  This means that for
> the non-call-exceptions case, either the move range includes insns[1],
> or we reject the pair (thus the assert tripped in the PR should always
> hold).
>
> Bootstrapped/regtested on aarch64-linux-gnu with/without ldp passes
> enabled on top of the PR113070 fixes, OK for trunk?
>
> Thanks,
> Alex
>
> gcc/ChangeLog:
>
> 	PR target/113356
> 	* config/aarch64/aarch64-ldp-fusion.cc (ldp_bb_info::try_fuse_pair):
> 	Don't record hazards against the opposite insn in the pair.
>
> gcc/testsuite/ChangeLog:
>
> 	PR target/113356
> 	* gcc.target/aarch64/pr113356.C: New test.

OK, thanks.

Richard

      reply	other threads:[~2024-01-22 16:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15 14:26 Alex Coplan
2024-01-22 16:05 ` Richard Sandiford [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=mptwms1nyjc.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=alex.coplan@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=kyrylo.tkachov@arm.com \
    --cc=richard.earnshaw@arm.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).