[llvm] [LangRef] Clarify the behavior of select with FP poison-generating flags (PR #137131)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 24 00:51:51 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Yingwei Zheng (dtcxzyw)
<details>
<summary>Changes</summary>
RFC link: https://discourse.llvm.org/t/rfc-clarify-the-behavior-of-select-with-fp-poison-generating-flags/85974
Actually, it does not conflict with the definition of FMF if we interpret a select as `applyFMF(select cond, applyFMF(TrueArm), applyFMF(FalseArm))`.
---
Full diff: https://github.com/llvm/llvm-project/pull/137131.diff
1 Files Affected:
- (modified) llvm/docs/LangRef.rst (+5-1)
``````````diff
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 9e78f317bd9ea..fe8eb411612b5 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -12895,12 +12895,16 @@ vectors of the same size, and the selection is done element by element.
If the condition is an i1 and the value arguments are vectors of the
same size, then an entire vector is selected.
+Note that violations of poison-generating flags for both arms may not result in poison return values.
+For simplicity, if :ref:`fast-math flags <fastmath>` are present, they are only applied to the result, not both arms.
+
Example:
""""""""
.. code-block:: llvm
- %X = select i1 true, i8 17, i8 42 ; yields i8:17
+ %X = select i1 true, i8 17, i8 42 ; yields i8:17
+ %Y = select nnan i1 true, float 0.0, float NaN ; yields float:0.0
.. _i_freeze:
``````````
</details>
https://github.com/llvm/llvm-project/pull/137131
More information about the llvm-commits
mailing list