This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix simd attribute handling on aarch64 (version 2)
- From: Steve Ellcey <sellcey at marvell dot com>
- To: "richard dot sandiford at arm dot com" <richard dot sandiford at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "jakub at redhat dot com" <jakub at redhat dot com>, "Richard dot Earnshaw at arm dot com" <Richard dot Earnshaw at arm dot com>, "Szabolcs dot Nagy at arm dot com" <Szabolcs dot Nagy at arm dot com>
- Date: Tue, 30 Jul 2019 22:13:26 +0000
- Subject: Re: [PATCH] Fix simd attribute handling on aarch64 (version 2)
- Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=marvell.com;dmarc=pass action=none header.from=marvell.com;dkim=pass header.d=marvell.com;arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=194PosrX7fINNhEBHGfy7nvBTWNsLXmrwA9LiY9iveQ=; b=kSAD/a4Gbgfw9pMYxdursOq/p8adhQZqKnsNIGergBN+aFVUIx/hhN9HTjZuOfP78tezHbVQhQEEyK3BzVykwDkpkVLdgQOK+bfFbqCzCZ0WRxCTMoqRjo99Rls3MG0tE1pIOt9eISPS9lGHb69wYQ3O8I6yymMPXPjYd1IGL0eWCZdpHquI55ILhEZ66GQzCuiblSRrmfu3aQveycpQ4QgjRDKD9+0/SJxROTklFCE0nP6D+tcxfuvT798wnNC0QHKFHOIiDRt9joYS02q2KnvVjEjYGJ/olJHUvPoiTV7J6SbQtb0YEWQ6b+Mc7O6fO0K3VoY4YXk5ar02JiGPNg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JqiEGkiVwAzLrnwtAnE0XeqAM//otgv0VNXf5Ams8q3uCGf2diln7LL8g6ug4Ebgz45YQTcP+V7TXM5WaKrc7yuA+ObETcYYWozyXvr+QgiL6bLMK+0vyCb14shEaZ8Gd7PGZAKIiDkcMJjXy1YImMWrvif+T3jd0B/agrNCoGrfG1AE6ufTatO739szFDx3ODI7Dy2KSCaUMm3YAEuPRvC39mCPk9VAzr2S6i3+A/lqPru/w4KW05K+YVNrjGJLMe1Ci/CtlhUtvNtUy0UwXJc/qtuLybDjwBVJ8nIG7pOkv/SRbJPc4+y4ntibzPffz2pgPBYdBltTmdKAnyF9nQ==
- References: <97b75bf8798a32e72827a3d021c11fb42d984c8e.camel@marvell.com> <mpttvbj4wum.fsf@arm.com> <1e0390e6291b7d75a7b4acd30c55dd1e7721f14f.camel@marvell.com> <mpttvbhzxuh.fsf@arm.com> <769cba60a078a7188a4110547cb872e501397aa4.camel@marvell.com> <mptd0hrhcnn.fsf@arm.com>
On Tue, 2019-07-30 at 14:31 +0100, Richard Sandiford wrote:
>
> > -
> > - tree new_type = build_distinct_type_copy (TREE_TYPE (node-
> > >decl));
> > - TYPE_ARG_TYPES (new_type) = new_reversed;
>
> I think you still need this line, just applied to the existing type
> rather than a new one.
>
> > - TREE_TYPE (node->decl) = new_type;
> > -
> > adjustments.release ();
> > }
OK, I fixed that and retested with no regressions.
Steve Ellcey
sellcey@marvell.com
2019-07-30 Steve Ellcey <sellcey@marvell.com>
* omp-simd-clone.c (simd_clone_adjust_return_type): Remove call to
build_distinct_type_copy.
(simd_clone_adjust_argument_types): Ditto.
(simd_clone_adjust): Call build_distinct_type_copy here.
(expand_simd_clones): Ditto.
2019-07-30 Steve Ellcey <sellcey@marvell.com>
* gcc.target/aarch64/simd_pcs_attribute.c: New test.
* gcc.target/aarch64/simd_pcs_attribute-2.c: Ditto.
* gcc.target/aarch64/simd_pcs_attribute-3.c: Ditto.
diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index caa8da3cba5..c8c528471a3 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -498,7 +498,6 @@ simd_clone_adjust_return_type (struct cgraph_node *node)
/* Adjust the function return type. */
if (orig_rettype == void_type_node)
return NULL_TREE;
- TREE_TYPE (fndecl) = build_distinct_type_copy (TREE_TYPE (fndecl));
t = TREE_TYPE (TREE_TYPE (fndecl));
if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t))
veclen = node->simdclone->vecsize_int;
@@ -724,11 +723,7 @@ simd_clone_adjust_argument_types (struct cgraph_node *node)
else
new_reversed = void_list_node;
}
-
- tree new_type = build_distinct_type_copy (TREE_TYPE (node->decl));
- TYPE_ARG_TYPES (new_type) = new_reversed;
- TREE_TYPE (node->decl) = new_type;
-
+ TYPE_ARG_TYPES (TREE_TYPE (node->decl)) = new_reversed;
adjustments.release ();
}
args.release ();
@@ -1164,6 +1159,7 @@ simd_clone_adjust (struct cgraph_node *node)
{
push_cfun (DECL_STRUCT_FUNCTION (node->decl));
+ TREE_TYPE (node->decl) = build_distinct_type_copy (TREE_TYPE (node->decl));
targetm.simd_clone.adjust (node);
tree retval = simd_clone_adjust_return_type (node);
@@ -1737,6 +1733,8 @@ expand_simd_clones (struct cgraph_node *node)
simd_clone_adjust (n);
else
{
+ TREE_TYPE (n->decl)
+ = build_distinct_type_copy (TREE_TYPE (n->decl));
targetm.simd_clone.adjust (n);
simd_clone_adjust_return_type (n);
simd_clone_adjust_argument_types (n);
diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
index e69de29bb2d..8eec6824f37 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-2.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+__attribute__ ((__simd__ ("notinbranch")))
+__attribute__ ((__nothrow__ , __leaf__ , __const__))
+extern double foo (double x);
+
+void bar(double * f, int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ f[i] = foo(f[i]);
+}
+
+/* { dg-final { scan-assembler-not {\.variant_pcs\tfoo} } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_foo} 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
index e69de29bb2d..95f6a6803e8 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute-3.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+__attribute__ ((__simd__))
+__attribute__ ((__nothrow__ , __leaf__ , __const__))
+double foo (double x);
+
+void bar(double *f, int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ f[i] = foo(f[i]);
+}
+
+double foo(double x)
+{
+ return x * x / 3.0;
+}
+
+/* { dg-final { scan-assembler-not {\.variant_pcs\tfoo} } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM1v_foo} 1 } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnM2v_foo} 1 } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN1v_foo} 1 } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_foo} 1 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
index e69de29bb2d..eddcef3597c 100644
--- a/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
+++ b/gcc/testsuite/gcc.target/aarch64/simd_pcs_attribute.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast" } */
+
+__attribute__ ((__simd__ ("notinbranch")))
+__attribute__ ((__nothrow__ , __leaf__ , __const__))
+extern double log (double __x);
+
+void foo(double *f, int n)
+{
+ int i;
+ for (i = 0; i < n; i++)
+ f[i] = log(f[i]);
+}
+
+/* { dg-final { scan-assembler-not {\.variant_pcs\tlog} } } */
+/* { dg-final { scan-assembler-times {\.variant_pcs\t_ZGVnN2v_log} 1 } } */