Skip to content

Try using real _mm_mulhi_epu16 now that it's no longer unsafe #130

Open
@Shnatsel

Description

@Shnatsel

Rust 1.87 made SIMD intrinsics that don't touch pointers safe to call: rust-lang/stdarch#1714

Due to the requirement to match libwebp output bit-for-bit we're using an emulation of the _mm_mulhi_epu16 intrinsic used by libwebp:

image-webp/src/vp8.rs

Lines 971 to 974 in 93baf7d

/// `_mm_mulhi_epu16` emulation used in `Frame::fill_rgb` and `Frame::fill_rgba`.
fn mulhi(v: u8, coeff: u16) -> i32 {
((u32::from(v) * u32::from(coeff)) >> 8) as i32
}

It would be interesting to try replacing it with the actual _mm_mulhi_epu16 now that it doesn't need unsafe and see if that changes the assembly in any way (hopefully for the better).

Here's the current state on godbolt, and it produces quite a lot of assembly: https://rust.godbolt.org/z/3afeY35EG

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions