https://gcc.gnu.org/g:b01ae7a2b589e015617bed7110b6291c5ecd420c

commit r16-3388-gb01ae7a2b589e015617bed7110b6291c5ecd420c
Author: Richard Biener <rguent...@suse.de>
Date:   Tue Aug 26 10:43:42 2025 +0200

    Fix UBSAN issue with load-store data refactoring
    
    The following makes sure to read from the lanes_ifn member only
    when necessary (and thus it was set).
    
            * tree-vect-stmts.cc (vectorizable_store): Access lanes_ifn
            only when VMAT_LOAD_STORE_LANES.
            (vectorizable_load): Likewise.

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

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 653c5e38e274..1545fab36479 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -7891,7 +7891,6 @@ vectorizable_store (vec_info *vinfo,
     = ls.alignment_support_scheme;
   const int misalignment = ls.misalignment;
   const poly_int64 poffset = ls.poffset;
-  const internal_fn lanes_ifn = ls.lanes_ifn;
 
   if (slp_node->ldst_lanes
       && memory_access_type != VMAT_LOAD_STORE_LANES)
@@ -8395,6 +8394,8 @@ vectorizable_store (vec_info *vinfo,
 
   if (memory_access_type == VMAT_LOAD_STORE_LANES)
     {
+      const internal_fn lanes_ifn = ls.lanes_ifn;
+
       if (costing_p)
        /* Update all incoming store operand nodes, the general handling
           above only handles the mask and the first store operand node.  */
@@ -9460,7 +9461,6 @@ vectorizable_load (vec_info *vinfo,
     = ls.alignment_support_scheme;
   const int misalignment = ls.misalignment;
   const poly_int64 poffset = ls.poffset;
-  const internal_fn lanes_ifn = ls.lanes_ifn;
   const vec<int> &elsvals = ls.elsvals;
 
   int maskload_elsval = 0;
@@ -10241,6 +10241,8 @@ vectorizable_load (vec_info *vinfo,
   tree vec_els = NULL_TREE;
   if (memory_access_type == VMAT_LOAD_STORE_LANES)
     {
+      const internal_fn lanes_ifn = ls.lanes_ifn;
+
       gcc_assert (alignment_support_scheme == dr_aligned
                  || alignment_support_scheme == dr_unaligned_supported);

Reply via email to