From 999f8cf9b4b8e39dc33d30de5b4478d52e3fe783 Mon Sep 17 00:00:00 2001 From: simonmar Date: Tue, 1 Apr 2003 09:35:13 +0000 Subject: [PATCH] [project @ 2003-04-01 09:35:13 by simonmar] Don't constant-fold (negateFloat# 0.0#), because the compiler's internal representation of floating-point literals (Rational) can't represent -0.0. This means that main = print (-0.0) now gives the same results with -O as it does without. Fixes test arith005. --- ghc/compiler/prelude/PrelRules.lhs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ghc/compiler/prelude/PrelRules.lhs b/ghc/compiler/prelude/PrelRules.lhs index 2c2a2e4..c13d6ed 100644 --- a/ghc/compiler/prelude/PrelRules.lhs +++ b/ghc/compiler/prelude/PrelRules.lhs @@ -208,10 +208,12 @@ cmpOp cmp l1 l2 -------------------------- -negOp (MachFloat f) = Just (mkFloatVal (-f)) -negOp (MachDouble d) = Just (mkDoubleVal (-d)) -negOp (MachInt i) = intResult (-i) -negOp l = Nothing +negOp (MachFloat 0.0) = Nothing -- can't represent -0.0 as a Rational +negOp (MachFloat f) = Just (mkFloatVal (-f)) +negOp (MachDouble 0.0) = Nothing +negOp (MachDouble d) = Just (mkDoubleVal (-d)) +negOp (MachInt i) = intResult (-i) +negOp l = Nothing -------------------------- intOp2 op (MachInt i1) (MachInt i2) = intResult (i1 `op` i2) -- 1.7.10.4