Opened 9 years ago

Closed 4 years ago

#2823 closed bug (fixed)

Another arity expansion bug

Reported by: simonpj Owned by:
Priority: lowest Milestone: 7.6.2
Component: Compiler Version: 6.10.1
Keywords: Cc: jan.stolarek@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Runtime performance bug Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Roman reports: I've finally tracked down one big optimisation problem (at least, I think it is big). Here is a small example:

foo :: Eq a => a -> a
{-# NOINLINE foo #-}
foo x = x

bar :: Eq a => a -> a
{-# INLINE [1] bar #-}
bar x = let p = foo (x,x)
             q = foo (p,p) in fst (fst q)

For some reason, bar's arity is 1 which is wrong. If we replace (fst (fst q)) by (fst p), it gets the correct arity of 2.

The problem is that because of the arity, (bar $dEq) is then floated out as far as possible which breaks fusion if we have RULES for bar. In case you are interested, this affects splitSD in `dph-prim-par/Data/ Array/Parallel/Unlifted/Distributed/Arrays.hs`. I haven't noticed this previously because we didn't use segmented arrays as much.

Change History (12)

comment:1 Changed 9 years ago by igloo

Milestone: 6.10.2

comment:2 Changed 9 years ago by igloo

Milestone: 6.10.26.12 branch

comment:3 Changed 8 years ago by simonmar

Type of failure: Runtime performance bug

comment:4 Changed 8 years ago by igloo

Milestone: 6.12 branch6.12.3

comment:5 Changed 7 years ago by igloo

Milestone: 6.12.36.14.1
Priority: normallow

comment:6 Changed 7 years ago by igloo

Milestone: 7.0.17.0.2

comment:7 Changed 7 years ago by igloo

Milestone: 7.0.27.2.1

comment:8 Changed 6 years ago by igloo

Milestone: 7.2.17.4.1

comment:9 Changed 6 years ago by igloo

Milestone: 7.4.17.6.1
Priority: lowlowest

comment:10 Changed 5 years ago by igloo

Milestone: 7.6.17.6.2

comment:11 Changed 4 years ago by jstolarek

Cc: jan.stolarek@… added

comment:12 Changed 4 years ago by nomeata

Resolution: fixed
Status: newclosed

It seems that this has been fixed in ghc-7.6.3 or before:

T2823.foo [InlPrag=NOINLINE]
  :: forall a. GHC.Classes.Eq a => a -> a
[GblId, Arity=2, Caf=NoCafRefs, Str=DmdType AS]
T2823.foo = \ (@ a) _ (x :: a) -> x

T2823.bar [InlPrag=INLINE[1] (sat-args=1)]
  :: forall a. GHC.Classes.Eq a => a -> a
[GblId,
 Arity=2,
 Caf=NoCafRefs,
 Str=DmdType LL]
T2823.bar =
  \ (@ a) ($dEq :: GHC.Classes.Eq a) (eta :: a) ->
    let {
      p [Dmd=Just L] :: (a, a)
      [LclId, Str=DmdType]
      p =
        T2823.foo
          @ (a, a) (GHC.Classes.$fEq(,) @ a @ a $dEq $dEq) (eta, eta) } in
    let {
      $dEq1 [Dmd=Just A] :: GHC.Classes.Eq (a, a)
      [LclId, Str=DmdType]
      $dEq1 = GHC.Classes.$fEq(,) @ a @ a $dEq $dEq } in
    case T2823.foo
           @ ((a, a), (a, a))
           (GHC.Classes.$fEq(,) @ (a, a) @ (a, a) $dEq1 $dEq1)
           (p, p)
    of _ { (x, _) ->
    case x of _ { (x1, ds2) -> x1 }
    }
Note: See TracTickets for help on using tickets.