Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
uva
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
uva
Commits
9d4a71b3
Commit
9d4a71b3
authored
Dec 01, 2010
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
ssh://vo20.nl/home/git/repos/uva
parents
ceb0fac1
f1bff911
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
121 additions
and
0 deletions
+121
-0
compiler/.gitignore
compiler/.gitignore
+4
-0
compiler/ass1.tex
compiler/ass1.tex
+117
-0
graphics/ass10/assignment_texture_mapping.pdf
graphics/ass10/assignment_texture_mapping.pdf
+0
-0
No files found.
compiler/.gitignore
0 → 100644
View file @
9d4a71b3
*.aux
*.pdf
*.log
*.toc
compiler/ass1.tex
0 → 100644
View file @
9d4a71b3
\documentclass
[10pt,a4paper]
{
article
}
\usepackage
{
float
}
% aliases
\newcommand
{
\tab
}{
\hspace*
{
1cm
}}
\title
{
Compiler Optimalisation Assignment 1: Loops
}
\author
{
Sander van Veen (6167969)
}
\begin{document}
\maketitle
\section
{
Natural loops
}
% (fold)
\label
{
sec:Natural loops
}
Given flow graph
$
G
=
(
V,E,v
_
0
)
$
, where
$
V
$
is a collection of all vertices
(typically basic blocks),
$
E
$
is a collection of edges (which represent the
relation between the basic blocks) and
$
v
_
0
$
is the entry node. A natural loop
has the following definition:
\begin{itemize}
\item
A loop has a single entry point, which dominates the loop.
\item
There must be a path back to the entry point of the loop.
\item
Loops can be found by searching for edges of which their heads
dominate their tails, also know as backedges.
\item
Given an backedge
$
n
\rightarrow
d
$
, the natural loop is
$
d
$
plus the
nodes that can reach
$
n
$
without going through
$
d
$
.
\end{itemize}
\noindent
\textbf
{
Assignment: Give the natural loop(s) of the assignment's flow graph.
}
\\
To answer this assignment, I'll go through the definition of a natural loop and
discard the basic blocks which do not met the criteria.
\begin{enumerate}
\item
A loop has a single entry point, which dominates the loop.
\\
Blocks
$
B
_
1
$
and
$
B
_
2
$
met this criteria. Block
$
B
_
5
$
does not, since
$
B
_
3
$
and
$
B
_
4
$
both have an edge to
$
B
_
5
$
, which
makes
$
B
_
5
$
a multiple entrance point.
$
B
_
3
$
and
$
B
_
4
$
do not
dominate the loop, since they are both a successor of
$
B
_
2
$
.
\item
There must be a path back to the entry point of the loop.
\\
Block
$
B
_
1
$
does not have a path back to itself, so only block
$
B
_
2
$
remains.
\item
Loops can be found by searching for edges of which their heads
dominate their tails, also know as backedges.
\\
Block
$
B
_
2
$
has a backedge
$
B
_
5
\rightarrow
B
_
2
$
.
\item
Given an backedge
$
n
\rightarrow
d
$
, the natural loop is
$
d
$
plus the
nodes that can reach
$
n
$
without going through
$
d
$
.
\\
Since
$
B
_
2
$
is
the only remaining header, the assignment's flow graph has one
natural loop:
$
\{
B
_
2
, B
_
3
, B
_
4
, B
_
5
\}
$
. Note:
$
B
_
6
$
is not part of
the loop, because it is not stated if
$
B
_
6
$
has a path back to
$
B
_
2
$
.
\end{enumerate}
% section Natural loops (end)
\section
{
Reaching definition
}
% (fold)
\label
{
sec:Reaching definition
}
\textbf
{
Assignment: Give the
\texttt
{
gen
}
and
\texttt
{
kill
}
sets of the basic blocks.
}
%A typical dataflow equation has the form:
%\[\texttt{out}[S] = \texttt{gen}[S] \cup ( \texttt{in}[S] - \texttt{kill}[S])\]
\begin{table}
[H]
\begin{tabular}
{
|l|l|l|
}
\hline
$
B
_
i
$
&
\texttt
{
gen
}
$
[
B
_
i
]
$
&
\texttt
{
kill
}
$
[
B
_
i
]
$
\\
\hline
1
&
$
\{
d
_
1
,d
_
2
,d
_
3
,d
_
4
\}
$
&
$
\{
d
_
5
,d
_
6
,d
_
7
,d
_
8
,d
_
9
\}
$
\\
\hline
2
&
$
\{
d
_
5
\}
$
&
$
\{
d
_
4
,d
_
7
,d
_
8
\}
$
\\
\hline
3
&
$
\{
d
_
6
,
7
\}
$
&
$
\{
d
_
1
,d
_
3
,d
_
4
,d
_
5
,d
_
8
\}
$
\\
\hline
4
&
$
\{
d
_
8
\}
$
&
$
\{
d
_
4
,d
_
5
\}
$
\\
\hline
5
&
$
\{
d
_
9
\}
$
&
$
\{\}
$
\\
\hline
6
&
undefined
&
undefined
\\
\hline
\end{tabular}
\end{table}
\noindent
Note: I'm not sure about the
\texttt
{
gen
}
and
\texttt
{
kill
}
set of
$
B
_
1
$
. I noticed
$
d
_
3
$
will overwrite
$
d
_
1
$
, but I thought that doesn't mean
that
$
d
_
1
$
should be added to this
\texttt
{
kill
}
set.
% section Reaching definition (end)
\section
{
Iterative algorithm for reaching definitions
}
% (fold)
\label
{
sec:Iterative algorithm for reaching definitions
}
\textbf
{
algorithm
}
\\
for each block B:
\\
\tab
out[B] = gen[B]
\\
\\
changed = true
\\
while changed:
\\
\tab
changed = false
\\
\tab
for each block B:
\\
\tab
\tab
in[B] =
$
\bigcup
_{
p
\in
pred
(
B
)
}$
out[p]
\\
\tab
\tab
oldout = out[B]
\\
\tab
\tab
out[B] = gen[B]
$
\cup
$
(in[B]
$
-
$
kill[B])
\\
\tab
\tab
if out[B]
$
\neq
$
oldout:
\\
\tab
\tab
\tab
changed = true
\\
\noindent
Using this algorithm, the following result is generated.
\begin{table}
[H]
\begin{tabular}
{
|l|l|l|l|l|l|
}
\hline
&
start
&
first
&
first
&
second
&
second
\\
\hline
$
B
_
i
$
&
\texttt
{
out
}
[
$
B
_
i
$
]
&
\texttt
{
in
}
[
$
B
_
i
$
]
&
\texttt
{
out
}
[
$
B
_
i
$
]
&
\texttt
{
in
}
[
$
B
_
i
$
]
&
\texttt
{
out
}
[
$
B
_
i
$
]
\\
\hline
1
&
1,2,3,4
&
$
\emptyset
$
&
1,2,3,4
&
$
\emptyset
$
&
1,2,3,4
\\
\hline
2
&
5
&
1,2,3,4,9
&
1,2,3,5,9
&
1,2,3,4,5,8,9
&
1,2,3,5,9
\\
\hline
3
&
6,7
&
1,2,3,5,9
&
2,6,7,9
&
1,2,3,5,9
&
2,6,7,9
\\
\hline
4
&
8
&
1,2,3,5,9
&
1,2,3,8,9
&
1,2,3,5,9
&
1,2,3,8,9
\\
\hline
5
&
9
&
1,2,3,5,8,9
&
1,2,3,5,8,9
&
1,2,3,5,8,9
&
1,2,3,5,8,9
\\
\hline
6
&
undef.
&
1,2,3,8,9
&
undef.
&
1,2,3,8,9
&
undef.
\\
\hline
\end{tabular}
\end{table}
% section Iterative algorithm for reaching definitions (end)
\end{document}
graphics/ass10/assigment_texture_mapping.pdf
→
graphics/ass10/assig
n
ment_texture_mapping.pdf
View file @
9d4a71b3
File moved
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