<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/115751>115751</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failure to infer that `ctpop(y) == 1` implies `y != 0`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
missed-optimization
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kmeakin
</td>
</tr>
</table>
<pre>
If `y.is_power_of_two()` is `true`, then `y` cannot be `0`, so the `panic` branch should be eliminated
```rust
#[no_mangle]
pub fn src1(x: u32, y: u32) -> u32 {
if y.is_power_of_two() {
x / y
} else {
0
}
}
#[no_mangle]
pub fn tgt1(x: u32, y: u32) -> u32 {
if y.is_power_of_two() {
x >> y.trailing_zeros()
} else {
0
}
}
#[no_mangle]
pub fn src2(x: u32, y: u32) -> u32 {
if y.is_power_of_two() {
x % y
} else {
0
}
}
#[no_mangle]
pub fn tgt2(x: u32, y: u32) -> u32 {
if y.is_power_of_two() {
x & (y - 1)
} else {
0
}
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VNFunDoQ_ZrhxdqVPV5g94GH5G6QrvoRKwMDuDU2sk0S8vWVyTZRVFVqUq2FYDRzxvjMkY8KQQ-WqIL8HvJzppY4Ol99m0j90DZrXLdW__cMCr7udbjM7on8xfWX-OQAj4AnKDjTIQGiXwgKDvgfiyPZrSdVW2Wti6yhlOFXRHAJlDKzsrpNuMYr244sjG4xXYKT0ZO2KlIH_Az87vou-OvjlxA_FFBCfm_dZVJ2MAT5-TU_Lw3rLQu-FYDHZ5B3bJGYDrG-xSe2A_mQYgbl_WsfY4zpnv2B90dcWs8MsGbrexLKMyMT6Hco_wC6Hv8t-Bs2cYg3ZyMf0i7rPnqljbbD5YW8C1fZP8HyixSDb_HmguWfE-zrat2eSsEAjyvbMfHv-vy6Y1lXye4kTyqjSpRSyMNJFiIbq6bve4HHU1dyJfOu52VPqmhaJQt-4C3PdIUcDyKtI-JB7AUSHVVBqhRt3zUIB06T0mZvzOO0d37IdAgLVULkZS4yoxoyYbMlxEmHQN3OzVFP-kVF7SwgJr_yVWrfNcsQ4MCNDjG8bxh1NFTVSpvFE4uOaduTZ3FUMTlPG2c3p5ltI5VnkGcmNj-bZqNpM7WVAYpU2KaxeFONMc4B5B1gDVgPOo5Ls2_dBFinH18_u9m779RGwHqjFQDrK7PHCn8GAAD__9XHddw">