[llvm] [NVPTX] Add IR pass for FMA transformation in the llc pipeline (PR #154735)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 12:14:51 PST 2025


arsenm wrote:

> > By moving this transformation earlier into the IR phase, we enable more opportunities for FMA folding, including across basic blocks.

This is what isProfitableToSinkOperands is for; codegen prepare already tries to sink to enable FMA formation if you implement it. I think within the last year we turned that on and then had to revert it due to regressions 

> 
> This sounds like something that may be useful in general. Perhaps it makes sense to make it a generic pass. There's nothing in it that's NVPTX-specific.
> 
> @arsenm -- would this be useful for AMDGPU?

If it's useful, I suppose? Mostly I think this is redundant. FMA formation in the IR cannot replace doing it in codegen - plenty of FMAable situations will appear in codegen of assorted math intrinsics. The net result will be new optimizations get implemented here, the pattern gets missed in codegen and/or there's duplicated work to do the same there 



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


More information about the llvm-commits mailing list