Ticket #5776 (closed bug: fixed)
Rule matching regression
| Reported by: | rl | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.4.2 |
| Component: | Compiler | Version: | 7.5 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime performance bug | Difficulty: | Unknown |
| Test Case: | simplCore/should_compile/T5776 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
This shows up in the Quickhull benchmark from the vector package. I haven't been able to come up with a smaller example so far. To reproduce, download vector-0.9.1, compile benchmarks/Algo/Quickhull.hs with -O2 and look at the output of simplifier phase 2.
The bit in question is this (in hsplit, in the let-binding for packed):
(Data.Vector.Generic.stream
@ Data.Vector.Unboxed.Base.Vector
@ ((GHC.Types.Double, GHC.Types.Double), GHC.Types.Double)
$dVector_a1uD
(Data.Vector.Generic.new
@ Data.Vector.Unboxed.Base.Vector
@ ((GHC.Types.Double, GHC.Types.Double), GHC.Types.Double)
$dVector_a1nZ
(Data.Vector.Generic.New.unstream
@ Data.Vector.Unboxed.Base.Vector
@ ((GHC.Types.Double, GHC.Types.Double), GHC.Types.Double)
$dVector_a1nZ
...
The two dictionaries here are actually equivalent:
$dVector_a1nZ
:: Data.Vector.Generic.Base.Vector
Data.Vector.Unboxed.Base.Vector
((GHC.Types.Double, GHC.Types.Double), GHC.Types.Double)
$dVector_a1nZ =
Data.Vector.Unboxed.Base.$fVectorVector(,)
@ (GHC.Types.Double, GHC.Types.Double)
@ GHC.Types.Double
$dUnbox_s1ne
Data.Vector.Unboxed.Base.$fUnboxDouble
$dVector_a1uD
:: Data.Vector.Generic.Base.Vector
Data.Vector.Unboxed.Base.Vector
((GHC.Types.Double, GHC.Types.Double), GHC.Types.Double)
$dVector_a1uD =
Data.Vector.Unboxed.Base.$fVectorVector(,)
@ (GHC.Types.Double, GHC.Types.Double)
@ GHC.Types.Double
$dUnbox_s1ne
Data.Vector.Unboxed.Base.$fUnboxDouble
The bit of code in question should be fused away by this rule in Data/Vector/Generic.hs:
"stream/unstream [Vector]" forall s. stream (new (New.unstream s)) = s
But this isn't happening, I suspect because the dictionary arguments don't match. This was working fine in 7.2.2 which also didn't generate duplicate dictionary bindings.
