This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: basic VRP min/max range overflow question
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Paul Schlie <schlie at comcast dot net>
- Cc: Paolo Bonzini <paolo dot bonzini at lu dot unisi dot ch>, GCC Development <gcc at gcc dot gnu dot org>
- Date: Fri, 17 Jun 2005 18:48:11 -0400
- Subject: Re: basic VRP min/max range overflow question
- References: <42B2BDBB.3060700@lu.unisi.ch> <BED88EAA.A85A%schlie@comcast.net>
On Fri, Jun 17, 2005 at 02:28:58PM -0400, Paul Schlie wrote:
> int x;
> volatile int v;
>
> x = (v ? 0 : INT_MAX) + 1; // [1, INT_MAX] (without -fwrapv)
>
> if (x <= 0) // Which may be erroneously
> printf("%i is <= 0.", x); // optimized away, with this.
> else
> printf("%i is > 0.", x); // Leaving only this in error.
>
You want to file a DR with the language standards. This is now
wasting everybody's time.
The compiler is perfectly free to fold that if() away. The fact
that it doesn't do it now is actually a missed optimization
opportunity (a PHI node with all arguments > 0 could produce the
range [1, +INF]).
Diego.