From f787ce433d400004f34c3f0b1e34a7197fd9f349 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 16 Nov 2021 16:47:12 -0600 Subject: [PATCH] aarch64: Remove manual sign extension in lowering (#3538) Currently the lowering for `iconst` will sign-extend the payload value of the `iconst` instruction itself, but the payload is already sign-extended to this isn't necessary. This commit removes the redundant sign extension. --- cranelift/codegen/src/isa/aarch64/lower_inst.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/cranelift/codegen/src/isa/aarch64/lower_inst.rs b/cranelift/codegen/src/isa/aarch64/lower_inst.rs index 5b898ef835..c2ae72055e 100644 --- a/cranelift/codegen/src/isa/aarch64/lower_inst.rs +++ b/cranelift/codegen/src/isa/aarch64/lower_inst.rs @@ -41,20 +41,16 @@ pub(crate) fn lower_insn_to_regs>( match op { Opcode::Iconst | Opcode::Bconst | Opcode::Null => { let value = ctx.get_constant(insn).unwrap(); - // Sign extend constant if necessary - let value = match ty.unwrap() { - I8 => (((value as i64) << 56) >> 56) as u64, - I16 => (((value as i64) << 48) >> 48) as u64, - I32 => (((value as i64) << 32) >> 32) as u64, - I64 | R64 => value, - ty if ty.is_bool() => value, + match ty.unwrap() { + I8 | I16 | I32 | I64 | R64 => {} + ty if ty.is_bool() => {} ty => { return Err(CodegenError::Unsupported(format!( "{}: Unsupported type: {:?}", op, ty - ))) + ))); } - }; + } let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap(); lower_constant_u64(ctx, rd, value); }