Re:ZFS 128 bit storage: Are you high? (2004)
by smitherfield on Tuesday February 13, 2018 @03:12PM
(#16370296)
Oops, I used `#pragma pack` incorrectly in my code, but it doesn't change the codegen for the 96-bit structs other than offsets. Also `restrict` is only needed on the output argument to enable full vectorization of the 128-bit structs.
New link: https://godbolt.org/g/8uGn4h
Changing the loop to 4 iterations for compactness' sake, (aligned) structs of two u64s generate the following, vectorized code:
https://godbolt.org/g/jB4jki
And if the pointer arguments are declared `restrict`, the loop can be vectorized even more aggressively: Either of which is much more efficient than the code generated for unaligned, packed 96-bit structs: A smaller cost is that in non-vector code, using a 64-bit register (rax) in 32-bit mode (eax) is wasting half of the register.IIRC, unaligned loads and stores will also, at the hardware level, stall the pipeline and inhibit out-of-order execution.