Skip to content

Should "Fallback" mul operations be implemented as truncating multiplication? #11

Open
@ajakubowicz-canva

Description

@ajakubowicz-canva

While implementing WASMmul_u8x16 and mul_i8x16 I added the following two tests (which test parity between WASM and Fallback:

test_wasm_simd_parity! {
    fn mul_u8x16() {
        |s| -> [u8; 16] {
            let a = u8x16::from_slice(s, &[0,0,1,1,2,4,8,16,32,64,128,255,255,255,255,255]);
            let b = u8x16::from_slice(s, &[0,0,0, 1,1,2,4,8,16,32,64,128,255,255,255,0]);
            (a * b).into()
        }
    }
}

test_wasm_simd_parity! {
    fn mul_i8x16() {
        |s| -> [i8; 16] {
            let a = i8x16::from_slice(s, &[0,0,127,-0,2,4,8,16,32,64,127,127,127,127,127,127]);
            let b = i8x16::from_slice(s, &[0,0,-128,0,2,4,-8,-16,-32,-64,127,0,1,-1,0,1]);
            (a * b).into()
        }
    }
}

These failed with a panic message: attempt to multiply with overflow from fallback.

How should the Fallback implementation handle those test cases? I've implemented the WASM operations as truncated multiplication. I believe the neon implementation also uses truncating multiplication as Neon's mul_u8x16 operation uses the vmulq_u8 intrinsic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions