Browse Source
We have a special lowering that allows us to fuse a `bitselect` with a comparison instruction. This saves us a few instructions due to the mismatch that exists between native RISC-V masks and WASM masks. Native RISC-V masks have a single bit per lane, whereas WASM masks have all bits in a lane set to 1. The lowering for `bitselect+bitcast+{i,f}cmp` avoids the need to generate the WASM mask, by directly using the comparison mask with `vmerge`. The bug that this fixes was that when we introduce a `bitcast` in the middle, the comparison and the merge may have different types with different lanes. And if that happens the `vmerge` will only look at the first n bits of the mask. n being the number of lanes currently configured. This commit ensures that they are always equal by using the same type for both vmerge and the comparison instruction. I also manually checked all other uses of `gen_{f,i}cmp_mask` and they are all using the same type in the subsequent instructions. With this fix we no longer really care about the type of the `bitselect` as long as it has the same bitlength as the type of `{i,f}cmp`, which I think is enforced by the verifier. (i.e. We would have the same bug if `bitselect.i8x16+icmp.i8xi8` was legal.)pull/8137/head
Afonso Bordado
8 months ago
committed by
GitHub
3 changed files with 162 additions and 8 deletions
Loading…
Reference in new issue