<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118485>118485</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[LoongArch] Miscompilation when converting `float` to `u32`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
heiher
</td>
</tr>
</table>
<pre>
### How to reproduce:
```llvm
define zeroext i32 @test_f32_to_u32(float %a) nounwind {
entry:
%conv = fptoui float %a to i32
ret i32 %conv
}
```
```sh
llc --mtriple loongarch64 --mattr=+f,+d -o - f32-to-u32.ll
```
### Expected result:
| f32 | u32 |
|------------|----------|
| -1 | 0 |
| -2 | 0 |
| 4294967296 | ffffffff |
| NAN | 0 |
| +INFINITY | ffffffff |
| -INFINITY | 0 |
### Unexpected result:
| f32 | u32(Clang) | u32(GCC) |
|------------|------------|----------|
| -1 | ffffffff | ffffffff |
| -2 | fffffffe | fffffffe |
| 4294967296 | 0 | ffffffff |
| NAN | 0 | 0 |
| +INFINITY | ffffffff | ffffffff |
| -INFINITY | 0 | 80000000 |
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVMtu6zYQ_ZrRZiCDGuphLbTwo24DtF61i64CPUYWC1o0KCpO-vUXlJzYCWLk5g4ICIc8HA4PR6ccBnXomQtI1pBsg3J0nbFFx6pjG1SmeSmA5DzwD3NGZ9DyyZpmrBnkCsQ0UjEPrZ-OIFYNt6pn_J-t4WeHShJCLBwP7rGV9OjM4ygJaNlqUzoESkqgHHsz9mfVNwjZGsSKe2df5iPQc2rTPyHILbYnZ0aF182-KCVpIlq-nDdv8MVl29sSP1Q8dCBWWtcYhkdn1UkzamP6Q2nrLo39bOmcBbkFWrdAG6B1g6HBEFtJoTPhKGmh9ScnvMn22_OJa8cNWh5G7a6qZRufBP13lIRTQLaZl8KbeAffGBhG-BoeihvwyqB7KzHlcZ5mlKcTo73EDWO_2n-RHWj9sN897B_-_hfvZQnfMz5mudXpn56_UOqmnLmBNrrsD753rlO_bzaXiS90_FlZ3y51_4702Qb-CO-KL777BL_2It95nhkuxRweBE0hm1zmZcBFlElJUiTpMuiKJsryOG0jyqukqYWom3Ipq6aqSMhItlmgChIURx5SkorlImZikadNFSdS5qWEWPCxVHrh7WNh7CFQwzByEUXLeJkEuqxYD5NDEfV8xmkViLxh2cJvCqvxMEAstBrccE3jlNOTtf3pf-mVrTtItviXGmpzPCldOmV6PHfco_cKtk71B4RUTNYCqfDGAqnwjZWKYLS66Jw7Db4vaQe0OyjXjdWiNkeg3eR98yc8WfMf1w5oN9U6AO0ul3kq6EcAAAD___fMbNE">