[llvm] [llvm] Don't combine repeated subnormal divisors (PR #149333)
Andy Kaylor via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 18:05:03 PDT 2025
andykaylor wrote:
> it's rather strange to me to refuse to generally do the prototypical transformation of the flag--that's why the user added it in the first place!
I think it's a matter of the compiler causing a problem that the compiler itself should be able to spot. Specifically, when 'ninf' is set, we shouldn't be performing operations that we know are introducing an infinity where one didn't previously exist. This PR doesn't actually check for `ninf` so in that sense it may be more conservative than necessary, but as a general rule, the optimizer shouldn't knowingly introduce infinities when the `ninf` flag is set.
In this case, I think the original code probably just shouldn't have been compiled with fast-math enabled. It's obviously not able to tolerate it. If we don't perform this optimization, I would expect DAZ to turn the subnormals into zero anyway, which will make the result of the division infinity.
However, as I understand it, the problem that @ashermancinelli encountered was different than that. What happened was that the compiler introduced an infinity and then, based on the fact that the user had claimed their code contained no infinities, traded out the result of the infinity for an arbitrary value that caused a visible problem.
https://github.com/llvm/llvm-project/pull/149333
More information about the llvm-commits
mailing list