Could you add testcase and dump tree check??







 ----------Reply to Message----------
 On Fri, Dec 13, 2024 19:47 PM Robin Dapp<rdapp....@gmail.com&gt; wrote:

  Hi,

for a generic vec_construct from scalar elements we need
to load each scalar element and move it over to a vector register.
This patch uses register-move cost and scalar_to_vec and multiplies
it with the number of elements in the vector.

This helps vectorization of e.g. x264 SATD with the default
-mvector-strict-align.

Regtested on rv64gcv_zvl512b.

Regards
&nbsp;Robin

PR target/118019

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_builtin_vectorization_cost):
Increase vec_construct cost.
---
&nbsp;gcc/config/riscv/riscv.cc | 8 +++++++-
&nbsp;1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index be2ebf9d9c0..aa8a4562d9a 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -12263,7 +12263,13 @@ riscv_builtin_vectorization_cost (enum 
vect_cost_for_stmt type_of_cost,
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return fp ? common_costs-&gt;fp_stmt_cost 
: common_costs-&gt;int_stmt_cost;
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; case vec_construct:
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return estimated_poly_value 
(TYPE_VECTOR_SUBPARTS (vectype));
+{
+&nbsp; /* TODO: This is too pessimistic in case we can splat.&nbsp; */
+&nbsp; int regmove_cost = fp ? costs-&gt;regmove-&gt;FR2VR
+&nbsp;&nbsp;&nbsp; : costs-&gt;regmove-&gt;GR2VR;
+&nbsp; return (regmove_cost + common_costs-&gt;scalar_to_vec_cost)
+&nbsp;&nbsp;&nbsp; * estimated_poly_value (TYPE_VECTOR_SUBPARTS (vectype));
+}
&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; default:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gcc_unreachable ();
-- 
2.47.1

Reply via email to