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
bd8913da
Commit
bd8913da
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Final changes to report
parent
3774dbc1
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
+18
-46
18 additions, 46 deletions
report/report.tex
with
18 additions
and
46 deletions
report/report.tex
+
18
−
46
View file @
bd8913da
...
...
@@ -7,9 +7,10 @@
\setlength
{
\parindent
}{
0pt
}
\setlength
{
\parskip
}{
1ex plus 0.5ex minus 0.2ex
}
\title
{
Peephole Optimizer
}
\author
{
Jayke Meijer (6049885), Richard Torenvliet (6138861), Tadde
\"
us Kroes
(6054129)
}
\title
{
Compilerbouw - Peephole Optimizer
}
\author
{
Jayke Meijer (6049885),
\\
Richard Torenvliet (6138861),
\\
Tadde
\"
us Kroes (6054129)
}
\begin{document}
...
...
@@ -140,7 +141,17 @@ redefinition of x.
Arithmetics in Assembly are always performed between two registers or a
register and a constant. If the current value of all used registers is known,
The expression can be executed at
-
compile
-
time and the instruction can be
replaced by an immediate load of the result. See
\ref
{
opt
}
for an example.
replaced by an immediate load of the result. The following example illustrates
this:
\begin
{
verbatim
}
li
$
2, 2 #
$
2
=
2
sw
$
2, 16(
$
fp
)
#
16
(
$
fp) = 2
li
$
2
,
3
#
$
2 = 3
sw
$
2
,
20
(
$
fp) # 20(
$
fp
)
=
3
lw
$
2, 16(
$
fp
)
#
$
2 = 16(
$
fp
)
=
2
lw
$
3, 20(
$
fp
)
#
$
3 = 20(
$
fp
)
=
3
addu
$
2,
$
2
,
$
3 # change to "li
$
2
,
0
x
00000005
"
\end
{
verbatim
}
%In other words until the current definition of \texttt{x} becomes dead.
%Therefore reaching definitions analysis is needed. Reaching definitions is a
...
...
@@ -151,8 +162,8 @@ During the constant folding, so-called algebraic transformations are performed
as well. When calculations are performed using constants, some calculations can
be replaced by a load
-
or move
-
instruction. An example is the statement
$
x = y + 0
$
, or in Assembly:
\texttt
{
addu
\$
1
,
\$
2
,
0
}
. This can be replaced by
$
x = y
$
or
\texttt
{
move
\$
1
,
\$
2
}
.
A list of
transformations that are
performed
can be found in appendix
\ref
{
opt
}
.
$
x = y
$
or
\texttt
{
move
\$
1
,
\$
2
}
.
To see all
transformations that are
performed, read the inline comment blocks in the corresponding code
.
\subsubsection
{
Copy propagation
}
...
...
@@ -433,7 +444,7 @@ clinpack & 3523 & 231 & 1543746 & 1457479 & 5.59\% \\
\pagebreak
\appendix
\section
{
List of
all
optimizations
}
\section
{
List of
straight
-
forward
optimizations
}
\label
{
opt
}
...
...
@@ -477,44 +488,5 @@ shift $regA,$regA,0 -> --- // remove it
add
$
regA,
$
regA,X -> lw ...,X(
$
regA
)
lw ...,
0
(
$
regA)
\end{verbatim}
\textbf
{
Advanced basic block optimizations
}
\begin{verbatim}
# Common subexpression elimination
addu
$
regA,
$
regB, 4 addu
$
regD,
$
regB, 4
... move
$
regA,
$
regD
Code not writing
$
regB
-
> ...
... ...
addu
$
regC,
$
regB,
4
move
$
regC,
$
regD
# Constant folding
li
$
2, 2
$
2
=
2
sw
$
2, 16(
$
fp
)
16
(
$
fp) = 2
li
$
2
,
3
$
2 = 3
sw
$
2
,
20
(
$
fp) -> 20(
$
fp
)
=
3
lw
$
2, 16(
$
fp
)
$
2 = 16(
$
fp
)
=
2
lw
$
3, 20(
$
fp
)
$
3 = 20(
$
fp
)
=
3
addu
$
2,
$
2
,
$
3 change to "li
$
2
,
0
x
00000005
"
# Copy propagation
move
$
regA,
$
regB move
$
regA,
$
regB
... ...
Code not writing
$
regA, -> ...
$
regB ...
... ...
addu
$
regC,
$
regA, ... addu
$
regC,
$
regB, ...
# Algebraic transformations
addu
$
regA,
$
regB,
0
-
> move
$
regA,
$
regB
subu
$
regA,
$
regB,
0
-
> move
$
regA,
$
regB
mult
$
regA,
$
regB,
1
-
> move
$
regA,
$
regB
mult
$
regA,
$
regB,
0
-
> li
$
regA, 0
mult
$
regA,
$
regB, 2 -> sll
$
regA,
$
regB, 1
\end{verbatim}
\end{document}
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