MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / resize_used_bits

Function resize_used_bits

hail-fuzz/src/load_resizer.rs:464–483  ·  view source on GitHub ↗

Removes upper bits from `a` and `b` for operations with partial constants. Handles cases like: ```pcode value:4 = load(value_addr) mask:1 = load(mask_addr); mask_zxt:4 = zext(mask); output = value & mask_zxt; ```

(op: pcode::Op, a: &'a [Bit], b: &'b [Bit])

Source from the content-addressed store, hash-verified

462/// output = value & mask_zxt;
463/// ```
464fn resize_used_bits<'a, 'b>(op: pcode::Op, a: &'a [Bit], b: &'b [Bit]) -> (&'a [Bit], &'b [Bit]) {
465 /// We didn't support this in the original implementation, so this flag can be set to enable
466 /// compatability with old traces.
467 const SKIP_AND_USAGE_ADJUSTMENT: bool = false;
468 if SKIP_AND_USAGE_ADJUSTMENT {
469 return (a, b);
470 }
471
472 match op {
473 pcode::Op::IntAnd => {
474 let a_zeros = a.known_leading_zeros();
475 let b_zeros = b.known_leading_zeros();
476 (&a[..a.len() - b_zeros], &b[..b.len() - a_zeros])
477 }
478
479 // TODO: add additional operations (e.g., IntOr with upper ones, Bool* operations, shift
480 // operations).
481 _ => (a, b),
482 }
483}
484
485impl icicle_vm::CodeInjector for LoadResizeInjector {
486 fn inject(&mut self, cpu: &mut Cpu, group: &BlockGroup, code: &mut BlockTable) {

Callers 1

find_loads_and_usesMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected