Skip to content

Negative Float literals aren't work-free

If I compile the following program:

module Lib where

f :: Float
f = -0.0

I get the following Core:

f :: Float
[GblId,
 Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
         WorkFree=False, Expandable=False, Guidance=IF_ARGS [] 11 10}]
f = GHC.Types.F# (GHC.Prim.negateFloat# 0.0#)

This binding is not work-free, because the strict field of F# is not a normal form. Indeed, if I review the Cmm I see non-trivial entry code, suggesting this is actually a thunk rather than a CAF constant in the object file.

Don't we have negative literals that we can rewrite this to?

Edited by Sebastian Graf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information