Skip to content
Snippets Groups Projects
Commit 056d48ae authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Add a rewrite rule for toInt# so literals work right

See the comments with toInt#, but the key point is
that we want (fromInteger 1)::Int to yield (I# 1)!
parent 30f9427f
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,12 @@ int64ToInteger i = if ((i `leInt64#` intToInt64# 0x7FFFFFFF#) &&
#endif
toInt# :: Integer -> Int#
{-# NOINLINE toInt# #-}
{-# RULES "toInt#" forall i. toInt# (S# i) = i #-}
-- Don't inline toInt#, because it can't do much unless
-- it sees a (S# i), and inlining just creates fruitless
-- join points. But we do need a RULE to get the constants
-- to work right: 1::Int had better optimise to (I# 1)!
toInt# (S# i) = i
toInt# (J# s d) = integer2Int# s d
......
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