[llvm] [AMDGPU] Add a target option to disable aggressive FMA fusion (PR #161450)
Yi Qian via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 2 08:46:56 PDT 2025
yiqian1 wrote:
> > Sometimes we need to disable fusing fmul+fadd/fsub into fma,
>
> Why? That's not something you should _need_ to do
>
This is because FMA may cause numerical errors when we want bitwise accuracy. For example, one of our test cases includes `q * k - q * k`. It's lowered to `fsub(fmul(q, k), fmul(q, k))` which does `round(round(q * k) - round(q * k))`. With FMA enabled, it's transformed into `fma(q, k, -fmul(q, k))`. or `round(q * k - round(q * k))`. In this case we want to disable fusing fmul + fsub into fma to ensure correct results.
https://github.com/llvm/llvm-project/pull/161450
More information about the llvm-commits
mailing list