Skip to content

Make small INLINE functions behave properly

Ömer Sinan Ağacan requested to merge osa1/ghc:inline_functions into master

Simon writes:

Currently we check for a type arg rather than isTyCoArg. This in turn makes INLINE things look bigger than they should be, and stops them being inlined into boring contexts when they perfectly well could be. E.g.

f x = g <refl> x
{-# INLINE g #-}

... (map (f x) xs) ...

The context is boring, so don't inline unconditionally. But f's RHS is no bigger than its call, provided you realise that the coercion argument is ultimately cost-free.

This happens in practice for $WHRefl. It's not a big deal: at most it means we have an extra function call overhead. But it's untidy, and actually worse than what happens without an INLINE pragma.

Fixes #17182

This makes 0.0% change in nofib binary sizes.

Merge request reports