[PATCH] Fix PR23603, teach VRP about comparison/truthop result ranges

Richard Guenther richard.guenther@gmail.com
Mon Jan 8 11:05:00 GMT 2007


On 1/8/07, Duncan Sands <duncan.sands@math.u-psud.fr> wrote:
> On Monday 8 January 2007 00:50, Richard Guenther wrote:
> > This fixes VRP to fall back to [0,1] instead of varying where a truthvalue
> > is the result and the TYPE_PRECISION covers more than [0,1].
>
> How about getting rid of VR_VARYING altogther for discrete types, replacing it
> with [TYPE_MIN_VALUE, TYPE_MAX_VALUE]?  Wouldn't that also solve this case?

No, the problem is that at least the C frontend has integer valued comparison
and truthop results.  And of course int's TYPE_PRECISION is 32.  It could
be argued that the middle-end should force the use of an intermediate
type with TYPE_PRECISION 1 and so a = b != c; would be represented as

 _Bool tmp = b != c;
 a = (int)tmp;

which would fix the problem, as from the conversion we derive the correct
range for a [0,1].  Just we have now

 int a = b != c;

and setting the result to VARYING will effectively make it [-INF, +INF] of
int type.

Of course I in principle agree to maybe drop VARYING completely
(we would need to think about pointer types here - those don't have
TYPE_MIN/MAX_VALUE), but that's an orthogonal issue.

Richard.



More information about the Gcc-patches mailing list