Fix validating wasm stores of boolean vector results (#3202)
Previously cranelift's wasm code generator would emit a raw `store` instruction for all wasm types, regardless of what the cranelift operand type was. Cranelift's `store` instruction, however, isn't valid for boolean vector types. This commit fixes this issue by inserting a bitcast specifically for the store instruction if a boolean vector type is being stored, continuing to avoid the bitcast for all other vector types. Closes #3099
This commit is contained in:
@@ -2407,8 +2407,16 @@ fn translate_store<FE: FuncEnvironment + ?Sized>(
|
||||
state: &mut FuncTranslationState,
|
||||
environ: &mut FE,
|
||||
) -> WasmResult<()> {
|
||||
let val = state.pop1();
|
||||
let val_ty = builder.func.dfg.value_type(val);
|
||||
let mut val = state.pop1();
|
||||
let mut val_ty = builder.func.dfg.value_type(val);
|
||||
|
||||
// Boolean-vector types don't validate with a `store` instruction, so
|
||||
// bitcast them to a vector type which is compatible with the store
|
||||
// instruction.
|
||||
if val_ty.is_vector() && val_ty.lane_type().is_bool() {
|
||||
val = builder.ins().raw_bitcast(I8X16, val);
|
||||
val_ty = I8X16;
|
||||
}
|
||||
|
||||
let (flags, base, offset) =
|
||||
prepare_addr(memarg, mem_op_size(opcode, val_ty), builder, state, environ)?;
|
||||
|
||||
Reference in New Issue
Block a user