[FFmpeg-devel] -fsingle-precision-constant
Michael Niedermayer
michaelni
Thu May 13 21:02:45 CEST 2010
On Thu, May 13, 2010 at 07:28:18PM +0100, M?ns Rullg?rd wrote:
> Michael Niedermayer <michaelni at gmx.at> writes:
>
> > On Thu, May 13, 2010 at 08:53:27PM +0300, Uoti Urpala wrote:
> >> On Thu, 2010-05-13 at 19:44 +0200, Michael Niedermayer wrote:
> >> > On Thu, May 13, 2010 at 01:31:07PM -0400, Ronald S. Bultje wrote:
> >> > > On Thu, May 13, 2010 at 1:13 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> >> > > > when i looked at the asm gcc generates for mp3float i noticed
> >> > > > it converts floats to doubles all over the place. Adding
> >> > > > -fsingle-precision-constant makes the code a whole 10% faster
> >> > > > overall on core2
> >> > >
> >> > > What if you add "f" as a postfix to relevant constants? Or can you
> >> > > give examples of functions where this is an issue so we can be more
> >> > > helpful?
> >> >
> >> > all functions i guess
> >> >
> >> > like
> >> > float func(float f){
> >> > return f*1.2;
> >> > }
> >>
> >> Here "1.2" is a constant of type "double", and since one operand is a
> >
> > sure
> > what pisses me off is that the compiler acts very unreasonable in practical
> > terms for an optimizing compiler.
> > floating point calculations are not exact theres no point to
> > convert every float that is multiplied by a constant to double before the
> > multiply and back to float afterwards. This just doesnt gain much, its
> > unreasonable and unexpected behavior.
> >
> >> double the multiplication is also a multiplication at double precision.
> >> As 1.2 is not exactly representable it is not possible to optimize it to
> >> a float without losing precision.
> >
> > floating point is inherently approximate, thus limiting optimizations to
> > being binary identical to some arbitrarily picked approximation is quite
> > silly besides gcc doesnt do this in other cases and i seriously doubt that
> > other compilers optimize floating point code so narrowly
>
> Silly as it is, that is what the relevant standards mandate, and GCC
> cannot do things differently. Complain to the ISO C and IEEE754
> committees instead.
does C really mandate the implementation to use double precision?
i mean it can mandate the high level type be double but what is
preventing the compiler from using a very slightly lower precission
float implemenattion.
i ve heared intels c compiler will even use trigonometric identities
to optimize float code ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Everything should be made as simple as possible, but not simpler.
-- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100513/fe0553ed/attachment.pgp>
More information about the ffmpeg-devel
mailing list