X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fprelude%2FPrelRules.lhs;fp=ghc%2Fcompiler%2Fprelude%2FPrelRules.lhs;h=8243b6e6b1c652fa7f1c238d00948fea29e76275;hb=a4124cf4314794968773cdf8e1ea8cca6e808177;hp=3ab8d6eedca650fc6048e5ea26af04506734f67c;hpb=2cf37ff932f52b68c73b0d6107d872b692a4cbf4;p=ghc-hetmet.git diff --git a/ghc/compiler/prelude/PrelRules.lhs b/ghc/compiler/prelude/PrelRules.lhs index 3ab8d6e..8243b6e 100644 --- a/ghc/compiler/prelude/PrelRules.lhs +++ b/ghc/compiler/prelude/PrelRules.lhs @@ -20,7 +20,7 @@ module PrelRules ( primOpRules, builtinRules ) where #include "HsVersions.h" import CoreSyn -import Id ( mkWildId ) +import Id ( mkWildId, isPrimOpId_maybe ) import Literal ( Literal(..), mkMachInt, mkMachWord , literalType , word2IntLit, int2WordLit @@ -381,12 +381,15 @@ For dataToTag#, we can reduce if either (b) the argument is a variable whose unfolding is a known constructor \begin{code} -dataToTagRule [_, val_arg] - = case exprIsConApp_maybe val_arg of - Just (dc,_) -> ASSERT( not (isNewTyCon (dataConTyCon dc)) ) - Just (mkIntVal (toInteger (dataConTag dc - fIRST_TAG))) +dataToTagRule [ty1, Var tag_to_enum `App` ty2 `App` tag] + | Just TagToEnumOp <- isPrimOpId_maybe tag_to_enum + , ty1 `coreEqType` ty2 + = Just tag -- dataToTag (tagToEnum x) ==> x - other -> Nothing +dataToTagRule [_, val_arg] + | Just (dc,_) <- exprIsConApp_maybe val_arg + = ASSERT( not (isNewTyCon (dataConTyCon dc)) ) + Just (mkIntVal (toInteger (dataConTag dc - fIRST_TAG))) dataToTagRule other = Nothing \end{code}