This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: basic VRP min/max range overflow question


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]