From: Richard Biener Date: Mon, 20 Nov 2023 14:16:44 +0000 (+0100) Subject: tree-optimization/111970 - fix issue with SLP of emulated gather/scatter X-Git-Tag: basepoints/gcc-15~4504 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c656d268c9dac8b6f710b9bbd399214cb11b3287;p=thirdparty%2Fgcc.git tree-optimization/111970 - fix issue with SLP of emulated gather/scatter There's a missed index adjustment for the SLP vector number when computing the index/data vectors for emulated gather/scatter with SLP. The following fixes this. PR tree-optimization/111970 * tree-vect-stmts.cc (vectorizable_load): Fix offset calculation for SLP gather load. (vectorizable_store): Likewise for SLP scatter store. --- diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 96e4a6cffade..bf8c99779aee 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9188,7 +9188,8 @@ vectorizable_store (vec_info *vinfo, unsigned HOST_WIDE_INT factor = const_offset_nunits / const_nunits; vec_offset = vec_offsets[(vec_num * j + i) / factor]; - unsigned elt_offset = (j % factor) * const_nunits; + unsigned elt_offset + = ((vec_num * j + i) % factor) * const_nunits; tree idx_type = TREE_TYPE (TREE_TYPE (vec_offset)); tree scale = size_int (gs_info.scale); align = get_object_alignment (DR_REF (first_dr_info->dr)); @@ -11150,7 +11151,8 @@ vectorizable_load (vec_info *vinfo, unsigned HOST_WIDE_INT factor = const_offset_nunits / const_nunits; vec_offset = vec_offsets[(vec_num * j + i) / factor]; - unsigned elt_offset = (j % factor) * const_nunits; + unsigned elt_offset + = ((vec_num * j + i) % factor) * const_nunits; tree idx_type = TREE_TYPE (TREE_TYPE (vec_offset)); tree scale = size_int (gs_info.scale); align = get_object_alignment (DR_REF (first_dr_info->dr));