Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-10 Thread Richard Biener
On December 10, 2016 12:01:37 PM GMT+01:00, Jakub Jelinek wrote: >On Sat, Dec 10, 2016 at 11:45:35AM +0100, Marc Glisse wrote: >> On Sat, 10 Dec 2016, Jakub Jelinek wrote: >> >> >* match.pd (A < 0 ? C : 0): Only optimize for signed A. If shift >> >is negative, first

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-10 Thread Jakub Jelinek
On Sat, Dec 10, 2016 at 11:45:35AM +0100, Marc Glisse wrote: > On Sat, 10 Dec 2016, Jakub Jelinek wrote: > > > * match.pd (A < 0 ? C : 0): Only optimize for signed A. If shift > > is negative, first convert to @1's type and then lshift it by -shift. > > Thanks, the ChangeLog needs

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-10 Thread Marc Glisse
On Sat, 10 Dec 2016, Jakub Jelinek wrote: * match.pd (A < 0 ? C : 0): Only optimize for signed A. If shift is negative, first convert to @1's type and then lshift it by -shift. Thanks, the ChangeLog needs updating. --- gcc/match.pd.jj 2016-12-09 10:19:10.909735559 +0100

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-10 Thread Jakub Jelinek
On Sat, Dec 10, 2016 at 10:05:50AM +0100, Paolo Bonzini wrote: > > > On 09/12/2016 20:26, Jakub Jelinek wrote: > > +tree ctype = TREE_TYPE (@1); > > + } > > + (if (shift >= 0) > > +(bit_and > > + (convert (rshift @0 { build_int_cst (integer_type_node, shift); })) > > + @1) >

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-10 Thread Paolo Bonzini
On 09/12/2016 20:26, Jakub Jelinek wrote: > +tree ctype = TREE_TYPE (@1); > + } > + (if (shift >= 0) > +(bit_and > + (convert (rshift @0 { build_int_cst (integer_type_node, shift); })) > + @1) > +(bit_and > + (lshift (convert:ctype @0) { build_int_cst

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-09 Thread Jakub Jelinek
On Sat, Dec 10, 2016 at 12:04:25AM +0100, Marc Glisse wrote: > On Fri, 9 Dec 2016, Jakub Jelinek wrote: > > >This patch fixes the recently added A < 0 ? C : 0 for power of 2 C > >optimization. The if (!TYPE_UNSIGNED (TREE_TYPE (@0))) part is just > >for safety, I'd hope that unsigned < 0 is

Re: [PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-09 Thread Marc Glisse
On Fri, 9 Dec 2016, Jakub Jelinek wrote: This patch fixes the recently added A < 0 ? C : 0 for power of 2 C optimization. The if (!TYPE_UNSIGNED (TREE_TYPE (@0))) part is just for safety, I'd hope that unsigned < 0 is folded into 0 earlier, but just in case this is handled first. The issue

[PATCH] Fix A < 0 ? C : 0 optimization (PR tree-optimization/78720)

2016-12-09 Thread Jakub Jelinek
Hi! This patch fixes the recently added A < 0 ? C : 0 for power of 2 C optimization. The if (!TYPE_UNSIGNED (TREE_TYPE (@0))) part is just for safety, I'd hope that unsigned < 0 is folded into 0 earlier, but just in case this is handled first. The issue which breaks the testcase is that the