Skip to content

Draft: Optimizer: unpack small strict enum fields by default

Luite Stegeman requested to merge unpack-small-enums into master

Experimental MR to see if we can get any benefits from unpacking strict small enum fields (like !Bool) by default (when optimization is turned on). The idea is that it's more efficient to store the tag (Word8# for enums with up to 256 constructors) than a pointer to the closure. The downside is that we potentially have to convert between pointers and tags more often.

Related: Unpacked small enums take less than one word of storage because of ghc/ghc!13926 (closed) . In the UbxSumUnpackedSize testcase from ghc/ghc!13926 (closed) it became clear that GHC generates quite inefficient code around unpacking large enums. We likely need to improve this to get a net benefit from unpacking by default.

Edited by Luite Stegeman

Merge request reports

Loading