diff --git a/cranelift/codegen/src/souper_harvest.rs b/cranelift/codegen/src/souper_harvest.rs index a690fa7262..d818eee9f9 100644 --- a/cranelift/codegen/src/souper_harvest.rs +++ b/cranelift/codegen/src/souper_harvest.rs @@ -387,7 +387,8 @@ fn harvest_candidate_lhs( let a = arg(allocs, 0); // While Cranelift allows any width condition for - // `select`, Souper requires an `i1`. + // `select` and checks it against `0`, Souper requires + // an `i1`. So insert a `ne %x, 0` as needed. let a = match a { ast::Operand::Value(id) => match lhs.get_value(id).r#type { Some(ast::Type { width: 1 }) => a, @@ -395,7 +396,14 @@ fn harvest_candidate_lhs( .assignment( None, Some(ast::Type { width: 1 }), - ast::Instruction::Trunc { a }, + ast::Instruction::Ne { + a, + b: ast::Constant { + value: 0, + r#type: None, + } + .into(), + }, vec![], ) .into(),