Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
peephole
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
peephole
Commits
95cbd4de
Commit
95cbd4de
authored
Dec 29, 2011
by
Jayke Meijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added constant folding to report.
parent
b53e9197
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
report/report.tex
report/report.tex
+19
-6
No files found.
report/report.tex
View file @
95cbd4de
...
@@ -118,7 +118,21 @@ primary concern, this is not a big problem.
...
@@ -118,7 +118,21 @@ primary concern, this is not a big problem.
\subsubsection
*
{
Constant folding
}
\subsubsection
*
{
Constant folding
}
Another optimization is to do constant folding. Constant folding is replacing
a expensive step like addition with a more simple step like loading a constant.
Of course, this is not always possible. It is possible in cases where you apply
an operation on two constants, or a constant and a variable of which you know
for sure that it always has a certain value at that point. For example:
\begin
{
verbatim
}
li
$
regA, 1 li
$
regA,
1
addu
$
regB,
$
regA,
2
-
> li
$
regB, 3
\end{verbatim}
Of course, if
\texttt
{
\$
regA
}
is not used after this, it can be removed, which
will be done by the dead code elimination.
One problem we encountered with this is that the use of a
\texttt
{
li
}
is that
the program often also stores this in the memory, so we had to check whether
this was necessary here as well.
\subsubsection*
{
Copy propagation
}
\subsubsection*
{
Copy propagation
}
...
@@ -145,12 +159,11 @@ of the move operation.
...
@@ -145,12 +159,11 @@ of the move operation.
An example would be the following:
An example would be the following:
\begin{verbatim}
\begin{verbatim}
move
$
regA,
$
regB move
$
regA,
$
regB
move
$
regA,
$
regB move
$
regA,
$
regB
... ...
... ...
Code not writing
$
regA, -> ...
Code not writing
$
regA,
$
regB -> ...
$
regB ...
... ...
... ...
addu
$
regC,
$
regA, ... addu
$
regC,
$
regB, ...
addu
$
regC,
$
regA, ... addu
$
regC,
$
regB, ...
\end{verbatim}
\end{verbatim}
This code shows that
\texttt
{
\$
regA
}
is replaced with
\texttt
{
\$
regB
}
. This
This code shows that
\texttt
{
\$
regA
}
is replaced with
\texttt
{
\$
regB
}
. This
way, the move instruction might have become useless, and it will then be
way, the move instruction might have become useless, and it will then be
...
...
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