From: Richard Biener <richard.guenther@gmail.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Richard Biener <rguenther@suse.de>,
Jiufu Guo <guojiufu@linux.ibm.com>,
gcc-patches@gcc.gnu.org, dje.gcc@gmail.com, linkw@gcc.gnu.org,
bergner@linux.ibm.com, richard.sandiford@arm.com,
jeffreyalaw@gmail.com
Subject: Re: [PATCH] rs6000: replace '(const_int 0)' to 'unspec:BLK [(const_int 0)]' for stack_tie
Date: Wed, 14 Jun 2023 18:25:10 +0200 [thread overview]
Message-ID: <DFAECB77-037A-496B-806D-84369AB93266@gmail.com> (raw)
In-Reply-To: <20230614153816.GX19790@gate.crashing.org>
> Am 14.06.2023 um 17:41 schrieb Segher Boessenkool <segher@kernel.crashing.org>:
>
> Hi!
>
>> On Wed, Jun 14, 2023 at 07:59:04AM +0000, Richard Biener wrote:
>>> On Wed, 14 Jun 2023, Jiufu Guo wrote:
>>> 3. "set (mem/c:DI (reg/f:DI 1 1) unspec:DI (const_int 0 [0])
>>> UNSPEC_TIE".
>>> This avoids using BLK on unspec, but using DI.
>>
>> That gives the MEM a size which means we can interpret the (set ..)
>> as killing a specific area of memory, enabling DSE of earlier
>> stores.
>
> Or DSE can delete this tie even, if it can see some later store to the
> same location without anything in between that can read what the tie
> stores.
>
> BLKmode avoids all of this. You can call that elegant, you can call it
> cheating, you can call it many things -- but it *works*.
>
>> AFAIU this special instruction is only supposed to prevent
>> code motion (of stack memory accesses?) across this instruction?
>
> Form rs6000.md:
> ; This is to explain that changes to the stack pointer should
> ; not be moved over loads from or stores to stack memory.
> (define_insn "stack_tie"
That suggests it’s the hard register value that‘s protected, not the memory pointed to. I suppose that means an unspec volatile with the reg as input would serve the same?
Or maybe that’s not the whole story.
> and from rs6000-logue.cc:
> /* This ties together stack memory (MEM with an alias set of frame_alias_set)
> and the change to the stack pointer. */
> static void
> rs6000_emit_stack_tie (rtx fp, bool hard_frame_needed)
I cannot make sense of that comment, but not sure if I really want to know …
> A big reason this is needed is because of all the hard frame pointer
> stuff, which the generic parts of GCC require, but there is no register
> for that in the Power architecture. Nothing is an issue here in most
> cases, but sometimes we need to do unusual things to the stack, say for
> alloca.
>
>> I'd say a
>>
>> (may_clobber (mem:BLK (reg:DI 1 1)))
>
> "clobber" always means "may clobber". (clobber X) means X is written
> with some unspecified value, which may well be whatever value it
> currently holds. Via some magical means or whatever, there is no
> mechanism specified, just the effects :-)
>
>> might be more to the point? I've used "may_clobber" which doesn't
>> exist since I'm not sure whether a clobber is considered a kill.
>> The docs say "Represents the storing or possible storing of an
>> unpredictable..." - what is it? Storing or possible storing?
>
> It is the same thing. "clobber" means the same thing as "set", except
> the value that is written is not specified.
>
>> I suppose stack_tie should be less strict than the documented
>> (clobber (mem:BLK (const_int 0))) (clobber all memory).
>
> "clobber" is nicer than the set to (const_int 0). Does it work though?
> All this code is always fragile :-/ I'm all for this change, don't get
> me wrong, but preferably things stay in working order.
>
> We use "stack_tie" as a last resort heavy hammer anyway, in all normal
> cases we explain the actual data flow explicitly and correctly, also
> between the various registers used in the *logues.
>
>
> Segher
next prev parent reply other threads:[~2023-06-14 16:25 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-13 12:23 Jiufu Guo
2023-06-13 12:48 ` Xi Ruoyao
2023-06-14 1:55 ` Jiufu Guo
2023-06-14 9:18 ` Xi Ruoyao
2023-06-14 15:05 ` Segher Boessenkool
2023-06-15 7:59 ` Jiufu Guo
2023-06-13 18:33 ` Segher Boessenkool
2023-06-14 4:06 ` Jiufu Guo
2023-06-14 7:59 ` Richard Biener
2023-06-14 9:04 ` Richard Sandiford
2023-06-14 9:22 ` Richard Biener
2023-06-14 9:43 ` Richard Sandiford
2023-06-14 9:52 ` Richard Biener
2023-06-14 10:02 ` Richard Sandiford
2023-06-14 16:08 ` Segher Boessenkool
2023-06-14 16:32 ` Segher Boessenkool
2023-06-14 9:29 ` Jiufu Guo
2023-06-14 16:38 ` Segher Boessenkool
2023-06-14 9:26 ` Jiufu Guo
2023-06-14 15:45 ` Segher Boessenkool
2023-06-14 15:38 ` Segher Boessenkool
2023-06-14 16:25 ` Richard Biener [this message]
2023-06-14 17:03 ` Segher Boessenkool
2023-06-14 15:15 ` Segher Boessenkool
2023-06-15 7:00 ` Jiufu Guo
2023-06-15 16:30 ` Segher Boessenkool
2023-06-16 2:24 ` Jiufu Guo
-- strict thread matches above, loose matches on Subject: below --
2023-06-12 13:19 Jiufu Guo
2023-06-13 0:24 ` David Edelsohn
2023-06-13 2:15 ` Jiufu Guo
2023-06-13 18:14 ` Segher Boessenkool
2023-06-13 18:59 ` David Edelsohn
2023-06-14 3:00 ` Jiufu Guo
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=DFAECB77-037A-496B-806D-84369AB93266@gmail.com \
--to=richard.guenther@gmail.com \
--cc=bergner@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guojiufu@linux.ibm.com \
--cc=jeffreyalaw@gmail.com \
--cc=linkw@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=richard.sandiford@arm.com \
--cc=segher@kernel.crashing.org \
/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).