comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <rm.dash-bauhaus@futureapps.de>
Subject: Re: gnat 4.4.5 generates surprising code when enabling FP checks
Date: Thu, 07 Apr 2011 19:10:52 +0200
Date: 2011-04-07T19:10:52+02:00	[thread overview]
Message-ID: <4d9df01c$0$7669$9b4e6d93@newsspool1.arcor-online.net> (raw)
In-Reply-To: <inkmbf$lhb$1@speranza.aioe.org>

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
> <system__fat_sflt__attr_short_float__valid@plt>
>  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



  reply	other threads:[~2011-04-07 17:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-07 15:48 gnat 4.4.5 generates surprising code when enabling FP checks Markus Schöpflin
2011-04-07 17:10 ` Georg Bauhaus [this message]
2011-04-08 10:43   ` Markus Schöpflin
replies disabled

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