wasm->CLIF translation: consistently bitcast V128 values that are block formal parameters.
In the current translation of wasm (128-bit) SIMD into CLIF, we work around differences in the
type system models of wasm vs CLIF by inserting `bitcast` (a no-op cast) CLIF instructions before
more or less every use of a SIMD value. Unfortunately this was not being done consistently and
even small examples with a single if-then-else diamond that produces a SIMD value, could cause a
verification failure downstream. In this case, the jump out of the "else" block needed a
bitcast, but didn't have one.
This patch wraps creation of CLIF jumps and conditional branches up into three functions,
`canonicalise_then_jump` and `canonicalise_then_br{z,nz}`, and uses them consistently. They
first cast the relevant block formal parameters, then generate the relevant kind of branch/jump.
Hence, provided they are also used consistently in future to generate branches/jumps in this
file, we are protected against such failures.
The patch also adds a large(ish) comment at the top explaining this in more detail.
This commit is contained in:
committed by
julian-seward1
parent
76998f0404
commit
ab65d8f10c
15
cranelift/wasmtests/pr2303.wat
Normal file
15
cranelift/wasmtests/pr2303.wat
Normal file
@@ -0,0 +1,15 @@
|
||||
(module
|
||||
(memory (export "mem") 1 1)
|
||||
(func (export "runif") (param $cond i32)
|
||||
i32.const 48
|
||||
(v128.load (i32.const 0))
|
||||
(v128.load (i32.const 16))
|
||||
(if (param v128) (param v128) (result v128 v128)
|
||||
(local.get $cond)
|
||||
(then i64x2.add
|
||||
(v128.load (i32.const 32)))
|
||||
(else i32x4.sub
|
||||
(v128.load (i32.const 0))))
|
||||
i16x8.mul
|
||||
v128.store)
|
||||
)
|
||||
Reference in New Issue
Block a user