diff mbox series

Fix fold-left reduction vectorization with multiple stmt copies

Message ID 20240607074536.608E0133F3@imap1.dmz-prg2.suse.org
State New
Headers show
Series Fix fold-left reduction vectorization with multiple stmt copies | expand

Commit Message

Richard Biener June 7, 2024, 7:45 a.m. UTC
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.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

	* tree-vect-loop.cc (vectorize_fold_left_reduction): Fix
	mask vector operand indexing.
---
 gcc/tree-vect-loop.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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,