From: Christophe Lyon Date: Fri, 13 Nov 2020 13:05:43 +0000 (+0000) Subject: arm: Auto-vectorization for MVE: veor X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=434fb3b6cc7d4a8d9d07c7e0052a89093953c8c0;p=gcc.git arm: Auto-vectorization for MVE: veor This patch enables MVE veorq instructions for auto-vectorization. MVE veorq insns in mve.md are modified to use xor instead of unspec expression to support xor3. The xor3 expander is added to vec-common.md 2020-12-11 Christophe Lyon gcc/ * config/arm/iterators.md (supf): Remove VEORQ_S and VEORQ_U. (VEORQ): Remove. * config/arm/mve.md (mve_veorq_u): New entry for veor instruction using expression xor. (mve_veorq_s): New expander. (mve_veorq_f): Use 'xor' code instead of unspec. * config/arm/neon.md (xor3): Renamed into xor3_neon. * config/arm/unspecs.md (VEORQ_S, VEORQ_U, VEORQ_F): Remove. * config/arm/vec-common.md (xor3): New expander. gcc/testsuite/ * gcc.target/arm/simd/mve-veor.c: Add tests for veor. --- diff --git a/gcc/config/arm/iterators.md b/gcc/config/arm/iterators.md index 5fcb7afe565..01952756e08 100644 --- a/gcc/config/arm/iterators.md +++ b/gcc/config/arm/iterators.md @@ -1237,7 +1237,7 @@ (VCADDQ_ROT270_U "u") (VCADDQ_ROT90_S "s") (VCMPEQQ_S "s") (VCMPEQQ_U "u") (VCADDQ_ROT90_U "u") (VCMPEQQ_N_S "s") (VCMPEQQ_N_U "u") (VCMPNEQ_N_S "s") - (VCMPNEQ_N_U "u") (VEORQ_S "s") (VEORQ_U "u") + (VCMPNEQ_N_U "u") (VHADDQ_N_S "s") (VHADDQ_N_U "u") (VHADDQ_S "s") (VHADDQ_U "u") (VHSUBQ_N_S "s") (VHSUBQ_N_U "u") (VHSUBQ_S "s") (VMAXQ_S "s") (VMAXQ_U "u") (VHSUBQ_U "u") @@ -1507,7 +1507,6 @@ (define_int_iterator VCMPEQQ [VCMPEQQ_U VCMPEQQ_S]) (define_int_iterator VCMPEQQ_N [VCMPEQQ_N_S VCMPEQQ_N_U]) (define_int_iterator VCMPNEQ_N [VCMPNEQ_N_U VCMPNEQ_N_S]) -(define_int_iterator VEORQ [VEORQ_U VEORQ_S]) (define_int_iterator VHADDQ [VHADDQ_S VHADDQ_U]) (define_int_iterator VHADDQ_N [VHADDQ_N_U VHADDQ_N_S]) (define_int_iterator VHSUBQ [VHSUBQ_S VHSUBQ_U]) diff --git a/gcc/config/arm/mve.md b/gcc/config/arm/mve.md index 4b2e46afc19..10512ad0007 100644 --- a/gcc/config/arm/mve.md +++ b/gcc/config/arm/mve.md @@ -1207,17 +1207,24 @@ ;; ;; [veorq_u, veorq_s]) ;; -(define_insn "mve_veorq_" +(define_insn "mve_veorq_u" [ (set (match_operand:MVE_2 0 "s_register_operand" "=w") - (unspec:MVE_2 [(match_operand:MVE_2 1 "s_register_operand" "w") - (match_operand:MVE_2 2 "s_register_operand" "w")] - VEORQ)) + (xor:MVE_2 (match_operand:MVE_2 1 "s_register_operand" "w") + (match_operand:MVE_2 2 "s_register_operand" "w"))) ] "TARGET_HAVE_MVE" - "veor %q0, %q1, %q2" + "veor\t%q0, %q1, %q2" [(set_attr "type" "mve_move") ]) +(define_expand "mve_veorq_s" + [ + (set (match_operand:MVE_2 0 "s_register_operand") + (xor:MVE_2 (match_operand:MVE_2 1 "s_register_operand") + (match_operand:MVE_2 2 "s_register_operand"))) + ] + "TARGET_HAVE_MVE" +) ;; ;; [vhaddq_n_u, vhaddq_n_s]) @@ -2404,9 +2411,8 @@ (define_insn "mve_veorq_f" [ (set (match_operand:MVE_0 0 "s_register_operand" "=w") - (unspec:MVE_0 [(match_operand:MVE_0 1 "s_register_operand" "w") - (match_operand:MVE_0 2 "s_register_operand" "w")] - VEORQ_F)) + (xor:MVE_0 (match_operand:MVE_0 1 "s_register_operand" "w") + (match_operand:MVE_0 2 "s_register_operand" "w"))) ] "TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT" "veor %q0, %q1, %q2" diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md index 669c34da4e0..e1263b00b39 100644 --- a/gcc/config/arm/neon.md +++ b/gcc/config/arm/neon.md @@ -747,7 +747,7 @@ [(set_attr "type" "neon_logic")] ) -(define_insn "xor3" +(define_insn "xor3_neon" [(set (match_operand:VDQ 0 "s_register_operand" "=w") (xor:VDQ (match_operand:VDQ 1 "s_register_operand" "w") (match_operand:VDQ 2 "s_register_operand" "w")))] diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md index c2076c9ce6f..fe240e8968a 100644 --- a/gcc/config/arm/unspecs.md +++ b/gcc/config/arm/unspecs.md @@ -608,7 +608,6 @@ VCMPEQQ_S VCMPEQQ_N_S VCMPNEQ_N_S - VEORQ_S VHADDQ_S VHADDQ_N_S VHSUBQ_S @@ -653,7 +652,6 @@ VCMPEQQ_U VCMPEQQ_N_U VCMPNEQ_N_U - VEORQ_U VHADDQ_U VHADDQ_N_U VHSUBQ_U @@ -736,7 +734,6 @@ VCMULQ_ROT180_F VCMULQ_ROT270_F VCMULQ_ROT90_F - VEORQ_F VMAXNMAQ_F VMAXNMAVQ_F VMAXNMQ_F diff --git a/gcc/config/arm/vec-common.md b/gcc/config/arm/vec-common.md index 8d9c89c5b2b..030ed82ca7e 100644 --- a/gcc/config/arm/vec-common.md +++ b/gcc/config/arm/vec-common.md @@ -186,3 +186,10 @@ (match_operand:VDQ 2 "neon_logic_op2" "")))] "ARM_HAVE__ARITH" ) + +(define_expand "xor3" + [(set (match_operand:VDQ 0 "s_register_operand" "") + (xor:VDQ (match_operand:VDQ 1 "s_register_operand" "") + (match_operand:VDQ 2 "s_register_operand" "")))] + "ARM_HAVE__ARITH" +) diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-veor.c b/gcc/testsuite/gcc.target/arm/simd/mve-veor.c new file mode 100644 index 00000000000..321961f251e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/simd/mve-veor.c @@ -0,0 +1,61 @@ +/* { dg-do assemble } */ +/* { dg-require-effective-target arm_v8_1m_mve_ok } */ +/* { dg-add-options arm_v8_1m_mve } */ +/* { dg-additional-options "-O3" } */ + +#include + +#define FUNC(SIGN, TYPE, BITS, NB, OP, NAME) \ + void test_ ## NAME ##_ ## SIGN ## BITS ## x ## NB (TYPE##BITS##_t * __restrict__ dest, TYPE##BITS##_t *a, TYPE##BITS##_t *b) { \ + int i; \ + for (i=0; i