Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
1d8621c1
Commit
1d8621c1
authored
Nov 20, 2001
by
simonpj
Browse files
[project @ 2001-11-20 14:12:48 by simonpj]
Add constant-folding rules for Float# and Double#
parent
57d15e1c
Changes
1
Hide whitespace changes
Inline
Side-by-side
ghc/lib/std/PrelFloat.lhs
View file @
1d8621c1
% ------------------------------------------------------------------------------
% $Id: PrelFloat.lhs,v 1.1
3
2001/
09/14 15:45:53
simonpj Exp $
% $Id: PrelFloat.lhs,v 1.1
4
2001/
11/20 14:12:48
simonpj Exp $
%
% (c) The University of Glasgow, 1994-2000
%
...
...
@@ -768,6 +768,18 @@ minusFloat (F# x) (F# y) = F# (minusFloat# x y)
timesFloat (F# x) (F# y) = F# (timesFloat# x y)
divideFloat (F# x) (F# y) = F# (divideFloat# x y)
{-# RULES
"plusFloat x 0.0" forall x#. plusFloat# x# 0.0# = x#
"plusFloat 0.0 x" forall x#. plusFloat# 0.0# x# = x#
"minusFloat x 0.0" forall x#. minusFloat# x# 0.0# = x#
"minusFloat x x" forall x#. minusFloat# x# x# = 0.0#
"timesFloat x 0.0" forall x#. timesFloat# x# 0.0# = 0.0#
"timesFloat0.0 x" forall x#. timesFloat# 0.0# x# = 0.0#
"timesFloat x 1.0" forall x#. timesFloat# x# 1.0# = x#
"timesFloat 1.0 x" forall x#. timesFloat# 1.0# x# = x#
"divideFloat x 1.0" forall x#. divideFloat# x# 1.0# = x#
#-}
negateFloat :: Float -> Float
negateFloat (F# x) = F# (negateFloat# x)
...
...
@@ -814,6 +826,18 @@ minusDouble (D# x) (D# y) = D# (x -## y)
timesDouble (D# x) (D# y) = D# (x *## y)
divideDouble (D# x) (D# y) = D# (x /## y)
{-# RULES
"plusDouble x 0.0" forall x#. (+##) x# 0.0## = x#
"plusDouble 0.0 x" forall x#. (+##) 0.0## x# = x#
"minusDouble x 0.0" forall x#. (-##) x# 0.0## = x#
"minusDouble x x" forall x#. (-##) x# x# = 0.0##
"timesDouble x 0.0" forall x#. (*##) x# 0.0## = 0.0##
"timesDouble 0.0 x" forall x#. (*##) 0.0## x# = 0.0##
"timesDouble x 1.0" forall x#. (*##) x# 1.0## = x#
"timesDouble 1.0 x" forall x#. (*##) 1.0## x# = x#
"divideDouble x 1.0" forall x#. (/##) x# 1.0## = x#
#-}
negateDouble :: Double -> Double
negateDouble (D# x) = D# (negateDouble# x)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment