[clang] [clang] Allow `ConditionalOperator` fast-math flags to be overridden by `pragma float_control` (PR #105912)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 8 11:34:10 PDT 2024
andykaylor wrote:
> Are you suggesting that loads need to have fast-math flags attached to them? Because this sounds like a bad representation in IR.
What I'm primarily suggesting is that we should be handling conditional operators consistently in the presence of pragmas. Whether that can be done with CompoundStmt or requires some other intervention, I don't know.
In the example I linked above, clang is attaching fast-math flags to a phi instruction when fast-math flags are used on the command line, which causes the optimizer to keep the flags and move them to a select instruction when the call graph is simplified. However, when a pragma is used to disable fast-math locally, clang still puts the fast-math flags on the phi instruction, which is a bug.
The question of whether we should be putting fast-math flags on load instructions has come up before (see https://github.com/llvm/llvm-project/issues/51601), and we resisted doing it. The current solution for that case is to use function attributes to deduce that fast-math rules apply throughout the function. That works, but it is more conservative than we'd like in cases where a function with fast-math enabled is inlined into a function with fast-math disabled. I don't have a solution to that other than attaching fast-math flags to the load instruction. I'm just noting it as a problem. It's certainly better to have the conservative behavior than to apply fast-math where it shouldn't be applied (which can happen currently with the conditional operator).
https://github.com/llvm/llvm-project/pull/105912
More information about the cfe-commits
mailing list