<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86711>86711</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] Wrong code for i64 to f32 vector conversion
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hvdijk
</td>
</tr>
</table>
<pre>
Please consider:
```c++
#include <stdio.h>
typedef unsigned long ul;
typedef float f;
typedef unsigned long ul1 __attribute__((ext_vector_type(1)));
typedef float f1 __attribute__((ext_vector_type(1)));
__attribute__((noinline))
f converts(ul v) { return (f)v; }
__attribute__((noinline))
f1 convertv(ul1 v) { return __builtin_convertvector(v, f1); }
int main(void) {
ul s = 0xffffff7fffffffff;
ul1 v = 0xffffff7fffffffff;
printf("%A %A\n", converts(s), convertv(v)[0]);
}
```
Expected output, and actual output with `clang -O0`:
```
0X1.FFFFFEP+63 0X1.FFFFFEP+63
```
Actual output with `clang -O3`:
```
0X1.FFFFFEP+63 0X1P+64
```
This happens because the vector conversion from i64 to f32 is performed as a vector conversion from i64 to f64, and then a conversion from f64 to f32. But both of these conversions round, and the first conversion does not preserve enough information for the second conversion to produce the correct result.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVE2T2ygQ_TX40jUuCcn6OOhgj8fXzWGrdm8uJBqLLAYVNMrk328J2bNOZjaphKKwgff60R9qEYK-WMSO7Q5sd9yISKPz3ThL_fmfTe_k1-6TQREQBmeDluhZsWfZkWV7VmXrHBg_LHM95YW2g4kSgRXPgaR225EVL7fbtNLXCSUqiDaJSzDOXiAaVhy-BSjjBIF6O_8xPYfzWRB53UfC85nxhvEGX-k840DOnxce403OeHub_6P3-4bW9QO2ddoabfGGTzC1xHRGT4HxJhqYGW-B1QfwSNFbYLxRjLczKw7A6uPvKOR3iTlJ5O80zuc-akPanu_A5CLjzcz4M6h89e57fW0JrkLbBee0vBld7wCigQCsOEL2qtKo1X28RQpSwuafwyavLankI2d8t4dlYbtnm_bPjzEMyffnR58Xf9nukLHd8Zs8vblzL-J1-_I64UAowUWaIi3GhJUgBorC3A7hi6YRlro3wl7g6Y9Ef_dVrNvs73x7WsbLJ8YPVQHfH3zI2v9Qr_hFvfSv_BD-56gDjGKa0AbocRAxINCIsJbBLZJBOwvKuyvoqgRyoAoOOsCEXjl_RQkigPgZpyrv4aQRLYh3QPVmfAuHSNA7GsGpBb72nxs6gHfRygdroLQP9GhQOgxgHcHkMaCfEdC6eBlB2-XJgpKq84kdcHBWPtLJweSdjMMajcF5jwOBxxANbTeyK2RbtGKDXV7neVk3ddtuxq4tZNkUdcnrBsse21wqVZXDoGou5aDaje54xsus4FXelFXRbhsh-K6WfdlU2Je8YGWGV6HN1pj5unX-stEhROyaqs7zjRE9mpB6NecWv0C6XD6E3XHju4Xz1MdLYGVmdKDwnxXSZFKT3-_9MFYl2x3hL7_0zcFJTJF4yO27TG6iN91INIWl8PiJ8dNF0xj77eCujJ8WndvP0-TdZxyI8VN6XWD8lF7_bwAAAP__RA_2oA">