[llvm] Update foldFMulReassoc to respect absent fast-math flags (PR #88589)

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 12 16:01:34 PDT 2024


andykaylor wrote:

This PR is probably opening a huge can of worms. I intend to post an RFC to discuss the general topic of requiring fast-math flag checks on all instructions involved in a transformation. There seem to be a lot of places where we aren't bothering with this, and many existing tests don't have uniform FMF on the instructions being transformed. Getting this clean everywhere may be a huge project.

The transformation this is targeting is the one from https://github.com/llvm/llvm-project/issues/82857: `(C1 / X) * C --> (C * C1) / X`

In the problem case, fast-math flags are set on the multiplication operation, but not on the division, as a result of inlining a function that didn't have fast-math enabled. The folded operation is assigned the fast-math flags from the multiplication. Issue 82857 arrived at this state using `#pragma float_control(precise, on)` but the same thing could happen with LTO.

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


More information about the llvm-commits mailing list