Ticket #5776 (closed bug: fixed)

Opened 4 months ago

Last modified 4 months ago

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.

Change History

Changed 4 months ago by igloo

  • difficulty set to Unknown
  • milestone set to 7.4.2

Changed 4 months 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(-)

Changed 4 months ago by simonpj

  • status changed from new to merge
  • testcase set to simplCore/should_compile/T5776

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

Ian: pls merge.

Simon

Changed 4 months ago by rl

Thanks, it fuses now!

Changed 4 months ago by igloo

  • status changed from merge to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.