Skip to content

Re-introduce polymorphic specialisation by default

Polymorphic specialisation has led to a number of hard to diagnose incorrect runtime result bugs (see #23469 (closed), #23109 (closed), #21229 (closed), #23445 (closed)) so we introduced a flag -fpolymorphic-specialisation which allows users to turn on this experimental optimisation if they are willing to buy into things going very wrong.

commit 9f01d14b5bc1c73828b2b061206c45b84353620e
Author: Matthew Pickering <matthewtpickering@gmail.com>
Date:   Mon Jun 26 10:37:55 2023 +0100

    Add -fpolymorphic-specialisation flag (off by default at all optimisation levels)
    
    Polymorphic specialisation has led to a number of hard to diagnose
    incorrect runtime result bugs (see #23469, #23109, #21229, #23445) so
    this commit introduces a flag `-fpolymorhphic-specialisation` which
    allows users to turn on this experimental optimisation if they are
    willing to buy into things going very wrong.

But polymorphic specialisation is a Very Good Thing: see Note [Specialising polymorphic dictionaries] in Specialise.hs

This ticket tracks progress on switching it on by-default again.

We have a MR in progress, !10479 (closed), that allegedly fixes the unsound-ness. Just need to get it landed! It tickles some Simplifier infelicities, which in turn leasds to compile-time regressions, so I'm fixing them first: #23745 (closed), #23627 (closed).

Things to check

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information