cranelift: Fix bint implementation on interpreter (#4299)

* cranelift: Fix `bint` implementation on interpreter

The interpreter was returning -1 instead of 1 for positive values.
This also extends the bint test suite to cover all types.

* cranelift: Restrict `bint` to scalar values only
This commit is contained in:
Afonso Bordado
2022-06-23 21:43:35 +01:00
committed by GitHub
parent 51c1655b6e
commit 87007c5839
4 changed files with 414 additions and 22 deletions

View File

@@ -716,11 +716,15 @@ where
| Opcode::ScalarToVector
| Opcode::Breduce
| Opcode::Bextend
| Opcode::Bint
| Opcode::Ireduce => assign(Value::convert(
arg(0)?,
ValueConversionKind::Exact(ctrl_ty),
)?),
Opcode::Bint => {
let bool = arg(0)?.into_bool()?;
let int = if bool { 1 } else { 0 };
assign(Value::int(int, ctrl_ty)?)
}
Opcode::Snarrow | Opcode::Unarrow | Opcode::Uunarrow => {
let arg0 = extractlanes(&arg(0)?, ctrl_ty.lane_type())?;
let arg1 = extractlanes(&arg(1)?, ctrl_ty.lane_type())?;