Re: Move some bit and binary optimizations in simplify and match

2015-10-26 Thread Richard Biener
On Mon, Oct 26, 2015 at 10:26 AM, Richard Biener wrote: > On Sat, Oct 24, 2015 at 11:15 PM, Marc Glisse wrote: >> On Fri, 23 Oct 2015, Hurugalawadi, Naveen wrote: >> >> + (minus (bit_and:cs @0 (bit_not @1)) (bit_and:s @0 @1)) >> >> I am not sure why we have :c on one bit_and but not the other. >

Re: Move some bit and binary optimizations in simplify and match

2015-10-26 Thread Richard Biener
On Sat, Oct 24, 2015 at 11:15 PM, Marc Glisse wrote: > On Fri, 23 Oct 2015, Hurugalawadi, Naveen wrote: > > + (minus (bit_and:cs @0 (bit_not @1)) (bit_and:s @0 @1)) > > I am not sure why we have :c on one bit_and but not the other. Clearly an omission. > + (bit_ior:c (bit_and:c @0 (bit_not @1))

Re: Move some bit and binary optimizations in simplify and match

2015-10-24 Thread Marc Glisse
On Fri, 23 Oct 2015, Hurugalawadi, Naveen wrote: + (minus (bit_and:cs @0 (bit_not @1)) (bit_and:s @0 @1)) I am not sure why we have :c on one bit_and but not the other. + (bit_ior:c (bit_and:c @0 (bit_not @1)) (bit_and:c (bit_not @0) @1)) Here on the other hand, I believe the :c on bit_ior is

Re: Move some bit and binary optimizations in simplify and match

2015-10-23 Thread Richard Biener
On Fri, Oct 23, 2015 at 6:29 AM, Hurugalawadi, Naveen wrote: > Hi, > >>> So I suggest to modify your patch to do > Done. > > Please find attached the modified patch. > > Regression tested successfully on X86_64. Ok. Thanks, Richard. > Thanks, > Naveen

Re: Move some bit and binary optimizations in simplify and match

2015-10-22 Thread Hurugalawadi, Naveen
Hi, >> So I suggest to modify your patch to do Done. Please find attached the modified patch. Regression tested successfully on X86_64. Thanks, Naveendiff --git a/gcc/fold-const.c b/gcc/fold-const.c index 1e7fbb4..23c6fa9 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9692,28 +9692,6

Re: Move some bit and binary optimizations in simplify and match

2015-10-21 Thread Richard Biener
On Wed, Oct 21, 2015 at 8:48 AM, Marc Glisse wrote: > On Tue, 20 Oct 2015, Richard Biener wrote: > >> On Tue, Oct 20, 2015 at 8:46 AM, Hurugalawadi, Naveen >> wrote: >>> >>> Hi, >>> > +/* Fold X + (X / CST) * -CST to X % CST. */ > This one is still wrong >>> >>> Removed. >>> > I don'

Re: Move some bit and binary optimizations in simplify and match

2015-10-20 Thread Marc Glisse
On Tue, 20 Oct 2015, Richard Biener wrote: On Tue, Oct 20, 2015 at 8:46 AM, Hurugalawadi, Naveen wrote: Hi, +/* Fold X + (X / CST) * -CST to X % CST. */ This one is still wrong Removed. I don't understand the point of the FLOAT_TYPE_P check. The check was there in fold-const. So, just h

Re: Move some bit and binary optimizations in simplify and match

2015-10-20 Thread Hurugalawadi, Naveen
Hi, >> use if (wi::bit_and (@2, @1) == 0) Done. >> and instead of the 2nd group >> place a :c on the minus of the one not matching INTEGER_CSTs. Done. Just curious to know whether ":c" act as commutative operation in the input as well as output in this case? Regression tested without any extra f

Re: Move some bit and binary optimizations in simplify and match

2015-10-20 Thread Richard Biener
On Tue, Oct 20, 2015 at 8:46 AM, Hurugalawadi, Naveen wrote: > Hi, > >>> +/* Fold X + (X / CST) * -CST to X % CST. */ >>> This one is still wrong > Removed. > >>> I don't understand the point of the FLOAT_TYPE_P check. > The check was there in fold-const. So, just had the same check. > >>> Will w

Re: Move some bit and binary optimizations in simplify and match

2015-10-19 Thread Hurugalawadi, Naveen
Hi, >> +/* Fold X + (X / CST) * -CST to X % CST. */ >> This one is still wrong Removed. >> I don't understand the point of the FLOAT_TYPE_P check. The check was there in fold-const. So, just had the same check. >> Will we also simplify (A & B) - (A & ~B) into B - (A ^ B) ? Done. >> or maybe in

Re: Move some bit and binary optimizations in simplify and match

2015-10-19 Thread Richard Biener
On Mon, Oct 19, 2015 at 1:14 PM, Hurugalawadi, Naveen wrote: > Hi, > >>> That's not what Richard meant. We already have: > > Done. As per the comments. > > Please find attached the modified patch as per your comments. > > Please review them and let me know if any further modifications are required

Re: Move some bit and binary optimizations in simplify and match

2015-10-19 Thread Marc Glisse
+/* Fold X + (X / CST) * -CST to X % CST. */ This one is still wrong. It is extremely similar to X-(X/CST)*CST, and the current version of that one in match.pd is broken, we should fix that one first. +/* Fold (A & ~B) - (A & B) into (A ^ B) - B. */ +(simplify + (minus (bit_and:s @0 (bit_no

Re: Move some bit and binary optimizations in simplify and match

2015-10-19 Thread Hurugalawadi, Naveen
Hi, Please find attached the modified patch of duplicate patterns which were posted in the earlier part. Please review them and let me know if any further modifications are required. Thanks, Naveendiff --git a/gcc/fold-const.c b/gcc/fold-const.c index de45a2c..b36e2f5 100644 --- a/gcc/fold-const

Re: Move some bit and binary optimizations in simplify and match

2015-10-19 Thread Hurugalawadi, Naveen
Hi, >> That's not what Richard meant. We already have: Done. As per the comments. Please find attached the modified patch as per your comments. Please review them and let me know if any further modifications are required. Thanks, Naveendiff --git a/gcc/fold-const.c b/gcc/fold-const.c index de4

Re: Move some bit and binary optimizations in simplify and match

2015-10-16 Thread Marc Glisse
+(match (logical_inverted_value @0) + (truth_not @0)) That's good. +/* Simplify ~X & X as zero. */ +(simplify + (bit_and:c (convert? truth_valued_p@0) (convert? (logical_inverted_value @0))) + { build_zero_cst (type); }) That's not what Richard meant. We already have: /* X & !X -> 0. */ (s

Re: Move some bit and binary optimizations in simplify and match

2015-10-16 Thread Hurugalawadi, Naveen
Hi, Thanks very much for your detailed explanation regarding the queries. >> you are missing the convert? on the lshift now, without it the >> tree_nop_conversion_p check always evaluates to true. Done. >> fold-const.c which handles TRUTH_NOT_EXPR but logical_inverted_value >> does not handle it

Re: Move some bit and binary optimizations in simplify and match

2015-10-15 Thread Richard Biener
On Thu, Oct 15, 2015 at 8:11 AM, Hurugalawadi, Naveen wrote: > Hi, > > Thanks for all the suggestions. > Please find attached the modified patch as per your suggestions. > > I had missed a mail as pointed by Marc Glisse. Now I have implemented > everything suggested. > Please review the patch and

Re: Move some bit and binary optimizations in simplify and match

2015-10-14 Thread Hurugalawadi, Naveen
Hi, Thanks for all the suggestions. Please find attached the modified patch as per your suggestions. I had missed a mail as pointed by Marc Glisse. Now I have implemented everything suggested. Please review the patch and let me know if any further modifications are required. I have some queries

Re: Move some bit and binary optimizations in simplify and match

2015-10-14 Thread Marc Glisse
On Wed, 14 Oct 2015, Richard Biener wrote: On Wed, Oct 14, 2015 at 12:45 PM, Marc Glisse wrote: On Wed, 14 Oct 2015, Richard Biener wrote: +/* Fold (a * (1 << b)) into (a << b) */ +(simplify + (mult:c @0 (convert? (lshift integer_onep@1 @2))) + (if (! FLOAT_TYPE_P (type) +&& tree_n

Re: Move some bit and binary optimizations in simplify and match

2015-10-14 Thread Richard Biener
On Wed, Oct 14, 2015 at 12:45 PM, Marc Glisse wrote: > On Wed, 14 Oct 2015, Richard Biener wrote: > >>> +/* Fold (a * (1 << b)) into (a << b) */ >>> +(simplify >>> + (mult:c @0 (convert? (lshift integer_onep@1 @2))) >>> + (if (! FLOAT_TYPE_P (type) >>> +&& tree_nop_conversion_p (type, TR

Re: Move some bit and binary optimizations in simplify and match

2015-10-14 Thread Marc Glisse
On Wed, 14 Oct 2015, Richard Biener wrote: +/* Fold (a * (1 << b)) into (a << b) */ +(simplify + (mult:c @0 (convert? (lshift integer_onep@1 @2))) + (if (! FLOAT_TYPE_P (type) +&& tree_nop_conversion_p (type, TREE_TYPE (@2))) + (lshift @0 (convert @2 You don't need/want to conve

Re: Move some bit and binary optimizations in simplify and match

2015-10-14 Thread Richard Biener
On Wed, Oct 14, 2015 at 7:39 AM, Marc Glisse wrote: > > +(simplify > + (plus (convert? @0) (convert? (xdivamulminusa @0 @1))) > + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type)) > + && tree_nop_conversion_p (type, TREE_TYPE (@0))) > + (trunc_mod (convert @0) (convert @1

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Marc Glisse
+(simplify + (plus (convert? @0) (convert? (xdivamulminusa @0 @1))) + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type)) + && tree_nop_conversion_p (type, TREE_TYPE (@0))) + (trunc_mod (convert @0) (convert @1 See PR 67953. +(match (abitandnotb @0 @1) + (bit_and:c @0 (bi

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Hurugalawadi, Naveen
Hi. >> please adjust also according to these comments. Adjusted the patch as per your comments. Please find attached the patch as per your comments. Please review the patch and let me know if any further modifications are required. Thanks, Naveendiff --git a/gcc/fold-const.c b/gcc/fold-const.c

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Richard Biener
On Tue, Oct 13, 2015 at 2:18 PM, Marc Glisse wrote: > On Tue, 13 Oct 2015, Richard Biener wrote: > >> +/* Simplify ~X & X as zero. */ >> +(simplify >> + (bit_and:c (convert? @0) (convert? (bit_not @0))) >> + (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) > > > The test seems unnecessary for

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Marc Glisse
On Tue, 13 Oct 2015, Richard Biener wrote: +/* Simplify ~X & X as zero. */ +(simplify + (bit_and:c (convert? @0) (convert? (bit_not @0))) + (if (tree_nop_conversion_p (type, TREE_TYPE (@0))) The test seems unnecessary for this specific transformation. + { build_zero_cst (TREE_TYPE (@0));

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Richard Biener
On Tue, Oct 13, 2015 at 12:52 PM, Hurugalawadi, Naveen wrote: > Hi Richard, > > Thanks for the comments. Sorry, I was confused with handling the const and > variable > together part. Have modified them. > Also, considered that both (X & Y) can be const or variable in those cases > for which match

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Marc Glisse
On Tue, 13 Oct 2015, Hurugalawadi, Naveen wrote: Please find attached the patch as per your comments. (hmm, maybe you missed the email I sent with other comments?) +(simplify + (plus (convert? @0) (convert? (xdivamulminusa @0 @1))) + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (typ

Re: Move some bit and binary optimizations in simplify and match

2015-10-13 Thread Hurugalawadi, Naveen
Hi Richard, Thanks for the comments. Sorry, I was confused with handling the const and variable together part. Have modified them. Also, considered that both (X & Y) can be const or variable in those cases for which match patterns have been added. Please let me know whether its correct or only "

Re: Move some bit and binary optimizations in simplify and match

2015-10-12 Thread Richard Biener
On Mon, Oct 12, 2015 at 12:22 PM, Hurugalawadi, Naveen wrote: > Hi Richard, > > Thanks for your review and useful comments. > I will move the future optimization patterns with all the conditions > present in fold-const or builtins file as per your suggestions. > > Please find attached the patch a

Re: Move some bit and binary optimizations in simplify and match

2015-10-12 Thread Marc Glisse
On Mon, 12 Oct 2015, Hurugalawadi, Naveen wrote: +/* Fold X + (X / CST) * -CST to X % CST. */ +(simplify + (plus (convert1? @0) (convert2? (mult (trunc_div @0 INTEGER_CST@1) INTEGER_CST@2))) + (if ((INTEGRAL_TYPE_P (type) || VECTOR_INTEGER_TYPE_P (type)) + && wi::add (@1, @2) == 0) + (

Re: Move some bit and binary optimizations in simplify and match

2015-10-12 Thread Hurugalawadi, Naveen
Hi Richard, Thanks for your review and useful comments. I will move the future optimization patterns with all the conditions present in fold-const or builtins file as per your suggestions. Please find attached the patch as per your comments. Please review the patch and let me know if any further

Re: Move some bit and binary optimizations in simplify and match

2015-10-09 Thread Richard Biener
On Thu, Oct 8, 2015 at 8:15 PM, Bernd Schmidt wrote: > On 10/08/2015 08:03 PM, Joseph Myers wrote: >> >> On Thu, 8 Oct 2015, Bernd Schmidt wrote: >> >>> On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote: Move Fold X & (X ^ Y) as X & ~Y to match.pd. Move Fold X & (Y

Re: Move some bit and binary optimizations in simplify and match

2015-10-08 Thread Bernd Schmidt
On 10/08/2015 08:03 PM, Joseph Myers wrote: On Thu, 8 Oct 2015, Bernd Schmidt wrote: On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote: Move Fold X & (X ^ Y) as X & ~Y to match.pd. Move Fold X & (Y ^ X) as ~Y & X to match.pd. I wonder if we shouldn't try to autogenerate patt

Re: Move some bit and binary optimizations in simplify and match

2015-10-08 Thread Joseph Myers
On Thu, 8 Oct 2015, Bernd Schmidt wrote: > On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote: > > Move Fold X & (X ^ Y) as X & ~Y to match.pd. > > Move Fold X & (Y ^ X) as ~Y & X to match.pd. > > I wonder if we shouldn't try to autogenerate patterns such as these. I did > something like

Re: Move some bit and binary optimizations in simplify and match

2015-10-08 Thread Bernd Schmidt
On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote: Move Fold X & (X ^ Y) as X & ~Y to match.pd. Move Fold X & (Y ^ X) as ~Y & X to match.pd. I wonder if we shouldn't try to autogenerate patterns such as these. I did something like that for a different project a long time ago.

Re: Move some bit and binary optimizations in simplify and match

2015-10-08 Thread Richard Biener
On Wed, Oct 7, 2015 at 11:54 AM, Hurugalawadi, Naveen wrote: > Hi, > > Please find attached the patch that moves some more patterns from > fold-const using simplify and match. > > Please review the patch and let me know if any modifications are required. +/* Fold X + (X / CST) * -CST to X % CST.