public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Sandiford <richard.sandiford@arm.com>
To: Steve Ellcey <sellcey@marvell.com>
Cc: "gcc-patches\@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	 "Richard.Earnshaw\@arm.com" <Richard.Earnshaw@arm.com>,
	 "Szabolcs.Nagy\@arm.com" <Szabolcs.Nagy@arm.com>
Subject: Re: [PATCH] Fix simd attribute handling on aarch64
Date: Thu, 18 Jul 2019 09:22:00 -0000	[thread overview]
Message-ID: <mpttvbj4wum.fsf@arm.com> (raw)
In-Reply-To: <97b75bf8798a32e72827a3d021c11fb42d984c8e.camel@marvell.com>	(Steve Ellcey's message of "Wed, 17 Jul 2019 21:24:24 +0000")

Steve Ellcey <sellcey@marvell.com> writes:
> This patch fixes a bug with SIMD functions on Aarch64.  I found it
> while trying to run SPEC with ToT GCC and a glibc that defines vector
> math functions for aarch64.  When a function is declared with the simd
> attribute GCC creates vector clones of that function with the return
> and argument types changed to vector types.  On Aarch64 the vector
> clones are also marked with the aarch64_vector_pcs attribute to signify
> that they use an alternate calling convention.  Due to a bug in GCC the
> non-vector version of the function being cloned was also being marked
> with this attribute.
>
> Because simd_clone_adjust and expand_simd_clones are calling
> targetm.simd_clone.adjust (which attached the aarch64_vector_pcs
> attribute to the function type) before calling
> simd_clone_adjust_return_type (which created a new distinct type tree
> for the cloned function) the attribute got attached to both the
> 'normal' scalar version of the SIMD function and any vector versions of
> the function.  The attribute should only be on the vector versions.
>
> My fix is to call simd_clone_adjust_return_type and create the new type
> before calling targetm.simd_clone.adjust which adds the attribute.  The
> only other platform that this patch could affect is x86 because that is
> the only other platform to use targetm.simd_clone.adjust.  I did a
> bootstrap and gcc test run on x86 (as well as Aarch64) and got no
> regressions.
>
> OK to checkin?
>
> Steve Ellcey
> sellcey@marvell.com
>
>
> 2019-07-17  Steve Ellcey  <sellcey@marvell.com>
>
> 	* omp-simd-clone.c (simd_clone_adjust):  Call targetm.simd_clone.adjust
> 	after calling simd_clone_adjust_return_type.
> 	(expand_simd_clones): Ditto.

It should be pretty easy to add a test for this, now that we use
.variant_pcs to mark symbols with the attribute.

> diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
> index caa8da3cba5..6a6b439d146 100644
> --- a/gcc/omp-simd-clone.c
> +++ b/gcc/omp-simd-clone.c
> @@ -1164,9 +1164,8 @@ simd_clone_adjust (struct cgraph_node *node)
>  {
>    push_cfun (DECL_STRUCT_FUNCTION (node->decl));
>  
> -  targetm.simd_clone.adjust (node);
> -
>    tree retval = simd_clone_adjust_return_type (node);
> +  targetm.simd_clone.adjust (node);
>    ipa_parm_adjustment_vec adjustments
>      = simd_clone_adjust_argument_types (node);
>  
> @@ -1737,8 +1736,8 @@ expand_simd_clones (struct cgraph_node *node)
>  	    simd_clone_adjust (n);
>  	  else
>  	    {
> -	      targetm.simd_clone.adjust (n);
>  	      simd_clone_adjust_return_type (n);
> +	      targetm.simd_clone.adjust (n);
>  	      simd_clone_adjust_argument_types (n);
>  	    }
>  	}

I don't think this is enough, since simd_clone_adjust_return_type
does nothing for functions that return void (e.g. sincos).
I think instead aarch64_simd_clone_adjust should do something like:

  TREE_TYPE (node->decl) = build_distinct_type_copy (TREE_TYPE (node->decl));

But maybe that has consequences that I've not thought about...

Thanks,
Richard

  reply	other threads:[~2019-07-18  7:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17 21:29 Steve Ellcey
2019-07-18  9:22 ` Richard Sandiford [this message]
2019-07-18 16:04   ` Steve Ellcey
2019-07-19 15:57   ` [PATCH] Fix simd attribute handling on aarch64 (version 2) Steve Ellcey
2019-07-19 18:26     ` Richard Sandiford
2019-07-22 18:26       ` Steve Ellcey
2019-07-29 23:00         ` Steve Ellcey
2019-07-30 13:35         ` Richard Sandiford
2019-07-30 22:14           ` Steve Ellcey
2019-07-31  7:34             ` Richard Sandiford
2019-08-07 10:51               ` Szabolcs Nagy
2019-08-07 18:16                 ` Steve Ellcey

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=mpttvbj4wum.fsf@arm.com \
    --to=richard.sandiford@arm.com \
    --cc=Richard.Earnshaw@arm.com \
    --cc=Szabolcs.Nagy@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=sellcey@marvell.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).