Folding constants for floats

Sven Panne svenpanne at gmail.com
Tue Jan 14 16:48:23 UTC 2014


2014/1/14 Carter Schonwald <carter.schonwald at gmail.com>:
> maybe so, but having a semantics by default is huge, and honestly i'm not
> super interested in optimizations that merely change one infinity for
> another. What would the alternative semantics be?

I'm not sure that I understood your reply: My example regarding -0 was
only demonstrating the status quo of GHCi and is IEEE-754-conformant.
The 1/foo is only used to distinguish between 0 and -0, it is not
about infinities per se.

My point was: As much as I propose to keep these current semantics,
there might be users who care more about performance than
IEEE-754-conformance. For those, relatively simple semantics could be:
Regarding optimizations, numbers are considered "mathematical"
numbers, ignoring any rounding and precision issues, and everything
involving -0, NaN, and infinities is undefined. This would open up
optimizations like easy constant folding, transforming 0 + x to x, x -
x to 0, x `op` y to y `op` x for mathematically commutative operators,
associativity, etc.

I'm not 100% sure how useful this would really be, but I think we
agree that this shouldn't be the default.

Cheers,
   S.


More information about the ghc-devs mailing list