aarch64: Add missing clobber for fjcvtzs
authorAndrea Corallo <andrea.corallo@arm.com>
Wed, 29 Jul 2020 17:04:40 +0000 (19:04 +0200)
committerAndrea Corallo <andrea.corallo@arm.com>
Tue, 4 Aug 2020 10:22:41 +0000 (12:22 +0200)
gcc/ChangeLog

2020-07-30  Andrea Corallo  <andrea.corallo@arm.com>

* config/aarch64/aarch64.md (aarch64_fjcvtzs): Add missing
clobber.
* doc/sourcebuild.texi (aarch64_fjcvtzs_hw) Document new
target supports option.

gcc/testsuite/ChangeLog

2020-07-30  Andrea Corallo  <andrea.corallo@arm.com>

* gcc.target/aarch64/acle/jcvt_2.c: New testcase.
* lib/target-supports.exp
(check_effective_target_aarch64_fjcvtzs_hw): Add new check for
FJCVTZS hw.

gcc/config/aarch64/aarch64.md
gcc/doc/sourcebuild.texi
gcc/testsuite/gcc.target/aarch64/acle/jcvt_2.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp

index d5ca1898c02eed79969bbc61351abd2487f296c6..df780b863707fb83119ddc8359917a9e7bfc9e6e 100644 (file)
 (define_insn "aarch64_fjcvtzs"
   [(set (match_operand:SI 0 "register_operand" "=r")
        (unspec:SI [(match_operand:DF 1 "register_operand" "w")]
-                  UNSPEC_FJCVTZS))]
+                  UNSPEC_FJCVTZS))
+   (clobber (reg:CC CC_REGNUM))]
   "TARGET_JSCVT"
   "fjcvtzs\\t%w0, %d1"
   [(set_attr "type" "f_cvtf2i")]
index a7a922d84a206284b0bc5687b1b8ca1b31ec8725..63216a0daba48ed3aefb9e2df59cd2268439c11e 100644 (file)
@@ -2063,6 +2063,9 @@ whether it does so by default).
 @itemx aarch64_sve2048_hw
 Like @code{aarch64_sve_hw}, but also test for an exact hardware vector length.
 
+@item aarch64_fjcvtzs_hw
+AArch64 target that is able to generate and execute armv8.3-a FJCVTZS
+instruction.
 @end table
 
 @subsubsection MIPS-specific attributes
diff --git a/gcc/testsuite/gcc.target/aarch64/acle/jcvt_2.c b/gcc/testsuite/gcc.target/aarch64/acle/jcvt_2.c
new file mode 100644 (file)
index 0000000..ea2dfd1
--- /dev/null
@@ -0,0 +1,33 @@
+/* Test the __jcvt ACLE intrinsic.  */
+/* { dg-do run } */
+/* { dg-options "-O2 -march=armv8.3-a -save-temps" } */
+/* { dg-require-effective-target aarch64_fjcvtzs_hw } */
+
+#include <arm_acle.h>
+
+extern void abort (void);
+
+#ifdef __ARM_FEATURE_JCVT
+volatile int32_t x;
+
+int __attribute__((noinline))
+foo (double a, int b, int c)
+{
+  b = b > c;
+  x = __jcvt (a);
+  return b;
+}
+
+int
+main (void)
+{
+  int x = foo (1.1, 2, 3);
+  if (x)
+    abort ();
+
+  return 0;
+}
+
+#endif
+
+/* { dg-final { scan-assembler-times "fjcvtzs\tw\[0-9\]+, d\[0-9\]+\n" 1 } } */
index ba9db0be2f971329bcbabb899f3a1f9c1a47b014..e79015b4d5489eb1c9e159fc65a4b5aa11f2eb93 100644 (file)
@@ -4848,6 +4848,27 @@ proc check_effective_target_aarch64_bti_hw { } {
     } "-O2" ]
 }
 
+# Return 1 if the target supports executing the armv8.3-a FJCVTZS
+# instruction.
+proc check_effective_target_aarch64_fjcvtzs_hw { } {
+    if { ![istarget aarch64*-*-*] } {
+       return 0
+    }
+    return [check_runtime aarch64_fjcvtzs_hw_available {
+       int
+       main (void)
+       {
+         double in = 25.1;
+         int out;
+         asm volatile ("fjcvtzs %w0, %d1"
+                       : "=r" (out)
+                       : "w" (in)
+                       : /* No clobbers.  */);
+         return out != 25;
+       }
+    } "-march=armv8.3-a" ]
+}
+
 # Return 1 if GCC was configured with --enable-standard-branch-protection
 proc check_effective_target_default_branch_protection { } {
     return [check_configured_with "enable-standard-branch-protection"]