#2422: Unrelated instance foils optimizer
--------------------------+-------------------------------------------------
    Reporter:  sedillard  |       Owner:          
        Type:  bug        |      Status:  new     
    Priority:  normal     |   Component:  Compiler
     Version:  6.8.3      |    Severity:  normal  
    Keywords:             |    Testcase:          
Architecture:  x86        |          Os:  Linux   
--------------------------+-------------------------------------------------
 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. 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.

 Compiled with -O2.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2422>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to