PrelRules: Don't break let/app invariant in shiftRule wip/backport-T16742
authorBen Gamari <ben@smart-cactus.org>
Mon, 10 Jun 2019 13:25:57 +0000 (09:25 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sat, 15 Jun 2019 19:39:03 +0000 (15:39 -0400)
commitfee015b557a4bd2c078b826f554dfb24870bb410
tree697e984e131c51c1b66aa300fdc3c142b50eb887
parent4b40bad6182ca19a387ca136d569c6a9755c545a
PrelRules: Don't break let/app invariant in shiftRule

Previously shiftRule would rewrite as invalid shift like
```
let x = I# (uncheckedIShiftL# n 80)
in ...
```
to
```
let x = I# (error "invalid shift")
in ...
```
However, this breaks the let/app invariant as `error` is not
okay-for-speculation. There isn't an easy way to avoid this so let's not
try. Instead we just take advantage of the undefined nature of invalid
shifts and return zero.

Fixes #16742.

(cherry picked from commit 0bd3b9dd0428855b6f72f757c1214b5253aa7753)
compiler/coreSyn/CoreSyn.hs
compiler/prelude/PrelRules.hs
compiler/prelude/PrimOp.hs
testsuite/tests/codeGen/should_run/T16449_2.hs
testsuite/tests/codeGen/should_run/T16449_2.stderr [deleted file]
testsuite/tests/codeGen/should_run/T16449_2.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/all.T