<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97181>97181</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[AARCH64] clang __builtin_flt_rounds() doesn't respect soft float ABI selection
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
keith-packard
</td>
</tr>
</table>
<pre>
`__builtin_flt_rounds()` should return the constant `1` when building for soft float targets. Instead, it accesses the (non-existant) FPSR register as if it were still building for a hardware float target. This is using llvm built from main yesterday, e34dbb127af0596d07d01b9fa6cab5b2488ff37b
Code:
```
int foo()
{
return __builtin_flt_rounds();
}
```
Compilation command:
```
clang -m64 -target aarch64-none-elf -march=armv8-a+nofp -mabi=aapcs-soft -S foo.c
```
Output:
```
.text
.file "foo.c"
.globl foo // -- Begin function foo
.p2align 2
.type foo,@function
foo: // @foo
// %bb.0:
mrs x8, S3_3_C4_C4_0
// kill: def $w8 killed $w8 killed $x8
add w8, w8, #1024, lsl #12 // =4194304
ubfx w0, w8, #22, #2
ret
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
// -- End function
.ident "clang version 19.0.0git (https://github.com/llvm/llvm-project.git e34dbb127af0596d07d01b9fa6cab5b2488ff37b)"
.section ".note.GNU-stack","",@progbits
.addrsig
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU2P8yYQ_jXkMrKFsWObQw67SdO-UtVW77bnCJvBoYshArwf_fUVdj426m7VRhZhxjPPzDwzYBGCHizihqwfyXq3ElM8Or95Rh2P2Un0z8LLVefk-4bU9HDoJm2itgdl4sG7ycpAWEsYJzWFcHSTkeAxTt5CPCL0zoYobARS0yKZvB7RQsKQ2g6gnIfgVARlnIgQhR8whhy-2RBRSMK2oCOIvscQMMyIhLXW2Qzf9AxMGIf9b0_fweOgQ0QPIoBWye0VPUKI2pj7gAKOwstX4f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