From: Jeff Law <law@redhat.com>
To: Segher Boessenkool <segher@kernel.crashing.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
Richard Biener <rguenther@suse.de>,
Eric Botcazou <ebotcazou@adacore.com>,
gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Reenable CSE of non-volatile inline asm (PR rtl-optimization/63637)
Date: Thu, 15 Jan 2015 06:46:00 -0000 [thread overview]
Message-ID: <54B74AD9.4010905@redhat.com> (raw)
In-Reply-To: <20150114151906.GA21784@gate.crashing.org>
On 01/14/15 08:19, Segher Boessenkool wrote:
> "
> @findex clobber
> @item (clobber @var{x})
> Represents the storing or possible storing of an unpredictable,
> undescribed value into @var{x}, which must be a @code{reg},
> @code{scratch}, @code{parallel} or @code{mem} expression.
>
> [...]
>
> If @var{x} is @code{(mem:BLK (const_int 0))} or
> @code{(mem:BLK (scratch))}, it means that all memory
> locations must be presumed clobbered.
> "
>
> Note it doesn't mention reading memory.
The documentation is incomplete. The right thing to do is fix the
documentation and treat the "memory" tag appearing in the "clobber"
section as a read as well as a write.
It's lame, but the historical decision by RMS to put that tag into the
clobbers section is what it is. Don't get too hung up on it. RMS just
botched it.
>
> Now if we go back to my earlier quote:
>
> "
> If your assembler instructions access memory in an unpredictable
> fashion, add @samp{memory} to the list of clobbered registers.
Note "access" not "write".
This
> causes GCC to not keep memory values cached in registers across the
> assembler instruction and not optimize stores or loads to that memory.
> You also should add the @code{volatile} keyword if the memory
> affected is not listed in the inputs or outputs of the @code{asm}, as
> the @samp{memory} clobber does not count as a side-effect of the
> @code{asm}.
> "
>
> That last line means the compiler is free to delete a non-volatile
> asm with a memory clobber if that asm is not needed for dataflow. Or
> that is how I read it; it is trying to indicate that if you want to
> prevent the memory clobber from being deleted (together with the rest
> of the asm), you need to make the asm volatile.
>
> So as far as I can see the compiler can CSE two identical non-volatile
> asms with memory clobber just fine. Older GCC (I tried 4.7.2) does do
> this; current mainline doesn't. I think it should.
No, it should not CSE those two cases. That's simply wrong and if an
older version did that optimization, that's a bug.
jeff
next prev parent reply other threads:[~2015-01-15 5:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-13 16:22 Jakub Jelinek
2015-01-13 17:06 ` Segher Boessenkool
2015-01-13 20:02 ` Jeff Law
2015-01-13 20:29 ` Jakub Jelinek
2015-01-13 22:28 ` Jeff Law
2015-01-14 3:44 ` Segher Boessenkool
2015-01-14 6:52 ` Jeff Law
2015-01-14 15:40 ` Segher Boessenkool
2015-01-15 6:46 ` Jeff Law [this message]
2015-01-15 7:54 ` Richard Biener
2015-01-15 8:40 ` Jakub Jelinek
2015-01-15 8:43 ` Richard Biener
2015-01-15 9:50 ` Jakub Jelinek
2015-01-15 18:22 ` Jeff Law
2015-01-23 21:39 ` Richard Henderson
2015-01-23 22:53 ` Segher Boessenkool
2015-01-23 23:12 ` Jakub Jelinek
2015-01-24 7:23 ` Segher Boessenkool
2015-01-24 14:39 ` Richard Sandiford
2015-01-13 22:42 ` Segher Boessenkool
2015-01-14 0:40 ` Segher Boessenkool
2015-01-14 7:12 ` 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=54B74AD9.4010905@redhat.com \
--to=law@redhat.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
--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).