<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/95443>95443</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Failed to convert integer range classification to branchfree form
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Kmeakin
</td>
</tr>
</table>
<pre>
`src` is taken from https://doc.rust-lang.org/src/core/char/methods.rs.html#1741. `tgt` is equivalent but generates branchfree code.
[godbolt](url)
```c
#include <stdint.h>
uint64_t src(uint32_t code) {
if (code < 0x80) {
return 1;
} else if (code < 0x800) {
return 2;
} else if (code < 0x10000) {
return 3;
} else {
return 4;
}
}
uint64_t tgt(uint32_t code) {
uint64_t len = 1;
len += (code >= 0x80);
len += (code >= 0x800);
len += (code >= 0x10000);
return len;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1zmzAQ_TXLRRNGSHzYBw5xHS79ERkhrUGNkFJpcdt_35HjxHabpi3DIHbe26fdByuVkp08Yg_NDpp9oVaaQ-w_L6ierC_GYH700PIUNbSc2cRIPaFnhxgWNhM9J5D3IAYQgwm6jGuiO6f8VIY4gRhymhh0iJiXWUUQw4I0B5PKmMqZFgdCVl1dlQxaThOdd8Gvqz0qh57YuBKb0GNUhImNUXk9HyIi08FgyYDvgd-fn81uCmYMjqDZg9is0YHY3jBa_nLrcyyk9dqtBhnIT4mM9VTOIB-uk1brqa0fiZ3a2eRQikc6FQBiy6DbvRAZY8weGIhNhrIi4983_DdOviLSGj2rQF4B0O0ZuoTvqXwoI_5RpuL8YyH5vtCf6PWFDt3-bNrby617-ev-zb03skPPQO6v_DmTToDYZezS2kMOz1bfNPAx-7_or9b9WtDFDIf-Ar6Z8PrHFaaXZiu3qsC-6qqN5LyVXTH3TdWNdauwrjedauuukqKuZatFV3casS1sL7ioeVvlSZGNKDtpjJFamMaYkbcSao6Lsq507rjk0StsSiv226auZeHUiC6dBlwIj9_YCQQh8rzHPufcjeuUoObOJkoXFbLksB-UdWgYBaaDP2IkZj3hhJFF5Sdk2uVD5GC1Iht85l0N6SHEpVij628Pi8nSvI6lDguIIe93Xu6eY_iCmkAMpyoTiOGli2MvfgYAAP__zUNOZA">