From: simonmar Date: Wed, 12 Jan 2005 16:33:54 +0000 (+0000) Subject: [project @ 2005-01-12 16:33:54 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~1251 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a609df425d10b6d5e87cf43d01b4c2cd83551fbb;p=ghc-hetmet.git [project @ 2005-01-12 16:33:54 by simonmar] Fix a bug in mk_switch. --- diff --git a/ghc/compiler/codeGen/CgUtils.hs b/ghc/compiler/codeGen/CgUtils.hs index a8e9c39..414e90a 100644 --- a/ghc/compiler/codeGen/CgUtils.hs +++ b/ghc/compiler/codeGen/CgUtils.hs @@ -405,11 +405,15 @@ mk_switch tag_expr branches mb_deflt lo_tag hi_tag find_branch :: ConTagZ -> Maybe BlockId find_branch i = assocDefault mb_deflt tagged_blk_ids i - arms = [ find_branch (i+lo_tag) | i <- [0..n_tags-1]] + -- NB. we have eliminated impossible branches at + -- either end of the range (see below), so the first + -- tag of a real branch is real_lo_tag (not lo_tag). + arms = [ find_branch i | i <- [real_lo_tag..real_hi_tag]] - switch_stmt = CmmSwitch (cmmOffset tag_expr (- lo_tag)) arms + switch_stmt = CmmSwitch (cmmOffset tag_expr (- real_lo_tag)) arms - ; return (oneCgStmt switch_stmt) + ; ASSERT(not (all isNothing arms)) + return (oneCgStmt switch_stmt) } -- if we can knock off a bunch of default cases with one if, then do so