https://gcc.gnu.org/g:1396d6015c968b69a3c45fe3ae4c3bd623ba4594
commit r17-5611-g1396d6015c968b69a3c45fe3ae4c3bd623ba4594 Author: Richard Biener <[email protected]> Date: Tue Oct 20 15:09:17 2026 +0200 Make match.pd single_use track a single use stmt The following adjusts single_use to instead of a single actual use tracks whether all uses are within a single statement. This is to make the existing (simplify (vec_perm (view_convert?@0 (vec_perm@1 @2 @3 VECTOR_CST@4)) @0 VECTOR_CST@5) ... /* If the new VEC_PERM_EXPR can't be handled but both original VEC_PERM_EXPRs can, punt. If one or both of the original VEC_PERM_EXPRs can't be handled and the new one can't be either, don't increase number of VEC_PERM_EXPRs that can't be handled. */ if (can_vec_perm_const_p (perm_mode, op2_mode, new_sel, false) || (single_use (@0) ? (!can_vec_perm_const_p (inner_mode, op2_mode, sel4, true) || !can_vec_perm_const_p (result_mode, vc_mode, sel5, true)) : !can_vec_perm_const_p (result_mode, vc_mode, sel5, true))) new_vcst = vec_perm_indices_to_tree (TREE_TYPE (@5), new_sel); work as expected where @0 has two uses in the single-vector permute. * gimple-match-head.cc (single_use): Track single use stmt. Diff: --- gcc/gimple-match-head.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gcc/gimple-match-head.cc b/gcc/gimple-match-head.cc index b2f26c71fc9c..c6a0c74eabb7 100644 --- a/gcc/gimple-match-head.cc +++ b/gcc/gimple-match-head.cc @@ -91,7 +91,7 @@ types_match (tree t1, tree t2, tree t3) return types_match (t1, t2) && types_match (t2, t3); } -/* Return if T has a single use. For GIMPLE, we also allow any +/* Return if T has uses in a single stmt. For GIMPLE, we also allow any non-SSA_NAME (ie constants) and zero uses to cope with uses that aren't linked up yet. */ @@ -107,14 +107,14 @@ single_use (const_tree t) /* Inline return has_zero_uses (t) || has_single_use (t); */ const ssa_use_operand_t *const head = &(SSA_NAME_IMM_USE_NODE (t)); const ssa_use_operand_t *ptr; - bool single = false; + gimple *single = NULL; for (ptr = head->next; ptr != head; ptr = ptr->next) - if (USE_STMT(ptr) && !is_gimple_debug (USE_STMT (ptr))) + if (USE_STMT (ptr) && !is_gimple_debug (USE_STMT (ptr))) { - if (single) + if (single && single != USE_STMT (ptr)) return false; - single = true; + single = USE_STMT (ptr); } return true; }
