[GHC] #11710: Fusion of a simple listArray call is very fragile

GHC ghc-devs at haskell.org
Tue Mar 15 11:50:46 UTC 2016


#11710: Fusion of a simple listArray call is very fragile
-------------------------------------+-------------------------------------
           Reporter:  bgamari        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  7.10.3
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Runtime
  Unknown/Multiple                   |  performance bug
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following (taken from ticket:11707#comment:2),
 {{{#!hs
 module Test where
 import Data.Array

 arr, arr2 :: Array Int Int
 arr = listArray (0,10) [ 1,1,1,1,1,1,1,1,1,1 ]
 arr2 = listArray (0,10) [ 1,1,1,1,1,1,1,1,1,-1 ]
 }}}
 Given that these are a small array, one might suspect it would be
 worthwhile for GHC to fuse the lists with `listArray`, giving rise to two
 nicely unrolled construction procedures.

 However, if you look at the Core produced by `-O1` this you'll find that
 this only happens in the case of `arr2`. `arr` on the other handle, is
 mysteriously not fused. The fact that these expressions are so similar and
 yet produce entirely different code is quite worrying.

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


More information about the ghc-tickets mailing list