Related articles |
---|
Placement of memory loads tetra2005@googlemail.com (YuGr) (2009-11-05) |
Re: Placement of memory loads cr88192@hotmail.com (BGB / cr88192) (2009-11-05) |
Re: Placement of memory loads kkylheku@gmail.com (Kaz Kylheku) (2009-11-06) |
From: | YuGr <tetra2005@googlemail.com> |
Newsgroups: | comp.compilers |
Date: | Thu, 5 Nov 2009 09:42:32 +0300 |
Organization: | Compilers Central |
Keywords: | optimize, question, architecture |
Posted-Date: | 05 Nov 2009 15:18:57 EST |
Hi,
I want to figure out the best way to place initial memory loads in generated
code.
My current approach is very simple and inefficient. I do a liveness analysis
and then insert memory loads for all undefined variables in the beginning of
initial basic block. Here is an example (both x and y are global):
int main() {
x = x + 1;
//A lot of code
y = y + 1;
}
I see that both x and y belong to initial block's Live_in and insert loads:
int main() {
load x;
load y;
x = x + 1;
//A lot of code
y = y + 1;
}
The problem is that this simple approach leads to artificial conflicts (e.g. x
and y are in conflict) and high register pressure. I think I would better do
with something like
int main() {
load x;
x = x + 1;
//A lot of code
load y;
y = y + 1;
}
i.e. put load immediatelly before first use (note that x and y are not
conflicting any more). But how should I approach non-linear situations e.g.
int main() {
if( ... ) {
//A lot of code
x = x + 1;
} else {
//A lot of code
x = x + 2;
}
}
Should I put load in every branch (this will lead to code bloat) or before
switch (this will lead to increased register pressure)?
Another problem is loops: surely I do not want to insert load inside loop body
because it will lead to poor performance.
So
1) where and how do you usually place loads in generated code?
2) how do you approach conditional operators, loops, etc.?
3) can you recommend some paper which covers this problem in detail? I haven't
found any mentions of it in my textbooks (Aho, Cooper).
--
Best regards,
Yuri
Return to the
comp.compilers page.
Search the
comp.compilers archives again.