[Git][ghc/ghc][wip/ghci-primcall] correctly use fadd primitive instead of + operator

Luite Stegeman (@luite) gitlab at gitlab.haskell.org
Wed Sep 28 09:15:04 UTC 2022



Luite Stegeman pushed to branch wip/ghci-primcall at Glasgow Haskell Compiler / GHC


Commits:
b5d0c9e8 by Luite Stegeman at 2022-09-28T11:14:08+02:00
correctly use fadd primitive instead of + operator

- - - - -


2 changed files:

- testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs
- testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm


Changes:

=====================================
testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall.hs
=====================================
@@ -222,11 +222,3 @@ foreign import prim cmm_tuple_4 :: Any -> Any -> (# Any, Any #)
 foreign import prim cmm_array_1 :: Array# Any -> Int#
 -- return some arrays
 foreign import prim cmm_array_2 :: Array# Any -> Array# Any -> (# Array# Any, Array# Any #)
-
--- (State# RealWorld -> (# State# RealWorld, Any #)
--- foreign import prim cmm_array_3 :: MutableArray# -> MutableArray# -> State# RealWorld -> State# RealWorld
-
--- some examples from base
--- foreign import prim cmm_decodeStack :: StackSnapshot# -> State# RealWorld -> (# State# RealWorld, Array# (Ptr InfoProvEnt) #)
--- foreign import prim cmm_cloneMyStack :: State# RealWorld -> (# State# RealWorld, StackSnapshot# #)
--- foreign import prim cmm_sendCloneStackMessage :: ThreadId# -> StablePtr# PrimMVar -> State# RealWorld -> (# State# RealWorld, (# #) #)


=====================================
testsuite/tests/ghci/should_run/GHCiPrimCall/GHCiPrimCall_cmm.cmm
=====================================
@@ -52,8 +52,8 @@ cmm_two2_l(L_ x, L_ y) { return (y); }
 
 /* additional tests for floating point, since D_ and F_ registers
    overlap on some platforms */
-cmm_floating_1(F_ x, F_ y) { return (x+y); }
-cmm_floating_2(D_ x, D_ y) { return (x+y); }
+cmm_floating_1(F_ x, F_ y) { F_ z; z = %fadd(x, y); return (z); }
+cmm_floating_2(D_ x, D_ y) { D_ z; z = %fadd(x, y); return (z); }
 cmm_floating_3(F_ x, D_ y) { return (x); }
 cmm_floating_4(F_ x, D_ y) { return (y); }
 
@@ -63,14 +63,13 @@ cmm_floating_5(F_ x1, D_ x2, F_ x3, D_ x4, F_ x5, D_ x6, F_ x7, D_ x8) {
     F_ y1;
     D_ y2;
 
-    /* for some reasons we can't do this in one sum? */
-    y1 = x1+x3;
-    y1 = y1+x5;
-    y1 = y1+x7;
+    y1 = %fadd(x1,x3);
+    y1 = %fadd(y1,x5);
+    y1 = %fadd(y1,x7);
 
-    y2 = x2+x4;
-    y2 = y2+x6;
-    y2 = y2+x8;
+    y2 = %fadd(x2,x4);
+    y2 = %fadd(y2,x6);
+    y2 = %fadd(y2,x8);
 
     return (y1, y2);
 }
@@ -80,14 +79,13 @@ cmm_floating_6(D_ x1, F_ x2, D_ x3, F_ x4, D_ x5, F_ x6, D_ x7, F_ x8) {
     D_ y1;
     F_ y2;
 
-    /* for some reasons we can't do this in one sum? */
-    y1 = x1+x3;
-    y1 = y1+x5;
-    y1 = y1+x7;
+    y1 = %fadd(x1,x3);
+    y1 = %fadd(y1,x5);
+    y1 = %fadd(y1,x7);
 
-    y2 = x2+x4;
-    y2 = y2+x6;
-    y2 = y2+x8;
+    y2 = %fadd(x2,x4);
+    y2 = %fadd(y2,x6);
+    y2 = %fadd(y2,x8);
 
     return (y1, y2);
 }
@@ -106,20 +104,19 @@ cmm_floating_7( W_ x1, F_ x2, D_ x3
     D_ y3;
     y1 = x1+x4+x7+x10+x13+x16+x19;
 
-    /* for some reasons we can't do this in one sum? */
-    y2 = x2+x5;
-    y2 = y2+x8;
-    y2 = y2+x11;
-    y2 = y2+x14;
-    y2 = y2+x17;
-    y2 = y2+x20;
-
-    y3 = x3+x6;
-    y3 = y3+x9;
-    y3 = y3+x12;
-    y3 = y3+x15;
-    y3 = y3+x18;
-    y3 = y3+x21;
+    y2 = %fadd(x2,x5);
+    y2 = %fadd(y2,x8);
+    y2 = %fadd(y2,x11);
+    y2 = %fadd(y2,x14);
+    y2 = %fadd(y2,x17);
+    y2 = %fadd(y2,x20);
+
+    y3 = %fadd(x3,x6);
+    y3 = %fadd(y3,x9);
+    y3 = %fadd(y3,x12);
+    y3 = %fadd(y3,x15);
+    y3 = %fadd(y3,x18);
+    y3 = %fadd(y3,x21);
 
     return ( y1, y2, y2 );
 }



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5d0c9e84eb1f6075c61a56d811f6cfad633ba3f

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b5d0c9e84eb1f6075c61a56d811f6cfad633ba3f
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/20220928/e79716a7/attachment-0001.html>


More information about the ghc-commits mailing list