[llvm] [InstCombineCompares] Replace the sqrt in if-condition (PR #91707)
Joshua Cranmer via llvm-commits
llvm-commits at lists.llvm.org
Fri May 10 12:56:22 PDT 2024
https://github.com/jcranmer-intel commented:
Some analysis for fast-math flags purposes (from exhaustive search of all half-precision {X, Y} pairs):
* `X` cannot be a negative number.
* `Y * Y` cannot be a subnormal number.
* `Y * Y` cannot overflow if `X` may be infinite.
* Past that, there are rounding issues. For example, `sqrt(0x1.004p-14) <=> 0x1p-7` is equal, but the target check of `0x1.004p-14 <=> 0x1p-14` returns greater than. (Note that `sqrt(0x1.004p-14)` rounds to `0x1p-7` in default rounding mode for binary16).
We don't really have any existing fast-math flags that allow the rounding tolerance issue in the last case. The `Y * Y` overflow and (semi-)underflow concerns aren't something that can really be constrained by any of the existing flags, and kind of need checks on constant values to guarantee correctness.
https://github.com/llvm/llvm-project/pull/91707
More information about the llvm-commits
mailing list