Skip to content

Use unsafe shifts inside GHC

While looking at the linear register allocator recently I noticed that the use of "normal" shifts like shiftR leads to the introduction of additional branches.

This was only added in !113 (closed), before that MR these would compile to a simple shift instruction, after these introduce a branch on top of the shift.

I think it's worthwhile to swap shifts inside GHC out for their unsafe variants. This essentially returns performance to a state pre !113 (closed) for this code.

If we want to be extra careful we could use the unsafe variant by default but keep using the safe variant for debug builds. But I'm not convinced it's worthwhile.

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