[Git][ghc/ghc][wip/angerman/aarch64-ncg] 2 commits: Fix -NaN for real this time.

Moritz Angermann gitlab at gitlab.haskell.org
Wed Jul 8 12:50:20 UTC 2020



Moritz Angermann pushed to branch wip/angerman/aarch64-ncg at Glasgow Haskell Compiler / GHC


Commits:
59c2bf31 by Moritz Angermann at 2020-07-08T12:14:51+00:00
Fix -NaN for real this time.

- - - - -
a5b00b4c by Moritz Angermann at 2020-07-08T12:21:24+00:00
Adds nan test.

- - - - -


3 changed files:

- compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- + tests/compiler/cmm/nan.cmm


Changes:

=====================================
compiler/GHC/CmmToAsm/AArch64/CodeGen.hs
=====================================
@@ -813,10 +813,10 @@ genCondJump bid expr
           MO_F_Eq w -> fbcond w EQ
           MO_F_Ne w -> fbcond w NE
 
-          MO_F_Gt w -> fbcond w SGT
-          MO_F_Ge w -> fbcond w SGE
-          MO_F_Lt w -> fbcond w SLT
-          MO_F_Le w -> fbcond w SLE
+          MO_F_Gt w -> fbcond w OGT
+          MO_F_Ge w -> fbcond w OGE
+          MO_F_Lt w -> fbcond w OLT
+          MO_F_Le w -> fbcond w OLE
 
           MO_Eq w   -> bcond w EQ
           MO_Ne w   -> bcond w NE


=====================================
compiler/GHC/CmmToAsm/AArch64/Ppr.hs
=====================================
@@ -322,7 +322,7 @@ pprReg w r = case r of
     ppr_reg_no :: Width -> Int -> SDoc
     ppr_reg_no w 31
          | w == W64 = text "sp"
-         | w == W32 = test "wsp"
+         | w == W32 = text "wsp"
 
     ppr_reg_no w i
          | i < 0, w == W32 = text "wzr"


=====================================
tests/compiler/cmm/nan.cmm
=====================================
@@ -0,0 +1,51 @@
+// RUN: "$HC" -cpp -dcmm-lint -keep-s-file -c "$1" && cat "${1%%.*}.s" | FileCheck "$1" -check-prefix=CHECK-A64
+// RUN: "$HC" -no-hs-main "${1%%.*}.o" -o "${1%%.*}.exe"
+// RUN: "$EXEC" "${1%%.cmm}.exe" | FileCheck "$1" -check-prefix=CHECK-RUN-A64
+
+#include "Cmm.h"
+#include "Types.h"
+
+// CHECK-A64: .globl main
+// CHECK-A64: main:
+
+main () {
+    F64 y;
+    I64 z;
+
+    D1 = 0.0 - 7.0;
+
+    (y) = foreign "C" sqrt(D1);
+
+    (z) = foreign "C" isDoubleNaN(y);
+
+    // CHECK-RUN-A64: sqrt(-7.000000) = nan
+    // CHECK-RUN-A64: isDoubleNaN(nan) = 1
+    foreign "C" printf("sqrt(%f) = %f\n", D1, y);
+    foreign "C" printf("isDoubleNaN(%f) = %d\n", y, z);
+
+    // CHECK-RUN-A64: nan < 0 = 0
+    foreign "C" printf("%f < 0 = %d\n", y, y `flt` 0.0);
+    // CHECK-RUN-A64: nan > 0 = 0
+    foreign "C" printf("%f > 0 = %d\n", y, y `fgt` 0.0);
+    // CHECK-RUN-A64: nan <= 0 = 0
+    foreign "C" printf("%f <= 0 = %d\n", y, y `fle` 0.0);
+    // CHECK-RUN-A64: nan >= 0 = 0
+    foreign "C" printf("%f >= 0 = %d\n", y, y `fge` 0.0);
+    // CHECK-RUN-A64: nan == 0 = 0
+    foreign "C" printf("%f == 0 = %d\n", y, y `feq` 0.0);
+    // CHECK-RUN-A64: nan /= 0 = 1
+    foreign "C" printf("%f /= 0 = %d\n", y, y `fne` 0.0);
+
+    F64 x;
+    x = 0.0; y = 0.0;
+    foreign "C" printf("%f / %f = %d\n", x, y, x `fquot` y);
+
+    // CHECK-RUN-A64: nan >= 0
+    if((x `fquot` y) < x) {
+        foreign "C" printf("%f < %f\n", x `fquot` y, x);
+    } else {
+        foreign "C" printf("%f >= %f\n", x `fquot` y, x);
+    }
+
+    foreign "C" exit(0::I64);
+}
\ No newline at end of file



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312e7d5e713d901f595df7ab875b8d10f0cb63ad...a5b00b4cd8db15ca91ebac52554b3399d4f14d82

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/312e7d5e713d901f595df7ab875b8d10f0cb63ad...a5b00b4cd8db15ca91ebac52554b3399d4f14d82
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200708/d26355cd/attachment-0001.html>


More information about the ghc-commits mailing list