Inline eqTypeRep
ClosedPublic

Authored by dfeuer on Feb 11 2018, 12:54 PM.

Details

Summary

GHC didn't inline eqTypeRep, presumably because it ended up
being too big. This was unfortunate because it produces a
Maybe, which will almost always be scrutinized immediately.

Split eqTypeRep into a worker and a tiny wrapper, and mark the
wrapper INLINE. This change actually seems to reduce Core size,
at least in a small test.

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dfeuer created this revision.Feb 11 2018, 12:54 PM

In principle, we should probably be able to do slightly better by using 0# and 1# instead of True and False in the result of sameTypeRep. But I don't know if it's worth the mess.

mpickering requested changes to this revision.Feb 11 2018, 4:44 PM
mpickering added a subscriber: mpickering.

We shouldn't do anything here until we have properly analysed the problem.

See my comments on the ticket about a possible analysis and maybe a more "correct" solution.

(Using 0# and 1# in sameTypeRep is a very ugly suggestion, the compiler should correctly treat Bool like this anyway.)

This revision now requires changes to proceed.Feb 11 2018, 4:44 PM
dfeuer updated this revision to Diff 15435.Feb 12 2018, 2:57 PM

Use INLINABLE instead of INLINE, as mpickering requests. Doing both
that and the eqTypeRep/sameTypeRep split seem to get GHC to produce
a nice small unfolding for eqTypeRep. Doing either alone doesn't cut it.

mpickering accepted this revision.Feb 13 2018, 6:58 AM

Looks ok like this.

This revision is now accepted and ready to land.Feb 13 2018, 6:58 AM
This revision was automatically updated to reflect the committed changes.