This is the mail archive of the
mailing list for the GCC project.
Re: Ada subtypes and base types
- From: Laurent GUERBY <laurent at guerby dot net>
- To: law at redhat dot com
- Cc: Waldek Hebisch <hebisch at math dot uni dot wroc dot pl>, gcc at gcc dot gnu dot org
- Date: Wed, 15 Mar 2006 23:45:39 +0100
- Subject: Re: Ada subtypes and base types
- References: <E1FDnj3email@example.com> <firstname.lastname@example.org>
On Mon, 2006-03-13 at 15:31 -0700, Jeffrey A Law wrote:
> On Mon, 2006-02-27 at 20:08 +0100, Waldek Hebisch wrote:
> > What do you mean by "abuse"? TYPE_MAX_VALUE means maximal value
> > allowed by given type.
> As long as you're *absolutely* clear that a variable with a
> restricted range can never hold a value outside that the
> restricted range in a conforming program, then I'll back off
> the "abuse" label and merely call it pointless :-)
Variables in a non erroneous Ada program all have their value between
their type bounds from the optimizer perspective (the special 'valid
case put aside).
The Ada FE and RTS are currently compiled with compiler checks off
so of course programming errors are magnified by VRP (as seen in one
> The scheme you're using "promoting" to a base type before all
> arithmetic creates lots of useless type conversions and means
> that the optimizers can't utilize TYPE_MIN_VALUE/TYPE_MAX_VALUE
> anyway. ie, you don't gain anything over keeping that knowledge
> in the front-end.
It just means that the optimizer has to be smarter than it currently is,
may be one day it will be, so yes front-end should pass their knowledge.
There's no reason in language design (unless you want to cripple
performance and usability) not to do what Ada and Pascal are doing:
intermediate values are kept in an implementation defined
"base" type. If you have a reason to do otherwise, please
let us know.
Anyway, I'm pretty sure that it's possible to find cases where
the current optimizer thanks to VRP improvements is able to remove
checks that the Ada front-end wasn't able to remove, and check removal
is usually a pretty important optimization in Ada and Pascal (of course
mostly useless in C :).