vect: Merge loop mask and cond_op mask in fold-left reduction [PR115382].
Currently we discard the cond-op mask when the loop is fully masked which causes wrong code in gcc.dg/vect/vect-cond-reduc-in-order-2-signed-zero.c when compiled with -O3 -march=cascadelake --param vect-partial-vector-usage=2. This patch ANDs both masks. gcc/ChangeLog: PR tree-optimization/115382 * tree-vect-loop.cc (vectorize_fold_left_reduction): Use prepare_vec_mask. * tree-vect-stmts.cc (check_load_store_for_partial_vectors): Remove static of prepare_vec_mask. * tree-vectorizer.h (prepare_vec_mask): Export. (cherry picked from commit 2b438a0d2aa80f051a09b245a58f643540d4004b)
This commit is contained in:
parent
c58bede01c
commit
bf64404280
3 changed files with 13 additions and 2 deletions
|
@ -7188,7 +7188,15 @@ vectorize_fold_left_reduction (loop_vec_info loop_vinfo,
|
|||
tree len = NULL_TREE;
|
||||
tree bias = NULL_TREE;
|
||||
if (LOOP_VINFO_FULLY_MASKED_P (loop_vinfo))
|
||||
mask = vect_get_loop_mask (loop_vinfo, gsi, masks, vec_num, vectype_in, i);
|
||||
{
|
||||
tree loop_mask = vect_get_loop_mask (loop_vinfo, gsi, masks,
|
||||
vec_num, vectype_in, i);
|
||||
if (is_cond_op)
|
||||
mask = prepare_vec_mask (loop_vinfo, TREE_TYPE (loop_mask),
|
||||
loop_mask, vec_opmask[i], gsi);
|
||||
else
|
||||
mask = loop_mask;
|
||||
}
|
||||
else if (is_cond_op)
|
||||
mask = vec_opmask[0];
|
||||
if (LOOP_VINFO_FULLY_WITH_LENGTH_P (loop_vinfo))
|
||||
|
|
|
@ -1643,7 +1643,7 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype,
|
|||
MASK_TYPE is the type of both masks. If new statements are needed,
|
||||
insert them before GSI. */
|
||||
|
||||
static tree
|
||||
tree
|
||||
prepare_vec_mask (loop_vec_info loop_vinfo, tree mask_type, tree loop_mask,
|
||||
tree vec_mask, gimple_stmt_iterator *gsi)
|
||||
{
|
||||
|
|
|
@ -2495,6 +2495,9 @@ extern void vect_free_slp_tree (slp_tree);
|
|||
extern bool compatible_calls_p (gcall *, gcall *);
|
||||
extern int vect_slp_child_index_for_operand (const gimple *, int op, bool);
|
||||
|
||||
extern tree prepare_vec_mask (loop_vec_info, tree, tree, tree,
|
||||
gimple_stmt_iterator *);
|
||||
|
||||
/* In tree-vect-patterns.cc. */
|
||||
extern void
|
||||
vect_mark_pattern_stmts (vec_info *, stmt_vec_info, gimple *, tree);
|
||||
|
|
Loading…
Add table
Reference in a new issue