-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added more references and rules based on gcc's -ffast-math implementa…
…tion
- Loading branch information
1 parent
c56f2c6
commit 9d8cbc6
Showing
7 changed files
with
60 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
-- | This module loads all rewrite rules. Unless you know that some rules | ||
-- will be unsafe for your application, this is the module you should load. | ||
-- Importing this module is roughly equivalent to gcc's @-ffast-math@ | ||
-- compilation flag. | ||
-- | ||
-- The best way to figure out what optimizations these modules do is by | ||
-- looking at the source code. RULES pragmas are surprisingly readable. | ||
|
||
module Numeric.FastMath | ||
( module Numeric.FastMath.Approximation | ||
, module Numeric.FastMath.NaN | ||
, module Numeric.FastMath.Infinitesimal | ||
, module Numeric.FastMath.SignedZeros | ||
) | ||
where | ||
|
||
import Numeric.FastMath.Approximation () | ||
import Numeric.FastMath.NaN () | ||
import Numeric.FastMath.Infinitesimal () | ||
import Numeric.FastMath.SignedZeros () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
-- | This module contains rules that break the way NaN is handled for "Float" | ||
-- and "Double" types. Still, these rules should be safe in the vast majority of | ||
-- applications. | ||
-- | ||
-- Importing this module is similar to compiling with gcc's @-fno-signaling-nans@ | ||
-- and @-ffinite-math-only@. | ||
-- | ||
module Numeric.FastMath.NaN | ||
where | ||
|
||
import GHC.Exts | ||
|
||
{-# RULES | ||
"minusDouble x x" forall x. (-##) x x = 0.0## | ||
|
||
"timesDouble 0 x" forall x. (*##) 0.0## x = 0.0## | ||
"timesDouble x 0" forall x. (*##) x 0.0## = 0.0## | ||
|
||
"divideDouble x 1" forall x. (/##) x 1.0## = x | ||
"divideDouble x -1" forall x. (/##) x (-1.0##) = negateDouble# x | ||
"divideDouble 0 x" forall x. (/##) 0.0## x = 0.0## | ||
#-} | ||
|
||
{-# RULES | ||
"minusFloat x x" forall x. minusFloat# x x = 0.0# | ||
|
||
"timesFloat x 0" forall x. timesFloat# x 0.0# = 0.0# | ||
"timesFloat 0 x" forall x. timesFloat# 0.0# x = 0.0# | ||
|
||
"minusDouble x x" forall x. (-##) x x = 0.0## | ||
"timesDouble 0 x" forall x. (*##) 0.0## x = 0.0## | ||
"timesDouble x 0" forall x. (*##) x 0.0## = 0.0## | ||
"divideFloat x 1" forall x. divideFloat# x 1.0# = x | ||
"divideFloat x -1" forall x. divideFloat# x (-1.0#) = negateFloat# x | ||
"divideFloat 0 x" forall x. divideFloat# 0.0# x = 0.0# | ||
|
||
#-} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
-- | IEEE 754 math makes a distrinction between -0.0 and +0.0. This module | ||
-- contains RULES that ignore this distinction. | ||
-- | ||
-- Importing this module is similar to compiling with gcc's | ||
-- @-fno-signed-zeros@. | ||
|
||
module Numeric.FastMath.SignedZeros () where | ||
|
||
import GHC.Exts | ||
|
||
{-# RULES | ||
|
||
"minusDouble 0 x" forall x. (-##) 0.0## x = negateDouble# x | ||
"divideDouble 0 x" forall x. (/##) 0.0## x = 0.0## | ||
#-} | ||
|
||
{-# RULES | ||
|
||
"minusFloat 0 x" forall x. minusFloat# 0.0# x = negateFloat# x | ||
"divideFloat 0 x" forall x. divideFloat# 0.0# x = 0.0# | ||
|
||
#-} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters