Patchwork [AARCH64] Fix support for vectorization over sqrt (), sqrtf ().

login
register
mail settings
Submitter James Greenhalgh
Date Jan. 8, 2013, 1:55 p.m.
Message ID <1357653333-29428-1-git-send-email-james.greenhalgh@arm.com>
Download mbox | patch
Permalink /patch/210389/
State New
Headers show

Comments

James Greenhalgh - Jan. 8, 2013, 1:55 p.m.
Hi,

This patch fixes the support for vectorizing sqrt and sqrtf
function calls on AArch64. While the standard name was implemented
previously, the glue in aarch64_builtin_vectorized_function was not.

We also fix the initialisation of vectors in the
gcc.target/aarch64/vsqrt.c testcase such that they are more
big-endian-safe.

This patch regresses clean on aarch64-none-elf.

Applying this patch gives:

FAIL->PASS: gcc.dg/vect/no-math-errno-slp-32.c scan-tree-dump vect "pattern recognized"
FAIL->PASS: gcc.dg/vect/no-math-errno-vect-pow-1.c scan-tree-dump vect "pattern recognized"

Is this OK to commit?

Thanks,
James Greenhalgh

---
gcc/

2013-01-08  James Greenhalgh  <james.greenhalgh@arm.com>

	* config/aarch64/aarch64-builtins.c
	(aarch64_builtin_vectorized_function): Handle sqrt, sqrtf.

gcc/testsuite/

2013-01-08  James Greenhalgh  <james.greenhalgh@arm.com>

	* gcc.target/aarch64/vsqrt.c (test_square_root_v2sf): Use
	endian-safe float pool loading.
	(test_square_root_v4sf): Likewise.
	(test_square_root_v2df): Likewise.
	* lib/target-supports.exp
	(check_effective_target_vect_call_sqrtf): Add AArch64.
Marcus Shawcroft - Jan. 8, 2013, 2:34 p.m.
On 8 January 2013 13:55, James Greenhalgh <james.greenhalgh@arm.com> wrote:
>
> Hi,
>
> This patch fixes the support for vectorizing sqrt and sqrtf
> function calls on AArch64. While the standard name was implemented
> previously, the glue in aarch64_builtin_vectorized_function was not.
>
> We also fix the initialisation of vectors in the
> gcc.target/aarch64/vsqrt.c testcase such that they are more
> big-endian-safe.
>
> This patch regresses clean on aarch64-none-elf.
>
> Applying this patch gives:
>
> FAIL->PASS: gcc.dg/vect/no-math-errno-slp-32.c scan-tree-dump vect "pattern recognized"
> FAIL->PASS: gcc.dg/vect/no-math-errno-vect-pow-1.c scan-tree-dump vect "pattern recognized"
>
> Is this OK to commit?


OK /Marcus

Patch

diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index a683afd..f54e9f4 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1271,6 +1271,9 @@  aarch64_builtin_vectorized_function (tree fndecl, tree type_out, tree type_in)
 	case BUILT_IN_NEARBYINT:
 	case BUILT_IN_NEARBYINTF:
 	  return AARCH64_FIND_FRINT_VARIANT (frinti);
+	case BUILT_IN_SQRT:
+	case BUILT_IN_SQRTF:
+	  return AARCH64_FIND_FRINT_VARIANT (sqrt);
 #undef AARCH64_CHECK_BUILTIN_MODE
 #define AARCH64_CHECK_BUILTIN_MODE(C, N) \
   (out_mode == N##Imode && out_n == C \
diff --git a/gcc/testsuite/gcc.target/aarch64/vsqrt.c b/gcc/testsuite/gcc.target/aarch64/vsqrt.c
index b59535a..5b777b2 100644
--- a/gcc/testsuite/gcc.target/aarch64/vsqrt.c
+++ b/gcc/testsuite/gcc.target/aarch64/vsqrt.c
@@ -11,9 +11,11 @@  extern void abort (void);
 void
 test_square_root_v2sf ()
 {
-  float32x2_t val = {4.0f, 9.0f};
+  const float32_t pool[] = {4.0f, 9.0f};
+  float32x2_t val;
   float32x2_t res;
 
+  val = vld1_f32 (pool);
   res = vsqrt_f32 (val);
 
   if (vget_lane_f32 (res, 0) != 2.0f)
@@ -25,9 +27,11 @@  test_square_root_v2sf ()
 void
 test_square_root_v4sf ()
 {
-  float32x4_t val = {4.0f, 9.0f, 16.0f, 25.0f};
+  const float32_t pool[] = {4.0f, 9.0f, 16.0f, 25.0f};
+  float32x4_t val;
   float32x4_t res;
 
+  val = vld1q_f32 (pool);
   res = vsqrtq_f32 (val);
 
   if (vgetq_lane_f32 (res, 0) != 2.0f)
@@ -43,9 +47,11 @@  test_square_root_v4sf ()
 void
 test_square_root_v2df ()
 {
-  float64x2_t val = {4.0, 9.0};
+  const float64_t pool[] = {4.0, 9.0};
+  float64x2_t val;
   float64x2_t res;
 
+  val = vld1q_f64 (pool);
   res = vsqrtq_f64 (val);
 
   if (vgetq_lane_f64 (res, 0) != 2.0)
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index a3828cb..a6d766e 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3952,7 +3952,8 @@  proc check_effective_target_vect_call_sqrtf { } {
 	verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
     } else {
 	set et_vect_call_sqrtf_saved 0
-	if { [istarget i?86-*-*]
+	if { [istarget aarch64*-*-*]
+	     || [istarget i?86-*-*]
 	     || [istarget x86_64-*-*]
 	     || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
 	    set et_vect_call_sqrtf_saved 1