This patch fixes following FAILs for RVV: FAIL: gcc.dg/vect/vect-gather-1.c -flto -ffat-lto-objects scan-tree-dump vect "Loop contains only SLP stmts" FAIL: gcc.dg/vect/vect-gather-1.c scan-tree-dump vect "Loop contains only SLP stmts"
Bootstrap on X86 and regtest passed. Tested on aarch64 passed. Ok for trunk ? PR tree-optimization/111721 gcc/ChangeLog: * tree-vect-slp.cc (vect_get_and_check_slp_defs): Support SLP for dummy mask -1. * tree-vect-stmts.cc (vectorizable_load): Ditto. --- gcc/tree-vect-slp.cc | 14 ++++++++++++-- gcc/tree-vect-stmts.cc | 8 +++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 43d742e3c92..23ca0318e31 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -756,8 +756,7 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap, { tree type = TREE_TYPE (oprnd); dt = dts[i]; - if ((dt == vect_constant_def - || dt == vect_external_def) + if (dt == vect_external_def && !GET_MODE_SIZE (vinfo->vector_mode).is_constant () && (TREE_CODE (type) == BOOLEAN_TYPE || !can_duplicate_and_interleave_p (vinfo, stmts.length (), @@ -769,6 +768,17 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap, "for variable-length SLP %T\n", oprnd); return -1; } + if (dt == vect_constant_def + && !GET_MODE_SIZE (vinfo->vector_mode).is_constant () + && !can_duplicate_and_interleave_p (vinfo, stmts.length (), type)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Build SLP failed: invalid type of def " + "for variable-length SLP %T\n", + oprnd); + return -1; + } /* For the swapping logic below force vect_reduction_def for the reduction op in a SLP reduction group. */ diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index 6ce4868d3e1..6c47121e158 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -9859,10 +9859,16 @@ vectorizable_load (vec_info *vinfo, mask_index = internal_fn_mask_index (ifn); if (mask_index >= 0 && slp_node) mask_index = vect_slp_child_index_for_operand (call, mask_index); + slp_tree slp_op = NULL; if (mask_index >= 0 && !vect_check_scalar_mask (vinfo, stmt_info, slp_node, mask_index, - &mask, NULL, &mask_dt, &mask_vectype)) + &mask, &slp_op, &mask_dt, &mask_vectype)) return false; + /* MASK_LEN_GATHER_LOAD dummy mask -1 should always match the + MASK_VECTYPE. */ + if (mask_index >= 0 && slp_node && mask_dt == vect_constant_def + && !vect_maybe_update_slp_op_vectype (slp_op, mask_vectype)) + gcc_unreachable (); } tree vectype = STMT_VINFO_VECTYPE (stmt_info); -- 2.36.3