From: Richard Biener Date: Fri, 7 Jun 2024 07:41:11 +0000 (+0200) Subject: Fix fold-left reduction vectorization with multiple stmt copies X-Git-Tag: basepoints/gcc-16~8456 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dd6f942c266533b2f72610f354bc9184f8276beb;p=thirdparty%2Fgcc.git Fix fold-left reduction vectorization with multiple stmt copies There's a typo when code generating the mask operand for conditional fold-left reductions in the case we have multiple stmt copies. The latter is now allowed for SLP and possibly disabled for non-SLP by accident. This fixes the observed run-FAIL for gcc.dg/vect/vect-cond-reduc-in-order-2-signed-zero.c with AVX512 and 256bit sized vectors. * tree-vect-loop.cc (vectorize_fold_left_reduction): Fix mask vector operand indexing. --- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index ceb92156b58..028692614bb 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -7217,7 +7217,7 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo, if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)) mask = vect_get_loop_mask (loop_vinfo, gsi, masks, vec_num, vectype_in, i); else if (is_cond_op) - mask = vec_opmask[0]; + mask = vec_opmask[i]; if (LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo)) { len = vect_get_loop_len (loop_vinfo, gsi, lens, vec_num, vectype_in,