MCPcopy Create free account
hub / github.com/RustCrypto/utils / from_u128_lt_halves

Method from_u128_lt_halves

ctutils/src/choice.rs:310–320  ·  view source on GitHub ↗
(x: u128, y: u128)

Source from the content-addressed store, hash-verified

308 #[inline]
309 #[allow(clippy::cast_possible_truncation)]
310 const fn from_u128_lt_halves(x: u128, y: u128) -> Self {
311 // Full-width subtraction can introduce conditional borrow propagation.
312 // Keep the half-width predicates opaque so LLVM cannot combine them into a short-circuiting
313 // multiword comparison.
314 let x_hi = (x >> 64) as u64;
315 let y_hi = (y >> 64) as u64;
316 let hi_lt = Self::from_u64_lt(x_hi, y_hi).to_u8();
317 let hi_eq = Self::from_u64_eq(x_hi, y_hi).to_u8();
318 let lo_lt = Self::from_u64_lt(x as u64, y as u64).to_u8();
319 Self::from_u8_lsb(hi_lt | (hi_eq & lo_lt))
320 }
321
322 /// Returns [`Choice::TRUE`] if `value != 0`, and [`Choice::FALSE`] otherwise.
323 #[inline]

Callers

nothing calls this directly

Calls 4

from_u64_ltFunction · 0.85
from_u64_eqFunction · 0.85
from_u8_lsbFunction · 0.85
to_u8Method · 0.80

Tested by

no test coverage detected