[llvm] InstSimplify: support floating-point equivalences (PR #115152)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 16 06:27:35 PST 2024


nikic wrote:

Alive reports a verification failure for one of the tests: https://alive2.llvm.org/ce/z/eHm-rS

```llvm
----------------------------------------
define half @src(half %x, half %y) {
#0:
  %fcmp = fcmp oeq half %x, 0x3c00
  %fmul = fmul half %y, %x
  %sel = select i1 %fcmp, half %y, half %fmul
  ret half %sel
}
=>
define half @tgt(half %x, half %y) {
#0:
  %fmul = fmul half %y, %x
  ret half %fmul
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
half %x = #x3c00 (1)
half %y = #xfc80 (SNaN)

Source:
i1 %fcmp = #x1 (1)
half %fmul = #x7e00 (QNaN)
half %sel = #xfc80 (SNaN)

Target:
half %fmul = #x7c80 (SNaN)
Source value: #xfc80 (SNaN)
Target value: #x7c80 (SNaN)
```

The problem is that the fmul may return a different NaN value than just passing the value through.

cc @nunoplopes 

https://github.com/llvm/llvm-project/pull/115152


More information about the llvm-commits mailing list