]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
RISC-V: Reorder insn cost match order to match corresponding expander match order
authorPatrick O'Neill <patrick@rivosinc.com>
Tue, 20 Aug 2024 18:38:20 +0000 (11:38 -0700)
committerPatrick O'Neill <patrick@rivosinc.com>
Tue, 27 Aug 2024 17:01:13 +0000 (10:01 -0700)
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

index 1f544c1287ecf68fd881f75c1219d9ef6d150c0d..ca86754ec8bf470540bf2f73d305a36410292199 100644 (file)
@@ -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))
              {
@@ -2186,6 +2177,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.  */