[GHC] #11527: Pattern match translation suboptimal

GHC ghc-devs at haskell.org
Tue Feb 2 11:01:54 UTC 2016


#11527: Pattern match translation suboptimal
-------------------------------------+-------------------------------------
           Reporter:  augustss       |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.8.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Compile the following code and look at the (sad) intermediate code:
 {{{
 baz :: Integer -> Int -> Int
 baz 10 1 = 1
 baz 20 1 = 2
 baz 10 2 = 2
 baz 20 2 = 3
 baz 10 3 = 1
 baz 20 3 = 2
 baz 10 4 = 2
 baz 20 4 = 3
 baz _ _  = 0
 }}}

 The pattern match compiler has not rearranged the clauses, and so it
 produces an 8 level deep nested test.

 Now change the type signature to
 {{{
 baz :: Int -> Int -> Int
 }}}
 Now the pattern match compiler does its job and rearranges the clauses to
 make the tests 2 levels deep.

 The same phenomenon happens when matching string literals.  For the
 predefined String type the right thing happens, but for some other string
 type (using OverloadedStrings) it doesn't.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11527>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list