comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: GNAT 4.9 - missing optimization feature?
Date: Wed, 6 Aug 2014 08:15:06 -0700 (PDT)
Date: 2014-08-06T08:15:06-07:00	[thread overview]
Message-ID: <c16edb7e-8e4a-470c-a3d2-47d7194eb8ed@googlegroups.com> (raw)
In-Reply-To: <lrtdgp$93q$1@speranza.aioe.org>

On Wednesday, August 6, 2014 7:19:08 AM UTC-7, Victor Porton wrote:
> Victor Porton wrote:
> 
> > The below program, compiled with GNAT 4.9, calls Adjust two times when
> > copying a T1 object.
> 
> > But it does the same operations with a T2 object without calling Adjust.
> 
> > So calling Adjust on a T1 object is here redundant and can be optimized
> > away for greater performance. If I recall correctly, Ada Reference Manual
> > allows this kind of optimization.

> Is it true that this kind of optimization is legitimate accordingly ARM?

Yes.  See 7.6(17.1 - 17.4).  You're using a function call to initialize an object.  This section says that an object must be "built in place" if the type is limited, which is why there is no copying and no Adjust for T2.  (Limited_Controlled doesn't have an Adjust procedure, of course.)  7.6(17.4) says that when the two cases where an object *must* be built in place don't apply, "it is unspecified whether the anonymous object is built in place".  That means that the compiler could generate code to put the function result directly in T1 (the optimization), or it could generate code to put the function result in some other object and then copy.

                                 -- Adam


      parent reply	other threads:[~2014-08-06 15:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-05 22:55 GNAT 4.9 - missing optimization feature? Victor Porton
2014-08-06 14:19 ` Victor Porton
2014-08-06 15:10   ` J-P. Rosen
2014-08-06 15:16     ` Adam Beneschan
2014-08-06 15:35       ` J-P. Rosen
2014-08-06 15:44         ` Adam Beneschan
2014-08-06 15:15   ` Adam Beneschan [this message]
replies disabled

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