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

GHC ghc-devs at haskell.org
Tue Mar 15 11:57:58 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
      Resolution:                    |             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:                    |
-------------------------------------+-------------------------------------

Comment (by bgamari):

 For the record, the case in comment:1 results in this Core,
 {{{#!hs
 Test2.arr10 = GHC.Types.I# 1
 Test2.arr11 = GHC.Types.I# (-1)

 Test2.arr1 =
   \ (@ s) (s1# :: GHC.Prim.State# s) ->
     case GHC.Prim.newArray# @Int @s 11 (GHC.Arr.arrEleBottom @Int) s1#
     of _ { (# ipv, ipv1 #) ->
     case GHC.Prim.writeArray# @s @Int ipv1 0 Test2.arr10 ipv
     of s4# { __DEFAULT ->
     case GHC.Prim.writeArray# @s @Int ipv1 1 Test2.arr10 s4#
     of s4#1 { __DEFAULT ->
     case GHC.Prim.writeArray# @s @Int ipv1 2 Test2.arr10 s4#1
     of s4#2 { __DEFAULT ->
     case GHC.Prim.writeArray# @s @Int ipv1 3 Test2.arr11 s4#2
     of s4#3 { __DEFAULT ->
     letrec {
       go :: [Int] -> GHC.Prim.Int# -> GHC.Prim.State# s -> GHC.Prim.State#
 s
       go =
         \ (ds :: [Int]) (eta :: GHC.Prim.Int#) (eta1 :: GHC.Prim.State# s)
 ->
           case ds of _ {
             [] -> eta1;
             : y ys ->
               case GHC.Prim.writeArray# @s @Int ipv1 eta y eta1
               of s4#4 { __DEFAULT ->
               case eta of wild1 {
                 __DEFAULT -> go ys (GHC.Prim.+# wild1 1) s4#4;
                 10 -> s4#4
               }
               }
           }; } in
     case go Test2.arr4 4 s4#3 of wild4 { __DEFAULT ->
     case GHC.Prim.unsafeFreezeArray# @s @Int ipv1 wild4
     of _ { (# ipv2, ipv3 #) ->
     (# ipv2, GHC.Arr.Array @Int @Int Test2.arr3 Test2.arr2 11 ipv3 #)
 }}}

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


More information about the ghc-tickets mailing list