
#11731: Simplifier: Inlining trivial let can lose sharing -------------------------------------+------------------------------------- Reporter: nomeata | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 8.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): Phab:D2064 Wiki Page: | -------------------------------------+------------------------------------- Comment (by nomeata):
A small change to exprIsTrivial fixes this
And almost validates, with one exception. There is an increase of
allocations in T5549 by 10%. The -ddump-simpl differs only slightly: In
the code of
{{{#!hs
aux (_,0) _ = ([],0)
aux _ (_,0) = ([],0)
aux (a@(ha:as),la) (b@(hb:bs), lb)
| ha == hb = let (s,n) = aux (as,la-1) (bs,lb-1) in (ha : s, n+1)
| otherwise =
let (sa,na) = aux (as,la-1) (b,lb) -- ←
(sb,nb) = aux (a,la) (bs,lb-1) in
if na > nb then (sa,na) else (sb,nb)
}}}
the marked recursive call to `aux` re-assembles the second tuple argument,
instead of passing the tuple that was passed to `aux`; this is CSE
failing.
CSE uses `exprIsTrivial` in `tryForCSE`. From my reading of the code, in
the context of
{{{
case foo of foo'
{ (x [Dmd=