Related articles |
---|
alias analysis vbrahmaiah@yahoo.com (brahmaiah vallabhaneni) (2002-03-31) |
Re: alias analysis sabre@nondot.org (Chris Lattner) (2002-04-06) |
Re: alias analysis journeyman@compilerguru.com (2002-04-06) |
Alias analysis shreyas76@gmail.com (shrey) (2005-11-21) |
Re: Alias Analysis ghiya@acaps.CS.McGill.CA (1995-11-30) |
From: | journeyman@compilerguru.com (journeyman) |
Newsgroups: | comp.compilers |
Date: | 6 Apr 2002 23:46:06 -0500 |
Organization: | Giganews.Com - Premium News Outsourcing |
References: | 02-03-182 |
Keywords: | optimize, analysis |
Posted-Date: | 06 Apr 2002 23:46:06 EST |
On 31 Mar 2002 23:26:10 -0500, brahmaiah vallabhaneni
<vbrahmaiah@yahoo.com> wrote:
>Hi All,
>
>Can somebody tell me the significance of alias anlysis optimization in
>compilers. I observed that you will get different results when this
>optimization is on... Currently don't have the piece of code....
>
> How is it justified ?
Alias analysis is not an optimization per se. It's a way of getting
more precise information about what is affected by a memory access.
For example, when you have a pointer:
int n;
int *p = &n; // p points to n, *p and n are two names for the same thing
n = 42;
*p = 17;
printf( "%d" n); // prints 17
Consider the following
p = &n; // p points to n;
*p = 1;
if (n) { // n == 1
do_something();
} else {
do_other();
}
If you (the compiler) know *p is an alias for n, you can use constant
propagation to determine that the if statement always evaluates true
and not generate the code for the else statement. Without alias
analysis, you have to make more conservative assumptions. The
optimization (constant propagation) is done either way, but you get
better results when you know what points where.
Aliasing doesn't just happen in languages with explicit pointers like
C and C++. For example, suppose you pass a global variable to a
function using call-by-reference semantics. The formal parameter and
the global are aliased.
>[If your program gives different answers with alias analysis, it's
>almost certainly got bugs, wild pointers or the like. -John]
Either the program is buggy, the compiler is buggy, or the language
spec is buggy. I know which way the smart money would bet. ;-)
Morris
Return to the
comp.compilers page.
Search the
comp.compilers archives again.