On Tue, 6 Oct 2026, [email protected] wrote: > From: Kyrylo Tkachov <[email protected]> > > nodes_overlap_p returns true for any two DT_OPERAND nodes whose > operand cases overlap. decision_tree::find_node uses this to set > overlap_node, which prevents a later node from merging into an earlier > equal sibling across the blocking node. > > Of the 163 barrier refusals on trunk, 135 (83%) are between the GIMPLE > form and the GENERIC form that lower_cond gives every COND_EXPR > condition. gen_kids_1 dispatches the GIMPLE form under the SSA_NAME > case and the GENERIC form by the operand's own TREE_CODE. An input > cannot satisfy both dispatch conditions simultaneously, so these 135 > refusals protect no ordering-sensitive case. > > Add a check in nodes_overlap_p: return false when the two expressions > differ in is_generic. This eliminates the spurious GIMPLE/GENERIC > overlap refusals while keeping every DT_MATCH and overlapping > operator-set refusal. The 7 remaining order-sensitive pattern pairs > all require degenerate inputs that other patterns fold first, and both > of the patterns in each pair produce the same result value. > > On aarch64 at ten GIMPLE parts, GIMPLE lines fall by about 0.6%. > GENERIC output is unchanged. > > Bootstrapped and tested on aarch64-none-linux-gnu. > Ok for trunk?
OK. Hopefully we manage to get rid of the GENERIC parts during GIMPLE matching, Andrea is working on this IIRC. Thanks, Richard. > Thanks, > Kyrill > > gcc/ChangeLog: > > * genmatch.cc (nodes_overlap_p): Return false when the two > expressions have different is_generic, as they cannot match the > same input. > > Signed-off-by: Kyrylo Tkachov <[email protected]> > --- > gcc/genmatch.cc | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc > index e6065a039ef..905ff420d6a 100644 > --- a/gcc/genmatch.cc > +++ b/gcc/genmatch.cc > @@ -2847,8 +2847,16 @@ nodes_overlap_p (dt_node *n1, dt_node *n2) > if (n1->type == dt_node::DT_MATCH || n2->type == dt_node::DT_MATCH) > return true; > > - return operand_cases_overlap_p (as_a <dt_operand *> (n1)->op, > - as_a <dt_operand *> (n2)->op); > + operand *op1 = as_a <dt_operand *> (n1)->op; > + operand *op2 = as_a <dt_operand *> (n2)->op; > + /* A GIMPLE expression and a GENERIC expression are dispatched through > + separate paths (SSA_NAME case vs. operand TREE_CODE) and cannot > + match the same input. */ > + expr *e1 = op1 ? dyn_cast <expr *> (op1) : NULL; > + expr *e2 = op2 ? dyn_cast <expr *> (op2) : NULL; > + if (e1 && e2 && e1->is_generic != e2->is_generic) > + return false; > + return operand_cases_overlap_p (op1, op2); > } > > /* Search OPS for a decision tree node like P and return it if found. */ > -- Richard Biener <[email protected]> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)
