[llvm] [InstCombine] Fold `fcmp (fmul X, C1), C2` to `fcmp X, C2/C1` (PR #205003)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 28 05:20:47 PDT 2026


================

----------------
VachanVY wrote:

> But this transformation should applies to all IEEE fp types.

I excluded half because of this counterexample, please advise me on the check:

```
----------------------------------------
define i1 @f(half %x) {
#0:
  %mul = fmul half %x, 0x4200
  %cmp = fcmp oeq half %mul, 0x3c00
  ret i1 %cmp
}
=>
define i1 @f(half %x) {
#0:
  %cmp = fcmp oeq half %x, 0x3555
  ret i1 %cmp
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
half %x = #x3556 (0.33349609375)

Source:
half %mul = #x3c00 (1)
i1 %cmp = #x1 (1)

Target:
i1 %cmp = #x0 (0)
Source value: #x1 (1)
Target value: #x0 (0)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```

> Please provide a generalized proof as requested by https://llvm.org/docs/InstCombineContributorGuide.html#proofs. Otherwise I cannot check whether the preconditions are correct.

Alive2: https://alive2.llvm.org/ce/z/dEfDaZ 
But it's giving a timeout for float, invalid transformation for half

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


More information about the llvm-commits mailing list