From c7039dbb2b601cff4a929e01c4941b00becadab2 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Mon, 20 Jun 2016 18:01:35 +0200 Subject: [PATCH] simplify the masked rhs computation --- src/primval.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/primval.rs b/src/primval.rs index fbb93012885..3399d697ed4 100644 --- a/src/primval.rs +++ b/src/primval.rs @@ -82,17 +82,19 @@ fn unrelated_ptr_ops<'tcx>(bin_op: mir::BinOp) -> EvalResult<'tcx, PrimVal> { U64(_) => 6, _ => unreachable!(), }; + let mask = (1 << mask_bits) - 1; let r = match right { - I8(i) => (i & ((1 << mask_bits) - 1)) as u32, - I16(i) => (i & ((1 << mask_bits) - 1)) as u32, - I32(i) => (i & ((1 << mask_bits) - 1)) as u32, - I64(i) => (i & ((1 << mask_bits) - 1)) as u32, - U8(i) => (i & ((1 << mask_bits) - 1)) as u32, - U16(i) => (i & ((1 << mask_bits) - 1)) as u32, - U32(i) => (i & ((1 << mask_bits) - 1)) as u32, - U64(i) => (i & ((1 << mask_bits) - 1)) as u32, + I8(i) => i as u8 & mask, + I16(i) => i as u8 & mask, + I32(i) => i as u8 & mask, + I64(i) => i as u8 & mask, + U8(i) => i as u8 & mask, + U16(i) => i as u8 & mask, + U32(i) => i as u8 & mask, + U64(i) => i as u8 & mask, _ => panic!("bad MIR: bitshift rhs is not integral"), }; + let r = r as u32; macro_rules! shift { ($v:ident, $l:ident, $r:ident) => ({ match bin_op {