[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 Jul 19 05:35:01 PDT 2026


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

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

@arsenm  oh, ok got it. So could you please advise me on how to proceed with this patch?

I suppose we should add restrictions on `X` in `fcmp (fmul X, C1), C2` => `fcmp X, C2/C1` transformation to make this work?

<details>

The bug is not just about denormal mode.
Even with full IEEE (denormals allowed), fmul itself can underflow a non-zero X to 0.0.

IEEE denormal mode “Tiny X gets flushed to 0 before multiply”
Underflow in fmul “Tiny X * 0.5 becomes 0 after multiply” <== actual bug

<img width="1814" height="918" alt="image" src="https://github.com/user-attachments/assets/b1044249-fb7e-4c20-8b87-2c050187d74b" />


</details>

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


More information about the llvm-commits mailing list