Skip to content

Commit

Permalink
reduce an mir code repetition like (n << amt) >> amt
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta7777 committed Feb 23, 2019
1 parent c6fd027 commit 42d5cf8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc_mir/interpret/place.rs
Expand Up @@ -7,6 +7,7 @@ use std::hash::Hash;

use rustc::hir;
use rustc::mir;
use rustc::mir::interpret::truncate;
use rustc::ty::{self, Ty};
use rustc::ty::layout::{self, Size, Align, LayoutOf, TyLayout, HasDataLayout, VariantIdx};
use rustc::ty::TypeFoldable;
Expand Down Expand Up @@ -959,8 +960,7 @@ where
// their computation, but the in-memory tag is the smallest possible
// representation
let size = tag.value.size(self);
let shift = 128 - size.bits();
let discr_val = (discr_val << shift) >> shift;
let discr_val = truncate(discr_val, size);

let discr_dest = self.place_field(dest, 0)?;
self.write_scalar(Scalar::from_uint(discr_val, size), discr_dest)?;
Expand Down

0 comments on commit 42d5cf8

Please sign in to comment.