summaryrefslogtreecommitdiff
path: root/compiler/codeGen/CgCase.lhs
diff options
context:
space:
mode:
authorDimitrios Vytiniotis <dimitris@microsoft.com>2011-11-16 16:12:48 +0000
committerDimitrios Vytiniotis <dimitris@microsoft.com>2011-11-16 16:12:48 +0000
commit0007c0ec9c0de68e3a348b8c4112ac48fd861b1e (patch)
tree78ff33800fad55d7dbb4e1b1732d4f82c4e092a2 /compiler/codeGen/CgCase.lhs
parent1bbb89f3ab009367fcca84b73b351ddcf5be16a4 (diff)
downloadhaskell-0007c0ec9c0de68e3a348b8c4112ac48fd861b1e.tar.gz
GHC gets a new constraint solver. More efficient and smaller in size.
Diffstat (limited to 'compiler/codeGen/CgCase.lhs')
-rw-r--r--compiler/codeGen/CgCase.lhs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/codeGen/CgCase.lhs b/compiler/codeGen/CgCase.lhs
index c3141f4fd7..e4fe386043 100644
--- a/compiler/codeGen/CgCase.lhs
+++ b/compiler/codeGen/CgCase.lhs
@@ -47,6 +47,7 @@ import Type
import TyCon
import Util
import Outputable
+import FastString
import Control.Monad (when)
\end{code}
@@ -127,6 +128,13 @@ allocating more heap than strictly necessary, but it will sometimes
eliminate a heap check altogether.
\begin{code}
+cgCase (StgApp _v []) _live_in_whole_case _live_in_alts bndr
+ (PrimAlt _) [(DEFAULT,bndrs,_,rhs)]
+ | isVoidArg (idCgRep bndr)
+ = ASSERT( null bndrs )
+ WARN( True, ptext (sLit "Case of void constant; missing optimisation somewhere") <+> ppr bndr)
+ cgExpr rhs
+
cgCase (StgApp v []) _live_in_whole_case _live_in_alts bndr
alt_type@(PrimAlt _) alts
-- Note [ticket #3132]: we might be looking at a case of a lifted Id
@@ -147,17 +155,18 @@ cgCase (StgApp v []) _live_in_whole_case _live_in_alts bndr
-- the HValue really is a MutVar#. The types are compatible though,
-- so we can just generate an assignment.
|| reps_compatible
- =
- do { -- Careful! we can't just bind the default binder to the same thing
+ = do { when (not reps_compatible) $
+ panic "cgCase: reps do not match, perhaps a dodgy unsafeCoerce?"
+
+ -- Careful! we can't just bind the default binder to the same thing
-- as the scrutinee, since it might be a stack location, and having
-- two bindings pointing at the same stack locn doesn't work (it
-- confuses nukeDeadBindings). Hence, use a new temp.
- when (not reps_compatible) $
- panic "cgCase: reps do not match, perhaps a dodgy unsafeCoerce?"
; v_info <- getCgIdInfo v
; amode <- idInfoToAmode v_info
; tmp_reg <- bindNewToTemp bndr
; stmtC (CmmAssign (CmmLocal tmp_reg) amode)
+
; cgPrimAlts NoGC alt_type (CmmLocal tmp_reg) alts }
where
reps_compatible = idCgRep v == idCgRep bndr
@@ -327,6 +336,7 @@ cgInlinePrimOp primop args bndr (PrimAlt _) live_in_alts alts
= ASSERT( con == DEFAULT && isSingleton alts && null bs )
do { -- VOID RESULT; just sequencing,
-- so get in there and do it
+ -- The bndr should not occur, so no need to bind it
cgPrimOp [] primop args live_in_alts
; cgExpr rhs }
where