Skip to content
Snippets Groups Projects
Commit b106d641 authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 1999-04-26 10:16:25 by simonm]

Reduce (dataToTag# x) where x is bound to a known constructor.
parent 3ee9bf03
No related merge requests found
......@@ -107,6 +107,16 @@ tryPrimOp TagToEnumOp [Type ty, Con (Literal (MachInt i _)) _]
tryPrimOp DataToTagOp [Type ty, Con (DataCon dc) _]
= Just (Con (Literal (mkMachInt (toInteger (dataConTag dc - fIRST_TAG)))) [])
tryPrimOp DataToTagOp [Type ty, Var x]
| unfolding_is_constr
= Just (Con (Literal (mkMachInt (toInteger (dataConTag dc - fIRST_TAG)))) [])
where
unfolding = getIdUnfolding var
CoreUnfolding form guidance unf_template = unfolding
unfolding_is_constr = case unf_template of
Con con@(DataCon _) _ -> conOkForAlt con
other -> False
Con (DataCon dc) con_args = unf_template
\end{code}
\begin{code}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment