AArch64 fix ls64 intrinsics expansion [PR104409]

Message ID VI1PR08MB5325A26C2D253A9C12AD7526FFE69@VI1PR08MB5325.eurprd08.prod.outlook.com
State Committed
Commit af3cadb59fe6cb2097d2e636c1c70b26df39ae19
Headers
Series AArch64 fix ls64 intrinsics expansion [PR104409] |

Commit Message

Tamar Christina April 7, 2022, 3:04 p.m. UTC
  Hi All,

The LS64 intrinsics used a machinery that's not safe to use unless being
called from a pragma instantiation.

This moves the initialization code to a new pragma for arm_acle.h.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

I didn't add the testcase from the PR as it's 65kb but valgrind shows the memory
error is gone.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	PR target/104409
	* config/aarch64/aarch64-builtins.cc (handle_arm_acle_h): New.
	(aarch64_general_init_builtins): Move LS64 code.
	* config/aarch64/aarch64-c.cc (aarch64_pragma_aarch64): Support
	arm_acle.h
	* config/aarch64/aarch64-protos.h (handle_arm_acle_h): New.
	* config/aarch64/arm_acle.h: Add pragma GCC aarch64 "arm_acle.h".

--- inline copy of patch -- 
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index 5217dbdb2ac78bba0a669d22af6d769d1fe91a3d..65d09afc008b891d8b67a443140b4157cfa84c44 100644


--
diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
index 5217dbdb2ac78bba0a669d22af6d769d1fe91a3d..65d09afc008b891d8b67a443140b4157cfa84c44 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1641,6 +1641,14 @@ aarch64_init_ls64_builtins (void)
       = aarch64_general_add_builtin (data[i].name, data[i].type, data[i].code);
 }
 
+/* Implement #pragma GCC aarch64 "arm_acle.h".  */
+void
+handle_arm_acle_h (void)
+{
+  if (TARGET_LS64)
+    aarch64_init_ls64_builtins ();
+}
+
 /* Initialize fpsr fpcr getters and setters.  */
 
 static void
@@ -1730,9 +1738,6 @@ aarch64_general_init_builtins (void)
 
   if (TARGET_MEMTAG)
     aarch64_init_memtag_builtins ();
-
-  if (TARGET_LS64)
-    aarch64_init_ls64_builtins ();
 }
 
 /* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group.  */
diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
index caf8e332ea0da0a34f4e96f12a934a5eaeaa1fb2..767ee0c763c56a022089a647c7425afb00644644 100644
--- a/gcc/config/aarch64/aarch64-c.cc
+++ b/gcc/config/aarch64/aarch64-c.cc
@@ -302,6 +302,8 @@ aarch64_pragma_aarch64 (cpp_reader *)
     aarch64_sve::handle_arm_sve_h ();
   else if (strcmp (name, "arm_neon.h") == 0)
     handle_arm_neon_h ();
+  else if (strcmp (name, "arm_acle.h") == 0)
+    handle_arm_acle_h ();
   else
     error ("unknown %<#pragma GCC aarch64%> option %qs", name);
 }
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 46bade28ed6056bea90067d3af1311f300cea559..c478bb59ae1208329facc74200fe98d00bf93f7c 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -982,6 +982,7 @@ rtx aarch64_general_expand_builtin (unsigned int, tree, rtx, int);
 tree aarch64_general_builtin_decl (unsigned, bool);
 tree aarch64_general_builtin_rsqrt (unsigned int);
 tree aarch64_builtin_vectorized_function (unsigned int, tree, tree);
