https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64946

--- Comment #22 from rguenther at suse dot de <rguenther at suse dot de> ---
On Wed, 8 Jun 2016, shiva0217 at gmail dot com wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64946
> 
> --- Comment #21 from Shiva Chen <shiva0217 at gmail dot com> ---
> Hi, Richard
> 
> On following example
> 
> int a = ABS_EXPR (b);
> int c = a - 1;
> 
> c will get it's range base on a which is ~[INT_MIN+1, -1]

No, a has [0, INT_MAX] and thus c gets [-1, INT_MAX-1] currently.

> Even if we transfer to 
> 
> int a = (int) ABSU_EXPR (b);
> int c = a - 1;
> 
> Therefore, c still have to consider INT_MIN.

Only now we have to consider INT_MIN.  This is why we should do the
transform to ABSU_EXPR only when it will likely help or when it
doesn't change things.  Like for short types.  Thus

 short s;
 int a = (int) s;
 int b = ABS_EXPR (a);
 int c = b - 1;

can be transformed to

 unsigned short bp = ABSU_EXPR (s);
 int b = (int) bp;
 int c = b - 1;

and VRP analysis result will be unchanged but vectorization is now happy
and ABSU_EXPR does not invoke undefined behavior when s == SHORT_MIN.

Reply via email to