summaryrefslogtreecommitdiff
path: root/compiler/cmm
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2017-03-07 09:26:16 -0500
committerBen Gamari <ben@smart-cactus.org>2017-03-07 13:32:33 -0500
commit12ccf767af3373e319b75d5d61fe79df4a389e45 (patch)
treeec4bf27785be88d67617ddddd5968e4c128fb6a1 /compiler/cmm
parent48759c0ef0e7ce718b52557599ebbb884c19a2ad (diff)
downloadhaskell-12ccf767af3373e319b75d5d61fe79df4a389e45.tar.gz
Generate better fp abs for X86 and llvm with default cmm otherwise
Currently we have this in libraries/base/GHC/Float.hs: ``` abs x | x == 0 = 0 -- handles (-0.0) | x > 0 = x | otherwise = negateFloat x ``` But 3-4 years ago it was noted that this was inefficient: https://mail.haskell.org/pipermail/libraries/2013-April/019690.html We can generate better code for X86 and llvm and for others generate some custom cmm code which is similar to what the compiler generates now. Reviewers: austin, simonmar, hvr, bgamari Reviewed By: bgamari Subscribers: dfeuer, thomie Differential Revision: https://phabricator.haskell.org/D3265
Diffstat (limited to 'compiler/cmm')
-rw-r--r--compiler/cmm/CmmMachOp.hs2
-rw-r--r--compiler/cmm/PprC.hs2
2 files changed, 4 insertions, 0 deletions
diff --git a/compiler/cmm/CmmMachOp.hs b/compiler/cmm/CmmMachOp.hs
index a8cbd682e6..d736f14bfc 100644
--- a/compiler/cmm/CmmMachOp.hs
+++ b/compiler/cmm/CmmMachOp.hs
@@ -528,6 +528,7 @@ data CallishMachOp
| MO_F64_Atan
| MO_F64_Log
| MO_F64_Exp
+ | MO_F64_Fabs
| MO_F64_Sqrt
| MO_F32_Pwr
| MO_F32_Sin
@@ -541,6 +542,7 @@ data CallishMachOp
| MO_F32_Atan
| MO_F32_Log
| MO_F32_Exp
+ | MO_F32_Fabs
| MO_F32_Sqrt
| MO_UF_Conv Width
diff --git a/compiler/cmm/PprC.hs b/compiler/cmm/PprC.hs
index dba8ca6e8c..6a84e30abb 100644
--- a/compiler/cmm/PprC.hs
+++ b/compiler/cmm/PprC.hs
@@ -754,6 +754,7 @@ pprCallishMachOp_for_C mop
MO_F64_Log -> text "log"
MO_F64_Exp -> text "exp"
MO_F64_Sqrt -> text "sqrt"
+ MO_F64_Fabs -> unsupported
MO_F32_Pwr -> text "powf"
MO_F32_Sin -> text "sinf"
MO_F32_Cos -> text "cosf"
@@ -767,6 +768,7 @@ pprCallishMachOp_for_C mop
MO_F32_Log -> text "logf"
MO_F32_Exp -> text "expf"
MO_F32_Sqrt -> text "sqrtf"
+ MO_F32_Fabs -> unsupported
MO_WriteBarrier -> text "write_barrier"
MO_Memcpy _ -> text "memcpy"
MO_Memset _ -> text "memset"