https://gcc.gnu.org/g:38370907dce41bd170cf37d864d6ddc9ca3a9652

commit r17-4605-g38370907dce41bd170cf37d864d6ddc9ca3a9652
Author: Richard Biener <[email protected]>
Date:   Wed Sep 23 09:53:06 2026 +0200

    Adjust scalar_to_vec use for invariant loads
    
    When the invariant load is not uniform we cost it wrongly, fix that
    and avoid using scalar_to_vec for non-splats.  We have vec_construct
    for that now.
    
            * tree-vect-stmts.cc (vectorizable_load): Cost non-uniform
            invariant loads more appropriately.

Diff:
---
 gcc/tree-vect-stmts.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index eb78fd2eba39..9cfec1bb4ac5 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -10080,9 +10080,13 @@ vectorizable_load (vec_info *vinfo,
            }
          enum vect_cost_model_location cost_loc
            = hoist_p ? vect_prologue : vect_body;
-         unsigned int cost = record_stmt_cost (cost_vec, 1, scalar_load,
+         unsigned int cost = record_stmt_cost (cost_vec,
+                                               uniform_p
+                                               ? 1 : SLP_TREE_LANES (slp_node),
+                                               scalar_load,
                                                slp_node, 0, cost_loc);
-         cost += record_stmt_cost (cost_vec, 1, scalar_to_vec,
+         cost += record_stmt_cost (cost_vec, 1,
+                                   uniform_p ? scalar_to_vec : vec_construct,
                                    slp_node, 0, cost_loc);
          unsigned int prologue_cost = hoist_p ? cost : 0;
          unsigned int inside_cost = hoist_p ? 0 : cost;

Reply via email to