From cca5f22b2def1fea7c7d792908a000bac8b4c0b9 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 7 Jul 2005 13:50:40 +0000 Subject: [PATCH] [project @ 2005-07-07 13:50:40 by simonmar] small performance fix: in via-C mode we previously always created a switch instead of an conditional-tree for a multi-branch case. Refine this slightly so that 2-branch switches turn into conditionals again, since gcc doesn't do a good job of optimising the equivalent switch. --- ghc/compiler/codeGen/CgUtils.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghc/compiler/codeGen/CgUtils.hs b/ghc/compiler/codeGen/CgUtils.hs index b70bd26..68958d2 100644 --- a/ghc/compiler/codeGen/CgUtils.hs +++ b/ghc/compiler/codeGen/CgUtils.hs @@ -413,7 +413,7 @@ mk_switch tag_expr [(tag,stmts)] (Just deflt) lo_tag hi_tag via_C -- time works around that problem. -- mk_switch tag_expr branches mb_deflt lo_tag hi_tag via_C - | use_switch || via_C -- Use a switch + | use_switch -- Use a switch = do { branch_ids <- mapM forkCgStmts (map snd branches) ; let tagged_blk_ids = zip (map fst branches) (map Just branch_ids) @@ -479,7 +479,7 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag via_C text "real_lo_tag: " <+> int real_lo_tag <+> text "real_hi_tag: " <+> int real_hi_tag) $ -} ASSERT( n_branches > 1 && n_tags > 1 ) - n_tags > 2 && (small || dense) + n_tags > 2 && (small || dense || via_C) -- a 2-branch switch always turns into an if. small = n_tags <= 4 dense = n_branches > (n_tags `div` 2) -- 1.7.10.4