diff options
author | simonmar <unknown> | 2004-08-23 10:11:24 +0000 |
---|---|---|
committer | simonmar <unknown> | 2004-08-23 10:11:24 +0000 |
commit | 12cad97e06919e86e5b94559de8ca9900084b5ab (patch) | |
tree | 97279b8770aff8f63d7f5e68c7fa479f3547f3d2 /ghc/compiler/cmm | |
parent | aa47e9aaabf6b11875749923c2e2726a30235e0a (diff) | |
download | haskell-12cad97e06919e86e5b94559de8ca9900084b5ab.tar.gz |
[project @ 2004-08-23 10:11:23 by simonmar]
Fix an infinite loop in the cmm-optimiser in the native codegen, and
refactor: move isAssociativeMachOp into MachOp.
Diffstat (limited to 'ghc/compiler/cmm')
-rw-r--r-- | ghc/compiler/cmm/MachOp.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ghc/compiler/cmm/MachOp.hs b/ghc/compiler/cmm/MachOp.hs index 55aaa3e7ec..2d933e083e 100644 --- a/ghc/compiler/cmm/MachOp.hs +++ b/ghc/compiler/cmm/MachOp.hs @@ -18,6 +18,7 @@ module MachOp ( MachOp(..), pprMachOp, isCommutableMachOp, + isAssociativeMachOp, isComparisonMachOp, resultRepOfMachOp, machOpArgReps, @@ -492,6 +493,27 @@ isCommutableMachOp mop = _other -> False -- ---------------------------------------------------------------------------- +-- isAssociativeMachOp + +{- | +Returns 'True' if the MachOp is associative (i.e. @(x+y)+z == x+(y+z)@) +This is used in the platform-independent Cmm optimisations. + +If in doubt, return 'False'. This generates worse code on the +native routes, but is otherwise harmless. +-} +isAssociativeMachOp :: MachOp -> Bool +isAssociativeMachOp mop = + case mop of + MO_Add r -> not (isFloatingRep r) + MO_Sub r -> not (isFloatingRep r) + MO_Mul r -> not (isFloatingRep r) + MO_And _ -> True + MO_Or _ -> True + MO_Xor _ -> True + _other -> False + +-- ---------------------------------------------------------------------------- -- isComparisonMachOp {- | |