Fix sign extension

Co-authored-by: Max Graey <maxgraey@gmail.com>
This commit is contained in:
bjorn3
2020-09-01 23:02:29 +02:00
committed by Benjamin Bouvier
parent 067255ef45
commit 9999913a31

View File

@@ -52,8 +52,8 @@ pub(crate) fn lower_insn_to_regs<C: LowerCtx<I = Inst>>(
let value = ctx.get_constant(insn).unwrap();
// Sign extend constant if necessary
let value = match ty.unwrap() {
I8 => (((value as i64) << 8) >> 8) as u64,
I16 => (((value as i64) << 16) >> 16) as u64,
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,