Repository navigation
Add SimdInt::reverse_bits - #434
Conversation
|
A shuffle-based formulation models on llvm-mca as 2.5x faster than lots of shifts and bitwise ops, benchmarks with about the same improvements on my CPU. I've pushed it. |
Shnatsel
left a comment
There was a problem hiding this comment.
Looks good to me but I'd appreciate if you could take a look at my changes
|
And in case you're wondering, the scalar fallback on SSE2 autovectorizes into the same slow-ish sequence of SIMD shifts. |
Ohh, I read about exactly this use case before and completely forgot about it. Great catch! Changes LGTM!
I was wondering that. Thanks! |
Github does let you. It doesn't let anyone merge the code with only your review, but you can still leave a review. |
|
Ah I see! I didn't think of that |

This adds another method from
std::simd:reverse_bits.It's implemented as first reversing the bits within the u8 bytes of the vector and then using
swap_bytesto reverse the byte order for the given integer type. Platforms only differ in how they do the 8-bit reversal:vrbitq_u8instruction.gf2p8affinefamily of intrinsics to do the bit reversal in a single instruction (plus loading a constant). See this blog post.