diff mbox series

arm: [MVE intrinsics] Fix moves of tuples (PR target/118131)

Message ID 20241219164511.3016966-1-christophe.lyon@linaro.org
State New
Headers show
Series arm: [MVE intrinsics] Fix moves of tuples (PR target/118131) | expand

Commit Message

Christophe Lyon Dec. 19, 2024, 4:45 p.m. UTC
Commit r15-6245-g4f4e13dd235b introduced new modes for MVE tuples, but
missed adding support for them in a few places.

Adding them to the list in arm_attr_length_move_neon is not sufficient
since we later face another ICE where the compiler does not know how
to split move of such data.

The patch therefore enhances the define_splits for OI and XI moves in
neon.md, via the introduction of new iterators.

In addition, it seems consistent to update output_move_neon such that
VALID_NEON_*_MODE are used only when TARGET_NEON.

gcc/ChangeLog:

	PR target/118131
	* config/arm/arm.cc (output_move_neon): Check TARGET_NEON as
	needed.
	(arm_attr_length_move_neon): Add support for V2x and V4x MVE tuple
	modes.
	* config/arm/iterators.md (VSTRUCT2, VSTRUCT4): New.
	* config/arm/neon.md: Use VSTRUCT2 instead of OI and VSTRUCT4
	instead of XI in define_split.
---
 gcc/config/arm/arm.cc       | 25 +++++++++++++++++++------
 gcc/config/arm/iterators.md | 18 ++++++++++++++++++
 gcc/config/arm/neon.md      |  8 ++++----
 3 files changed, 41 insertions(+), 10 deletions(-)

Comments

Richard Earnshaw (lists) Dec. 20, 2024, 10:15 a.m. UTC | #1
On 19/12/2024 16:45, Christophe Lyon wrote:
> Commit r15-6245-g4f4e13dd235b introduced new modes for MVE tuples, but
> missed adding support for them in a few places.
> 
> Adding them to the list in arm_attr_length_move_neon is not sufficient
> since we later face another ICE where the compiler does not know how
> to split move of such data.
> 
> The patch therefore enhances the define_splits for OI and XI moves in
> neon.md, via the introduction of new iterators.
> 
> In addition, it seems consistent to update output_move_neon such that
> VALID_NEON_*_MODE are used only when TARGET_NEON.
> 
> gcc/ChangeLog:
> 
> 	PR target/118131
> 	* config/arm/arm.cc (output_move_neon): Check TARGET_NEON as
> 	needed.
> 	(arm_attr_length_move_neon): Add support for V2x and V4x MVE tuple
> 	modes.
> 	* config/arm/iterators.md (VSTRUCT2, VSTRUCT4): New.
> 	* config/arm/neon.md: Use VSTRUCT2 instead of OI and VSTRUCT4
> 	instead of XI in define_split.

OK.

R.
diff mbox series

Patch

diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index ecdb1bd136e..7a750e02d61 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -20775,11 +20775,13 @@  output_move_neon (rtx *operands)
   nregs = REG_NREGS (reg) / 2;
   gcc_assert (VFP_REGNO_OK_FOR_DOUBLE (regno)
 	      || NEON_REGNO_OK_FOR_QUAD (regno));
-  gcc_assert (VALID_NEON_DREG_MODE (mode)
-	      || VALID_NEON_QREG_MODE (mode)
-	      || VALID_NEON_STRUCT_MODE (mode)
+  gcc_assert ((TARGET_NEON
+	       && (VALID_NEON_DREG_MODE (mode)
+		   || VALID_NEON_QREG_MODE (mode)
+		   || VALID_NEON_STRUCT_MODE (mode)))
 	      || (TARGET_HAVE_MVE
-		  && VALID_MVE_STRUCT_MODE (mode)));
+		  && (VALID_MVE_MODE (mode)
+		      || VALID_MVE_STRUCT_MODE (mode))));
   gcc_assert (MEM_P (mem));
 
   addr = XEXP (mem, 0);
@@ -20882,8 +20884,9 @@  output_move_neon (rtx *operands)
   return "";
 }
 
