[gcc(refs/users/clyon/heads/mve-autovec)] arm: Auto-vectorization for MVE: vorr
Christophe Lyon
clyon@gcc.gnu.org
Mon Nov 23 10:42:47 GMT 2020
https://gcc.gnu.org/g:ef044ad53da1b55e3b480e656a8d4a8dcbe143d4
commit ef044ad53da1b55e3b480e656a8d4a8dcbe143d4
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date: Fri Nov 13 12:34:12 2020 +0000
arm: Auto-vectorization for MVE: vorr
This patch enables MVE vorrq instructions for auto-vectorization. MVE
vorrq insns in mve.md are modified to use ior instead of unspec
expression to support ior<mode>3. The ior<mode>3 expander is added to
vec-common.md
2020-11-13 Christophe Lyon <christophe.lyon@linaro.org>
gcc/
* config/arm/iterators.md (supf): Remove VORRQ_S and VORRQ_U.
(VORRQ): Remove.
* config/arm/mve.md (mve_vorrq_s<mode>): New entry for vorr
instruction using expression ior.
(mve_vorrq_u<mode>): New expander.
* config/arm/neon.md (ior<mode>3): Renamed into ior<mode>3_neon.
* config/arm/unspecs.md (VORRQ_S, VORRQ_U): Remove.
* config/arm/vec-common.md (ior<mode>3): New expander.
gcc/testsuite/
* gcc.target/arm/simd/mve-vorr.c: Add vorr tests.
Diff:
---
gcc/config/arm/iterators.md | 5 +-
gcc/config/arm/mve.md | 17 +++--
gcc/config/arm/neon.md | 2 +-
gcc/config/arm/unspecs.md | 2 -
gcc/config/arm/vec-common.md | 7 ++
gcc/testsuite/gcc.target/arm/simd/mve-vorr.c | 96 ++++++++++++++++++++++++++++
6 files changed, 118 insertions(+), 11 deletions(-)
diff --git a/gcc/config/arm/iterators.md b/gcc/config/arm/iterators.md
index 72039e4e898..5fcb7afe565 100644
--- a/gcc/config/arm/iterators.md
+++ b/gcc/config/arm/iterators.md
@@ -1247,8 +1247,8 @@
(VMULLBQ_INT_S "s") (VMULLBQ_INT_U "u") (VQADDQ_S "s")
(VMULLTQ_INT_S "s") (VMULLTQ_INT_U "u") (VQADDQ_U "u")
(VMULQ_N_S "s") (VMULQ_N_U "u") (VMULQ_S "s")
- (VMULQ_U "u") (VORNQ_S "s") (VORNQ_U "u") (VORRQ_S "s")
- (VORRQ_U "u") (VQADDQ_N_S "s") (VQADDQ_N_U "u")
+ (VMULQ_U "u") (VORNQ_S "s") (VORNQ_U "u")
+ (VQADDQ_N_S "s") (VQADDQ_N_U "u")
(VQRSHLQ_N_S "s") (VQRSHLQ_N_U "u") (VQRSHLQ_S "s")
(VQRSHLQ_U "u") (VQSHLQ_N_S "s") (VQSHLQ_N_U "u")
(VQSHLQ_R_S "s") (VQSHLQ_R_U "u") (VQSHLQ_S "s")
@@ -1523,7 +1523,6 @@
(define_int_iterator VMULQ [VMULQ_U VMULQ_S])
(define_int_iterator VMULQ_N [VMULQ_N_U VMULQ_N_S])
(define_int_iterator VORNQ [VORNQ_U VORNQ_S])
-(define_int_iterator VORRQ [VORRQ_S VORRQ_U])
(define_int_iterator VQADDQ [VQADDQ_U VQADDQ_S])
(define_int_iterator VQADDQ_N [VQADDQ_N_S VQADDQ_N_U])
(define_int_iterator VQRSHLQ [VQRSHLQ_S VQRSHLQ_U])
diff --git a/gcc/config/arm/mve.md b/gcc/config/arm/mve.md
index 975eb7d6409..0f040444861 100644
--- a/gcc/config/arm/mve.md
+++ b/gcc/config/arm/mve.md
@@ -1610,17 +1610,24 @@
;;
;; [vorrq_s, vorrq_u])
;;
-(define_insn "mve_vorrq_<supf><mode>"
+(define_insn "mve_vorrq_s<mode>"
[
(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")]
- VORRQ))
+ (ior:MVE_2 (match_operand:MVE_2 1 "s_register_operand" "w")
+ (match_operand:MVE_2 2 "s_register_operand" "w")))
]
"TARGET_HAVE_MVE"
- "vorr %q0, %q1, %q2"
+ "vorr\t%q0, %q1, %q2"
[(set_attr "type" "mve_move")
])
+(define_expand "mve_vorrq_u<mode>"
+ [
+ (set (match_operand:MVE_2 0 "s_register_operand")
+ (ior:MVE_2 (match_operand:MVE_2 1 "s_register_operand")
+ (match_operand:MVE_2 2 "s_register_operand")))
+ ]
+ "TARGET_HAVE_MVE"
+)
;;
;; [vqaddq_n_s, vqaddq_n_u])
diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index dc4707d7447..669c34da4e0 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -690,7 +690,7 @@
(set_attr "predicable" "no")]
)
-(define_insn "ior<mode>3"
+(define_insn "ior<mode>3_neon"
[(set (match_operand:VDQ 0 "s_register_operand" "=w,w")
(ior:VDQ (match_operand:VDQ 1 "s_register_operand" "w,0")
(match_operand:VDQ 2 "neon_logic_op2" "w,Dl")))]
diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md
index e8bf68e9a73..f111ad80ead 100644
--- a/gcc/config/arm/unspecs.md
+++ b/gcc/config/arm/unspecs.md
@@ -624,7 +624,6 @@
VMULQ_S
VMULQ_N_S
VORNQ_S
- VORRQ_S
VQADDQ_S
VQADDQ_N_S
VQRSHLQ_S
@@ -670,7 +669,6 @@
VMULQ_U
VMULQ_N_U
VORNQ_U
- VORRQ_U
VQADDQ_U
VQADDQ_N_U
VQRSHLQ_U
diff --git a/gcc/config/arm/vec-common.md b/gcc/config/arm/vec-common.md
index cbc9e25acbc..3e8387c54cb 100644
--- a/gcc/config/arm/vec-common.md
+++ b/gcc/config/arm/vec-common.md
@@ -179,3 +179,10 @@
(match_operand:VDQ 2 "neon_inv_logic_op2" "")))]
"TARGET_NEON || TARGET_HAVE_MVE"
)
+
+(define_expand "ior<mode>3"
+ [(set (match_operand:VDQ 0 "s_register_operand" "")
+ (ior:VDQ (match_operand:VDQ 1 "s_register_operand" "")
+ (match_operand:VDQ 2 "neon_logic_op2" "")))]
+ "TARGET_NEON || TARGET_HAVE_MVE"
+)
\ No newline at end of file
diff --git a/gcc/testsuite/gcc.target/arm/simd/mve-vorr.c b/gcc/testsuite/gcc.target/arm/simd/mve-vorr.c
new file mode 100644
index 00000000000..0d445fbe7a9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/simd/mve-vorr.c
@@ -0,0 +1,96 @@
+/* { dg-do assemble } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+/* { dg-additional-options "-O3" } */
+
+#include <stdint.h>
+
+/* 64-bit vectors. */
+void test_vorr_i32x2 (int32_t * __restrict__ dest, int32_t * a, int32_t * b) {
+ int i;
+ for (i=0; i<2; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u32x2 (uint32_t * __restrict__ dest, uint32_t * a, uint32_t * b) {
+ int i;
+ for (i=0; i<2; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_i16x4 (int16_t * __restrict__ dest, int16_t * a, int16_t * b) {
+ int i;
+ for (i=0; i<4; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u16x4 (uint16_t * __restrict__ dest, uint16_t * a, uint16_t * b) {
+ int i;
+ for (i=0; i<4; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_i8x8 (int8_t * __restrict__ dest, int8_t * a, int8_t * b) {
+ int i;
+ for (i=0; i<8; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u8x8 (uint8_t * __restrict__ dest, uint8_t * a, uint8_t * b) {
+ int i;
+ for (i=0; i<8; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+/* 128-bit vectors. */
+void test_vorr_i32x4 (int32_t * __restrict__ dest, int32_t * a, int32_t * b) {
+ int i;
+ for (i=0; i<4; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u32x4 (uint32_t * __restrict__ dest, uint32_t * a, uint32_t * b) {
+ int i;
+ for (i=0; i<4; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_i16x8 (int16_t * __restrict__ dest, int16_t * a, int16_t * b) {
+ int i;
+ for (i=0; i<8; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u16x8 (uint16_t * __restrict__ dest, uint16_t * a, uint16_t * b) {
+ int i;
+ for (i=0; i<8; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_i8x16 (int8_t * __restrict__ dest, int8_t * a, int8_t * b) {
+ int i;
+ for (i=0; i<16; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+void test_vorr_u8x16 (uint8_t * __restrict__ dest, uint8_t * a, uint8_t * b) {
+ int i;
+ for (i=0; i<16; i++) {
+ dest[i] = a[i] | b[i];
+ }
+}
+
+/* MVE has only 128-bit vectors, so we can vectorize only half of the
+ functions above. */
+/* { dg-final { scan-assembler-times {vorr\tq[0-9]+, q[0-9]+, q[0-9]+} 6 } } */
More information about the Gcc-cvs
mailing list