Commit 60ebfcff authored by Joachim Breitner's avatar Joachim Breitner
Browse files

Improve list fusion for [n::Integer..m]

enumFromTo for Integers goes via enumDeltaToInteger, which is less
efficient, as the "delta > = 0" check prevents more inlining which is
required for good fusion code. This rule avoids tihs check for the
common case of "delta = 1", makes up_fb visible and hence inlineable,
which greatly improves "length [n:Integer..m]"; even more so with
CallArity enabled. (#8766)
parent 79dfb968
......@@ -701,6 +701,13 @@ enumDeltaToIntegerFB c n x delta lim
| delta >= 0 = up_fb c n x delta lim
| otherwise = dn_fb c n x delta lim
"enumDeltaToInteger1" [0] forall c n x . enumDeltaToIntegerFB c n x 1 = up_fb c n x 1
-- This rule ensures that in the common case (delta = 1), we do not do the check here,
-- and also that we have the chance to inline up_fb, which would allow the constuctor to be
-- inlined and good things to happen.
{-# NOINLINE [1] enumDeltaToInteger #-}
enumDeltaToInteger :: Integer -> Integer -> Integer -> [Integer]
enumDeltaToInteger x delta lim
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