comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@blueyonder.co.uk>
Subject: Re: Overhead for type conversions?
Date: Sat, 26 Jul 2003 16:54:13 +0100
Date: 2003-07-26T16:54:13+01:00	[thread overview]
Message-ID: <bfu83g$ibodl$1@ID-25716.news.uni-berlin.de> (raw)
In-Reply-To: pan.2003.07.25.01.01.43.5699@mail.utexas.edu

"Bobby D. Bryant" <bdbryant@mail.utexas.edu> wrote in message
news:pan.2003.07.25.01.01.43.5699@mail.utexas.edu...

> Given these declarations -
>
>    type f1 is new float;
>    type f2 is new float;
>
>    function "*"( left : in f1; right : in f2 ) return f1 is
>    begin
>       return( left * f1( right ) );
>    end "*";
>
> and given that run-time range checks are enabled, should I expect my
> compiler to execute range checking code for each f1*f2 multiplication,
> or will the compiler conclude from the definitions that the two types
> are always convertible without error regardless of the specific value,
> and thus not generate any code for a range check?

The type Standard.Float is unconstrained (RM95 3.5.7(12)), so the types f1
and f2 derived from it will also be unconstrained (RM95 3.4(6)). Thus, there
will be no range checks (there may be other checks).

I would also suggest that a function like this should be declared inline,
since it is likely that the eliminated call and return code would be bigger
(as well as much slower) than the intrinsic code for the multiplication
anyway.

Furthermore, should f1 and/or f2 become constrained in the future, such
inlining could give an optimising compiler the opportunity to eliminate
range checks (and to perform other optimisations).

> (In practice the compiler is GNAT.)

I can't help you with the specifics of GNAT; sorry.

--
Nick Roberts
Jabber: debater@charente.de [ICQ: 159718630]






  parent reply	other threads:[~2003-07-26 15:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-25  1:01 Overhead for type conversions? Bobby D. Bryant
2003-07-25  2:36 ` Robert I. Eachus
2003-07-25  7:12   ` Bobby D. Bryant
2003-07-25 15:34 ` Matthew Heaney
2003-07-25 18:28 ` Randy Brukardt
2003-07-26 15:54 ` Nick Roberts [this message]
2003-07-26 16:01   ` Warren W. Gay VE3WWG
2003-07-26 23:39     ` Bobby D. Bryant
2003-07-27 13:41       ` Loop Optimisation [was: Overhead for type conversions?] Nick Roberts
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox