Skip to content

Very poor constant folding

GHC seems to lack constant folding for encodeFloat/decodeFloat. For many examples, compile the numeric-limits package on hackage, or just this snippet:

epsilon :: Double
epsilon = r
  where r = 1 - encodeFloat (m-1) e
        (m, e) = decodeFloat (1 `asTypeOf` r)

This has a very simple value, but GHC refuses to compute it at compile time. This in turn inhibits other constant folding that should be going on.

Trac metadata
Trac field Value
Version 7.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information