From e4fa35586654675297aaa502f7b6e1f504a01d8b Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 30 Jan 2023 15:32:47 -0800 Subject: [PATCH] cranelift: Generate the correct souper size for comparisons in LHSes (#5659) --- cranelift/codegen/src/souper_harvest.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cranelift/codegen/src/souper_harvest.rs b/cranelift/codegen/src/souper_harvest.rs index d24b58b997..a690fa7262 100644 --- a/cranelift/codegen/src/souper_harvest.rs +++ b/cranelift/codegen/src/souper_harvest.rs @@ -528,9 +528,16 @@ fn souper_type_of(dfg: &ir::DataFlowGraph, val: ir::Value) -> Option let ty = dfg.value_type(val); assert!(ty.is_int()); assert_eq!(ty.lane_count(), 1); - Some(ast::Type { - width: ty.bits().try_into().unwrap(), - }) + let width = match dfg.value_def(val).inst() { + Some(inst) + if dfg.insts[inst].opcode() == ir::Opcode::IcmpImm + || dfg.insts[inst].opcode() == ir::Opcode::Icmp => + { + 1 + } + _ => ty.bits().try_into().unwrap(), + }; + Some(ast::Type { width }) } #[derive(Debug)]