Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
a3209843
Commit
a3209843
authored
Jan 19, 2007
by
mrchebas@gmail.com
Browse files
don't make jump tables for small switches (<= 4 branches)
Only affects -fasm: gcc makes its own decisions about jump tables
parent
95d05f88
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/codeGen/CgUtils.hs
View file @
a3209843
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment