Open Kmeakin opened 2 weeks ago
If y.is_power_of_two() is true, then y cannot be 0, so the panic branch should be eliminated
y.is_power_of_two()
true
y
0
panic
https://godbolt.org/z/q9jhsnqs7
pub fn div(x: u32, y: u32) -> u32 { if y.is_power_of_two() { x / y } else { 0 } } pub fn rem(x: u32, y: u32) -> u32 { if y.is_power_of_two() { x % y } else { 0 } }
Should probably be addressed in LVI/CVP.
If
y.is_power_of_two()
istrue
, theny
cannot be0
, so thepanic
branch should be eliminatedhttps://godbolt.org/z/q9jhsnqs7