[GHC] #14372: CMM contains a bunch of tail-merging opportunities
GHC
ghc-devs at haskell.org
Sat Jan 13 22:03:22 UTC 2018
#14372: CMM contains a bunch of tail-merging opportunities
-------------------------------------+-------------------------------------
Reporter: heisenbug | Owner: (none)
Type: feature request | 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 AndreasK):
I think this can be solved in two steps:
----
Change the Cmm generation for case statements:
Currently we generate cmm of the sort
{{{
...
case 1: goto foo;
...
foo:
Register = Value
return(Register)
}}}
Instead we could inline this when generating the switch.
{{{
#include "Cmm.h"
test_entry()
{
switch [1 .. 8] R2 {
case 1 : {R1 = 0; return();}
...
case 8 : {R1 = 8; return();}
}
}
}}}
From what I've seen this hopefully won't change the generated assembly
since GHC does this already when compiling the switch in the cases I
looked at.
----
The second step would be to change the Assembly generated to something
like the listing in [comment:17 the comment above].
I imagine a way to do that would be to:
* Check if
* Assignments are into the same register.
* The rest of the code is the same
* Collect all the constants, put them into a lookup table and generate
assembly that uses the lookup table like [comment:17 above].
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14372#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list