Skip to main content

magic_eval

Function magic_eval 

Source
pub fn magic_eval(x: i64, magic: u64, more: u8, mul_back: i64) -> i64
Expand description

Evaluate the unsigned magic reciprocal for MicroOp::MagicDivU: x / c when mul_back == 0, else x % c (mul_back == c). The dividend is reinterpreted as u64, sound because the op is emitted ONLY for a proven non-negative x (the i64 bit pattern equals the value, and unsigned and signed-truncating //% agree there). The remainder is x - q*c in wrapping i64 (its low 64 bits equal the u64 difference). The more encoding is the logicaffeine_data::LogosDivU64 one: low 6 bits = shift, 0x40 = the 65-bit add-marker path, 0x80 = the pure-shift power-of-two path.