[Git][ghc/ghc][wip/js-staging] Primop: fix bswap32/64 (cf cgrun072)

Sylvain Henry (@hsyl20) gitlab at gitlab.haskell.org
Thu Aug 25 21:17:34 UTC 2022



Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC


Commits:
77fcfcd0 by Sylvain Henry at 2022-08-25T23:20:26+02:00
Primop: fix bswap32/64 (cf cgrun072)

- - - - -


2 changed files:

- compiler/GHC/StgToJS/Prim.hs
- js/arith.js.pp


Changes:

=====================================
compiler/GHC/StgToJS/Prim.hs
=====================================
@@ -429,10 +429,10 @@ genPrim prof ty op = case op of
       r |= BOr ((mask8 x) .<<. (Int 8))
                (mask8 (x .>>>. (Int 8)))
   BSwap32Op   -> \[r] [x]   -> PrimInline $
-      r |= (x .<<. (Int 24))
+      r |= u32 ((x .<<. (Int 24))
             `BOr` ((BAnd x (Int 0xFF00)) .<<. (Int 8))
             `BOr` ((BAnd x (Int 0xFF0000)) .>>. (Int 8))
-            `BOr` (x .>>>. (Int 24))
+            `BOr` (x .>>>. (Int 24)))
   BSwap64Op   -> \[r1,r2] [x,y] -> PrimInline $ appT [r1,r2] "h$bswap64" [x,y]
   BSwapOp     -> \[r] [x]       -> genPrim prof ty BSwap32Op [r] [x]
 


=====================================
js/arith.js.pp
=====================================
@@ -505,8 +505,8 @@ function h$popCnt64(x1,x2) {
 }
 
 function h$bswap64(x1,x2) {
-  RETURN_UBX_TUP2((x2 >>> 24) | (x2 << 24) | ((x2 & 0xFF00) << 8) | ((x2 & 0xFF0000) >> 8)
-                 ,(x1 >>> 24) | (x1 << 24) | ((x1 & 0xFF00) << 8) | ((x1 & 0xFF0000) >> 8));
+  RETURN_UBX_TUP2(UN((x2 >>> 24) | (x2 << 24) | ((x2 & 0xFF00) << 8) | ((x2 & 0xFF0000) >> 8))
+                 ,UN((x1 >>> 24) | (x1 << 24) | ((x1 & 0xFF00) << 8) | ((x1 & 0xFF0000) >> 8)));
 }
 
 var h$clz32 = Math.clz32 || function(x) {



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/77fcfcd04e42dfbdd420a5664597671ba2cc6865
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/20220825/c5a3a0bc/attachment-0001.html>


More information about the ghc-commits mailing list