[Git][ghc/ghc][wip/uf-conf-codegen] 2 commits: CmmToAsm/X86: Improve code generation for MO_UF_Conv of literal
Ben Gamari
gitlab at gitlab.haskell.org
Mon Oct 26 17:58:18 UTC 2020
Ben Gamari pushed to branch wip/uf-conf-codegen at Glasgow Haskell Compiler / GHC
Commits:
5c756080 by Ben Gamari at 2020-10-26T13:58:13-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.
- - - - -
1b92bde8 by Ben Gamari at 2020-10-26T13:58:13-04:00
primops: Document semantics of Float/Int conversions
Fixes #18840.
- - - - -
2 changed files:
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/CmmToAsm/X86/CodeGen.hs
Changes:
=====================================
compiler/GHC/Builtin/primops.txt.pp
=====================================
@@ -607,10 +607,22 @@ primop IntToWordOp "int2Word#" GenPrimOp Int# -> Word#
with code_size = 0
primop IntToFloatOp "int2Float#" GenPrimOp Int# -> Float#
+ {Convert an {\tt Int#} to the corrsponding {\tt Float#} with the same
+ integral value (up to truncation due to floating-point precision). e.g.
+ {\tt int2Float# 1# == 1.0#}}
primop IntToDoubleOp "int2Double#" GenPrimOp Int# -> Double#
+ {Convert an {\tt Int#} to the corrsponding {\tt Double#} with the same
+ integral value (up to truncation due to floating-point precision). e.g.
+ {\tt int2Double# 1# == 1.0#}}
primop WordToFloatOp "word2Float#" GenPrimOp Word# -> Float#
+ {Convert an {\tt Word#} to the corrsponding {\tt Float#} with the same
+ integral value (up to truncation due to floating-point precision). e.g.
+ {\tt int2Float# 1# == 1.0#}}
primop WordToDoubleOp "word2Double#" GenPrimOp Word# -> Double#
+ {Convert an {\tt Word#} to the corrsponding {\tt Double#} with the same
+ integral value (up to truncation due to floating-point precision). e.g.
+ {\tt int2Double# 1# == 1.0#}}
primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
{Shift left. Result undefined if shift amount is not
=====================================
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 n) 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/-/compare/fa34519a875ed13c66f6c5e990a873239d53a234...1b92bde80e492895ff2be26d673a5f179543a539
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/fa34519a875ed13c66f6c5e990a873239d53a234...1b92bde80e492895ff2be26d673a5f179543a539
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/2cfb8fd0/attachment-0001.html>
More information about the ghc-commits
mailing list