[llvm] [IVDescriptors] Don't require nsz/nnan for (min|max)num. (PR #137003)
Andy Kaylor via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 12:04:25 PDT 2025
andykaylor wrote:
> Alive2 agrees that maxnum/minnum can be re-ordered (scalar version: https://alive2.llvm.org/ce/z/GVmgBX)
I'm not sure how Alive2 came to this conclusion, but I don't think it's correct. According to the LangRef definition of `llvm.maxnum`, "if either operand is sNaN, the result is qNaN" but "If either operand is a qNaN, returns the other non-NaN operand." So, if `%a` is sNaN and neither `%b` or `%c` are NaN,
%max = call float @llvm.maxnum.f32(float %a, float %b )
%max2 = call float @llvm.maxnum.f32(float %c, float %max)
will return `%c` whereas
%max = call float @llvm.maxnum.f32(float %b, float %c)
%max2 = call float @llvm.maxnum.f32(float %a, float %max)
will return qNaN.
I'm not sure how the LangRef defintion of `llvm.maxnum` squares with the general claim that "Floating-point math operations are allowed to treat all NaNs as if they were quiet NaNs."
https://github.com/llvm/llvm-project/pull/137003
More information about the llvm-commits
mailing list