Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Glasgow Haskell Compiler
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shayne Fletcher
Glasgow Haskell Compiler
Commits
b341b2d0
Commit
b341b2d0
authored
Mar 01, 2006
by
Simon Marlow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add comments
parent
fcd3864f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
6 deletions
+48
-6
ghc/compiler/cmm/CmmOpt.hs
ghc/compiler/cmm/CmmOpt.hs
+48
-6
No files found.
ghc/compiler/cmm/CmmOpt.hs
View file @
b341b2d0
...
...
@@ -35,13 +35,55 @@ import GLAEXTS
-- -----------------------------------------------------------------------------
-- The mini-inliner
-- This pass inlines assignments to temporaries that are used just
-- once in the very next statement only. Generalising this would be
-- quite difficult (have to take into account aliasing of memory
-- writes, and so on), but at the moment it catches a number of useful
-- cases and lets the code generator generate much better code.
{-
This pass inlines assignments to temporaries that are used just
once. It works as follows:
- count uses of each temporary
- for each temporary that occurs just once:
- attempt to push it forward to the statement that uses it
- only push forward past assignments to other temporaries
(assumes that temporaries are single-assignment)
- if we reach the statement that uses it, inline the rhs
and delete the original assignment.
Possible generalisations: here is an example from factorial
Fac_zdwfac_entry:
cmG:
_smi = R2;
if (_smi != 0) goto cmK;
R1 = R3;
jump I64[Sp];
cmK:
_smn = _smi * R3;
R2 = _smi + (-1);
R3 = _smn;
jump Fac_zdwfac_info;
We want to inline _smi and _smn. To inline _smn:
- we must be able to push forward past assignments to global regs.
We can do this if the rhs of the assignment we are pushing
forward doesn't refer to the global reg being assigned to; easy
to test.
To inline _smi:
- It is a trivial replacement, reg for reg, but it occurs more than
once.
- We can inline trivial assignments even if the temporary occurs
more than once, as long as we don't eliminate the original assignment
(this doesn't help much on its own).
- We need to be able to propagate the assignment forward through jumps;
if we did this, we would find that it can be inlined safely in all
its occurrences.
-}
It
catches
many
useful
cases
,
but
could
be
generalised
in
-- several ways.
-- NB. This assumes that temporaries are single-assignment.
cmmMiniInline
::
[
CmmBasicBlock
]
->
[
CmmBasicBlock
]
cmmMiniInline
blocks
=
map
do_inline
blocks
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment