Re: [GHC] #855: Improvements to SpecConstr
#855: Improvements to SpecConstr -------------------------------------+------------------------------------- Reporter: simonpj | Owner: (none) Type: task | Status: new Priority: normal | Milestone: ⊥ Component: Compiler | Version: 6.4.2 Resolution: | Keywords: SpecConstr Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: N/A Blocked By: | Blocking: 915 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by sgraf): Long story short, I had success with the following [https://github.com/sgraf812/ghc/compare/master...sgraf812:stream-fusion diff]. Currently, it optimizes `ex1` to this code: {{{ -- RHS size: {terms: 39, types: 21, coercions: 0, joins: 3/3} Main.$wex1 [InlPrag=NOINLINE] :: GHC.Prim.Int# -> GHC.Prim.Int# [GblId, Arity=1, Caf=NoCafRefs, Str=<S,U>, Unf=OtherCon []] Main.$wex1 = \ (ww_s4pl :: GHC.Prim.Int#) -> joinrec { $s$wgo_s4rk :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# [LclId[JoinId(3)], Arity=3, Str=<L,A><S,U><S,U>] $s$wgo_s4rk _ [Occ=Dead] (sc1_s4ri :: GHC.Prim.Int#) (sc2_s4rh :: GHC.Prim.Int#) = jump $s$wgo2_s4rc sc1_s4ri sc2_s4rh; $s$wgo1_s4rg :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# [LclId[JoinId(3)], Arity=3, Str=<S,U><S,U><S,U>] $s$wgo1_s4rg (sc_s4rf :: GHC.Prim.Int#) (sc1_s4re :: GHC.Prim.Int#) (sc2_s4rd :: GHC.Prim.Int#) = jump $s$wgo_s4rk sc_s4rf sc1_s4re (GHC.Prim.+# sc2_s4rd sc_s4rf); $s$wgo2_s4rc [Occ=LoopBreaker] :: GHC.Prim.Int# -> GHC.Prim.Int# -> GHC.Prim.Int# [LclId[JoinId(2)], Arity=2, Str=<S,U><S,U>, Unf=OtherCon []] $s$wgo2_s4rc (sc_s4rb :: GHC.Prim.Int#) (sc1_s4ra :: GHC.Prim.Int#) = case GHC.Prim.<# sc_s4rb ww_s4pl of { __DEFAULT -> sc1_s4ra; 1# -> jump $s$wgo1_s4rg (GHC.Prim.*# sc_s4rb sc_s4rb) (GHC.Prim.+# sc_s4rb 1#) sc1_s4ra }; } in jump $s$wgo2_s4rc 1# 0# }}} Which is just a stone throw (or rather an inlining pass) away from the `goal`! For the examples `ex{2,3}` with increasing nesting level, things don't look so bright yet. Also I got some cleanup work to do tomorrow. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/855#comment:19> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC