2 ms·
There's a trick here I hadn't noticed. Good times. If the plan is 8 byte aligned data and use the three low bits for other stuff, you mask them off before load
by JonChesterfield 3y ago
There's a trick here I hadn't noticed. Good times.
If the plan is 8 byte aligned data and use the three low bits for other stuff, you mask them off before loads/stores. An alternative is to use the high three bits, store the pointer/8, and multiply by 8 to retrieve.
That's appealing on x64 because memory operations can include a *8 in the encoding.
Specifically, I've long wondered whether the pointer masking tricks mess up prefetch/speculation. It seems plausible that making the dereference look more like a normal memory operation is helpful for that.
(It also means the low-alignment-bits and high-unused-bits can be considered contiguous modulo the *8 on decode which is probably less annoying when using both ranges)