From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.66.136.71 with SMTP id py7mr5966301pab.35.1407338107193; Wed, 06 Aug 2014 08:15:07 -0700 (PDT) X-Received: by 10.50.134.3 with SMTP id pg3mr84177igb.4.1407338106912; Wed, 06 Aug 2014 08:15:06 -0700 (PDT) Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!h18no9519475igc.0!news-out.google.com!px9ni585igc.0!nntp.google.com!h18no9519463igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 6 Aug 2014 08:15:06 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: GNAT 4.9 - missing optimization feature? From: Adam Beneschan Injection-Date: Wed, 06 Aug 2014 15:15:06 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:188187 Date: 2014-08-06T08:15:06-07:00 List-Id: On Wednesday, August 6, 2014 7:19:08 AM UTC-7, Victor Porton wrote: > Victor Porton wrote: >=20 > > The below program, compiled with GNAT 4.9, calls Adjust two times when > > copying a T1 object. >=20 > > But it does the same operations with a T2 object without calling Adjust= . >=20 > > So calling Adjust on a T1 object is here redundant and can be optimized > > away for greater performance. If I recall correctly, Ada Reference Manu= al > > 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 t= ype is limited, which is why there is no copying and no Adjust for T2. (Li= mited_Controlled doesn't have an Adjust procedure, of course.) 7.6(17.4) s= ays 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 resul= t directly in T1 (the optimization), or it could generate code to put the f= unction result in some other object and then copy. -- Adam