]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: Add support for __builtin_roundeven[f] (PR100966)
authorWilco Dijkstra <wdijkstr@arm.com>
Wed, 20 Oct 2021 12:09:30 +0000 (13:09 +0100)
committerWilco Dijkstra <wdijkstr@arm.com>
Wed, 20 Oct 2021 12:38:12 +0000 (13:38 +0100)
Enable __builtin_roundeven[f] by changing existing frintn to roundeven.

2021-10-20  Wilco Dijkstra  <wdijkstr@arm.com>

gcc/
PR target/100966
* config/aarch64/aarch64.md (frint_pattern): Update comment.
* config/aarch64/aarch64-simd-builtins.def: Change frintn to roundeven.
* config/aarch64/arm_fp16.h: Change frintn to roundeven.
* config/aarch64/arm_neon.h: Likewise.
* config/aarch64/iterators.md (frint_pattern): Use roundeven for FRINTN.

gcc/testsuite/
PR target/100966
* gcc.target/aarch64/frint.x: Add roundeven tests.
* gcc.target/aarch64/frint_double.c: Likewise.
* gcc.target/aarch64/frint_float.c: Likewise.

gcc/config/aarch64/aarch64-simd-builtins.def
gcc/config/aarch64/aarch64.md
gcc/config/aarch64/arm_fp16.h
gcc/config/aarch64/arm_neon.h
gcc/config/aarch64/iterators.md
gcc/testsuite/gcc.target/aarch64/frint.x
gcc/testsuite/gcc.target/aarch64/frint_double.c
gcc/testsuite/gcc.target/aarch64/frint_float.c

index 35dc075dde60d3db3e30122dd5d21e5ff115e204..be1c5b543fe5f364250c32de30c9f0b33b694f97 100644 (file)
   BUILTIN_VHSDF (UNOP, nearbyint, 2, FP)
   BUILTIN_VHSDF (UNOP, rint, 2, FP)
   BUILTIN_VHSDF (UNOP, round, 2, FP)
-  BUILTIN_VHSDF_HSDF (UNOP, frintn, 2, FP)
+  BUILTIN_VHSDF_HSDF (UNOP, roundeven, 2, FP)
 
   VAR1 (UNOP, btrunc, 2, FP, hf)
   VAR1 (UNOP, ceil, 2, FP, hf)
index 7085cd4a51dc4c22def9b95f2221b3847603a9e5..1a39470a1feeb8d23a3d0d4f8a9b54535f769fd9 100644 (file)
 ;; -------------------------------------------------------------------
 
 ;; frint floating-point round to integral standard patterns.
