arch-gcn3: Replace some instances of std::isnormal with std::fpclassify
authorTravis Boraten <travis.boraten@amd.com>
Wed, 1 May 2019 05:11:08 +0000 (01:11 -0400)
committerAnthony Gutierrez <anthony.gutierrez@amd.com>
Fri, 17 Jul 2020 16:33:26 +0000 (16:33 +0000)
Affected instructions: V_DIV_SCALE_F64, V_CMP_CLASS_F64,
V_CMPX_CLASS_F64 and their VOPC, VOP3, F32 variants.

These instances of std::isnormal were being used to check for
subnormal (denorms) values. std::isnormal is not specific enough.
It returns true for normal values but false for NaN, Inf, 0.0, and
subnormals. std::fpclassify returns macros for each category of
floating point numbers. Now we only catch subnormals.

Change-Id: I8d8f4452ff58de71e7c8e0b2b5e73467b532e196
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29967
Maintainer: Anthony Gutierrez <anthony.gutierrez@amd.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Matt Sinclair <mattdsinclair@gmail.com>
src/arch/gcn3/insts/instructions.cc

index 302dad4ebfefecc2307c4b84169e24fb36d96521..9987fade013d2eade8c58d7f75ca179f8b06c900 100644 (file)
@@ -9439,7 +9439,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9463,7 +9463,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9551,7 +9551,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9575,7 +9575,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9664,7 +9664,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9688,7 +9688,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9777,7 +9777,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -9801,7 +9801,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         vcc.setBit(lane, 1);
                         continue;
@@ -15550,7 +15550,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         sdst.setBit(lane,  1);
                         continue;
@@ -15574,7 +15574,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         sdst.setBit(lane,  1);
                         continue;
@@ -15665,7 +15665,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         sdst.setBit(lane,  1);
                         continue;
@@ -15689,7 +15689,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         sdst.setBit(lane,  1);
                         continue;
@@ -15780,7 +15780,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         sdst.setBit(lane, 1);
                         continue;
@@ -15804,7 +15804,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         sdst.setBit(lane, 1);
                         continue;
@@ -15895,7 +15895,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 4)) {
                     // is -denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && std::signbit(src0[lane])) {
                         sdst.setBit(lane, 1);
                         continue;
@@ -15919,7 +15919,7 @@ namespace Gcn3ISA
                 }
                 if (bits(src1[lane], 7)) {
                     // is +denormal
-                    if (!std::isnormal(src0[lane])
+                    if (std::fpclassify(src0[lane]) == FP_SUBNORMAL
                         && !std::signbit(src0[lane])) {
                         sdst.setBit(lane, 1);
                         continue;
@@ -29249,17 +29249,19 @@ namespace Gcn3ISA
                     if (src0[lane] == src1[lane]) {
                         vdst[lane] = std::ldexp(src0[lane], 128);
                     }
-                } else if (!std::isnormal(src1[lane])) {
+                } else if (std::fpclassify(src1[lane]) == FP_SUBNORMAL) {
                     vdst[lane] = std::ldexp(src0[lane], 128);
-                } else if (!std::isnormal(1.0 / src1[lane])
-                           && !std::isnormal(src2[lane] / src1[lane])) {
+                } else if (std::fpclassify(1.0 / src1[lane]) == FP_SUBNORMAL
+                           && std::fpclassify(src2[lane] / src1[lane])
+                           == FP_SUBNORMAL) {
                     vcc.setBit(lane, 1);
                     if (src0[lane] == src1[lane]) {
                         vdst[lane] = std::ldexp(src0[lane], 128);
                     }
-                } else if (!std::isnormal(1.0 / src1[lane])) {
+                } else if (std::fpclassify(1.0 / src1[lane]) == FP_SUBNORMAL) {
                     vdst[lane] = std::ldexp(src0[lane], -128);
-                } else if (!std::isnormal(src2[lane] / src1[lane])) {
+                } else if (std::fpclassify(src2[lane] / src1[lane])
+                           == FP_SUBNORMAL) {
                     vcc.setBit(lane, 1);
                     if (src0[lane] == src2[lane]) {
                         vdst[lane] = std::ldexp(src0[lane], 128);