]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
PPC64, The function _get_maxmin_fp_NaN does not handle the case of QNaN, SNaN correctly.
authorCarl Love <carll@us.ibm.com>
Fri, 22 Mar 2019 17:32:29 +0000 (12:32 -0500)
committerCarl Love <carll@us.ibm.com>
Fri, 22 Mar 2019 17:32:29 +0000 (12:32 -0500)
This patch fixes Valgrind to handle the case of QNaN, SNaN input the same
as the HW handles it.

Valgrind bug 405365.

NEWS
VEX/priv/guest_ppc_toIR.c

diff --git a/NEWS b/NEWS
index fe30a0f7de9e9fbfc90ab948e8a97bee5c96e77c..a18d3406abdb69536438092f2f84b193dc1831cc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -117,6 +117,8 @@ where XXXXXX is the bug number as listed below.
         the upper and lower 32-bits of the 64-bit result
 405362  PPC64, vmsummbm instruction doesn't handle overflow case correctly
 405363  PPC64, xvcvdpsxws, xvcvdpuxws, do not handle NaN arguments correctly.
+405365  PPC64, function _get_maxmin_fp_NaN() doesn't handle QNaN, SNaN case
+        correctly.
 
 n-i-bz  add syswrap for PTRACE_GET|SET_THREAD_AREA on amd64.
 n-i-bz  Fix callgrind_annotate non deterministic order for equal total
index d40de2da926395adc50ccb2176e4a639cad11afa..3725e6ae9cfab887d26417b29db39efa64296560 100644 (file)
@@ -17485,7 +17485,10 @@ static IRExpr * _get_maxmin_fp_NaN(IRTemp frA_I64, IRTemp frB_I64)
     *   if frA is a SNaN
     *     result = frA converted to QNaN
     *   else if frB is a SNaN
-    *     result = frB converted to QNaN
+    *     if (frA is QNan)
+    *        result = frA
+    *     else
+    *        result = frB converted to QNaN
     *   else if frB is a QNaN
     *     result = frA
     *   // One of frA or frB was a NaN in order for this function to be called, so
@@ -17496,14 +17499,19 @@ static IRExpr * _get_maxmin_fp_NaN(IRTemp frA_I64, IRTemp frB_I64)
     */
 
 #define SNAN_MASK 0x0008000000000000ULL
+
    return
-   IRExpr_ITE(mkexpr(frA_isSNaN),
+      IRExpr_ITE(mkexpr(frA_isSNaN),
               /* then: result = frA converted to QNaN */
               binop(Iop_Or64, mkexpr(frA_I64), mkU64(SNAN_MASK)),
               /* else:  if frB is a SNaN */
               IRExpr_ITE(mkexpr(frB_isSNaN),
-                         /* then: result = frB converted to QNaN */
-                         binop(Iop_Or64, mkexpr(frB_I64), mkU64(SNAN_MASK)),
+                         IRExpr_ITE(mkexpr(frA_isQNaN),
+                                    /* then: result = frA  */
+                                    mkexpr(frA_I64),
+                                    /* else: result = frB converted to QNaN */
+                                    binop(Iop_Or64, mkexpr(frB_I64),
+                                          mkU64(SNAN_MASK))),
                          /* else:  if frB is a QNaN */
                          IRExpr_ITE(mkexpr(frB_isQNaN),
                                     /* then: result = frA */