Skip to content

Non-cheap primop is duplicated

Conal Elliot writes: I have

exampleC :: Double -> Double -> Double
exampleC = \ t -> let s = sin t in \ x -> x + s

But the sin ends up being pushed inside the lambda by the optimiser, like so:

exampleC = \ t x -> x + sin t

So if I do map (exampleC v) xs I end up computing sin v once for each element of xs rather than once.

Trac metadata
Trac field Value
Version 8.0.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