diff mbox series

[4/9] RISC-V: Reorder insn cost match order to match corresponding expander match order

Message ID 20240822194705.2789364-5-patrick@rivosinc.com
State New
Headers show
Series RISC-V: Improve const vector costing and expansion | expand

Commit Message

Patrick O'Neill Aug. 22, 2024, 7:46 p.m. UTC
The corresponding expander (riscv-v.cc:expand_const_vector) matches
const_vec_duplicate_p before const_vec_series_p. Reorder to match this
behavior when calculating costs.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_const_insns): Relocate.

Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
---
 gcc/config/riscv/riscv.cc | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

Comments

Jeff Law Aug. 25, 2024, 1:50 p.m. UTC | #1
On 8/22/24 1:46 PM, Patrick O'Neill wrote:
> The corresponding expander (riscv-v.cc:expand_const_vector) matches
> const_vec_duplicate_p before const_vec_series_p. Reorder to match this
> behavior when calculating costs.
> 
> gcc/ChangeLog:
> 
> 	* config/riscv/riscv.cc (riscv_const_insns): Relocate.
OK
jeff
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index dc9e9280c8c..eb1c172d1ce 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -2142,15 +2142,6 @@  riscv_const_insns (rtx x, bool allow_new_pseudos)
 	  ...etc.  */
 	if (riscv_v_ext_mode_p (GET_MODE (x)))
 	  {
-	    /* const series vector.  */
-	    rtx base, step;
-	    if (const_vec_series_p (x, &base, &step))
-	      {
-		/* This is not accurate, we will need to adapt the COST
-		 * accurately according to BASE && STEP.  */
-		return 1;
-	      }
-
 	    rtx elt;
 	    if (const_vec_duplicate_p (x, &elt))
 	      {
@@ -2184,6 +2175,15 @@  riscv_const_insns (rtx x, bool allow_new_pseudos)
 		      return 1 + 4; /*vmv.v.x + memory access.  */
 		  }
 	      }
+
+	    /* const series vector.  */
+	    rtx base, step;
+	    if (const_vec_series_p (x, &base, &step))
+	      {
+		/* This cost is not accurate, we will need to adapt the COST
+		   accurately according to BASE && STEP.  */
+		return 1;
+	      }
 	  }
 
 	/* TODO: We may support more const vector in the future.  */