Skip to content

Commit

Permalink
cls_i64
Browse files Browse the repository at this point in the history
  • Loading branch information
Qazalin committed Oct 15, 2024
1 parent 1a1d8b3 commit 54ee5d2
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ impl<'a> Thread<'a> {
let ret = match op {
9 => self.ctz_i32_b64(s0),
11 => self.clz_i32_u64(s0),
13 => self.cls_i64(s0),
_ => panic!(),
};
self.write_to_sdst(sdst, ret);
Expand Down Expand Up @@ -1813,6 +1814,17 @@ impl<'a> Thread<'a> {
}
ret as u32
}
fn cls_i64(&self, s0: u64) -> u32 {
let mut ret: i32 = -1;
let s0 = s0 as i64;
for i in (1..=63).into_iter() {
if s0 >> (63 - i as u32) != s0 >> 63 {
ret = i;
break;
}
}
ret as u32
}
fn clz_i32_u32(&self, s0: u32) -> u32 {
let mut ret: i32 = -1;
for i in (0..=31).into_iter() {
Expand Down

0 comments on commit 54ee5d2

Please sign in to comment.