[llvm] [DAGCombiner] Fold freeze(fmul) + fadd/fsub into FMA combine (PR #142250)
Harrison Hao via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 1 06:24:35 PDT 2025
harrisonGPU wrote:
> By the looks of it SelectionDAG::canCreateUndefOrPoison doesn't handle fp ops at all - should we start with fixing those to more closely match ValueTracking llvm::canCreateUndefOrPoison?
Thanks for the pointer. After rereading the **LLVM Language Reference Manual** I agree that
`SelectionDAG::canCreateUndefOrPoison` should return **false** for plain FP ops (`fadd`, `fmul`, …):
by default they **propagate** poison but never **create** it.
The only time they can generate new poison is when the instruction carries the `nnan` or `ninf`
(or the umbrella `fast`) *fast-math* flags, because those flags require a NaN/Inf result to become poison.
The LangRef notes for every FP op include:
> “This instruction can also take any number of
> [fast-math flags](https://llvm.org/docs/LangRef.html#fastmath), which are optimization hints to enable otherwise
> unsafe floating-point optimizations.”
What do you think of this?
**References**
* [`fadd` instruction](https://llvm.org/docs/LangRef.html#fadd-instruction)
* [Fast-Math Flags](https://llvm.org/docs/LangRef.html#fast-math-flags)
https://github.com/llvm/llvm-project/pull/142250
More information about the llvm-commits
mailing list