public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix simd attribute handling on aarch64
@ 2019-07-17 21:29 Steve Ellcey
  2019-07-18  9:22 ` Richard Sandiford
  0 siblings, 1 reply; 12+ messages in thread
From: Steve Ellcey @ 2019-07-17 21:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard.Earnshaw, richard.sandiford, Szabolcs.Nagy

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.


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);
 	    }
 	}



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

end of thread, other threads:[~2019-08-07 17:20 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 21:29 [PATCH] Fix simd attribute handling on aarch64 Steve Ellcey
2019-07-18  9:22 ` Richard Sandiford
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

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