-;; Expands to btrunc, ceil, floor, nearbyint, rint, round, frintn.
+;; Expands to btrunc, ceil, floor, nearbyint, rint, round, roundeven.
 
 (define_insn "<frint_pattern><mode>2"
   [(set (match_operand:GPF_F16 0 "register_operand" "=w")
index 26339533cd6e4878bd3de50a1bb215d244032175..c2235460f5522afc2767e8bb212197b50a07ab8a 100644 (file)
@@ -383,7 +383,7 @@ __extension__ extern __inline float16_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndnh_f16 (float16_t __a)
 {
-  return __builtin_aarch64_frintnhf (__a);
+  return __builtin_aarch64_roundevenhf (__a);
 }
 
 __extension__ extern __inline float16_t
index 24068f8d7da5b123360a479f66b53fe2d4eea28e..1768c6b56c132cd1648b2ff8aeeddd09e676234a 100644 (file)
@@ -26359,35 +26359,35 @@ __extension__ extern __inline float32_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndns_f32 (float32_t __a)
 {
-  return __builtin_aarch64_frintnsf (__a);
+  return __builtin_aarch64_roundevensf (__a);
 }
 
 __extension__ extern __inline float32x2_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndn_f32 (float32x2_t __a)
 {
-  return __builtin_aarch64_frintnv2sf (__a);
+  return __builtin_aarch64_roundevenv2sf (__a);
 }
 
 __extension__ extern __inline float64x1_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndn_f64 (float64x1_t __a)
 {
-  return (float64x1_t) {__builtin_aarch64_frintndf (__a[0])};
+  return (float64x1_t) {__builtin_aarch64_roundevendf (__a[0])};
 }
 
 __extension__ extern __inline float32x4_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndnq_f32 (float32x4_t __a)
 {
-  return __builtin_aarch64_frintnv4sf (__a);
+  return __builtin_aarch64_roundevenv4sf (__a);
 }
 
 __extension__ extern __inline float64x2_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndnq_f64 (float64x2_t __a)
 {
-  return __builtin_aarch64_frintnv2df (__a);
+  return __builtin_aarch64_roundevenv2df (__a);
 }
 
 /* vrndp  */
@@ -32792,14 +32792,14 @@ __extension__ extern __inline float16x4_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndn_f16 (float16x4_t __a)
 {
-  return __builtin_aarch64_frintnv4hf (__a);
+  return __builtin_aarch64_roundevenv4hf (__a);
 }
 
 __extension__ extern __inline float16x8_t
 __attribute__ ((__always_inline__, __gnu_inline__, __artificial__))
 vrndnq_f16 (float16x8_t __a)
 {
-  return __builtin_aarch64_frintnv8hf (__a);
+  return __builtin_aarch64_roundevenv8hf (__a);
 }
 
 __extension__ extern __inline float16x4_t
index caa42f8f169fbf2cf46a90cf73dee05619acc300..e4af27b058c953737e21c13f8886a7813fd790a2 100644 (file)
                                (UNSPEC_FRINTI "nearbyint")
                                (UNSPEC_FRINTX "rint")
                                (UNSPEC_FRINTA "round")
-                               (UNSPEC_FRINTN "frintn")])
+                               (UNSPEC_FRINTN "roundeven")])
 
 ;; frint suffix for floating-point rounding instructions.
 (define_int_attr frint_suffix [(UNSPEC_FRINTZ "z") (UNSPEC_FRINTP "p")
index 1403740686ea3927d2c39eb2466ef8cc67e223b2..d598a25ff21b8feeca6a96de79848b2fbde7f31e 100644 (file)
@@ -4,6 +4,7 @@ extern GPF SUFFIX(floor) (GPF);
 extern GPF SUFFIX(nearbyint) (GPF);
 extern GPF SUFFIX(rint) (GPF);
 extern GPF SUFFIX(round) (GPF);
+extern GPF SUFFIX(roundeven) (GPF);
 
 GPF test1a (GPF x)
 {
@@ -64,3 +65,14 @@ GPF test6b (GPF x)
 {
   return SUFFIX(round)(x);
 }
+
+GPF test7a (GPF x)
+{
+  return SUFFIX(__builtin_roundeven)(x);
+}
+
+GPF test7b (GPF x)
+{
+  return SUFFIX(roundeven)(x);
+}
+
index 96139496ca454cebd41d31e8b018dab7ffa33a3f..1d28eb09e11842802ab632a7696de4407263f8ce 100644 (file)
@@ -12,3 +12,4 @@
 /* { dg-final { scan-assembler-times "frinti\td\[0-9\]" 2 } } */
 /* { dg-final { scan-assembler-times "frintx\td\[0-9\]" 2 } } */
 /* { dg-final { scan-assembler-times "frinta\td\[0-9\]" 2 } } */
+/* { dg-final { scan-assembler-times "frintn\td\[0-9\]" 2 } } */
index 493ec37f940a6e8cb01ea7e324073fa22099636c..530cf975db3d52c30bce43d0c40229b2b375cdea 100644 (file)
@@ -12,3 +12,4 @@
 /* { dg-final { scan-assembler-times "frinti\ts\[0-9\]" 2 } } */
 /* { dg-final { scan-assembler-times "frintx\ts\[0-9\]" 2 } } */
 /* { dg-final { scan-assembler-times "frinta\ts\[0-9\]" 2 } } */
+/* { dg-final { scan-assembler-times "frintn\ts\[0-9\]" 2 } } */