Float coercions out of lets
authorsimonpj@microsoft.com <unknown>
Thu, 5 Oct 2006 13:24:37 +0000 (13:24 +0000)
committersimonpj@microsoft.com <unknown>
Thu, 5 Oct 2006 13:24:37 +0000 (13:24 +0000)
commitb041525cb968351c4b790639820e99a9d232ea0c
treed9d3a33b102adbb2ed77ddc6a68b4f46bb47018c
parentaae14ad368aa747386cc46caf80f8181e4259c6e
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
compiler/simplCore/Simplify.lhs