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.
This commit is contained in:
Alex Crichton
2021-11-16 16:47:12 -06:00
committed by GitHub
parent f30c8eb464
commit f787ce433d

View File

@@ -41,20 +41,16 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
match op { match op {
Opcode::Iconst | Opcode::Bconst | Opcode::Null => { Opcode::Iconst | Opcode::Bconst | Opcode::Null => {
let value = ctx.get_constant(insn).unwrap(); let value = ctx.get_constant(insn).unwrap();
// Sign extend constant if necessary match ty.unwrap() {
let value = match ty.unwrap() { I8 | I16 | I32 | I64 | R64 => {}
I8 => (((value as i64) << 56) >> 56) as u64, ty if ty.is_bool() => {}
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,
ty => { ty => {
return Err(CodegenError::Unsupported(format!( return Err(CodegenError::Unsupported(format!(
"{}: Unsupported type: {:?}", "{}: Unsupported type: {:?}",
op, ty op, ty
))) )));
}
} }
};
let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap(); let rd = get_output_reg(ctx, outputs[0]).only_reg().unwrap();
lower_constant_u64(ctx, rd, value); lower_constant_u64(ctx, rd, value);
} }