On Fri, Nov 21, 2025 at 2:41 PM Li, Pan2 <[email protected]> wrote: > > Thanks Richard. > > > Please use (nop_convert (bitop... > > It complains predicate cannot be outermost expr with blow change, is there > something missing from my side? > I searched match.pd with ^\s(nop_con but failed to find anything I can ref.... > > (simplify > - (convert (bitop:cs@2 (convert:s @0) @1)) > + (nop_convert (bitop:cs@2 (convert:s @0) @1)) > > .../gcc/__build__/../gcc/match.pd:2316:3 error: outermost expression cannot > be a predicate > (nop_convert (bitop:cs@2 (convert:s @0) @1))
Ah, true - I forgot about this limitation. The original patch is OK. Thanks, Richard. > > Pan > > -----Original Message----- > From: Richard Biener <[email protected]> > Sent: Friday, November 21, 2025 8:52 PM > To: Li, Pan2 <[email protected]> > Cc: [email protected]; [email protected]; [email protected]; > [email protected]; [email protected]; Chen, Ken <[email protected]>; > Liu, Hongtao <[email protected]>; [email protected] > Subject: Re: [PATCH v2 1/3] Match: Simplify (T1)(a bit_op (T2)b) to (T1)a > bit_op (T1)b > > On Sat, Nov 15, 2025 at 4:26 AM <[email protected]> wrote: > > > > From: Pan Li <[email protected]> > > > > During the match pattern of SAT_U_MUL form 7, we found there is > > a pattern like below: > > > > (nop_convert)(a bit_op (convert b)) > > > > which result in the pattern match of SAT_U_MUL complicated and > > unintuitive. According to the suggestion of Richard, we would > > like to simply it to blew: > > > > (convert a) bit_op (convert b) > > > > which is more friendly for reading and bit_op. There are three > > bit_op here, aka bit_ior, bit_and and bit_xor. > > > > gcc/ChangeLog: > > > > * match.pd: Add simplfy to fold outer convert of bit_op > > to inner captures. > > > > Signed-off-by: Pan Li <[email protected]> > > --- > > gcc/match.pd | 14 +++++++++++++- > > 1 file changed, 13 insertions(+), 1 deletion(-) > > > > diff --git a/gcc/match.pd b/gcc/match.pd > > index 63d56b08192..22b1bd054b0 100644 > > --- a/gcc/match.pd > > +++ b/gcc/match.pd > > @@ -2310,7 +2310,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > && types_match (type, @0) > > && !POINTER_TYPE_P (TREE_TYPE (@0)) > > && TREE_CODE (TREE_TYPE (@0)) != OFFSET_TYPE) > > - (bitop @0 (convert @1))))) > > + (bitop @0 (convert @1)))) > > + /* Similar as above, but @0 has a widen type. */ > > + (simplify > > + (convert (bitop:cs@2 (convert:s @0) @1)) > > Please use (nop_convert (bitop... > > > + (if (GIMPLE > > + && INTEGRAL_TYPE_P (type) > > + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) > > + && TREE_CODE (@1) != INTEGER_CST > > + && tree_nop_conversion_p (type, TREE_TYPE (@2)) > > ... instead of testing tree_nop_conversion_p here. > > OK with that change. > > Richard. > > > + && !POINTER_TYPE_P (TREE_TYPE (@0)) > > + && TREE_CODE (TREE_TYPE (@0)) != OFFSET_TYPE > > + && TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (type)) > > + (bitop:type (convert @0) (convert @1))))) > > > > (for bitop (bit_and bit_ior) > > rbitop (bit_ior bit_and) > > -- > > 2.43.0 > >
