simplify the masked rhs computation

This commit is contained in:
Oliver Schneider 2016-06-20 18:01:35 +02:00
parent 001ae69212
commit c7039dbb2b
No known key found for this signature in database
GPG Key ID: 56D6EEA0FC67AC46

View File

@ -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 {