<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61984>61984</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AArch64] Miscompilation of code mixing fp16 and bf16
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:AArch64,
miscompilation
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ostannard
</td>
</tr>
</table>
<pre>
This code is miscompiled when targeting AArch64:
```c
struct S80 {
__bf16 M0;
__fp16 M1;
};
int F54(struct S80 P0) {
return P0.M1 == 1025.0f;
}
```
```
$ /work/llvm/build/bin/clang --target=aarch64--none-eabi -march=armv8.2-a+fp16+bf16 -c test.c -O2 -o - -S
.text
.file "test.c"
.globl F54 // -- Begin function F54
.p2align 2
.type F54,@function
F54: // @F54
.cfi_startproc
// %bb.0: // %entry
mov w0, wzr
ret
.Lfunc_end0:
.size F54, .Lfunc_end0-F54
.cfi_endproc
// -- End function
.ident "clang version 17.0.0 (git@github.com:llvm/llvm-project.git 626b7e5dd249f569203e024141c1a2a0f618df9c)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
The value `1025.0` is representable by `__fp16` (checked with https://evanw.github.io/float-toy/), so there should be no reason to remove the comparison.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VMFyozgQ_Rr50gUlGozhwMGJ13vZ7E7VzJ5dQmpAG5BcknAm8_VbgjixM1PjcknQtJ7U77We8F73hqhh2we2PWzEHAbrGuuDMEY4tWmtem2-DdqDtIpAe5i0l3Y665EUvAxkIAjXU9Cmh_3eyaEsWL5n_MD4dSz5-pfruw9ulgG-VhzY7mGNwenUdlkJT5zl1xCcTt05xrL3GNsdPp6XUZsAx23BsLqB_cIZ1jfg4CjMzsAXnj5lwPIDyw-QcdymvLvDvj_vL4t4e8UCGB5frHtmeBzHy8Tw2M56VHHWhuFRjsL0kCQrPSw_CLGwkyTGGkpItBq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