public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Fix pure/const function attributes for intrinsics
@ 2022-06-30 16:03 Andrew Carlotti
  2022-07-01  6:42 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Carlotti @ 2022-06-30 16:03 UTC (permalink / raw)
  To: gcc-patches

No testcase for this, since I haven't found a way to turn the incorrect
attribute into incorrect codegen.

Bootstrapped and tested on aarch64-none-linux gnu.

gcc/

	* config/aarch64/aarch64-builtins.c
	(aarch64_get_attributes): Fix choice of pure/const attributes.

---

diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index e0a741ac663188713e21f457affa57217d074783..877f54aab787862794413259cd36ca0fb7bd49c5 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1085,9 +1085,9 @@ aarch64_get_attributes (unsigned int f, machine_mode mode)
   if (!aarch64_modifies_global_state_p (f, mode))
     {
       if (aarch64_reads_global_state_p (f, mode))
-       attrs = aarch64_add_attribute ("pure", attrs);
-      else
        attrs = aarch64_add_attribute ("const", attrs);
+      else
+       attrs = aarch64_add_attribute ("pure", attrs);
     }

   if (!flag_non_call_exceptions || !aarch64_could_trap_p (f, mode))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aarch64: Fix pure/const function attributes for intrinsics
  2022-06-30 16:03 [PATCH] aarch64: Fix pure/const function attributes for intrinsics Andrew Carlotti
@ 2022-07-01  6:42 ` Richard Biener
  2022-07-01 15:59   ` Andrew Carlotti
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2022-07-01  6:42 UTC (permalink / raw)
  To: Andrew Carlotti; +Cc: gcc-patches

On Thu, Jun 30, 2022 at 6:04 PM Andrew Carlotti via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> No testcase for this, since I haven't found a way to turn the incorrect
> attribute into incorrect codegen.
>
> Bootstrapped and tested on aarch64-none-linux gnu.
>
> gcc/
>
>         * config/aarch64/aarch64-builtins.c
>         (aarch64_get_attributes): Fix choice of pure/const attributes.
>
> ---
>
> diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> index e0a741ac663188713e21f457affa57217d074783..877f54aab787862794413259cd36ca0fb7bd49c5 100644
> --- a/gcc/config/aarch64/aarch64-builtins.cc
> +++ b/gcc/config/aarch64/aarch64-builtins.cc
> @@ -1085,9 +1085,9 @@ aarch64_get_attributes (unsigned int f, machine_mode mode)
>    if (!aarch64_modifies_global_state_p (f, mode))
>      {
>        if (aarch64_reads_global_state_p (f, mode))
> -       attrs = aarch64_add_attribute ("pure", attrs);
> -      else
>         attrs = aarch64_add_attribute ("const", attrs);
> +      else
> +       attrs = aarch64_add_attribute ("pure", attrs);

that looks backwards.  'pure' allows read of global memory while
'const' does not.  Is
aarch64_reads_global_state_p really backwards?

>      }
>
>    if (!flag_non_call_exceptions || !aarch64_could_trap_p (f, mode))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aarch64: Fix pure/const function attributes for intrinsics
  2022-07-01  6:42 ` Richard Biener
@ 2022-07-01 15:59   ` Andrew Carlotti
  2022-07-04  6:49     ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Carlotti @ 2022-07-01 15:59 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Fri, Jul 01, 2022 at 08:42:15AM +0200, Richard Biener wrote:
> On Thu, Jun 30, 2022 at 6:04 PM Andrew Carlotti via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> > diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> > index e0a741ac663188713e21f457affa57217d074783..877f54aab787862794413259cd36ca0fb7bd49c5 100644
> > --- a/gcc/config/aarch64/aarch64-builtins.cc
> > +++ b/gcc/config/aarch64/aarch64-builtins.cc
> > @@ -1085,9 +1085,9 @@ aarch64_get_attributes (unsigned int f, machine_mode mode)
> >    if (!aarch64_modifies_global_state_p (f, mode))
> >      {
> >        if (aarch64_reads_global_state_p (f, mode))
> > -       attrs = aarch64_add_attribute ("pure", attrs);
> > -      else
> >         attrs = aarch64_add_attribute ("const", attrs);
> > +      else
> > +       attrs = aarch64_add_attribute ("pure", attrs);
> 
> that looks backwards.  'pure' allows read of global memory while
> 'const' does not.  Is
> aarch64_reads_global_state_p really backwards?

Oh - the thing that's backwards is my understanding of what "pure" and
"const" mean. Their meanings as GCC function attributes seem to be
approximately the opposite way round to their meanings in general usage.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] aarch64: Fix pure/const function attributes for intrinsics
  2022-07-01 15:59   ` Andrew Carlotti
@ 2022-07-04  6:49     ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2022-07-04  6:49 UTC (permalink / raw)
  To: Andrew Carlotti; +Cc: gcc-patches

On Fri, Jul 1, 2022 at 5:59 PM Andrew Carlotti <andrew.carlotti@arm.com> wrote:
>
> On Fri, Jul 01, 2022 at 08:42:15AM +0200, Richard Biener wrote:
> > On Thu, Jun 30, 2022 at 6:04 PM Andrew Carlotti via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> > > diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> > > index e0a741ac663188713e21f457affa57217d074783..877f54aab787862794413259cd36ca0fb7bd49c5 100644
> > > --- a/gcc/config/aarch64/aarch64-builtins.cc
> > > +++ b/gcc/config/aarch64/aarch64-builtins.cc
> > > @@ -1085,9 +1085,9 @@ aarch64_get_attributes (unsigned int f, machine_mode mode)
> > >    if (!aarch64_modifies_global_state_p (f, mode))
> > >      {
> > >        if (aarch64_reads_global_state_p (f, mode))
> > > -       attrs = aarch64_add_attribute ("pure", attrs);
> > > -      else
> > >         attrs = aarch64_add_attribute ("const", attrs);
> > > +      else
> > > +       attrs = aarch64_add_attribute ("pure", attrs);
> >
> > that looks backwards.  'pure' allows read of global memory while
> > 'const' does not.  Is
> > aarch64_reads_global_state_p really backwards?
>
> Oh - the thing that's backwards is my understanding of what "pure" and
> "const" mean. Their meanings as GCC function attributes seem to be
> approximately the opposite way round to their meanings in general usage.

I bet GCCs reading is older ;)

Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-04  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-30 16:03 [PATCH] aarch64: Fix pure/const function attributes for intrinsics Andrew Carlotti
2022-07-01  6:42 ` Richard Biener
2022-07-01 15:59   ` Andrew Carlotti
2022-07-04  6:49     ` Richard Biener

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).