patch applied (ghc): Float coercions out of lets
Simon Peyton Jones
simonpj at microsoft.com
Thu Oct 5 09:33:16 EDT 2006
Thu Oct 5 06:24:37 PDT 2006 simonpj at microsoft.com
* Float coercions out of lets
Note [Float coercions]
~~~~~~~~~~~~~~~~~~~~~~
When we find the binding
x = e `cast` co
we'd like to transform it to
x' = e
x = x `cast` co -- A trivial binding
There's a chance that e will be a constructor application or function, or something
like that, so moving the coerion to the usage site may well cancel the coersions
and lead to further optimisation. Example:
data family T a :: *
data instance T Int = T Int
foo :: Int -> Int -> Int
foo m n = ...
where
x = T m
go 0 = 0
go n = case x of { T m -> go (n-m) }
-- This case should optimise
M ./compiler/simplCore/Simplify.lhs -3 +37
More information about the Cvs-ghc
mailing list