Ensure that Literals are in range
authorJoachim Breitner <mail@joachim-breitner.de>
Sun, 26 Feb 2017 21:27:52 +0000 (16:27 -0500)
committerBen Gamari <ben@smart-cactus.org>
Sun, 26 Feb 2017 21:34:27 +0000 (16:34 -0500)
commit6dfc5ebf70df8f0fdccc5004d914b777f21f3b72
treea90ab81945e5492ee078e97263e0c579e8bd6f6a
parent0d86aa5904e5a06c93632357122e57e4e118fd2a
Ensure that Literals are in range

This commit fixes several bugs related to case expressions
involving numeric literals which are not in the range of values of
their (fixed-width, integral) type.

There is a new invariant on Literal: The argument of a MachInt[64]
or MachWord[64] must lie within the range of the corresponding
primitive type Int[64]# or Word[64]#, as defined by the target machine.
This invariant is enforced in mkMachInt[64]/mkMachWord[64] by wrapping
the argument to the target type's range if necessary.

Test Plan: Test Plan: make slowtest TEST="T9533 T9533b T9533c T10245
T10246"

Trac issues: #9533, #10245, #10246, #13171

Reviewers: simonmar, simonpj, austin, bgamari, nomeata

Reviewed By: bgamari

Subscribers: thomie, rwbarton

Differential Revision: https://phabricator.haskell.org/D810
compiler/basicTypes/Literal.hs
compiler/deSugar/Match.hs
compiler/deSugar/MatchLit.hs
compiler/simplCore/SimplUtils.hs
testsuite/tests/codeGen/should_run/T9533.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/T9533.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/T9533b.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/T9533b.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/T9533c.hs [new file with mode: 0644]
testsuite/tests/codeGen/should_run/T9533c.stdout [new file with mode: 0644]
testsuite/tests/codeGen/should_run/all.T