Skip to content

512-bit wide f32x16 {min,max}_element reductions incorrect for NaNs on wasm #91

Open
@gnzlbg

Description

@gnzlbg

The min_element and max_element reductions fail when NaNs are present on wasm32-unknown-unknown:

---- packed_simd::v512::f32x16_reduction_min_max_nan::min_element_test output ----
    error output:
        panicked at 'assertion failed: `(left == right)`
          left: `NaN`,
         right: `-3.0`: [D]: nan at 0 => NaN | f32x16(NaN, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0)', src/v512.rs:59:1
    
    JS exception that was thrown:
        RuntimeError: unreachable
            at wasm-function[20942]:33
            at wasm-function[20936]:30
            at wasm-function[20931]:448
            at wasm-function[20929]:130
            at wasm-function[20928]:3
            at wasm-function[21145]:70
            at wasm-function[8636]:2400
            at wasm-function[18652]:71
            at wasm-function[20734]:15
            at wasm-function[20735]:5

---- packed_simd::v512::f32x16_reduction_min_max_nan::max_element_test output ----
    error output:
        panicked at 'assertion failed: `(left == right)`
          left: `NaN`,
         right: `-3.0`: [D]: nan at 0 => NaN | f32x16(NaN, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0, -3.0)', src/v512.rs:59:1
    
    JS exception that was thrown:
        RuntimeError: unreachable
            at wasm-function[20931]:390
            at wasm-function[20929]:130
            at wasm-function[20928]:3
            at wasm-function[21145]:70
            at wasm-function[8634]:2400
            at wasm-function[19467]:71
            at wasm-function[20734]:15
            at wasm-function[20735]:5
            at Function.cbarg0 (/Users/gnzlbg/projects/sideprojects/packed_simd/target/wasm32-unknown-unknown/wbg-tmp/wasm-bindgen-test.js:197:25)
            at global.__wbg_test_invoke.f (/Users/gnzlbg/projects/sideprojects/packed_simd/target/wasm32-unknown-unknown/wbg-tmp/run.js:27:41)

failures:

    packed_simd::v512::f32x16_reduction_min_max_nan::min_element_test
    packed_simd::v512::f32x16_reduction_min_max_nan::max_element_test

Surprisingly, these reductions work fine for NaNs for vectors of f64 and all other f32 vectors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-WASMWebAssembly architectureUnsoundSomething breaks Rust safety guarantees

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions