stdarch
stdarch copied to clipboard
`_mm_adds_epu8` doesn't generate the right instruction.
https://godbolt.org/z/KTTPcKP58
#[target_feature(enable = "sse2")]
pub fn simd_gte2(x: __m128i) -> i32 {
let bc = _mm_set1_epi8(0x7e);
let y = _mm_adds_epu8(x, bc);
_mm_movemask_epi8(y)
}
.LCPI0_0:
.zero 16,2
example::simd_gte2:
movdqa xmm0, xmmword ptr [rdi]
movdqa xmm1, xmmword ptr [rip + .LCPI0_0]
pmaxub xmm1, xmm0 ; 1
pcmpeqb xmm1, xmm0 ; 2: these two instructions can be simplified to paddusb
pmovmskb eax, xmm1
ret
Looks like a missed optimization in LLVM. Can you report it there as "[X86] Poor codegen for ..."?
Our implementation seems pretty reasonable
pub const fn _mm_adds_epu8(a: __m128i, b: __m128i) -> __m128i {
unsafe { transmute(simd_saturating_add(a.as_u8x16(), b.as_u8x16())) }
}
@rustbot label +A-x86 +A-llvm