[Git][ghc/ghc][wip/uf-conf-codegen] CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal

Ben Gamari gitlab at gitlab.haskell.org
Mon Oct 26 17:27:36 UTC 2020



Ben Gamari pushed to branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC


Commits:
d5cc796b by Ben Gamari at 2020-10-26T13:27:29-04:00
CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal

Previously we would call hs_word2float which is incredibly expensive
compared to just a MOV.

- - - - -


1 changed file:

- compiler/GHC/CmmToAsm/X86/CodeGen.hs


Changes:

=====================================
compiler/GHC/CmmToAsm/X86/CodeGen.hs
=====================================
@@ -2511,6 +2511,14 @@ genCCall' config is32Bit (PrimTarget (MO_Clz width)) dest_regs@[dst] args@[src]
     bw = widthInBits width
     lbl = mkCmmCodeLabel primUnitId (fsLit (clzLabel width))
 
+genCCall' config _ (PrimTarget (MO_UF_Conv width)) [dst] [CmmLit arg_lit] _
+  | CmmFloat n _ <- arg_lit = do
+    let fmt = floatFormat width
+    Amode amode amode_code <- memConstant (mkAlignment $ widthInBytes width) (CmmFloat (realToFrac arg_lit) width)
+    let platform = ncgPlatform config
+    let dst_r = getRegisterReg platform (CmmLocal dst)
+    return $ amode_code `appOL` unitOL (MOV fmt (OpAddr amode) (OpReg dst_r))
+
 genCCall' config is32Bit (PrimTarget (MO_UF_Conv width)) dest_regs args bid = do
     targetExpr <- cmmMakeDynamicReference config
                   CallReference lbl



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d5cc796b8fb6501445641dcb79a7237c8ccfd3fa
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/20201026/d7c429d5/attachment.html>


More information about the ghc-commits mailing list