summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2023-01-26 18:26:18 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-02-24 17:27:45 -0500
commit4eb9c234886993e569ec43504f3c547c464ece4e (patch)
tree0c0a6b3a5dc022c247395c61f279f08374e367fa /compiler
parente9e7a00da2c5963a53dbcedaec793400fde07563 (diff)
downloadhaskell-4eb9c234886993e569ec43504f3c547c464ece4e.tar.gz
JS: make some arithmetic primops faster (#22835)
Don't use BigInt for wordAdd2, mulWord32, and timesInt32. Co-authored-by: Matthew Craven <5086-clyring@users.noreply.gitlab.haskell.org>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/GHC/StgToJS/Prim.hs4
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/GHC/StgToJS/Prim.hs b/compiler/GHC/StgToJS/Prim.hs
index 6085b110cf..8687b1db72 100644
--- a/compiler/GHC/StgToJS/Prim.hs
+++ b/compiler/GHC/StgToJS/Prim.hs
@@ -59,7 +59,7 @@ genPrim prof bound ty op = case op of
IntAddOp -> \[r] [x,y] -> PrimInline $ r |= toI32 (Add x y)
IntSubOp -> \[r] [x,y] -> PrimInline $ r |= toI32 (Sub x y)
- IntMulOp -> \[r] [x,y] -> PrimInline $ r |= app "h$mulInt32" [x, y]
+ IntMulOp -> \[r] [x,y] -> PrimInline $ r |= app "Math.imul" [x, y]
IntMul2Op -> \[c,hr,lr] [x,y] -> PrimInline $ appT [c,hr,lr] "h$hs_timesInt2" [x, y]
IntMulMayOfloOp -> \[r] [x,y] -> PrimInline $ jVar \tmp -> mconcat
[ tmp |= Mul x y
@@ -374,7 +374,7 @@ genPrim prof bound ty op = case op of
]
WordAdd2Op -> \[h,l] [x,y] -> PrimInline $ appT [h,l] "h$wordAdd2" [x,y]
WordSubOp -> \ [r] [x,y] -> PrimInline $ r |= toU32 (Sub x y)
- WordMulOp -> \ [r] [x,y] -> PrimInline $ r |= app "h$mulWord32" [x, y]
+ WordMulOp -> \ [r] [x,y] -> PrimInline $ r |= toU32 (app "Math.imul" [x, y])
WordMul2Op -> \[h,l] [x,y] -> PrimInline $ appT [h,l] "h$mul2Word32" [x,y]
WordQuotOp -> \ [q] [x,y] -> PrimInline $ q |= app "h$quotWord32" [x,y]
WordRemOp -> \ [r] [x,y] -> PrimInline $ r |= app "h$remWord32" [x,y]