]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[arm] Fix use of CRC32 intrinsics with Armv8-a and hard-float
authorktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Aug 2019 15:55:39 +0000 (15:55 +0000)
committerktkachov <ktkachov@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 22 Aug 2019 15:55:39 +0000 (15:55 +0000)
We currently have a nasty error when trying to use the __crc* intrinsics
with an -mfloat-abi=hard.
That is because the target pragma guarding them uses armv8-a+crc that
does not include fp by default.
So we get errors like:
error: '-mfloat-abi=hard': selected processor lacks an FPU

This patch fixes that by using an FP-enabled arch target pragma to guard
these intrinsics when floating-point is available.
That way both the softfloat and hardfloat variants work.

     * config/arm/arm_acle.h: Use arch=armv8-a+crc+simd pragma for CRC32
     intrinsics if __ARM_FP.
     Use __ARM_FEATURE_CRC32 ifdef guard.

     * gcc.target/arm/acle/crc_hf_1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274827 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/arm/arm_acle.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c [new file with mode: 0644]

index 8984d0e566bd27b081d7058717df1e68f65ce3de..2e58369b6142d7071f125337f8c01b3dd8c4e201 100644 (file)
@@ -1,3 +1,9 @@
+2019-08-22  Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+       * config/arm/arm_acle.h: Use arch=armv8-a+crc+simd pragma for CRC32
+       intrinsics if __ARM_FP.
+       Use __ARM_FEATURE_CRC32 ifdef guard.
+
 2019-08-22  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * config/arm/arm.md (neon_for_64bits): Remove.
index 2c7acc698ea50e0cd539a7d9647498746cd1536f..6857ab1787df0ffa672e5078e5a0b9c9cc52e695 100644 (file)
@@ -174,8 +174,12 @@ __arm_mrrc2 (const unsigned int __coproc, const unsigned int __opc1,
 #endif /* (!__thumb__ || __thumb2__) &&  __ARM_ARCH >= 4.  */
 
 #pragma GCC push_options
-#if __ARM_ARCH >= 8
+#ifdef __ARM_FEATURE_CRC32
+#ifdef __ARM_FP
+#pragma GCC target ("arch=armv8-a+crc+simd")
+#else
 #pragma GCC target ("arch=armv8-a+crc")
+#endif
 
 __extension__ static __inline uint32_t __attribute__ ((__always_inline__))
 __crc32b (uint32_t __a, uint8_t __b)
@@ -235,7 +239,7 @@ __crc32cd (uint32_t __a, uint64_t __b)
 }
 #endif
 
-#endif /* __ARM_ARCH >= 8.  */
+#endif /* __ARM_FEATURE_CRC32  */
 #pragma GCC pop_options
 
 #ifdef __cplusplus
index a3890674c8618144df4a0e644de0fa550971fd77..46b63d52f0d32098ec44b6137b7a51ad47da10e6 100644 (file)
@@ -1,3 +1,7 @@
+2019-08-22  Kyrylo Tkachov <kyrylo.tkachov@arm.com>
+
+       * gcc.target/arm/acle/crc_hf_1.c: New test.
+
 2019-08-22  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * gcc.target/arm/neon-extend-1.c: Remove test.
diff --git a/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c b/gcc/testsuite/gcc.target/arm/acle/crc_hf_1.c
new file mode 100644 (file)
index 0000000..e6cbfc0
--- /dev/null
@@ -0,0 +1,14 @@
+/* Test that using an Armv8-a hard-float target doesn't
+   break CRC intrinsics.  */
+
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_hard_vfp_ok }  */
+/* { dg-options "-mfloat-abi=hard -march=armv8-a+simd+crc" } */
+
+#include <arm_acle.h>
+
+uint32_t
+foo (uint32_t a, uint32_t b)
+{
+  return __crc32cw (a, b);
+}