From: Christophe Lyon Date: Thu, 3 Jun 2021 12:06:38 +0000 (+0000) Subject: arm: Auto-vectorization for MVE: vabs X-Git-Tag: basepoints/gcc-13~7133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4242710c7966a965bbd14cd50ecdba28fd5717e;p=thirdparty%2Fgcc.git arm: Auto-vectorization for MVE: vabs This patch adds support for auto-vectorization of absolute value computation using vabs. We use a similar pattern to what is used in neon.md and extend the existing neg2 expander to match both 'neg' and 'abs'. This implies renaming the existing abs2 define_insn in neon.md to avoid a clash with the new expander with the same name. 2021-06-03 Christophe Lyon gcc/ * config/arm/mve.md (mve_vabsq_f): Use 'abs' instead of unspec. (mve_vabsq_s): Likewise. * config/arm/neon.md (abs2): Rename to neon_abs2. * config/arm/unspecs.md (VABSQ_F, VABSQ_S): Delete. * config/arm/vec-common.md (neg2): Rename to 2. gcc/testsuite/ * gcc.target/arm/simd/mve-vabs.c: New test. --- diff --git a/gcc/config/arm/mve.md b/gcc/config/arm/mve.md index 0a6ba80c99db..0bfa6a91d55c 100644 --- a/gcc/config/arm/mve.md +++ b/gcc/config/arm/mve.md @@ -269,8 +269,7 @@ (define_insn "mve_vabsq_f" [ (set (match_operand:MVE_0 0 "s_register_operand" "=w") - (unspec:MVE_0 [(match_operand:MVE_0 1 "s_register_operand" "w")] - VABSQ_F)) + (abs:MVE_0 (match_operand:MVE_0 1 "s_register_operand" "w"))) ] "TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT" "vabs.f%# %q0, %q1" @@ -481,8 +480,7 @@ (define_insn "mve_vabsq_s" [ (set (match_operand:MVE_2 0 "s_register_operand" "=w") - (unspec:MVE_2 [(match_operand:MVE_2 1 "s_register_operand" "w")] - VABSQ_S)) + (abs:MVE_2 (match_operand:MVE_2 1 "s_register_operand" "w"))) ] "TARGET_HAVE_MVE" "vabs.s%#\t%q0, %q1" diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md index 6a6573317cf7..077c62ffd20a 100644 --- a/gcc/config/arm/neon.md +++ b/gcc/config/arm/neon.md @@ -739,7 +739,7 @@ [(set_attr "type" "neon_move")] ) -(define_insn "abs2" +(define_insn "neon_abs2" [(set (match_operand:VDQW 0 "s_register_operand" "=w") (abs:VDQW (match_operand:VDQW 1 "s_register_operand" "w")))] "TARGET_NEON" diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md index 0778db1bf4f8..ed1bc293b784 100644 --- a/gcc/config/arm/unspecs.md +++ b/gcc/config/arm/unspecs.md @@ -538,7 +538,6 @@ VRNDAQ_F VREV64Q_F VDUPQ_N_F - VABSQ_F VREV32Q_F VCVTTQ_F32_F16 VCVTBQ_F32_F16 @@ -562,7 +561,6 @@ VCLSQ_S VADDVQ_S VADDVQ_U - VABSQ_S VREV32Q_U VREV32Q_S VMOVLTQ_U diff --git a/gcc/config/arm/vec-common.md b/gcc/config/arm/vec-common.md index 8e35151da467..80b273229f5d 100644 --- a/gcc/config/arm/vec-common.md +++ b/gcc/config/arm/vec-common.md @@ -208,9 +208,9 @@ "ARM_HAVE__ARITH && !TARGET_REALLY_IWMMXT" ) -(define_expand "neg2" +(define_expand "2" [(set (match_operand:VDQWH 0 "s_register_operand" "") - (neg:VDQWH (match_operand:VDQWH 1 "s_register_operand" "")))] + (ABSNEG:VDQWH (match_operand:VDQWH 1 "s_register_operand" "")))] "ARM_HAVE__ARITH && !TARGET_REALLY_IWMMXT" ) diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c new file mode 100644 index 000000000000..64cd1c2eb4a8 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/simd/mve-vabs.c @@ -0,0 +1,44 @@ +/* { dg-do assemble } */ +/* { dg-require-effective-target arm_v8_1m_mve_fp_ok } */ +/* { dg-add-options arm_v8_1m_mve_fp } */ +/* { dg-additional-options "-O3 -funsafe-math-optimizations" } */ + +#include +#include + +#define ABS(a) ((a < 0) ? -a : a) + +#define FUNC(SIGN, TYPE, BITS, NB, NAME) \ + void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, TYPE##BITS##_t *a) { \ + int i; \ + for (i=0; i