isqrt: assume that isqrt takes half as many bits

https://github.com/rust-lang/rust/issues/89273#issuecomment-970581089
This commit is contained in:
Federico Stra 2023-09-28 13:59:19 +02:00
parent 77f9eae995
commit fcdfd5b0b9

View File

@ -2017,6 +2017,13 @@ macro_rules! uint_impl {
one >>= 2;
}
// SAFETY: the result is positive and fits in an integer with half as many bits.
// Inform the optimizer about it.
unsafe {
intrinsics::assume(0 < res);
intrinsics::assume(res < 1 << (Self::BITS / 2));
}
res
}