Commit 1d8621c1 authored by simonpj's avatar simonpj
Browse files

[project @ 2001-11-20 14:12:48 by simonpj]

Add constant-folding rules for Float# and Double#
parent 57d15e1c
% ------------------------------------------------------------------------------ % ------------------------------------------------------------------------------
% $Id: PrelFloat.lhs,v 1.13 2001/09/14 15:45:53 simonpj Exp $ % $Id: PrelFloat.lhs,v 1.14 2001/11/20 14:12:48 simonpj Exp $
% %
% (c) The University of Glasgow, 1994-2000 % (c) The University of Glasgow, 1994-2000
% %
...@@ -768,6 +768,18 @@ minusFloat (F# x) (F# y) = F# (minusFloat# x y) ...@@ -768,6 +768,18 @@ minusFloat (F# x) (F# y) = F# (minusFloat# x y)
timesFloat (F# x) (F# y) = F# (timesFloat# x y) timesFloat (F# x) (F# y) = F# (timesFloat# x y)
divideFloat (F# x) (F# y) = F# (divideFloat# 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 :: Float -> Float
negateFloat (F# x) = F# (negateFloat# x) negateFloat (F# x) = F# (negateFloat# x)
...@@ -814,6 +826,18 @@ minusDouble (D# x) (D# y) = D# (x -## y) ...@@ -814,6 +826,18 @@ minusDouble (D# x) (D# y) = D# (x -## y)
timesDouble (D# x) (D# y) = D# (x *## y) timesDouble (D# x) (D# y) = D# (x *## y)
divideDouble (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 :: Double -> Double
negateDouble (D# x) = D# (negateDouble# x) negateDouble (D# x) = D# (negateDouble# x)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment