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
941ce4df
Commit
941ce4df
authored
13 years ago
by
Jayke Meijer
Browse files
Options
Downloads
Patches
Plain Diff
Filled list of optimizations.
parent
134aea82
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
+48
-35
48 additions, 35 deletions
report/report.tex
with
48 additions
and
35 deletions
report/report.tex
+
48
−
35
View file @
941ce4df
...
...
@@ -45,10 +45,11 @@ will be discussed seperatly
We only perform one global optimization, which is optimizing branch-jump
statements. The unoptimized Assembly code contains sequences of code of the
following structure:
\begin{
lstlisting
}
\begin{
verbatim
}
beq ...,
$
Lx
j
$
Ly
$
Lx: ...
\end
{
lstlisting
}
$
Lx: ...
\end
{
verbatim
}
This is inefficient, since there is a jump to a label that follows this code.
It would be more efficient to replace the branch statement with a
\texttt
{
bne
}
(
the opposite case
)
to the label used in the jump statement. This way the jump
...
...
@@ -79,14 +80,14 @@ will describe the types of optimizations here in stead of each optimization.
These are optimizations that simply look for a certain statement or pattern of
statements, and optimize these. For example,
\begin
{
lstlisting
}
\begin
{
verbatim
}
mov
$
regA,
$
regB
instr
$
regA,
$
regA,...
\end
{
lstlisting
}
\end
{
verbatim
}
can be optimized into
\begin
{
lstlisting
}
\begin
{
verbatim
}
instr
$
regA,
$
regB,...
\end
{
lstlisting
}
\end
{
verbatim
}
since the register
\texttt
{
\$
regA
}
gets overwritten by the second instruction
anyway, and the instruction can easily use
\texttt
{
\$
regB
}
in stead of
\texttt
{
\$
regA
}
. There are a few more of these cases, which are the same as
...
...
@@ -163,36 +164,48 @@ this IR and writing the IR back to Assembly.
\textbf
{
Global optimizations
}
\begin
{
tabular
}{
| c c c |
}
\hline
\begin
{
lstlisting
}
beq ...,
$
Lx
j
$
Ly
$
Lx: ...
\end{lstlisting}
&
$
\Rightarrow
$
&
\begin{lstlisting}
bne ...,
$
Ly
$
Lx: ...
\end{lstlisting}
\\
\hline
\begin{lstlisting}
bne ...,
$
Lx
j
$
Ly
$
Lx: ...
\end
{
lstlisting
}
&
$
\Rightarrow
$
&
\begin
{
lstlisting
}
beq ...,
$
Ly
$
Lx: ...
\end
{
lstlisting
}
\\
\hline
\end
{
tabular
}
\\
\\
\begin
{
verbatim
}
beq ...,
$
Lx bne ...,
$
Ly
j
$
Ly ->
$
Lx: ...
$
Lx: ...
bne ...,
$
Lx beq ...,
$
Ly
j
$
Ly
-
>
$
Lx: ...
$
Lx: ...
\end
{
verbatim
}
\textbf
{
Simple basic block optimizations
}
\begin
{
tabular
}{
|c c c|
}
\hline
\begin
{
lstlisting
}
beq ...,
$
Lx
j
$
Ly
$
Lx: ...
\end{lstlisting}
&
$
\Rightarrow
$
&
\begin{lstlisting}
bne ...,
$
Ly
$
Lx: ...
\end{lstlisting}
\\
\hline
\end{tabular}
\\
\\
\begin
{
verbatim
}
mov
$
regA,
$
regA
-
>
---
//
remove it
mov
$
regA,
$
regB
-
> instr
$
regA,
$
regB,...
instr
$
regA,
$
regA,...
instr
$
regA,... instr
$
4
,...
mov
[
$
4-
$
7
]
,
$
regA -> jal XXX
jal XXX
sw
$
regA,XXX
-
> sw
$
regA, XXX
ld
$
regA,XXX
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
}
addu
$
regA,
$
regB,
4
addu
$
regD,
$
regB,
4
... move
$
regA,
$
regD
Code not writing
$
regB -> ...
... ...
addu
$
regC,
$
regB, 4 move
$
regC,
$
regD
\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