Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-19 Thread Richard Biener
On Tue, 18 Jul 2017, Jakub Jelinek wrote: > Hi! > > The following patch implements the: > /* Optimize (c>=1) && (c<=127) into (signed char)c > 0. */ > if (integer_onep (low) && TREE_CODE (high) == INTEGER_CST) > { > int prec = TYPE_PRECISION (etype); > > if (wi::mask (prec

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-19 Thread Richard Biener
On Tue, 18 Jul 2017, Jakub Jelinek wrote: > On Tue, Jul 18, 2017 at 10:47:37AM -0600, Martin Sebor wrote: > > On 07/18/2017 09:43 AM, Jakub Jelinek wrote: > > > On Tue, Jul 18, 2017 at 09:31:11AM -0600, Martin Sebor wrote: > > > > > --- gcc/match.pd.jj 2017-07-17 16:25:20.0 +0200 > > >

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Jakub Jelinek
On Tue, Jul 18, 2017 at 10:47:37AM -0600, Martin Sebor wrote: > On 07/18/2017 09:43 AM, Jakub Jelinek wrote: > > On Tue, Jul 18, 2017 at 09:31:11AM -0600, Martin Sebor wrote: > > > > --- gcc/match.pd.jj 2017-07-17 16:25:20.0 +0200 > > > > +++ gcc/match.pd2017-07-18

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Martin Sebor
On 07/18/2017 09:43 AM, Jakub Jelinek wrote: On Tue, Jul 18, 2017 at 09:31:11AM -0600, Martin Sebor wrote: --- gcc/match.pd.jj 2017-07-17 16:25:20.0 +0200 +++ gcc/match.pd2017-07-18 12:32:52.896924558 +0200 @@ -1125,6 +1125,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Marc Glisse
On Tue, 18 Jul 2017, Jakub Jelinek wrote: On Tue, Jul 18, 2017 at 05:35:54PM +0200, Marc Glisse wrote: On Tue, 18 Jul 2017, Jakub Jelinek wrote: In the PR Marc noted that the optimization might be useful even for constants other than 1, by transforming x+C1 <= C2 if unsigned and

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Jakub Jelinek
On Tue, Jul 18, 2017 at 05:35:54PM +0200, Marc Glisse wrote: > On Tue, 18 Jul 2017, Jakub Jelinek wrote: > > > In the PR Marc noted that the optimization might be useful even for > > constants other than 1, by transforming > > x+C1 <= C2 if unsigned and C2-C1==INT_MAX into (int)x > (int)(-1-C1).

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Jakub Jelinek
On Tue, Jul 18, 2017 at 09:31:11AM -0600, Martin Sebor wrote: > > --- gcc/match.pd.jj 2017-07-17 16:25:20.0 +0200 > > +++ gcc/match.pd2017-07-18 12:32:52.896924558 +0200 > > @@ -1125,6 +1125,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > > && wi::neg_p (@1, TYPE_SIGN (TREE_TYPE

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Marc Glisse
On Tue, 18 Jul 2017, Jakub Jelinek wrote: In the PR Marc noted that the optimization might be useful even for constants other than 1, by transforming x+C1 <= C2 if unsigned and C2-C1==INT_MAX into (int)x > (int)(-1-C1). (int)x >= (int)(-C1) might be easier (and more valid, except that the

Re: [PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Martin Sebor
--- gcc/match.pd.jj 2017-07-17 16:25:20.0 +0200 +++ gcc/match.pd2017-07-18 12:32:52.896924558 +0200 @@ -1125,6 +1125,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && wi::neg_p (@1, TYPE_SIGN (TREE_TYPE (@1 (cmp @2 @0)) +/* (X - 1U) <= INT_MAX-1U into (int) X

[PATCH] Implement one optimization from build_range_check in match.pd (PR tree-optimization/81346)

2017-07-18 Thread Jakub Jelinek
Hi! The following patch implements the: /* Optimize (c>=1) && (c<=127) into (signed char)c > 0. */ if (integer_onep (low) && TREE_CODE (high) == INTEGER_CST) { int prec = TYPE_PRECISION (etype); if (wi::mask (prec - 1, false, prec) == high) { if