https://gcc.gnu.org/g:81aa79e97763b1fd4616812d69a92c5c26ba34a1
commit r16-4281-g81aa79e97763b1fd4616812d69a92c5c26ba34a1 Author: Richard Biener <[email protected]> Date: Tue Oct 7 15:32:45 2025 +0200 Fixup store bool pattern I think the bool pattern recognition for a store from a bool we decided to represent with a mask type is a bit confused. The following streamlines it by using the mask to create a data 0/1 and first possibly converting the mask according to the vector data type we produce (that was missing and is noticable in PR110223). This alone doesn't fix the 2nd testcase from the PR, but is required. PR tree-optimization/110223 * tree-vect-patterns.cc (vect_recog_bool_pattern): Fix mistakes in the store-from-mask bool pattern. Add required mask conversions. Diff: --- gcc/tree-vect-patterns.cc | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index dccd3c9806e6..55c50420e32a 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -5763,30 +5763,18 @@ vect_recog_bool_pattern (vec_info *vinfo, return NULL; tree type = integer_type_for_mask (var, vinfo); - tree cst0, cst1, new_vectype; - if (!type) return NULL; - if (TYPE_MODE (type) == TYPE_MODE (TREE_TYPE (vectype))) - type = TREE_TYPE (vectype); - - cst0 = build_int_cst (type, 0); - cst1 = build_int_cst (type, 1); - new_vectype = get_vectype_for_scalar_type (vinfo, type); + var = vect_convert_mask_for_vectype (var, vectype, stmt_vinfo, vinfo); - rhs = vect_recog_temp_ssa_var (type, NULL); + tree cst0 = build_int_cst (TREE_TYPE (vectype), 0); + tree cst1 = build_int_cst (TREE_TYPE (vectype), 1); + rhs = vect_recog_temp_ssa_var (TREE_TYPE (vectype), NULL); pattern_stmt = gimple_build_assign (rhs, COND_EXPR, var, cst1, cst0); - append_pattern_def_seq (vinfo, stmt_vinfo, pattern_stmt, new_vectype); + append_pattern_def_seq (vinfo, stmt_vinfo, pattern_stmt, vectype); lhs = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vectype), lhs); - if (!useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (rhs))) - { - tree rhs2 = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); - gimple *cast_stmt = gimple_build_assign (rhs2, NOP_EXPR, rhs); - append_pattern_def_seq (vinfo, stmt_vinfo, cast_stmt); - rhs = rhs2; - } pattern_stmt = gimple_build_assign (lhs, SSA_NAME, rhs); pattern_stmt_info = vinfo->add_stmt (pattern_stmt); vinfo->move_dr (pattern_stmt_info, stmt_vinfo);
