3 ms·
Pure intuition, but if you don’t care about tagged pointers, I’d guess your approach would at worst break even and might even win some microbenchmarks: Flipping
by twoodfin 3y ago
Pure intuition, but if you don’t care about tagged pointers, I’d guess your approach would at worst break even and might even win some microbenchmarks: Flipping bits via a mask is cheaper transistor-wise than a shift, and a very cursory review of the latest Intel pipeline data from the canonical resource[1] suggests that this is reflected in the degree of macro-op fusion and number of execution units available for shift vs. bitlogic. See page 166 in particular.
[1] https://www.agner.org/optimize/microarchitecture.pdf https://www.agner.org/optimize/microarchitecture.pdf