[TIR] Fixup max/min with input containing NAN#19589
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the LLVM code generation for minimum and maximum operations to use LLVM's CreateMinimum and CreateMaximum instructions for non-integer types. Feedback highlights that these instructions require LLVM 12 or later, so version guards are necessary to prevent compilation failures on older supported versions. It is also suggested to restrict these calls specifically to floating-point types for better type safety.
|
@tqchen The failing test case in ir_module.py is due to the LLVM backend lagging behind LLVM IR in its support for llvm.{min,max}imum.{f32,f64}. How should we handle this situation?
The fmaximum instruction is supported in llvm 18.1.0 for x86-64 and in llvm 19.1.0 for i686. |
Hi @actinks !
Instead we could do:
Now, these new functions can be used to "protect" needed things in the higher level graph flow. @tqchen what do you think ? Later EDIt:
I think with workaround (emmiting multiple llvm insn) it can be made fully backward to any LLVM version. |
llvm.minimum and llvm.maximum: Return NaN if one the arguments is NaN.
refs: https://llvm.org/docs/LangRef.html#floating-point-min-max-intrinsics-comparison
fixed #19579