x86: use simd::intrinsics for bitshifts #2034
x86: use simd::intrinsics for bitshifts #2034okaneco wants to merge 6 commits intorust-lang:mainfrom
simd::intrinsics for bitshifts #2034Conversation
Use intrinsics in `sse2`, `avx2`, `avx512f`, and `avx512bw` Mark intrinsics and tests that call these functions as const
|
r? @Amanieu rustbot has assigned @Amanieu. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| pub const fn _mm_sll_epi16(a: __m128i, count: __m128i) -> __m128i { | ||
| let shift = count.as_u64x2().as_array()[0]; | ||
| unsafe { | ||
| if shift >= 16 { |
There was a problem hiding this comment.
Can you check that LLVM is actually able to eliminate this check and fold it into the psllw instruction? It might still be keeping the check and only doing a psllw on the else branch.
There was a problem hiding this comment.
Good point, I assumed the instruction threshold tests were low enough to catch that.
But it looks like neither left nor right shifts fold into the instructions we want. Branches for the left shifts and cmov for the right shifts.
https://rust.godbolt.org/z/rzsehj5b8
sse2,avx2,avx512f, andavx512bwNothing notable about the implementation.
Intrinsics take
countas the shift argument with the shift being au64in the low 64-bits of an__m128i. The shift amount must be less than the bit width of the type being shifted.