Skip to content

Commit ceaf862

Browse files
committed
clean up
1 parent ddf8b3a commit ceaf862

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cranelift/codegen/src/isle_prelude.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ macro_rules! isle_common_prelude_methods {
3434
let clz_offset = 64 - bits;
3535
let a_v: u64 = a.bits().cast_unsigned();
3636
let lz = a_v.leading_zeros() - clz_offset;
37-
Imm64::new(lz as i64)
37+
Imm64::new(i64::from(lz))
3838
}
3939

4040
#[inline]
4141
fn imm64_sdiv(&mut self, ty: Type, x: Imm64, y: Imm64) -> Option<Imm64> {
4242
// Sign extend `x` and `y`.
43-
let shift = u32::checked_sub(64, ty.bits()).unwrap_or(0);
43+
assert!(ty.bits() <= 64);
44+
let shift = 64 - ty.bits();
4445
let x = (x.bits() << shift) >> shift;
4546
let y = (y.bits() << shift) >> shift;
4647

@@ -62,7 +63,8 @@ macro_rules! isle_common_prelude_methods {
6263
#[inline]
6364
fn imm64_srem(&mut self, ty: Type, x: Imm64, y: Imm64) -> Option<Imm64> {
6465
// Sign extend `x` and `y`.
65-
let shift = u32::checked_sub(64, ty.bits()).unwrap_or(0);
66+
assert!(ty.bits() <= 64);
67+
let shift = 64 - ty.bits();
6668
let x = (x.bits() << shift) >> shift;
6769
let y = (y.bits() << shift) >> shift;
6870

0 commit comments

Comments
 (0)