Yes. You are right, ANSI C allows only load-time initializers. Attached
ANSI compatible version leads to the same assembly.
And let me suggest a bit-twiddling version as well. It gives 12
instructions, instead of 13. 12 is better, as modern x86 CPU will fetch
them at most in 3 cycles, one less than for 13 instructions. Also this
bit-twiddling is more parallel at instruction level.
And for ARM, which is unsurpassed at bit-twiddling this code is a way
better.
Of course speed is influenced by a lot of factors as always, so it needs
to be tested on some datasets.
- Mikhail, respectfully
On Fri, Sep 09, 2016 at 08:50:53AM +0500, Andrey Borodin wrote:
> Thank you for your attention to details, Mikhail.
>
> pack_float_good() looks good. But I'm not sure inline strict init is allowed under ansi C. Converting to regular
ancientform b.fp = v; won't change compile result, would it?
>
> Regards, Andrey Borodin.