public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/clyon/heads/mve-autovec)] WIP: add new constraint to thumb2_movhi* patterns, and assorted fixes
@ 2022-01-12 8:28 Christophe Lyon
0 siblings, 0 replies; only message in thread
From: Christophe Lyon @ 2022-01-12 8:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:99515083dc34ab4473c8801ab0390dbd90a2db6b
commit 99515083dc34ab4473c8801ab0390dbd90a2db6b
Author: Christophe Lyon <christophe.lyon@foss.st.com>
Date: Tue Nov 16 13:58:33 2021 +0000
WIP: add new constraint to thumb2_movhi* patterns, and assorted fixes
hack simd_valid_immediate
hack simd_valid_immediate
fix vector-compare-2
Diff:
---
gcc/config/arm/arm-protos.h | 1 +
gcc/config/arm/arm.c | 29 ++++++++++++++++++++++++++++-
gcc/config/arm/constraints.md | 6 ++++++
gcc/config/arm/vfp.md | 20 ++++++++++++++++----
4 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 9e3d71e0c29..66bca03803a 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -101,6 +101,7 @@ extern char *neon_output_shift_immediate (const char *, char, rtx *,
machine_mode, int, bool);
extern void neon_pairwise_reduce (rtx, rtx, machine_mode,
rtx (*) (rtx, rtx, rtx));
+extern rtx mve_const_bool_vec_to_hi (rtx const_vec);
extern rtx neon_make_constant (rtx, bool generate = true);
extern tree arm_builtin_vectorized_function (unsigned int, tree, tree);
extern void neon_expand_vector_init (rtx, rtx);
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index bc18d3c888d..3b6a52ce40c 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -12754,7 +12754,8 @@ simd_valid_immediate (rtx op, machine_mode mode, int inverse,
innersize = GET_MODE_UNIT_SIZE (mode);
/* Only support 128-bit vectors for MVE. */
- if (TARGET_HAVE_MVE && (!vector || n_elts * innersize != 16))
+ if (TARGET_HAVE_MVE
+ && (!vector || (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL) || n_elts * innersize != 16))
return -1;
/* Vectors of float constants. */
@@ -13119,6 +13120,30 @@ neon_vdup_constant (rtx vals, bool generate)
return gen_vec_duplicate (mode, x);
}
+/* FIXME: not sure this is really needed, since it doesn't fix
+ vector-compare-2.c at -O0. */
+rtx
+mve_const_bool_vec_to_hi (rtx const_vec)
+{
+ int n_elts = GET_MODE_NUNITS ( GET_MODE (const_vec));
+ int repeat = 16 / n_elts;
+ int i;
+ int hi_val = 0;
+
+ for (i = 0; i < n_elts; i++)
+ {
+ rtx el = CONST_VECTOR_ELT (const_vec, i);
+ unsigned HOST_WIDE_INT elpart;
+
+ gcc_assert (CONST_INT_P (el));
+ elpart = INTVAL (el);
+
+ for (int j = 0; j < repeat; j++)
+ hi_val |= elpart << (i * repeat + j);
+ }
+ return GEN_INT (hi_val);
+}
+
/* Return a non-NULL RTX iff VALS, which is a PARALLEL containing only
constants (for vec_init) or CONST_VECTOR, can be effeciently loaded
into a register.
@@ -13159,6 +13184,8 @@ neon_make_constant (rtx vals, bool generate)
&& simd_immediate_valid_for_move (const_vec, mode, NULL, NULL))
/* Load using VMOV. On Cortex-A8 this takes one cycle. */
return const_vec;
+ else if (TARGET_HAVE_MVE && (GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL))
+ return mve_const_bool_vec_to_hi (const_vec);
else if ((target = neon_vdup_constant (vals, generate)) != NULL_RTX)
/* Loaded using VDUP. On Cortex-A8 the VDUP takes one NEON
pipeline cycle; creating the constant takes one or two ARM
diff --git a/gcc/config/arm/constraints.md b/gcc/config/arm/constraints.md
index a5a19a7ed5b..acc447ba0f0 100644
--- a/gcc/config/arm/constraints.md
+++ b/gcc/config/arm/constraints.md
@@ -312,6 +312,12 @@
(and (match_code "const_vector")
(match_test "(TARGET_NEON || TARGET_HAVE_MVE) && op == CONST0_RTX (mode)")))
+(define_constraint "DB"
+ "@internal
+ In ARM/Thumb-2 state with MVE a constant vector of booleans."
+ (and (match_code "const_vector")
+ (match_test "TARGET_HAVE_MVE && GET_MODE_CLASS (mode) == MODE_VECTOR_BOOL")))
+
(define_constraint "Da"
"@internal
In ARM/Thumb-2 state a const_int, const_double or const_vector that can
diff --git a/gcc/config/arm/vfp.md b/gcc/config/arm/vfp.md
index b94b54e8a79..de17f5895dd 100644
--- a/gcc/config/arm/vfp.md
+++ b/gcc/config/arm/vfp.md
@@ -76,7 +76,7 @@
(match_operand:MVE_7_HI 0 "nonimmediate_operand"
"=rk, r, l, r, m, r, *t, r, *t, Up, r")
(match_operand:MVE_7_HI 1 "general_operand"
- "rk, I, Py, n, r, m, r, *t, *t, r, Up"))]
+ "rk, IDB, Py, n, r, m, r, *t, *t, r, Up"))]
"TARGET_THUMB2 && TARGET_VFP_BASE
&& !TARGET_VFP_FP16INST
&& (register_operand (operands[0], <MODE>mode)
@@ -85,9 +85,14 @@
switch (which_alternative)
{
case 0:
- case 1:
case 2:
return "mov%?\t%0, %1\t%@ movhi";
+ case 1:
+ if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_VECTOR_BOOL)
+ operands[1] = mve_const_bool_vec_to_hi (operands[1]);
+ else
+ operands[1] = gen_lowpart (HImode, operands[1]);
+ return "mov%?\t%0, %1\t%@ movhi";
case 3:
return "movw%?\t%0, %L1\t%@ movhi";
case 4:
@@ -176,17 +181,24 @@
(match_operand:MVE_7_HI 0 "nonimmediate_operand"
"=rk, r, l, r, m, r, *t, r, *t, Up, r")
(match_operand:MVE_7_HI 1 "general_operand"
- "rk, I, Py, n, r, m, r, *t, *t, r, Up"))]
+ "rk, IDB, Py, n, r, m, r, *t, *t, r, Up"))]
"TARGET_THUMB2 && (TARGET_VFP_FP16INST || TARGET_HAVE_MVE)
&& (register_operand (operands[0], <MODE>mode)
|| register_operand (operands[1], <MODE>mode))"
{
+extern rtx mve_const_bool_vec_to_hi (rtx const_vec);
+
switch (which_alternative)
{
case 0:
- case 1:
case 2:
return "mov%?\t%0, %1\t%@ movhi";
+ case 1:
+ if (GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_VECTOR_BOOL)
+ operands[1] = mve_const_bool_vec_to_hi (operands[1]);
+ else
+ operands[1] = gen_lowpart (HImode, operands[1]);
+ return "mov%?\t%0, %1\t%@ movhi";
case 3:
return "movw%?\t%0, %L1\t%@ movhi";
case 4:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-12 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-12 8:28 [gcc(refs/users/clyon/heads/mve-autovec)] WIP: add new constraint to thumb2_movhi* patterns, and assorted fixes Christophe Lyon
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).