[GHC] #14248: GHC misses optimization opportunity
GHC
ghc-devs at haskell.org
Mon Sep 18 22:35:58 UTC 2017
#14248: GHC misses optimization opportunity
-------------------------------------+-------------------------------------
Reporter: vagarenko | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Alas, your proposed optimsation changes the semantics of the function. As
it stands, it's not strict in `eta`, but after your transformation it has
become strict.
If you make it strict yourself, I think it'll probably optimise right.
This seems to do ths trick
{{{
unzipVec ps =
let (es1, es2) = unzip @n ps
!a1 = fromList es1
!a2 = fromList es2
in (a1, a2)
}}}
gives
{{{
unzipVecSpecialized
= \ (eta_B1 :: [(Float, Float)]) ->
case eta_B1 of {
[] -> case lvl20_r2SX of wild1_00 { };
: x_a14H xs_a14I ->
case x_a14H of { (a_a14J, b_a14K) ->
case xs_a14I of {
[] -> case lvl20_r2SX of wild3_00 { };
: x1_X18m xs1_X18o ->
case x1_X18m of { (a1_X18u, b1_X18w) ->
case a_a14J of { GHC.Types.F# dt1_a15E ->
case a1_X18u of { GHC.Types.F# dt3_a15F ->
case b_a14K of { GHC.Types.F# dt5_X17Q ->
case b1_X18w of { GHC.Types.F# dt7_X17W ->
((Unzip.Vector2f dt1_a15E dt3_a15F)
`cast` (Sym (Unzip.D:R:Vector2Float0[0])
:: (Unzip.R:Vector2Float :: *) ~R# (Vector 2 Float
:: *)),
(Unzip.Vector2f dt5_X17Q dt7_X17W)
`cast` (Sym (Unzip.D:R:Vector2Float0[0])
:: (Unzip.R:Vector2Float :: *) ~R# (Vector 2 Float
:: *)))
}
}
}
}
}
}
}
}
}}}
Does that make sense?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14248#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list