[linux-audio-dev] swh plugins and fixing undenormalize

Clemens Ladisch clemens at ladisch.de
Thu Jun 24 11:20:34 UTC 2004


Steve Harris wrote:
> You can do
>
> y += delta
> y -= delta
>
> but youre at the mercy of the optimiser.

The IEEE standard specifies exactly what happens with denormals, so,
in theory, the compiler must not optimize this away.  However,
optimization options for speed often disable strict IEEE
compatibility.  (I don't know how gcc's options behave.)

> A C99 safe version of the obove macro (with a bit of extension, to catch
> "P4 denormals") is:
>
> typedef union {
>         float f;
>         int32_t i;
> } ls_pcast32;
> ...
>         v.f = f;
>         return (v.i & 0x7f800000) < 0x08000000 ? 0.0f : f;

AFAIK this isn't safe either because the same type aliasing rules
apply to unions, too.  The only safe way is to go through char
pointers.


Regards,
Clemens





More information about the Linux-audio-dev mailing list