* [AArch64] implement FSQRT in RTL.
@ 2012-08-17 15:25 Sofiane Naci
0 siblings, 0 replies; 2+ messages in thread
From: Sofiane Naci @ 2012-08-17 15:25 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 639 bytes --]
Hi,
I've just committed the attached patch on the AArch64 branch to implement
FSQRT in RTL.
Thanks
Sofiane
-----
r190485 | sofiane | 2012-08-17 16:22:28 +0100 (Fri, 17 Aug 2012) | 12 lines
2012-08-17 Tejas Belagod <tejas.belagod@arm.com>
[AArch64] Implement FSQRT in RTL.
* config/aarch64/aarch64-builtins.c (aarch64_simd_builtin_data):
Add sqrt to the list of intrinsic descriptors.
* config/aarch64/aarch64-simd.md (sqrt<mode>2): Insn pattern for
sqrt.
(aarch64_sqrt<mode>): Builtin expansion.
* config/aarch64/arm_neon.h: Remove asm implementations of
vsqrt. Add builtin implementation of vsqrt.
[-- Attachment #2: aarch64-fsqrt.patch --]
[-- Type: application/octet-stream, Size: 4933 bytes --]
Index: gcc/testsuite/gcc.target/aarch64/vsqrt.c
===================================================================
--- gcc/testsuite/gcc.target/aarch64/vsqrt.c (revision 0)
+++ gcc/testsuite/gcc.target/aarch64/vsqrt.c (revision 0)
@@ -0,0 +1,66 @@
+
+
+/* { dg-do run } */
+/* { dg-options "-O3" } */
+
+#include "arm_neon.h"
+#include "stdio.h"
+
+extern void abort (void);
+
+void
+test_square_root_v2sf ()
+{
+ float32x2_t val = {4.0f, 9.0f};
+ float32x2_t res;
+
+ res = vsqrt_f32 (val);
+
+ if (vget_lane_f32 (res, 0) != 2.0f)
+ abort ();
+ if (vget_lane_f32 (res, 1) != 3.0f)
+ abort ();
+}
+
+void
+test_square_root_v4sf ()
+{
+ float32x4_t val = {4.0f, 9.0f, 16.0f, 25.0f};
+ float32x4_t res;
+
+ res = vsqrtq_f32 (val);
+
+ if (vgetq_lane_f32 (res, 0) != 2.0f)
+ abort ();
+ if (vgetq_lane_f32 (res, 1) != 3.0f)
+ abort ();
+ if (vgetq_lane_f32 (res, 2) != 4.0f)
+ abort ();
+ if (vgetq_lane_f32 (res, 3) != 5.0f)
+ abort ();
+}
+
+void
+test_square_root_v2df ()
+{
+ float64x2_t val = {4.0, 9.0};
+ float64x2_t res;
+
+ res = vsqrtq_f64 (val);
+
+ if (vgetq_lane_f64 (res, 0) != 2.0)
+ abort ();
+
+ if (vgetq_lane_f64 (res, 1) != 3.0)
+ abort ();
+}
+
+int
+main (void)
+{
+ test_square_root_v2sf ();
+ test_square_root_v4sf ();
+ test_square_root_v2df ();
+
+ return 0;
+}
Property changes on: gcc/testsuite/gcc.target/aarch64/vsqrt.c
___________________________________________________________________
Added: svn:keywords
+ Rev Date Author URL Id
Added: svn:eol-style
+ native
Index: gcc/config/aarch64/aarch64-simd.md
===================================================================
--- gcc/config/aarch64/aarch64-simd.md (revision 190484)
+++ gcc/config/aarch64/aarch64-simd.md (working copy)
@@ -2742,3 +2742,23 @@
[(set_attr "simd_type" "simd_fminmax")
(set_attr "simd_mode" "<MODE>")]
)
+
+;; sqrt
+
+(define_insn "sqrt<mode>2"
+ [(set (match_operand:VDQF 0 "register_operand" "=w")
+ (sqrt:VDQF (match_operand:VDQF 1 "register_operand" "w")))]
+ "TARGET_SIMD"
+ "fsqrt\\t%0.<Vtype>, %1.<Vtype>"
+ [(set_attr "simd_type" "simd_fsqrt")
+ (set_attr "simd_mode" "<MODE>")]
+)
+
+(define_expand "aarch64_sqrt<mode>"
+ [(match_operand:VDQF 0 "register_operand" "=w")
+ (match_operand:VDQF 1 "register_operand" "w")]
+ "TARGET_SIMD"
+{
+ emit_insn (gen_sqrt<mode>2 (operands[0], operands[1]));
+ DONE;
+})
Index: gcc/config/aarch64/arm_neon.h
===================================================================
--- gcc/config/aarch64/arm_neon.h (revision 190484)
+++ gcc/config/aarch64/arm_neon.h (working copy)
@@ -16289,39 +16289,6 @@
result; \
})
-__extension__ static __inline float32x2_t __attribute__ ((__always_inline__))
-vsqrt_f32 (float32x2_t a)
-{
- float32x2_t result;
- __asm__ ("fsqrt %0.2s,%1.2s"
- : "=w"(result)
- : "w"(a)
- : /* No clobbers */);
- return result;
-}
-
-__extension__ static __inline float32x4_t __attribute__ ((__always_inline__))
-vsqrtq_f32 (float32x4_t a)
-{
- float32x4_t result;
- __asm__ ("fsqrt %0.4s,%1.4s"
- : "=w"(result)
- : "w"(a)
- : /* No clobbers */);
- return result;
-}
-
-__extension__ static __inline float64x2_t __attribute__ ((__always_inline__))
-vsqrtq_f64 (float64x2_t a)
-{
- float64x2_t result;
- __asm__ ("fsqrt %0.2d,%1.2d"
- : "=w"(result)
- : "w"(a)
- : /* No clobbers */);
- return result;
-}
-
#define vsri_n_p8(a, b, c) \
__extension__ \
({ \
@@ -23572,6 +23539,25 @@
return (uint64x1_t) __builtin_aarch64_usqadddi ((int64x1_t) __a, __b);
}
+/* vsqrt */
+__extension__ static __inline float32x2_t __attribute__ ((__always_inline__))
+vsqrt_f32 (float32x2_t a)
+{
+ return __builtin_aarch64_sqrtv2sf (a);
+}
+
+__extension__ static __inline float32x4_t __attribute__ ((__always_inline__))
+vsqrtq_f32 (float32x4_t a)
+{
+ return __builtin_aarch64_sqrtv4sf (a);
+}
+
+__extension__ static __inline float64x2_t __attribute__ ((__always_inline__))
+vsqrtq_f64 (float64x2_t a)
+{
+ return __builtin_aarch64_sqrtv2df (a);
+}
+
/* vsra */
__extension__ static __inline int8x8_t __attribute__ ((__always_inline__))
Index: gcc/config/aarch64/aarch64-builtins.c
===================================================================
--- gcc/config/aarch64/aarch64-builtins.c (revision 190484)
+++ gcc/config/aarch64/aarch64-builtins.c (working copy)
@@ -340,6 +340,7 @@
{ VAR6 (BINOP, smin, v8qi, v4hi, v2si, v16qi, v8hi, v4si) },
{ VAR6 (BINOP, umax, v8qi, v4hi, v2si, v16qi, v8hi, v4si) },
{ VAR6 (BINOP, umin, v8qi, v4hi, v2si, v16qi, v8hi, v4si) },
+ { VAR3 (UNOP, sqrt, v2sf, v4sf, v2df) },
};
#undef CF
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [AArch64] implement FSQRT in RTL.
[not found] <502e6264.a7e3440a.4807.41b8SMTPIN_ADDED@mx.google.com>
@ 2012-08-17 17:17 ` Andrew Pinski
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2012-08-17 17:17 UTC (permalink / raw)
To: Sofiane Naci; +Cc: gcc-patches
On Fri, Aug 17, 2012 at 8:26 AM, Sofiane Naci <sofiane.naci@arm.com> wrote:
> Hi,
>
> I've just committed the attached patch on the AArch64 branch to implement
> FSQRT in RTL.
Maybe add a testcase which tests that sqrt gets vectorized?
Thanks,
Andrew
>
> Thanks
> Sofiane
>
> -----
>
> r190485 | sofiane | 2012-08-17 16:22:28 +0100 (Fri, 17 Aug 2012) | 12 lines
>
> 2012-08-17 Tejas Belagod <tejas.belagod@arm.com>
>
> [AArch64] Implement FSQRT in RTL.
>
> * config/aarch64/aarch64-builtins.c (aarch64_simd_builtin_data):
> Add sqrt to the list of intrinsic descriptors.
> * config/aarch64/aarch64-simd.md (sqrt<mode>2): Insn pattern for
> sqrt.
> (aarch64_sqrt<mode>): Builtin expansion.
> * config/aarch64/arm_neon.h: Remove asm implementations of
> vsqrt. Add builtin implementation of vsqrt.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-17 17:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-17 15:25 [AArch64] implement FSQRT in RTL Sofiane Naci
[not found] <502e6264.a7e3440a.4807.41b8SMTPIN_ADDED@mx.google.com>
2012-08-17 17:17 ` Andrew Pinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).