WebAssembly/simd

No `i8x16.mul`?

Cyborus04 opened this issue ยท 4 comments

Is there a reason why i8x16.mul is not included? I find it a bit odd, since i16x8.mul, i32x4.mul, and i64x2.mul exist. Is there something I'm missing?

penzn commented

This is instruction was dropped (#98), because result of i8 multiplication isn't likely to fit into an i8: #28 (comment)

Do you have code where you would need it?

I was making a toy SIMD library in Rust which only operates on 128 bits (like in WebAssembly), where each type for the lanes would implement a trait for their associated instructions. I hit the roadblock of mul as I didn't see a way to implement this trait for i8/u8 (except maybe extracting each lane and multiplying them manually, but that kinda defeats the point)

You can try using i16x8.extmul_low_i8x16 + i16x8.extmul_high_i8x16 + i8x16.narrow_i16x8_{s,u}, that's 3 instructions, which will be better than extracting individual lanes.

Oh, that works. Thank you!