Commit 39439207 authored by simonmar's avatar simonmar
Browse files

[project @ 2004-09-15 12:06:08 by simonmar]

Oops, fix bugs in previous commit.
parent f220cc51
...@@ -414,15 +414,17 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag ...@@ -414,15 +414,17 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag
| Just deflt <- mb_deflt, (lowest_branch - lo_tag) >= n_branches | Just deflt <- mb_deflt, (lowest_branch - lo_tag) >= n_branches
= do { (assign_tag, tag_expr') <- assignTemp' tag_expr = do { (assign_tag, tag_expr') <- assignTemp' tag_expr
; let cond = cmmULtWord tag_expr' (CmmLit (mkIntCLit lowest_branch)) ; let cond = cmmULtWord tag_expr' (CmmLit (mkIntCLit lowest_branch))
; stmtC (CmmCondBranch cond deflt) branch = CmmCondBranch cond deflt
; mk_switch tag_expr' branches mb_deflt lowest_branch hi_tag ; stmts <- mk_switch tag_expr' branches mb_deflt lowest_branch hi_tag
; return (assign_tag `consCgStmt` (branch `consCgStmt` stmts))
} }
| Just deflt <- mb_deflt, (hi_tag - highest_branch) >= n_branches | Just deflt <- mb_deflt, (hi_tag - highest_branch) >= n_branches
= do { (assign_tag, tag_expr') <- assignTemp' tag_expr = do { (assign_tag, tag_expr') <- assignTemp' tag_expr
; let cond = cmmUGtWord tag_expr' (CmmLit (mkIntCLit highest_branch)) ; let cond = cmmUGtWord tag_expr' (CmmLit (mkIntCLit highest_branch))
; stmtC (CmmCondBranch cond deflt) branch = CmmCondBranch cond deflt
; mk_switch tag_expr' branches mb_deflt lo_tag highest_branch ; stmts <- mk_switch tag_expr' branches mb_deflt lo_tag highest_branch
; return (assign_tag `consCgStmt` (branch `consCgStmt` stmts))
} }
| otherwise -- Use an if-tree | otherwise -- Use an if-tree
...@@ -437,9 +439,9 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag ...@@ -437,9 +439,9 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag
} }
where where
use_switch = ASSERT( n_branches > 1 && n_tags > 1 ) use_switch = ASSERT( n_branches > 1 && n_tags > 1 )
{- pprTrace "mk_switch" (ppr tag_expr <+> text "n_tags: " pprTrace "mk_switch" (ppr tag_expr <+> text "n_tags: "
<+> int n_tags <+> text "dense: " <+> int n_tags <+> text "dense: "
<+> int n_branches) $ -} <+> int n_branches) $
n_tags > 2 && (small || dense) n_tags > 2 && (small || dense)
-- a 2-branch switch always turns into an if. -- a 2-branch switch always turns into an if.
small = n_tags <= 4 small = n_tags <= 4
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment