Unrelated instance foils optimizer
I have a type (:.) a b
that I use for vectors, so a 4d vector is a:.a:.a:.a:.()
. This is just a linked list, so I also have a packed representation for Doubles, Vec4D
and a class that relates the two representations.
The Storable instances for (:.)
are inductive: if a
and (b:.c)
are Storable then so is (a:.b:.c)
. So long as the source is a peek and the destination is a poke, the method calls optimize neatly and no (:.)
values are allocated.
Here's the weird part: If I use the Storable methods of (:.)
and the pack/unpack methods to extend a Storable
instance to Vec4D
, then the optimization of the (:.)
Storable methods fails. The Vec4D
instances are not used at all, and yet they affect optimization of the (:.)
instances.
This is probably related to #2416 (closed). If I move the Storable
instance for (:.)
into Main.hs
, then all optimization fails regardless of any instance for Vec4D
. If I move the Storable
instance for Vec4D
into a different module than the instance for (:.)
, then optimization works fine.
The example is in two files. I tried to merge them into one but that's when I discovered #2416 (closed).
Compiled with -O2.
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |