On 5/3/25 2:14 AM, pan2...@intel.com wrote:
From: Pan Li <pan2...@intel.com>

During investigate the combine from vec_dup and vop.vv into
vop.vx, we need to depend on the cost of the insn operate
from the gr to vr, for example, vadd.vx.  Thus, for better
control and test, we introduce a new option, aka below:

--param=rvv-gr2vr-cost=<unsigned int>

To specific the cost value of the insn that operate from
the gr to vr.

gcc/ChangeLog:

        * config/riscv/riscv-opts.h (RVV_GR2VR_COST_UNPROVIDED): Add
        new macro to indicate the param is not provided.
        * config/riscv/riscv.cc (get_vector_gr2vr_cost): Add new func
        to get the cost value of rvv insn operate from gr to vr.
        * config/riscv/riscv.opt: Add new option --pararm=rvv-gr2vr-cost.

Signed-off-by: Pan Li <pan2...@intel.com>
---
  gcc/config/riscv/riscv-opts.h |  2 ++
  gcc/config/riscv/riscv.cc     | 11 +++++++++++
  gcc/config/riscv/riscv.opt    |  4 ++++
  3 files changed, 17 insertions(+)

diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h
index 26fe228e0f8..670f540f11d 100644
--- a/gcc/config/riscv/riscv-opts.h
+++ b/gcc/config/riscv/riscv-opts.h
@@ -162,4 +162,6 @@ enum riscv_tls_type {
  #define TARGET_VECTOR_AUTOVEC_SEGMENT                                        \
    (TARGET_VECTOR && riscv_mautovec_segment)
+#define RVV_GR2VR_COST_UNPROVIDED -1
+
  #endif /* ! GCC_RISCV_OPTS_H */
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index ed635ab42f4..ee23888cbf7 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -3851,6 +3851,17 @@ riscv_extend_cost (rtx op, bool unsigned_p)
    return COSTS_N_INSNS (2);
  }
+static inline int
+get_vector_gr2vr_cost ()
Make sure to include a function comment in the final patch. Otherwise nothing to add above and beyond Robin's comments.

jeff

Reply via email to