+void handle_arm_acle_h (void);
 void handle_arm_neon_h (void);
 
 namespace aarch64_sve {
diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h
index ecd852f8a46d87787912e6573bf363619812e48f..9775a48c65825b424d3eb442384f5ab87b734fd7 100644
--- a/gcc/config/aarch64/arm_acle.h
+++ b/gcc/config/aarch64/arm_acle.h
@@ -29,6 +29,8 @@
 
 #include <stdint.h>
 
+#pragma GCC aarch64 "arm_acle.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
  

Comments

Richard Sandiford April 7, 2022, 3:17 p.m. UTC | #1
Tamar Christina <Tamar.Christina@arm.com> writes:
> Hi All,
>
> The LS64 intrinsics used a machinery that's not safe to use unless being
> called from a pragma instantiation.
>
> This moves the initialization code to a new pragma for arm_acle.h.
>
> Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.
>
> I didn't add the testcase from the PR as it's 65kb but valgrind shows the memory
> error is gone.
>
> Ok for master?

OK, thanks.

Richard

>
> Thanks,
> Tamar
>
> gcc/ChangeLog:
>
>         PR target/104409
>         * config/aarch64/aarch64-builtins.cc (handle_arm_acle_h): New.
>         (aarch64_general_init_builtins): Move LS64 code.
>         * config/aarch64/aarch64-c.cc (aarch64_pragma_aarch64): Support
>         arm_acle.h
>         * config/aarch64/aarch64-protos.h (handle_arm_acle_h): New.
>         * config/aarch64/arm_acle.h: Add pragma GCC aarch64 "arm_acle.h".
>
> --- inline copy of patch --
> diff --git a/gcc/config/aarch64/aarch64-builtins.cc b/gcc/config/aarch64/aarch64-builtins.cc
> index 5217dbdb2ac78bba0a669d22af6d769d1fe91a3d..65d09afc008b891d8b67a443140b4157cfa84c44 100644
> --- a/gcc/config/aarch64/aarch64-builtins.cc
> +++ b/gcc/config/aarch64/aarch64-builtins.cc
> @@ -1641,6 +1641,14 @@ aarch64_init_ls64_builtins (void)
>        = aarch64_general_add_builtin (data[i].name, data[i].type, data[i].code);
>  }
>
> +/* Implement #pragma GCC aarch64 "arm_acle.h".  */
> +void
> +handle_arm_acle_h (void)
> +{
> +  if (TARGET_LS64)
> +    aarch64_init_ls64_builtins ();
> +}
> +
>  /* Initialize fpsr fpcr getters and setters.  */
>
>  static void
> @@ -1730,9 +1738,6 @@ aarch64_general_init_builtins (void)
>
>    if (TARGET_MEMTAG)
>      aarch64_init_memtag_builtins ();
> -
> -  if (TARGET_LS64)
> -    aarch64_init_ls64_builtins ();
>  }
>
>  /* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group.  */
> diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
> index caf8e332ea0da0a34f4e96f12a934a5eaeaa1fb2..767ee0c763c56a022089a647c7425afb00644644 100644
> --- a/gcc/config/aarch64/aarch64-c.cc
> +++ b/gcc/config/aarch64/aarch64-c.cc
> @@ -302,6 +302,8 @@ aarch64_pragma_aarch64 (cpp_reader *)
>      aarch64_sve::handle_arm_sve_h ();
>    else if (strcmp (name, "arm_neon.h") == 0)
>      handle_arm_neon_h ();
> +  else if (strcmp (name, "arm_acle.h") == 0)
> +    handle_arm_acle_h ();
>    else
>      error ("unknown %<#pragma GCC aarch64%> option %qs", name);
>  }
> diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
> index 46bade28ed6056bea90067d3af1311f300cea559..c478bb59ae1208329facc74200fe98d00bf93f7c 100644
> --- a/gcc/config/aarch64/aarch64-protos.h
> +++ b/gcc/config/aarch64/aarch64-protos.h
> @@ -982,6 +982,7 @@ rtx aarch64_general_expand_builtin (unsigned int, tree, rtx, int);
>  tree aarch64_general_builtin_decl (unsigned, bool);
>  tree aarch64_general_builtin_rsqrt (unsigned int);
>  tree aarch64_builtin_vectorized_function (unsigned int, tree, tree);
> +void handle_arm_acle_h (void);
>  void handle_arm_neon_h (void);
>
>  namespace aarch64_sve {
> diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h
> index ecd852f8a46d87787912e6573bf363619812e48f..9775a48c65825b424d3eb442384f5ab87b734fd7 100644
> --- a/gcc/config/aarch64/arm_acle.h
> +++ b/gcc/config/aarch64/arm_acle.h
> @@ -29,6 +29,8 @@
>
>  #include <stdint.h>
>
> +#pragma GCC aarch64 "arm_acle.h"
> +
>  #ifdef __cplusplus
>  extern "C" {
>  #endif
>
>
> --
  

Patch

--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1641,6 +1641,14 @@  aarch64_init_ls64_builtins (void)
       = aarch64_general_add_builtin (data[i].name, data[i].type, data[i].code);
 }
 
+/* Implement #pragma GCC aarch64 "arm_acle.h".  */
+void
+handle_arm_acle_h (void)
+{
+  if (TARGET_LS64)
+    aarch64_init_ls64_builtins ();
+}
+
 /* Initialize fpsr fpcr getters and setters.  */
 
 static void
@@ -1730,9 +1738,6 @@  aarch64_general_init_builtins (void)
 
   if (TARGET_MEMTAG)
     aarch64_init_memtag_builtins ();
-
-  if (TARGET_LS64)
-    aarch64_init_ls64_builtins ();
 }
 
 /* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group.  */
diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
index caf8e332ea0da0a34f4e96f12a934a5eaeaa1fb2..767ee0c763c56a022089a647c7425afb00644644 100644
--- a/gcc/config/aarch64/aarch64-c.cc
+++ b/gcc/config/aarch64/aarch64-c.cc
@@ -302,6 +302,8 @@  aarch64_pragma_aarch64 (cpp_reader *)
     aarch64_sve::handle_arm_sve_h ();
   else if (strcmp (name, "arm_neon.h") == 0)
     handle_arm_neon_h ();
+  else if (strcmp (name, "arm_acle.h") == 0)
+    handle_arm_acle_h ();
   else
     error ("unknown %<#pragma GCC aarch64%> option %qs", name);
 }
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 46bade28ed6056bea90067d3af1311f300cea559..c478bb59ae1208329facc74200fe98d00bf93f7c 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -982,6 +982,7 @@  rtx aarch64_general_expand_builtin (unsigned int, tree, rtx, int);
 tree aarch64_general_builtin_decl (unsigned, bool);
 tree aarch64_general_builtin_rsqrt (unsigned int);
 tree aarch64_builtin_vectorized_function (unsigned int, tree, tree);
+void handle_arm_acle_h (void);
 void handle_arm_neon_h (void);
 
 namespace aarch64_sve {
diff --git a/gcc/config/aarch64/arm_acle.h b/gcc/config/aarch64/arm_acle.h
index ecd852f8a46d87787912e6573bf363619812e48f..9775a48c65825b424d3eb442384f5ab87b734fd7 100644
--- a/gcc/config/aarch64/arm_acle.h
+++ b/gcc/config/aarch64/arm_acle.h
@@ -29,6 +29,8 @@ 
 
 #include <stdint.h>
 
+#pragma GCC aarch64 "arm_acle.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif