Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Jakub Jelinek
On Thu, Nov 27, 2014 at 08:24:03PM +0100, Marek Polacek wrote: > On Thu, Nov 27, 2014 at 10:56:06AM +0100, Richard Biener wrote: > > But then rather than using integer_type_node I'd convert to > > unsigned_type_node (if that doesn't work you know we have some nasty > > dependence on negative shift

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Marek Polacek
On Thu, Nov 27, 2014 at 10:56:06AM +0100, Richard Biener wrote: > But then rather than using integer_type_node I'd convert to > unsigned_type_node (if that doesn't work you know we have some nasty > dependence on negative shift counts "working") Yeah, I think adding the conversion into c_gimplify_

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Richard Biener
On Thu, 27 Nov 2014, Jakub Jelinek wrote: > On Thu, Nov 27, 2014 at 10:30:16AM +0100, Richard Biener wrote: > > On Wed, 26 Nov 2014, Jakub Jelinek wrote: > > > > > On Wed, Nov 26, 2014 at 10:20:39PM +0100, Richard Biener wrote: > > > > Well, if you want to aggressively prune unused bits then you

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Jakub Jelinek
On Thu, Nov 27, 2014 at 10:30:16AM +0100, Richard Biener wrote: > On Wed, 26 Nov 2014, Jakub Jelinek wrote: > > > On Wed, Nov 26, 2014 at 10:20:39PM +0100, Richard Biener wrote: > > > Well, if you want to aggressively prune unused bits then you could > > > "back-propagate" the shift count value-r

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-27 Thread Richard Biener
On Wed, 26 Nov 2014, Jakub Jelinek wrote: > On Wed, Nov 26, 2014 at 10:20:39PM +0100, Richard Biener wrote: > > Well, if you want to aggressively prune unused bits then you could > > "back-propagate" the shift count value-range. > > > > And note that all the frontend shorten-optimizations should

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 10:20:39PM +0100, Richard Biener wrote: > Well, if you want to aggressively prune unused bits then you could > "back-propagate" the shift count value-range. > > And note that all the frontend shorten-optimizations should move to the > middle-end. > > That said, instead o

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Richard Biener
On November 26, 2014 8:33:52 PM CET, Jakub Jelinek wrote: >On Wed, Nov 26, 2014 at 02:25:54PM -0500, Jason Merrill wrote: >> How about converting the rhs to unsigned int if it is already >unsigned? > >That is fine. I'm just worried about the casts to wider types. >So perhaps just promote and cast

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Richard Biener
On November 26, 2014 8:25:54 PM CET, Jason Merrill wrote: >How about converting the rhs to unsigned int if it is already unsigned? Does the standard say so? I think not. IMHO it's not the front ends business to do this. And I don't see how it helps either. Richard. >Jason

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 02:25:54PM -0500, Jason Merrill wrote: > How about converting the rhs to unsigned int if it is already unsigned? That is fine. I'm just worried about the casts to wider types. So perhaps just promote and cast to int if the promoted type is signed or unsigned if it is unsig

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jason Merrill
How about converting the rhs to unsigned int if it is already unsigned? Jason

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Richard Biener
On November 26, 2014 7:49:55 PM CET, Jakub Jelinek wrote: >On Wed, Nov 26, 2014 at 07:20:04PM +0100, Marek Polacek wrote: >> On Wed, Nov 26, 2014 at 06:50:29PM +0100, Jakub Jelinek wrote: >> > On Wed, Nov 26, 2014 at 06:39:44PM +0100, Marek Polacek wrote: >> > > Both C11 and C++14 standards specif

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 07:20:04PM +0100, Marek Polacek wrote: > On Wed, Nov 26, 2014 at 06:50:29PM +0100, Jakub Jelinek wrote: > > On Wed, Nov 26, 2014 at 06:39:44PM +0100, Marek Polacek wrote: > > > Both C11 and C++14 standards specify that integral promotions are > > > performed on both operands

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jason Merrill
On 11/26/2014 01:18 PM, Joseph Myers wrote: On Wed, 26 Nov 2014, Marek Polacek wrote: Joseph, is that C FE part ok? The C changes are OK once Jakub's middle-end/expander issue is resolved (possibly by adding execution tests of shifts by in-range 64-bit and 128-bit integers, both constant and

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Marek Polacek
On Wed, Nov 26, 2014 at 06:50:29PM +0100, Jakub Jelinek wrote: > On Wed, Nov 26, 2014 at 06:39:44PM +0100, Marek Polacek wrote: > > Both C11 and C++14 standards specify that integral promotions are > > performed on both operands of a shift-expression. This we do just > > fine. But then we convert

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Joseph Myers
On Wed, 26 Nov 2014, Marek Polacek wrote: > Joseph, is that C FE part ok? The C changes are OK once Jakub's middle-end/expander issue is resolved (possibly by adding execution tests of shifts by in-range 64-bit and 128-bit integers, both constant and non-constant, and compilation tests of shif

Re: [C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Jakub Jelinek
On Wed, Nov 26, 2014 at 06:39:44PM +0100, Marek Polacek wrote: > Both C11 and C++14 standards specify that integral promotions are > performed on both operands of a shift-expression. This we do just > fine. But then we convert the right operand to integer_type_node. > Not only is this unnecessary

[C/C++ PATCH] Don't convert RHS of a shift-expression to int (PR c/63862)

2014-11-26 Thread Marek Polacek
Both C11 and C++14 standards specify that integral promotions are performed on both operands of a shift-expression. This we do just fine. But then we convert the right operand to integer_type_node. Not only is this unnecessary, it can also be harfmul, because for e.g. void foo (unsigned int x) {