Skip to content

Fix types in silly shifts (#18589)

Krzysztof Gogolewski requested to merge tweag/ghc:wip/fix-18589 into master

Invalid shifts, such as uncheckedShiftL x (-1) are optimized to 0, as explained in Note [Guarding against silly shifts]. For this purpose, we always used the integer literal 0. However, this is incorrect when the shift primop returns a word - we have to use the word literal 0.

Patch by Simon, I only added a test case.

I have not included the original test case from the ticket - it takes a while to run and needs -O2. Instead, I added a test which makes sure we cover all shift operations.

Merge request reports