Generate better fp abs for X86 and llvm with default cmm otherwise
authorDominic Steinitz <dominic@steinitz.org>
Tue, 7 Mar 2017 14:26:16 +0000 (09:26 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 7 Mar 2017 18:32:33 +0000 (13:32 -0500)
commit12ccf767af3373e319b75d5d61fe79df4a389e45
treeec4bf27785be88d67617ddddd5968e4c128fb6a1
parent48759c0ef0e7ce718b52557599ebbb884c19a2ad
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
compiler/cmm/CmmMachOp.hs
compiler/cmm/PprC.hs
compiler/codeGen/StgCmmPrim.hs
compiler/llvmGen/LlvmCodeGen/CodeGen.hs
compiler/nativeGen/PPC/CodeGen.hs
compiler/nativeGen/SPARC/CodeGen.hs
compiler/nativeGen/X86/CodeGen.hs
compiler/nativeGen/X86/Ppr.hs
compiler/prelude/primops.txt.pp
libraries/base/GHC/Float.hs