Opened 8 years ago

Closed 8 years ago

#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 Test Case: simplCore/should_compile/T5776
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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.

Change History (5)

comment:1 Changed 8 years ago by igloo

difficulty: Unknown
Milestone: 7.4.2

comment:2 Changed 8 years ago by simonpj@…

commit f002a461768cb334355c17053dcd331aa9ed1e06

Author: Simon Peyton Jones <simonpj@microsoft.com>
Date:   Tue Jan 17 12:15:26 2012 +0000

    Do not combine dictionaries in the EvVarCache when simplEqsOnly is on
    
    This fixes Trac #5776; the background is in
    Note [Simplifying RULE lhs constraints] in TcSimplify

 compiler/typecheck/TcInteract.lhs |   67 +++++++++++++++++++++----------------
 1 files changed, 38 insertions(+), 29 deletions(-)

comment:3 Changed 8 years ago by simonpj

Status: newmerge
Test Case: simplCore/should_compile/T5776

Thanks for spotting this Roman. I've fixed it and added a resgression test.

Ian: pls merge.

Simon

comment:4 Changed 8 years ago by rl

Thanks, it fuses now!

comment:5 Changed 8 years ago by igloo

Resolution: fixed
Status: mergeclosed
Note: See TracTickets for help on using tickets.