public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Manolis Tsamis <manolis.tsamis@vrull.eu>
Cc: gcc-patches@gcc.gnu.org, "Richard Biener" <rguenther@suse.de>,
	"Philipp Tomsich" <philipp.tomsich@vrull.eu>,
	"Christoph Müllner" <christoph.muellner@vrull.eu>,
	"Jiangning Liu" <jiangning.liu@amperecomputing.com>,
	"Jakub Jelinek" <jakub@redhat.com>,
	"Andrew Pinski" <quic_apinski@quicinc.com>
Subject: Re: [PATCH v2] Target-independent store forwarding avoidance.
Date: Mon, 10 Jun 2024 12:03:14 -0600	[thread overview]
Message-ID: <264e248d-cb54-4d3d-860d-193fd7be1049@gmail.com> (raw)
In-Reply-To: <CAM3yNXp9qnJTzgL6+81Sc+2g=EmKnCW1XReqaGgy-5D43BmKDA@mail.gmail.com>



On 6/10/24 1:55 AM, Manolis Tsamis wrote:

>>
> There was an older submission of a load-pair specific pass but this is
> a complete reimplementation and indeed significantly more general.
> Apart from being target independant, it addresses a number of
> important restrictions and can handle multiple store forwardings per
> load.
> It should be noted that it cannot handle the load-pair cases as these
> need special handling, but that's something we're planning to do in
> the future by reusing this infrastructure.
ACK.  Thanks for the additional background.


> 
>>
>>> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
>>> index 4e8967fd8ab..c769744d178 100644
>>> --- a/gcc/doc/invoke.texi
>>> +++ b/gcc/doc/invoke.texi
>>> @@ -12657,6 +12657,15 @@ loop unrolling.
>>>    This option is enabled by default at optimization levels @option{-O1},
>>>    @option{-O2}, @option{-O3}, @option{-Os}.
>>>
>>> +@opindex favoid-store-forwarding
>>> +@item -favoid-store-forwarding
>>> +@itemx -fno-avoid-store-forwarding
>>> +Many CPUs will stall for many cycles when a load partially depends on previous
>>> +smaller stores.  This pass tries to detect such cases and avoid the penalty by
>>> +changing the order of the load and store and then fixing up the loaded value.
>>> +
>>> +Disabled by default.
>> Is there any particular reason why this would be off by default at -O1
>> or higher?  It would seem to me that on modern cores that this
>> transformation should easily be a win.  Even on an old in-order core,
>> avoiding the load with the bit insert is likely profitable, just not as
>> much so.
>>
> I don't have a strong opinion for that but I believe Richard's
> suggestion to decide this on a per-target basis also makes a lot of
> sense.
> Deciding whether the transformation is profitable is tightly tied to
> the architecture in question (i.e. how large the stall is and what
> sort of bit-insert instructions are available).
> In order to make this more widely applicable, I think we'll need a
> target hook that decides in which case the forwarded stores incur a
> penalty and thus the transformation makes sense.
You and Richi are probably right.   I'm not a big fan of passes being 
enabled/disabled on particular targets, but it may make sense here.



> Afaik, for each CPU there may be cases that store forwarding is
> handled efficiently.
Absolutely.   But forwarding from a smaller store to a wider load is 
painful from a hardware standpoint and if we can avoid it from a codegen 
standpoint, we should.

Did y'all look at spec2017 at all for this patch?  I've got our hardware 
guys to expose a signal for this case so that we can (in a month or so) 
get some hard data on how often it's happening in spec2017 and evaluate 
how this patch helps the most affected workloads.  But if y'all already 
have some data we can use it as a starting point.

jeff

  reply	other threads:[~2024-06-10 18:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 10:10 Manolis Tsamis
2024-06-07 22:31 ` Jeff Law
2024-06-09 14:29   ` Jeff Law
2024-06-10  8:03     ` Manolis Tsamis
2024-06-13 11:40     ` Manolis Tsamis
2024-06-13 13:59       ` Jeff Law
2024-06-10  6:26   ` Richard Biener
2024-06-10  7:55   ` Manolis Tsamis
2024-06-10 18:03     ` Jeff Law [this message]
2024-06-10 18:27       ` Philipp Tomsich
2024-06-10 18:37         ` Jeff Law
2024-06-12 13:02         ` Manolis Tsamis
2024-06-11  7:22       ` Richard Biener
2024-06-11 13:37         ` Jeff Law
2024-06-11 13:52           ` Philipp Tomsich
2024-06-11 14:18             ` Jeff Law
2024-06-12  6:47               ` Richard Biener
2024-06-12 14:18                 ` Jeff Law

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=264e248d-cb54-4d3d-860d-193fd7be1049@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=christoph.muellner@vrull.eu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jiangning.liu@amperecomputing.com \
    --cc=manolis.tsamis@vrull.eu \
    --cc=philipp.tomsich@vrull.eu \
    --cc=quic_apinski@quicinc.com \
    --cc=rguenther@suse.de \
    /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).