News for hackers. Stuff that matters.
Re:Reciprocal Approximation with 1 Subtraction by tekknolagi on Tuesday December 31, 2024 @10:28AM (#42559238)
We used memcpy everywhere in our runtime and after the 10th or so time doing it, it becomes less awkward.
Re:Reciprocal Approximation with 1 Subtraction by dahart on Tuesday December 31, 2024 @10:36AM (#42559299)
And it’s always reliably optimized out in release builds, I assume?
Re:Reciprocal Approximation with 1 Subtraction by LegionMammal978 on Tuesday December 31, 2024 @10:50AM (#42559425)
On platforms thar require aligned loads and stores (not x86 nor ARM), a direct pointer cast sometimes uses an aligned load/store where a memcpy uses multiple byte loads/stores, even on a good compiler, since memcpy() doesn't require that the pointers are aligned. This can be mitigated by going through a local variable, but it gets pretty verbose.
Re:Reciprocal Approximation with 1 Subtraction by stouset on Tuesday December 31, 2024 @02:40PM (#42561216)
Sounds like a good place for a macro?
Re:Reciprocal Approximation with 1 Subtraction by mbitsnbites on Thursday January 02, 2025 @02:08AM (#42572409)
We have memcpy behind a C++ template function that mimics the interface of std::bit_cast.
Re:Reciprocal Approximation with 1 Subtraction by ack_complete on Tuesday December 31, 2024 @03:28PM (#42561589)
Some ARM CPUs do require aligned loads and stores, such as the Cortex-M0+ in a Raspberry Pi Pico.
Re:Reciprocal Approximation with 1 Subtraction by Asooka on Tuesday December 31, 2024 @11:41AM (#42559817)
For MSVC you have to add "/Oi", otherwise it is always a function call at lower optimisation levels. Clang and GCC treat it as an intrinsic always, even in debug builds.
Re:Reciprocal Approximation with 1 Subtraction by tekknolagi on Tuesday December 31, 2024 @04:34PM (#42562010)
I haven't manually checked every case but it's normally folded into the load or shift or whatever and completely erased