wasm->CLIF: fn translate_operator: Select/TypedSelect: add missing bitcasts
The translation of Operator::Select and Operator::TypedSelect for vector-typed operands, lacks the relevant bitcasting of the operands to I8X16. This commit adds it.
This commit is contained in:
committed by
julian-seward1
parent
cacebfb19c
commit
07652ca0d4
@@ -201,14 +201,26 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
|
|||||||
state.pop1();
|
state.pop1();
|
||||||
}
|
}
|
||||||
Operator::Select => {
|
Operator::Select => {
|
||||||
let (arg1, arg2, cond) = state.pop3();
|
let (mut arg1, mut arg2, cond) = state.pop3();
|
||||||
|
if builder.func.dfg.value_type(arg1).is_vector() {
|
||||||
|
arg1 = optionally_bitcast_vector(arg1, I8X16, builder);
|
||||||
|
}
|
||||||
|
if builder.func.dfg.value_type(arg2).is_vector() {
|
||||||
|
arg2 = optionally_bitcast_vector(arg2, I8X16, builder);
|
||||||
|
}
|
||||||
state.push1(builder.ins().select(cond, arg1, arg2));
|
state.push1(builder.ins().select(cond, arg1, arg2));
|
||||||
}
|
}
|
||||||
Operator::TypedSelect { ty: _ } => {
|
Operator::TypedSelect { ty: _ } => {
|
||||||
// We ignore the explicit type parameter as it is only needed for
|
// We ignore the explicit type parameter as it is only needed for
|
||||||
// validation, which we require to have been performed before
|
// validation, which we require to have been performed before
|
||||||
// translation.
|
// translation.
|
||||||
let (arg1, arg2, cond) = state.pop3();
|
let (mut arg1, mut arg2, cond) = state.pop3();
|
||||||
|
if builder.func.dfg.value_type(arg1).is_vector() {
|
||||||
|
arg1 = optionally_bitcast_vector(arg1, I8X16, builder);
|
||||||
|
}
|
||||||
|
if builder.func.dfg.value_type(arg2).is_vector() {
|
||||||
|
arg2 = optionally_bitcast_vector(arg2, I8X16, builder);
|
||||||
|
}
|
||||||
state.push1(builder.ins().select(cond, arg1, arg2));
|
state.push1(builder.ins().select(cond, arg1, arg2));
|
||||||
}
|
}
|
||||||
Operator::Nop => {
|
Operator::Nop => {
|
||||||
|
|||||||
51
cranelift/wasmtests/pr2559.wat
Normal file
51
cranelift/wasmtests/pr2559.wat
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
(module
|
||||||
|
(type (;0;) (func (result v128 v128 v128)))
|
||||||
|
|
||||||
|
(func $main1 (type 0) (result v128 v128 v128)
|
||||||
|
call $main1
|
||||||
|
i8x16.add
|
||||||
|
call $main1
|
||||||
|
i8x16.ge_u
|
||||||
|
i16x8.ne
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 43
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 87
|
||||||
|
select
|
||||||
|
unreachable
|
||||||
|
i32.const 0
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 43
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
)
|
||||||
|
(export "main1" (func $main1))
|
||||||
|
|
||||||
|
(func $main2 (type 0) (result v128 v128 v128)
|
||||||
|
call $main2
|
||||||
|
i8x16.add
|
||||||
|
call $main2
|
||||||
|
i8x16.ge_u
|
||||||
|
i16x8.ne
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 43
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 87
|
||||||
|
select (result v128)
|
||||||
|
unreachable
|
||||||
|
i32.const 0
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 13
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
i32.const 43
|
||||||
|
br_if 0 (;@0;)
|
||||||
|
)
|
||||||
|
(export "main2" (func $main2))
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user