On Fri, 5 Sept 2025 at 13:54, Richard Biener <rguent...@suse.de> wrote: > > The PR reports > > vectorizer.h:276:3: runtime error: load of value 32695, which is not a valid > value for type 'internal_fn' > > which I believe is from > > slp_node->data = new vect_load_store_data (std::move (ls)); > > where 'ls' can be partly uninitialized (and that data will be not > used, but of course the move CTOR doesn't know this). The following > tries to fix that by using value-initialization of 'ls'. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu. > > Using ls() failed (somehow that got a function type?),
Yes, 'x y();' is a local declaration of a function that returns 'x', that syntax comes from C. > I hope {} is C++14. Yes, that's valid since C++11, and cannot be parsed as a function. > I also hope {} will value-initialize a union member in > the same way a defaulted move CTOR will access it. Yes, that should work fine. You could also just add a user-provided default constructor to vect_load_store_data so that it's always properly initialized, or at least add a default-initializer to the one member to ensure it's valid: --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -280,7 +280,7 @@ struct vect_load_store_data : vect_data { vect_memory_access_type memory_access_type; dr_alignment_support alignment_support_scheme; int misalignment; - internal_fn lanes_ifn; // VMAT_LOAD_STORE_LANES + internal_fn lanes_ifn{}; // VMAT_LOAD_STORE_LANES poly_int64 poffset; union { internal_fn ifn; // VMAT_GATHER_SCATTER_IFN > > PR tree-optimization/121703 > * tree-vect-stmts.cc (vectorizable_store): Value-initialize ls. > (vectorizable_load): Likewise. > --- > gcc/tree-vect-stmts.cc | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc > index 9fcc2fd0849..7eabf169a2b 100644 > --- a/gcc/tree-vect-stmts.cc > +++ b/gcc/tree-vect-stmts.cc > @@ -7881,7 +7881,7 @@ vectorizable_store (vec_info *vinfo, > if (!STMT_VINFO_DATA_REF (stmt_info)) > return false; > > - vect_load_store_data _ls_data; > + vect_load_store_data _ls_data{}; > vect_load_store_data &ls = slp_node->get_data (_ls_data); > if (cost_vec > && !get_load_store_type (vinfo, stmt_info, vectype, slp_node, > mask_node, > @@ -9451,7 +9451,7 @@ vectorizable_load (vec_info *vinfo, > else > group_size = 1; > > - vect_load_store_data _ls_data; > + vect_load_store_data _ls_data{}; > vect_load_store_data &ls = slp_node->get_data (_ls_data); > if (cost_vec > && !get_load_store_type (vinfo, stmt_info, vectype, slp_node, > mask_node, > -- > 2.51.0 >