Skip to content

Commit

Permalink
Optimize bitwise byte ops (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrLSD authored Nov 11, 2024
1 parent aca614c commit ddaf13b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions core/src/eval/bitwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ pub fn not(op1: U256) -> U256 {
#[inline]
pub fn byte(op1: U256, op2: U256) -> U256 {
let mut ret = U256::zero();

for i in 0..256 {
if i < 8 && op1 < 32.into() {
let o: usize = op1.as_usize();
if op1 < 32.into() {
let o = op1.as_usize();
for i in 0..8 {
let t = 255 - (7 - i + 8 * o);
let bit_mask = U256::one() << t;
let value = (op2 & bit_mask) >> t;
let value = (op2 >> t) & U256::one();
ret = ret.overflowing_add(value << i).0;
}
}

ret
}

Expand Down

0 comments on commit ddaf13b

Please sign in to comment.