[GHC] #2731: Avoid unnecessary evaluation when unpacking constructors
GHC
ghc-devs at haskell.org
Tue Jun 12 16:42:41 UTC 2018
#2731: Avoid unnecessary evaluation when unpacking constructors
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: (none)
Type: bug | Status: new
Priority: lowest | Milestone:
Component: Compiler | Version: 8.5
Resolution: | Keywords: CodeGen
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: |
-------------------------------------+-------------------------------------
Changes (by AndreasK):
* version: 6.8.3 => 8.5
Comment:
If anyone wonders this is still the case in GHC-8.4 / HEAD.
Changing the type of `T` to `data T = MkT !(Bool,Bool)` also doesn't
change anything.
Cmm Code.
{{{
{offset
c1pY:
if ((Sp + -8) < SpLim) (likely: False) goto c1q2; else goto
c1q3;
c1q2:
R2 = R2;
R1 = foo_closure;
call (stg_gc_fun)(R2, R1) args: 8, res: 0, upd: 8;
c1q3:
I64[Sp - 8] = c1pV;
R1 = R2;
Sp = Sp - 8;
if (R1 & 7 != 0) goto c1pV; else goto c1pW;
c1pW:
call (I64[R1])(R1) returns to c1pV, args: 8, res: 8, upd: 8;
c1pV:
I64[Sp] = c1q1;
R1 = P64[R1 + 7];
if (R1 & 7 != 0) goto c1q1; else goto c1q5;
c1q5:
call (I64[R1])(R1) returns to c1q1, args: 8, res: 8, upd: 8;
c1q1:
R1 = P64[R1 + 7] & (-8);
Sp = Sp + 8;
call (I64[R1])(R1) args: 8, res: 0, upd: 8;
}
}}}
To solve this we would need to track the evaluation requirements of
binders in STG. Something it seems we currently don't do.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/2731#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list