[FFmpeg-devel] -fsingle-precision-constant

Michael Niedermayer michaelni
Thu May 13 23:46:11 CEST 2010


On Thu, May 13, 2010 at 12:51:53PM -0700, Jason Garrett-Glaser wrote:
> On Thu, May 13, 2010 at 12:02 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > 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 ...
> 
> That's what -ffast-math is for.

i meant that what ive heard is intels compiler does this by default
and as mans said -ffast-math does a few things too much

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato
-------------- 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/5e02b9ad/attachment.pgp>



More information about the ffmpeg-devel mailing list