--- ghc-6.8.2-normal/compiler/codeGen/CgUtils.hs 2007-12-10 19:11:32.000000000 +0100 +++ ghc-6.8.2-fast2case/compiler/codeGen/CgUtils.hs 2008-02-22 14:06:14.000000000 +0100 @@ -696,6 +696,15 @@ -- the branches is the tag 0, because comparing '== 0' is likely to be -- more efficient than other kinds of comparison. +-- optimize 2 constructor datatype case +mk_switch (CmmMachOp (MO_And rep) [arg, CmmLit (CmmInt tAG_MASK' rep')]) [(1, stmts1), (2, stmts2)] Nothing _ _ via_C + | tAG_MASK' == fromIntegral tAG_MASK = do + id <- forkCgStmts stmts2 + return $ CmmComment (mkFastString "Fast2Case") `consCgStmt` (CmmCondBranch cond id `consCgStmt` stmts1) + where + tag_expr' = CmmMachOp (MO_And rep) [arg, CmmLit (CmmInt 2 rep')] + cond = cmmNeWord tag_expr' (CmmLit (mkIntCLit 0)) + -- DENSE TAG RANGE: use a switch statment. -- -- We also use a switch uncoditionally when compiling via C, because