cranelift: Support boolean arguments larger than b1 in trampoline (#4323)

This commit is contained in:
Afonso Bordado
2022-06-27 19:51:55 +01:00
committed by GitHub
parent dc2fe0ac67
commit 2327127b7d
3 changed files with 16 additions and 1 deletions

View File

@@ -1,4 +1,8 @@
test interpret
test run
target aarch64
target x86_64
target s390x
function %bextend_b1_b8(b1) -> b8 {
block0(v0: b1):

View File

@@ -1,4 +1,8 @@
test interpret
test run
target aarch64
target x86_64
target s390x
function %breduce_b8_b1(b8) -> b1 {
block0(v0: b8):

View File

@@ -308,7 +308,14 @@ fn make_trampoline(signature: &ir::Signature, isa: &dyn TargetIsa) -> Function {
// that we are using the architecture's canonical boolean representation (presumably
// comparison will emit this).
if param.value_type.is_bool() {
builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0)
let b = builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0);
// icmp_imm always produces a `b1`, `bextend` it if we need a larger bool
if param.value_type.bits() > 1 {
builder.ins().bextend(param.value_type, b)
} else {
b
}
} else if param.value_type.is_bool_vector() {
let zero_constant = builder.func.dfg.constants.insert(vec![0; 16].into());
let zero_vec = builder.ins().vconst(ty, zero_constant);