On Thu, 21 Aug 2014, Marc Glisse wrote: > On Thu, 21 Aug 2014, Richard Biener wrote: > > > +/* From fold_unary. */ > > + > > +/* (T1)(~(T2) X) -> ~(T1) X */ > > +(simplify > > + (convert (bit_not@0 (convert @1))) > > + (if (INTEGRAL_TYPE_P (type) > > + && INTEGRAL_TYPE_P (TREE_TYPE (@0)) > > + && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (@0)) > > + && INTEGRAL_TYPE_P (TREE_TYPE (@1)) > > + && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@1))) > > + (bit_not (convert (bit_not @0))))) > > There are a lot of bit_not in this line...
Oops. I've meant to delete all excessive stuff I put there for parser testing... Fixed. > I know the patterns themselves aren't your main preoccupation right now, and I > agree that finishing the infrastructure is the priority, but it seems that the > comments are becoming much terser during the move from fold-const to *.pd. I > believe the == could be <=, so I wanted to check the rationale, and fold-const > at least tries to explain the condition. It would be nice to copy-paste those > comments, if the version in fold-const.c is supposed to disappear. No, you are right - it's likely they'll get lost this way. But I _do_ have to do more "systematic" pattern writing at some point (started on fold_conversion this week just to notice the desirable changes to the language I've put in this week...). Thanks for keeping an eye on these patches, Richard. 2014-08-21 Richard Biener <rguent...@suse.de> * match.pd ((T1)(~(T2) X) -> ~(T1) X): Paste all comment from fold-const.c, fix simplification result. Index: gcc/match.pd =================================================================== --- gcc/match.pd (revision 214268) +++ gcc/match.pd (working copy) @@ -109,7 +109,9 @@ along with GCC; see the file COPYING3. /* From fold_unary. */ -/* (T1)(~(T2) X) -> ~(T1) X */ +/* Convert (T1)(~(T2)X) into ~(T1)X if T1 and T2 are integral types + of the same precision, and X is an integer type not narrower than + types T1 or T2, i.e. the cast (T2)X isn't an extension. */ (simplify (convert (bit_not@0 (convert @1))) (if (INTEGRAL_TYPE_P (type) @@ -117,7 +119,7 @@ along with GCC; see the file COPYING3. && TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (@0)) && INTEGRAL_TYPE_P (TREE_TYPE (@1)) && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@1))) - (bit_not (convert (bit_not @0))))) + (bit_not (convert @0)))) #include "match-plusminus.pd"