UNREG: fix emission of large Integer literals in C codegen
ClosedPublic

Authored by trofi on Aug 22 2014, 3:39 PM.

Details

Summary

On amd64/UNREG build there is many failing tests trying
to deal with 'Integer' types.

Looking at 'overflow1' test I've observed invalid C code generated by
GHC.

Cmm code

CInt a = -1; (a == -1)

yields 'False' with optimisations enabled via the following C code:

StgWord64 a = (StgWord32)0xFFFFffffFFFFffffu; (a == 0xFFFFffffFFFFffffu)

The patch fixes it by shrinking emitted literals to required sizes:

StgWord64 a = (StgWord32)0xFFFFffffu; (a == 0xFFFFffffu)

Thanks to Reid Barton for tracking down and fixing the issue.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>

Test Plan

validate on UNREG build (amd64)

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Lint Skipped
Unit
Unit Tests Skipped
trofi updated this revision to Diff 427.Aug 22 2014, 3:39 PM
trofi retitled this revision from to UNREG: fix emission of large Integer literals in C codegen.
trofi updated this object.
trofi edited the test plan for this revision. (Show Details)
trofi added reviewers: simonmar, rwbarton.
trofi added a comment.Aug 22 2014, 3:52 PM

Looking at 'overflow1'

That's incorrect test. Real test was 'integerConversions'.

hvr added a subscriber: hvr.Aug 23 2014, 3:29 AM
trofi closed this revision.Aug 26 2014, 5:13 AM
trofi updated this revision to Diff 440.

Closed by commit rGHC43f1b2ecd196 (authored by @trofi).