WebAssembly / simd

Branch of the spec repo scoped to discussion of SIMD in WebAssembly
Other
531 stars 43 forks source link

Specification for comparison instructions should return -1 (all ones) and not 1 #441

Closed ngzhian closed 3 years ago

ngzhian commented 3 years ago

Comparisons should set a lane to 0 if false or all ones if true (https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#comparisons).

For {i8x16,i16x8,i32x4}.{eq,ne...}, the specification seems to rely on http://localhost:9000/exec/numerics.html#xref-exec-numerics-op-ieq-mathrm-ieq-n-i-1-i-2 which sets a lane to 1 or 0.

E.g.: i8x16.eq gets matched by shape.vbinop, which uses the rule vbinop_shape, which is eq_i8x16 which applies eq_i8 lanewise.

Not sure how to solve this yet, filing a bug to track this. We might need a special rule to match comparisons and do a "signed extension" step after the comparisons. Or define a new set of comparisons that return -1.

Note that only the text is wrong, the interpreter implementation doing the right thing.