This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Mar 2008 19:18:55 -0000
- Subject: [Bug tree-optimization/30911] VRP fails to eliminate range checks in Ada code
- References: <bug-30911-13647@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #46 from rguenth at gcc dot gnu dot org 2008-03-28 19:18 -------
Ok, I didn't really expect that ;)
Some new background information. With the middle-end type-system work we now
omit conversions from sub-types T' to their base-types T. Thus we have
the three cases
T' sub;
T x;
x = sub; (1)
sub = (T')x; (2)
x = VIEW_CONVERT_EXPR <T>(sub); (3)
where VRP for the simple copy (1) does not restrict x value range based
on the T's TYPE_MIN/MAX_VALUE (but it should). For (2) the same is
true (though the conversion is _not_ truncating for out of bound values,
so I am not sure if this doesn't break something). But for both (1)
and (2) holds that a variable of type T' can be assumed to have a
value range restricted by its TYPE_MIN/MAX_VALUE.
Case (3) is special in that it is a propagation barrier, thus x will get
a varying value range. We could do better here if we knew that subs
value range was not restricted by its TYPE_MIN/MAX_VALUE only.
I don't know if this is really the best setup to optimize Ada range checks,
or if we should always fall back to the base types TYPE_MIN/MAX_VALUE
range and use the type defined range of the sub-types T' only in special
places like for example for the initial value-range of T' variables
default definitions (thus uninitialized values and function parameters
where if I understand correctly in Ada the caller ensures that the
value is in range). Of course this wouldn't work very well in
combination with inlining.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30911