From: Richard Biener Date: Tue, 22 Jun 2021 07:10:56 +0000 (+0200) Subject: tree-optimization/101154 - fix out-of bound access in SLP X-Git-Tag: basepoints/gcc-13~6600 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=26f05f5a823030ebb52b107a8c303d07f77fe317;p=thirdparty%2Fgcc.git tree-optimization/101154 - fix out-of bound access in SLP This fixes an out-of-bound access of matches. 2021-06-22 Richard Biener PR tree-optimization/101154 * tree-vect-slp.c (vect_build_slp_tree_2): Fix out-of-bound access. --- diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index a32f86b8bc70..b9f91e7c7bae 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1963,15 +1963,15 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, if (dt == vect_constant_def || dt == vect_external_def) { - /* We can always build those. Might want to sort last - or defer building. */ - vec ops; - ops.create (group_size); - for (lane = 0; lane < group_size; ++lane) - ops.quick_push (chains[lane][n].op); - slp_tree child = vect_create_new_slp_node (ops); - SLP_TREE_DEF_TYPE (child) = dt; - children.safe_push (child); + /* We can always build those. Might want to sort last + or defer building. */ + vec ops; + ops.create (group_size); + for (lane = 0; lane < group_size; ++lane) + ops.quick_push (chains[lane][n].op); + slp_tree child = vect_create_new_slp_node (ops); + SLP_TREE_DEF_TYPE (child) = dt; + children.safe_push (child); } else if (dt != vect_internal_def) { @@ -2036,9 +2036,10 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node, dump_printf_loc (MSG_NOTE, vect_location, "failed to match up op %d\n", n); op_stmts.release (); - matches[lane] = false; if (lane != group_size - 1) matches[0] = false; + else + matches[lane] = false; goto out; } if (dump_enabled_p ())