Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
peephole
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Taddeüs Kroes
peephole
Commits
1c867eea
Commit
1c867eea
authored
13 years ago
by
Jayke Meijer
Browse files
Options
Downloads
Patches
Plain Diff
Added algebraic transformations to report.
parent
2265148a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
report/report.tex
+15
-4
15 additions, 4 deletions
report/report.tex
with
15 additions
and
4 deletions
report/report.tex
+
15
−
4
View file @
1c867eea
...
...
@@ -112,11 +112,11 @@ We now add the instruction above the first use, and write the result in a new
variable. Then all occurrences of this expression can be replaced by a move of
from new variable into the original destination variable of the instruction.
This is a less efficient method then the
dag
, but because the basic blocks are
This is a less efficient method then the
DAG
, but because the basic blocks are
in general not very large and the execution time of the optimizer is not a
primary concern, this is not a big problem.
\subsubsection
*
{
Fold c
onstant
s
}
\subsubsection
*
{
C
onstant
folding
}
...
...
@@ -158,7 +158,18 @@ removed by the dead code elimination.
\subsubsection
*
{
Algebraic transformations
}
Some expression can easily be replaced with more simple once if you look at
what they are saying algebraically. An example is the statement
$
x = y + 0
$
, or
in Assembly
\texttt
{
addu
\$
1
,
\$
2
,
0
}
. This can easily be changed into
$
x = y
$
or
\texttt
{
move
\$
1
,
\$
2
}
.
Another case is the multiplication with a power of two. This can be done way
more efficiently by shifting left a number of times. An example:
\texttt
{
mult
\$
regA,
\$
regB,
4
-
> sll
\$
regA,
\$
regB,
2
}
. We perform this
optimization for any multiplication with a power of two.
There are a number of such cases, all of which are once again stated in
appendix
\ref
{
opt
}
.
\section
{
Implementation
}
...
...
@@ -195,7 +206,7 @@ The optimizations are done in two different steps. First the global
optimizations are performed, which are only the optimizations on branch
-
jump
constructions. This is done repeatedly until there are no more changes.
After all possible global optimizations are done, the program is sep
e
rated into
After all possible global optimizations are done, the program is sep
a
rated into
basic blocks. The algorithm to do this is described earlier, and means all
jump and branch instructions are called leaders, as are their targets. A basic
block then goes from leader to leader.
...
...
@@ -207,7 +218,7 @@ steps can be done to optimize something.
\subsection
{
Writing
}
Once all the optimizations have been done, the IR needs to be rewritten into
Assembly code, so the xgcc crosscompiler can make binary code out of it.
Assembly code, so the xgcc cross
compiler can make binary code out of it.
The writer expects a list of statements, so first the blocks have to be
concatenated again into a list. After this is done, the list is passed on to
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment