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=-0.4 required=5.0 tests=BAYES_00,UNCLOSED_BRACKET autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,6b8760de26d569f1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!usenet.stanford.edu!newsfeed.berkeley.edu!ucberkeley!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 07 Apr 2011 19:10:52 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: gnat 4.4.5 generates surprising code when enabling FP checks References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit Message-ID: <4d9df01c$0$7669$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 07 Apr 2011 19:10:52 CEST NNTP-Posting-Host: 66090db2.newsspool1.arcor-online.net X-Trace: DXC=223_aV2P690RadXUBHgFh3ic==]BZ:af>4Fo<]lROoR1<`=YMgDjhg2gJjA2iN6Xi6nc\616M64>:Lh>_cHTX3j=GlH8hLIN[[5 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:18706 Date: 2011-04-07T19:10:52+02:00 List-Id: On 07.04.11 17:48, Markus Sch�pflin wrote: > What really surprises me is that in the resulting assembler > code the last multiplication is actually performed twice, the disassembled > object code looks like this (for the last check and multiplication only): (I noticed that a big portion of the code is for performing the validity checks requested via -gnatVa; lots of detail documented in function Valid's body in System.Fat_Gen (that I do not fully understand). system__fat_sflt__attr_short_float__valid refers to an instance of Fat_Gen (Short_Float), a package that implements floating point attribute functions, IIUC. (I also noticed that there is a conditional jump after the call on system__fat_sflt__attr_short_float__valid to after the second multiplication.) > 8048ed6: d9 45 e4 flds -0x1c(%ebp) > 8048ed9: d8 4d e0 fmuls -0x20(%ebp) > 8048edc: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) > 8048ee3: 00 > 8048ee4: 89 3c 24 mov %edi,(%esp) > 8048ee7: d9 5d dc fstps -0x24(%ebp) > 8048eea: e8 61 fc ff ff call 8048b50 > > 8048eef: 84 c0 test %al,%al > 8048ef1: 74 2c je 8048f1f <_ada_float_checks+0xaf> > 8048ef3: 83 c3 01 add $0x1,%ebx > 8048ef6: d9 45 e4 flds -0x1c(%ebp) > 8048ef9: 81 fb 11 27 00 00 cmp $0x2711,%ebx > 8048eff: d8 4d e0 fmuls -0x20(%ebp) > 8048f02: dd d8 fstp %st(0) > > Is the second multiplication to be expected? Does anybody know if there is an > optimizer option which would eliminate the second multiplication? Since much of the generated code is a consequence of -gnatVA (which implies -gnatVf), shouldn't a smaller selection validity checking do the trick, i.e. if you exclude -gnatVf? Of course this doesn't answer the question if -gnatVa must be used. HTH