[Git][ghc/ghc][wip/js-staging] Primop: fix timesInt2#
Sylvain Henry (@hsyl20)
gitlab at gitlab.haskell.org
Wed Aug 24 10:16:54 UTC 2022
Sylvain Henry pushed to branch wip/js-staging at Glasgow Haskell Compiler / GHC
Commits:
61dadc50 by Sylvain Henry at 2022-08-24T12:19:51+02:00
Primop: fix timesInt2#
Pass arith003 test
- - - - -
1 changed file:
- js/arith.js.pp
Changes:
=====================================
js/arith.js.pp
=====================================
@@ -389,8 +389,6 @@ var h$mulInt32 = Math.imul ? Math.imul : h$imul_shim;
function h$hs_timesInt2(a,b) {
TRACE_ARITH("timesInt2 " + a + " " + b);
- // adapted from Hacker's Delight (p174)
-
// check for 0 and 1 operands
if (a === 0) {
RETURN_UBX_TUP3(0,0,0);
@@ -405,22 +403,11 @@ function h$hs_timesInt2(a,b) {
RETURN_UBX_TUP3(0,a<0?(-1):0,a);
}
- var cl = h$mulInt32(a,b);
-
- var ha = a >> 16;
- var la = a & 0xFFFF;
-
- var hb = b >> 16;
- var lb = b & 0xFFFF;
-
- var w0 = la * lb;
- var t = (h$mulInt32(ha,lb) + (w0 >>> 16))|0;
- var w1 = t & 0xFFFF;
- var w2 = t >> 16;
- w1 = (h$mulInt32(la,hb) + w1)|0;
-
- var ch = ((h$mulInt32(ha,hb) + w2)|0 + (w1 >> 16))|0;
- var nh = ((ch === 0 && cl >= 0) || (ch === -1 && cl < 0)) ? 0 : 1
+ var ha = a < 0 ? (-1) : 0;
+ var hb = b < 0 ? (-1) : 0;
+ var ch = h$hs_timesInt64(ha,a,hb,b);
+ var cl = h$ret1;
+ var nh = ((ch === 0 && cl >= 0) || (ch === -1 && cl < 0)) ? 0 : 1;
TRACE_ARITH("timesInt2 results:" + nh + " " + ch + " " + cl);
RETURN_UBX_TUP3(nh, ch, cl);
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61dadc50b4fe31a3f53e36505e39895c458c516a
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/61dadc50b4fe31a3f53e36505e39895c458c516a
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/20220824/ae3d50fc/attachment-0001.html>
More information about the ghc-commits
mailing list