[llvm] CodeGen: Strengthen definition of F{MIN|MAX}NUM_IEEE nodes (PR #85195)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 14 01:16:01 PDT 2024
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/85195
Previously these were declared as having the 2008 behavior, with underspecified signed zero handling. Currently, AMDGPU, PPC and LoongArch mark these as legal. The AMDGPU and PPC instructions respect the signed zero behavior. The LoongArch documentation doesn't state, but I'm assuming it also does.
>From 084ee7f608e0808195ab9c5c06863f7a81a76b0a Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Thu, 14 Mar 2024 13:21:43 +0530
Subject: [PATCH] CodeGen: Strengthen definition of F{MIN|MAX}NUM_IEEE nodes
Previously these were declared as having the 2008 behavior, with
underspecified signed zero handling. Currently, AMDGPU, PPC and LoongArch
mark these as legal. The AMDGPU and PPC instructions respect the signed
zero behavior. The LoongArch documentation doesn't state, but I'm assuming
it also does.
---
llvm/docs/GlobalISel/GenericOpcode.rst | 14 ++++++++------
llvm/include/llvm/CodeGen/ISDOpcodes.h | 9 +++++----
llvm/include/llvm/Target/GenericOpcodes.td | 9 +++++----
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/llvm/docs/GlobalISel/GenericOpcode.rst b/llvm/docs/GlobalISel/GenericOpcode.rst
index ac6217d08e6a60..f7d1d5b3edd6a2 100644
--- a/llvm/docs/GlobalISel/GenericOpcode.rst
+++ b/llvm/docs/GlobalISel/GenericOpcode.rst
@@ -521,16 +521,18 @@ The return value of (FMAXNUM 0.0, -0.0) could be either 0.0 or -0.0.
G_FMINNUM_IEEE
^^^^^^^^^^^^^^
-Perform floating-point minimum on two values, following the IEEE-754 2008
-definition. This differs from FMINNUM in the handling of signaling NaNs. If one
-input is a signaling NaN, returns a quiet NaN.
+Perform floating-point minimum on two values, following the IEEE-754
+2019 definition. This differs from FMINNUM in the handling of
+signaling NaNs. If one input is a signaling NaN, returns a quiet
+NaN. This treats -0 as ordered less than +0.
G_FMAXNUM_IEEE
^^^^^^^^^^^^^^
-Perform floating-point maximum on two values, following the IEEE-754 2008
-definition. This differs from FMAXNUM in the handling of signaling NaNs. If one
-input is a signaling NaN, returns a quiet NaN.
+Perform floating-point maximum on two values, following the IEEE-754
+2019 definition. This differs from FMAXNUM in the handling of
+signaling NaNs. If one input is a signaling NaN, returns a quiet
+NaN. This treats -0 as ordered less than +0.
G_FMINIMUM
^^^^^^^^^^
diff --git a/llvm/include/llvm/CodeGen/ISDOpcodes.h b/llvm/include/llvm/CodeGen/ISDOpcodes.h
index 49d51a27e3c0f6..3aa33ee2021250 100644
--- a/llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ b/llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -971,10 +971,11 @@ enum NodeType {
FMINNUM,
FMAXNUM,
- /// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
- /// two values, following the IEEE-754 2008 definition. This differs from
- /// FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
- /// signaling NaN, returns a quiet NaN.
+ /// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or
+ /// maximumNumber on two values, following the IEEE-754 2019 definition. This
+ /// differs from FMINNUM/FMAXNUM in the handling of signaling NaNs. If one
+ /// input is a signaling NaN, returns a quiet NaN. These treat -0 as ordered
+ /// less than +0.
FMINNUM_IEEE,
FMAXNUM_IEEE,
diff --git a/llvm/include/llvm/Target/GenericOpcodes.td b/llvm/include/llvm/Target/GenericOpcodes.td
index 67d405ba96fa10..c9513f70a7c613 100644
--- a/llvm/include/llvm/Target/GenericOpcodes.td
+++ b/llvm/include/llvm/Target/GenericOpcodes.td
@@ -795,10 +795,11 @@ def G_FMAXNUM : GenericInstruction {
let isCommutable = true;
}
-// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimum or maximum on
-// two values, following the IEEE-754 2008 definition. This differs from
-// FMINNUM/FMAXNUM in the handling of signaling NaNs. If one input is a
-// signaling NaN, returns a quiet NaN.
+// FMINNUM_IEEE/FMAXNUM_IEEE - Perform floating-point minimumNumber or
+// maximumNumber on two values, following the IEEE-754 2019
+// definition. This differs from FMINNUM/FMAXNUM in the handling of
+// signaling NaNs. If one input is a signaling NaN, returns a quiet
+// NaN. These treat -0 as ordered less than +0.
def G_FMINNUM_IEEE : GenericInstruction {
let OutOperandList = (outs type0:$dst);
let InOperandList = (ins type0:$src1, type0:$src2);
More information about the llvm-commits
mailing list