<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71429>71429</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
need a way to report branch removed due to poison values
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yxsamliu
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/bb3We4ozP
the following code results in an empty function:
`int foo(int *x) {
int sum = 0;
for (int i = 0; i < 19; i++) {
unsigned mask = 1U << (i - 1);
sum += x[i & mask];
}
return sum;
}`
This is because when i is 0, `1U << (i - 1)` is poison. BDCEPass will remove the branches with poison conditions.
However, clang is unable to diagnose this. Since only after loop unrolling the compiler knows `mask` is poison. We cannot simply diagnose any `unsigned << signed` by default since such uses are too common.
This kind of error is pretty common and is difficult for users to debug. Therefore better have a way to let LLVM mid-end to report it. Maybe by some -R options.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVE2P4zYM_TXyhRjDlhMnPvgwmTToYRdYtNvuWbboWB1ZNPSRjPfXF3SyM2l3gSCWST7y8ZGWCsGcHWIrtgexPWYqxZF8u7wFNVmTso700o4xzkFUz0KehDydSXdkY07-LOTpu5Cnrqu-4Ya-fxHFURTPt_84IgxkLV2NO0NPGsFjSDYGMA6UA5zmuMCQXB8NOU7_gBZ1YVyEgUjIPZ-EfH4TsgGxO9wigK0hTSCqIxSi-mGGgTzcQebduR5foGzWs5CH9feYDgCSW8XQMKnwukLLvxjGSM4IT1AK2TzUghsDeeDgN7E9GBCyXvFie3wIFLvjj6PHmLxj4LufvXXx2P_X0QQwATrsVQoI1xEdGLYUQr6AqItfU6sLjpnJBHI5HI4vv31RIcDVWAseJ7og8GA6r1w_IjvieA-Hnpw2PIuQP1L5na54Qc9le6vcmQskpzqLEAm0UWdHgdOakMOfxvUI5OwCaojowRLNkJwna3kPuHhP02wsenh1dA3cy6rXf6l_Q-iVcxQhmGm2y0ch5RbGvA_rrsLtjbN0C2gcVLKMZToh9SOkgAGUZ9LEFCZy-U-KvxqngQZA78mvdDzGuNzjQTnNRm2GwfScn3ctBfRhlQK7dM7h64geB_IIHUaWYFQXBAVXtXCUxQifPv39GSajn9BptnmcyUcwMYfPaumQWwg0ITz9ATT_PJJMt5VuqkZl2JZ108hmV8ldNrbbomp0te_LcjtItVf7naxqVW1UqZu-2W8z08pCVmVZ1GVTlNs6H6rNUDWNGuq63w_7UmwKnJSxubWXib_xzISQsN2VG9lkVnVow3pZSOnwCqtTSMl3h28Z89SlcxCbwpoQw0eWaKLF1iHqDynubd-W8b6eGnRaF-u-lBdlE4Ysefv_a8jEMXV5T5OQJy5zfzzNnv7BPgp5WskFIU8r-X8DAAD__2SSifA">