Make specialisation a bit more aggressive
The patch
commit c43c981705ec33da92a9ce91eb90f2ecf00be9fe
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Fri Oct 23 16:15:51 2009 +0000
Fix Trac #3591: very tricky specialiser bug
indeed fixed a nasty specialisation bug for DFuns. Then
commit 2b74bd9d8b4c6b20f3e8d9ada12e7db645cc3c19
Author: Simon Peyton Jones <simonpj@microsoft.com>
Date: Wed Jun 7 12:03:51 2017 +0100
Stop the specialiser generating loopy code
extended it to work for imported DFuns. But in the process we lost the fact that it was only needed for DFuns -- I think unintentionally. As a result we started silently losing useful specialisation for non-DFuns. But there was no regression test to spot the lossage.
Then, nearly four years later, Andreas filed #19599 (closed), which showed the lossage in high relief. This patch restores the DFun test, and adds Note [Avoiding loops (non-DFuns)]
to explain why.
This is undoubtedly a very tricky corner of the specialiser, and one where I would love to have a more solid argument, even a paper! But meanwhile I think this fixes the lost specialisations without introducing any new loops.
I have two regression tests, T19599 and T19599a, so I hope we'll know if we lose them again in the future.