From 3c1133379cbcbd18763fe35e18c5300469ba58d6 Mon Sep 17 00:00:00 2001 From: Afonso Bordado Date: Fri, 10 Sep 2021 15:46:14 +0100 Subject: [PATCH] cranelift: Add `is_bool_vector` helper --- cranelift/codegen/src/ir/types.rs | 5 +++++ cranelift/filetests/src/function_runner.rs | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cranelift/codegen/src/ir/types.rs b/cranelift/codegen/src/ir/types.rs index 1f59c9c07c..4284021190 100644 --- a/cranelift/codegen/src/ir/types.rs +++ b/cranelift/codegen/src/ir/types.rs @@ -208,6 +208,11 @@ impl Type { } } + /// Is this a vector boolean type? + pub fn is_bool_vector(self) -> bool { + self.is_vector() && self.lane_type().is_bool() + } + /// Is this a scalar integer type? pub fn is_int(self) -> bool { match self { diff --git a/cranelift/filetests/src/function_runner.rs b/cranelift/filetests/src/function_runner.rs index 698a37c01a..d764b916e5 100644 --- a/cranelift/filetests/src/function_runner.rs +++ b/cranelift/filetests/src/function_runner.rs @@ -307,16 +307,12 @@ fn make_trampoline(signature: &ir::Signature, isa: &dyn TargetIsa) -> Function { (i * UnboxedValues::SLOT_SIZE) as i32, ); - let is_scalar_bool = param.value_type.is_bool(); - let is_vector_bool = - param.value_type.is_vector() && param.value_type.lane_type().is_bool(); - // For booleans, we want to type-convert the loaded integer into a boolean and ensure // that we are using the architecture's canonical boolean representation (presumably // comparison will emit this). - if is_scalar_bool { + if param.value_type.is_bool() { builder.ins().icmp_imm(IntCC::NotEqual, loaded, 0) - } else if is_vector_bool { + } 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); builder.ins().icmp(IntCC::NotEqual, loaded, zero_vec)