News for hackers. Stuff that matters.
Re:What Every Computer Scientist Should Know About Floating-... by account42 on Monday June 29, 2020 @11:05AM (#23678245)
> and may use byteswap instructions if needed

Or it may not because often compilers fail to make simple optimizations:

https://godbolt.org/z/NAt3uX

Re:What Every Computer Scientist Should Know About Floating-... by pedrocr on Monday June 29, 2020 @11:31AM (#23678508)
It does fine if you actually write the correct code :)

https://godbolt.org/z/qpLeWP

Re:What Every Computer Scientist Should Know About Floating-... by account42 on Monday June 29, 2020 @11:41AM (#23678575)
There is nothing incorrect about the code I posted - clang will compile it to a single read + bswap just fine. And you don't need to go that far back for your code to not be recognized - GCC 4.9 will produce individual loads and shifts for that too.

The point is that you can't rely on compilers consistently to recognize complex patterns.

Re:What Every Computer Scientist Should Know About Floating-... by pedrocr on Monday June 29, 2020 @11:45AM (#23678621)
Incorrect was too strong but it's a weird pattern to do this with sums. The OR pattern is what is used pretty much everywhere and conveys the intention of the code much more clearly.

And even if the compiler doesn't always optimize ideally my original point still stands. Delegating this to the compiler instead of trying to manually call swap instructions is a much better way of going about it.