summaryrefslogtreecommitdiff
path: root/compiler/codeGen
diff options
context:
space:
mode:
authormrchebas@gmail.com <unknown>2007-01-19 15:07:49 +0000
committermrchebas@gmail.com <unknown>2007-01-19 15:07:49 +0000
commita32098431939d2411798312b11f18cf99e9f724b (patch)
tree746ea8ecbe3b9b6eef1822fca919b9ff40be2678 /compiler/codeGen
parent95d05f883245488f22bfa9dbbfd6d55cc7303a81 (diff)
downloadhaskell-a32098431939d2411798312b11f18cf99e9f724b.tar.gz
don't make jump tables for small switches (<= 4 branches)
Only affects -fasm: gcc makes its own decisions about jump tables
Diffstat (limited to 'compiler/codeGen')
-rw-r--r--compiler/codeGen/CgUtils.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/codeGen/CgUtils.hs b/compiler/codeGen/CgUtils.hs
index ab39080c16..29b972ce62 100644
--- a/compiler/codeGen/CgUtils.hs
+++ b/compiler/codeGen/CgUtils.hs
@@ -480,9 +480,11 @@ 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 || via_C)
- -- a 2-branch switch always turns into an if.
- small = n_tags <= 4
+ n_tags > 2 && (via_C || (dense && big_enough))
+ -- up to 4 branches we use a decision tree, otherwise
+ -- a switch (== jump table in the NCG). This seems to be
+ -- optimal, and corresponds with what gcc does.
+ big_enough = n_branches > 4
dense = n_branches > (n_tags `div` 2)
n_branches = length branches