[FFmpeg-devel] [PATCH 7/9] sbrdsp: unroll and use integer operations

Michael Niedermayer michaelni at gmx.at
Fri Apr 5 12:55:54 CEST 2013

On Fri, Apr 05, 2013 at 12:18:25PM +0200, Christophe Gisquet wrote:
> Hi,
> 2013/4/5 Michael Niedermayer <michaelni at gmx.at>:
> > casting  *float to *int32 and dereferencing is a strict aliassing
> > violation,

> My C-fu may be lacking here, but if instead I do:
>     union av_intfloat32 *p = (union av_intfloat32*)x;
>     for (i = 1; i < 64; i += 4)
>     {
>         p[i+0].i ^= 1U<<31;
>         p[i+2].i ^= 1U<<31;
>     }
> then it is ok, but I'm quite unsure I have improved anything.
> """
> The details may change (if it's called av_intfloat, the name of the
> union members) but you should get the picture.
> Given this additional data, do you have any updated opinion?

av_intfloat32 is ok

the other variant that generated additional instructions should better
be avoided for that reason

The whole is because such "strict aliassing violations" are undefined
in C and some compilers base optimizations on the absence of such
things, so the original code could have been miscompiled in theory.
Using a union should avoid the issue


Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130405/8d8eed20/attachment.asc>

More information about the ffmpeg-devel mailing list