llvm / llvm/llvm-project

[AArch64] Miscompile of fp operation `(a >= c) | (b >= c)`

Open
#223,089 3 comments 0 reactions 1 assignee Claimed by @MitchBriles View on GitHub
backend:AArch64 floating-point miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

This IR:

```llvm
define i1 @f(float %a, float %b, float %c) {
%4 = fcmp oge float %a, %c
%5 = fcmp oge float %b, %c
%6 = or i1 %4, %5
ret i1 %6
}
```

is lowered to

```asm
f:
fmaxnm s0, s0, s1
fcmp s0, s2
cset w0, ge
ret
```

For `a=c=+0.0` and `b=sNaN`, the IR returns `true` and the hardware returns `false`.

`llubi` output:

```
%1 = fcmp oge float 0.000000e+00, 0.000000e+00 => T
%2 = fcmp oge float +snan(0x1), 0.000000e+00 => F
%3 = or i1 %1, %2 => T
```

cc @regehr

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.