specifically, looking for which numeric instructions can trap. the spec makes figuring this out way harder than I feel it should be :pensive:
I know some of the float<-->int conversions can trap, but can't find the set of them all listed in one place
I guess all the truncating conversions?
IIRC yeah it's like i32.trunc_f32
or those
The trunc_sat_*
things explicitly don't trap though
right
do you know if there are anything in the simd instructions that trap other than loads and stores?
I don't believe so, let me double-check
ok no I don't think so but fuzzing will probably confirm that one way or another
ah there are a bunch more truncating conversions there
but they all seem to use the saturating logic, okay
of the SIMD instructions, (only) the binops seem to be spec'd to allow the possiblity of trapping
which suggests that at least one of them traps, although it's hard to work out which one(s) from the spec
(or the spec might just be written defensively because there's a feeling that binops might be particularly likely to trap in future?)
I don't recall any of the SIMD lowerings having a trap but I could be wrong... @Andrew Brown might be able to say for sure?
I was going to say the conversion instructions but they aren't binop (and don't really trap either); looking again at the spec I think you may be right that that is a defensive move
The SIMD load/store instructions can trap.
But otherwise yes, there was a concerted effort to minimize trapping in the SIMD proposal.
There was a moment I like to call "the great divide coincidence": it would be really awkward if we had to make divide non-trapping, because what else should it do, but then it turns out that a lot of SIMD units don't have integer divide anyway, so we could just leave it out of the spec altogether.
huh, that is indeed convenient
Last updated: Nov 22 2024 at 17:03 UTC