<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/225516>225516</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Compute known mantissa/fraction bits for `SIToFP`/`UIToFP`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZERICO2005
</td>
</tr>
</table>
<pre>
Follow up to: https://github.com/llvm/llvm-project/issues/225511
Currently, we do not have a way to compute the known mantissa bits from `__builtin_bit_cast(int32_t, (float)i32_value)`.
The `KnownBits` for the mantissa can be calculated by shifting `int_value` so that the `MSB` of `int_value` would be in the `LSB` of the exponent (and then discarding the `LSB` of the exponent since the mantissa bit is implicit (except for `x86_fp80`)). Note that if the conversion is inexact, we may have to round up, which may include rounding up to infinity.
One use case may be folding/simplifying integer/bitwise rounding code for performing `(bfloat)((float)int_value)` (assuming double-rounding is avoided).
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJykVE2P2zYQ_TXUZRCDplaydNBhd1sBQT9SNOmlF4MiR9a0NCmIQ3v97wvSu9sEBXrJSdB8vNGbN086Rjp5xEE0T6L5odKJl7ANf_74-8fnT0rKppqCvQ1jcC5cIa3AQdSPsDCvUdSPQo1CjSfiJU07E85Cjc5d3h4f1i38hYaFGinGhFGoUamm2e-FfBTy8TltG3p2N6Ge4YpgA_jAsOgLgoarvgEHMOG8JkbgBeFvH64eztozxahhIo4wb-EMopXH45TIMfnjRHw0OrJQHXmu1ZEzvlDd7IJmoXqq1fGiXUKhetHK3f1rviyYcX7KM56Io2glzGErg99HGu1hQjDameQ0o4XpBnGhmcmfcjt5fsVuJcQAvGguEKKVv3x-ytEw_6fwGpKzGZj8W_HP78U5gC9r8Og509De5pgHS9HozebJ_98UyRv8lshEDBSBzqsjQwUXXwyuXDiLVr507XFeOylamdek-h38GooOmoHuA0zwF9wiBV-wPL5ow69invXtriQH2ELyFtJaUguZpWTJG5cs3rOZRDkvID-TJ769yvLJI6SYVx7voBPCHFxuEGqMhcB8y-3kGU-4CTVOxFeKXyGbYLEQW3Gbw3Z-FUuobno7CqG6r0_kXZ1yImXtMabSaEOaHH54B6cI-hLIos1bquxQ277udYXD_tDLvezrdl8tg2z2dX9oHqbDYWqUbrCT6nDQ0naNaYzuKhqUVK3slVKybuV-p7Ttur2Rdav6vba1eJB41uR22Vy7sJ2qYquheKqtnJ7QxeJkpTxeoWSFUtnY21AcOaVTFA_SUeT4LwwTOxyeX532rcuEGudNG84i3w13v4_PH7-E8beyxFG08o-31yptbvjO_0NbXQb1TwAAAP__TxOCCQ">