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

@@ -718,6 +718,12 @@ pub(crate) fn define(
.build(),
);
let ScalarBool = &TypeVar::new(
"ScalarBool",
"A scalar boolean type",
TypeSetBuilder::new().bools(Interval::All).build(),
);
let iB = &TypeVar::new(
"iB",
"A scalar integer type",
@@ -3331,13 +3337,10 @@ pub(crate) fn define(
let IntTo = &TypeVar::new(
"IntTo",
"An integer type with the same number of lanes",
TypeSetBuilder::new()
.ints(Interval::All)
.simd_lanes(Interval::All)
.build(),
"A scalar integer type",
TypeSetBuilder::new().ints(Interval::All).build(),
);
let x = &Operand::new("x", Bool);
let x = &Operand::new("x", ScalarBool);
let a = &Operand::new("a", IntTo);
ig.push(
@@ -3346,8 +3349,7 @@ pub(crate) fn define(
r#"
Convert `x` to an integer.
True maps to 1 and false maps to 0. The result type must have the same
number of vector lanes as the input.
True maps to 1 and false maps to 0.
"#,
&formats.unary,
)
@@ -3355,6 +3357,17 @@ pub(crate) fn define(
.operands_out(vec![a]),
);
let IntTo = &TypeVar::new(
"IntTo",
"An integer type with the same number of lanes",
TypeSetBuilder::new()
.ints(Interval::All)
.simd_lanes(Interval::All)
.build(),
);
let x = &Operand::new("x", Bool);
let a = &Operand::new("a", IntTo);
ig.push(
Inst::new(
"bmask",