-/* Compute and return the length of neon_mov<mode>, where <mode> is
-   one of VSTRUCT modes: EI, OI, CI or XI.  */
+/* Compute and return the length of neon_mov<mode>, where <mode> is one of
+   VSTRUCT modes: EI, OI, CI or XI for Neon, and V2x16QI, V2x8HI, V2x4SI,
+   V2x8HF, V2x4SF, V2x16QI, V2x8HI, V2x4SI, V2x8HF, V2x4SF for MVE.  */
 int
 arm_attr_length_move_neon (rtx_insn *insn)
 {
@@ -20900,10 +20903,20 @@  arm_attr_length_move_neon (rtx_insn *insn)
 	{
 	case E_EImode:
 	case E_OImode:
+	case E_V2x16QImode:
+	case E_V2x8HImode:
+	case E_V2x4SImode:
+	case E_V2x8HFmode:
+	case E_V2x4SFmode:
 	  return 8;
 	case E_CImode:
 	  return 12;
 	case E_XImode:
+	case E_V4x16QImode:
+	case E_V4x8HImode:
+	case E_V4x4SImode:
+	case E_V4x8HFmode:
+	case E_V4x4SFmode:
 	  return 16;
 	default:
 	  gcc_unreachable ();
diff --git a/gcc/config/arm/iterators.md b/gcc/config/arm/iterators.md
index cfe712ceda9..6756e29721c 100644
--- a/gcc/config/arm/iterators.md
+++ b/gcc/config/arm/iterators.md
@@ -152,6 +152,24 @@  (define_mode_iterator VSTRUCT [(EI "!TARGET_HAVE_MVE") OI
 			       (V4x4SF "TARGET_HAVE_MVE_FLOAT")
 			       ])
 
+;; Structure types of the same size as OImode
+(define_mode_iterator VSTRUCT2 [OI
+			       (V2x16QI "TARGET_HAVE_MVE")
+			       (V2x8HI "TARGET_HAVE_MVE")
+			       (V2x4SI "TARGET_HAVE_MVE")
+			       (V2x8HF "TARGET_HAVE_MVE_FLOAT")
+			       (V2x4SF "TARGET_HAVE_MVE_FLOAT")
+			       ])
+
+;; Structure types of the same size as XImode
+(define_mode_iterator VSTRUCT4 [XI
+			       (V4x16QI "TARGET_HAVE_MVE")
+			       (V4x8HI "TARGET_HAVE_MVE")
+			       (V4x4SI "TARGET_HAVE_MVE")
+			       (V4x8HF "TARGET_HAVE_MVE_FLOAT")
+			       (V4x4SF "TARGET_HAVE_MVE_FLOAT")
+			       ])
+
 ;; Opaque structure types used in table lookups (except vtbl1/vtbx1).
 (define_mode_iterator VTAB [TI EI OI])
 
diff --git a/gcc/config/arm/neon.md b/gcc/config/arm/neon.md
index 6892b7b0f44..cfd8520c2ea 100644
--- a/gcc/config/arm/neon.md
+++ b/gcc/config/arm/neon.md
@@ -215,8 +215,8 @@  (define_split
 })
 
 (define_split
-  [(set (match_operand:OI 0 "s_register_operand" "")
-	(match_operand:OI 1 "s_register_operand" ""))]
+  [(set (match_operand:VSTRUCT2 0 "s_register_operand" "")
+	(match_operand:VSTRUCT2 1 "s_register_operand" ""))]
   "(TARGET_NEON || TARGET_HAVE_MVE)&& reload_completed"
   [(set (match_dup 0) (match_dup 1))
    (set (match_dup 2) (match_dup 3))]
@@ -256,8 +256,8 @@  (define_split
 })
 
 (define_split
-  [(set (match_operand:XI 0 "s_register_operand" "")
-	(match_operand:XI 1 "s_register_operand" ""))]
+  [(set (match_operand:VSTRUCT4 0 "s_register_operand" "")
+	(match_operand:VSTRUCT4 1 "s_register_operand" ""))]
   "(TARGET_NEON || TARGET_HAVE_MVE) && reload_completed"
   [(set (match_dup 0) (match_dup 1))
    (set (match_dup 2) (match_dup 3))