This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][match-and-simplify] Auto-guess conversion types
- From: Richard Biener <rguenther at suse dot de>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 26 Aug 2014 09:49:19 +0200 (CEST)
- Subject: Re: [PATCH][match-and-simplify] Auto-guess conversion types
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1408211322420 dot 20733 at zhemvz dot fhfr dot qr> <alpine dot DEB dot 2 dot 11 dot 1408211423210 dot 1764 at laptop-mg dot saclay dot inria dot fr> <alpine dot LSU dot 2 dot 11 dot 1408211442220 dot 20733 at zhemvz dot fhfr dot qr> <alpine dot DEB dot 2 dot 11 dot 1408211453130 dot 1764 at laptop-mg dot saclay dot inria dot fr>
On Thu, 21 Aug 2014, Marc Glisse wrote:
> On Thu, 21 Aug 2014, Richard Biener wrote:
>
> > 2014-08-21 Richard Biener <rguenther@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))))
>
> Er, I think you mean:
> (bit_not (convert @1))
Oops, fixed ;)
> Your pattern (bit_not (convert (bit_not @0))) was valid, @0 is the bit_not, so
> it simplifies, but that was a pretty unreadable way to write it, and I was
> scared that you had done it on purpose to help the machinery guess the type.
> Glad to see that the simple version is ok.
Of course.
Thanks,
Richard.
2014-08-26 Richard Biener <rguenther@suse.de>
* match.pd ((T1)(~(T2) X) -> ~(T1) X): Fix simplification
again.
Index: gcc/match.pd
===================================================================
--- gcc/match.pd (revision 214490)
+++ gcc/match.pd (working copy)
@@ -119,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 @0))))
+ (bit_not (convert @1))))
#include "match-plusminus.pd"