From 4c1dc827bcd17964743a8aced211247ee4b7a4a8 Mon Sep 17 00:00:00 2001 From: Travis Boraten Date: Wed, 1 May 2019 01:11:08 -0400 Subject: [PATCH] arch-gcn3: Replace some instances of std::isnormal with std::fpclassify 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 Tested-by: kokoro Reviewed-by: Matt Sinclair --- src/arch/gcn3/insts/instructions.cc | 44 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/arch/gcn3/insts/instructions.cc b/src/arch/gcn3/insts/instructions.cc index 302dad4eb..9987fade0 100644 --- a/src/arch/gcn3/insts/instructions.cc +++ b/src/arch/gcn3/insts/instructions.cc @@ -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); -- 2.30.2