Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Program flow analysis and Invariants.
Hi

I'm studying the program flow analysis and compiler optimization.
What's the purpose of program flow analysis? The answer I can come is
"to synthesize invariants". Is this claim true? Can we say the more
invariants we can find, the more optimization opportunities we can
explore?

Thanks

Neal

Report this thread to moderator Post Follow-up to this message
Old Post
Neal Wang
08-23-04 09:02 PM


Re: Program flow analysis and Invariants.
On 23 Aug 2004 12:11:54 -0400, Neal Wang <neal.wang@gmail.com> wrote:

>   I'm studying the program flow analysis and compiler optimization.
> What's the purpose of program flow analysis? The answer I can come
> is "to synthesize invariants". Is this claim true? Can we say the
> more invariants we can find, the more optimization opportunities we
> can explore?

No-one else seems to have answered this one.

I think that program flow analysis is used to provide a basis for
further analyses to be done, including loop-invariant code motion.

Are you able to obtain a good text on the subject, Neal?

--
Nick Roberts


Report this thread to moderator Post Follow-up to this message
Old Post
Nick Roberts
09-03-04 09:03 PM


Re: Program flow analysis and Invariants.
On Mon, 23 Aug 2004 12:11:54 -0400, Neal Wang wrote:

>   I'm studying the program flow analysis and compiler optimization.
> What's the purpose of program flow analysis? The answer I can come is
> "to synthesize invariants". Is this claim true? Can we say the more
> invariants we can find, the more optimization opportunities we can
> explore?

Control or data flow?

There are some obvious optimisations based on control
flow -- for example dead code elimination and tail
recursion optimisation.

Just as an example of data flow: consider

function f() ... return f();

Well that's clearly tail recursive but so is this:

function f() .. val x = f(); return x;

but you need data flow to discover this fact. My compiler
has a lot of heuristic optimisations based on pattern
matching such as

return f x;

generates the body of f, with x substituted, but I also
unravel expressions to 3 address code .. which defeats
detection by simple pattern matching, for example;

g = f;
return g x;

Now 'g' is a variable not a function, so we again need data
flow to discover it is always equal to f, and thus we can
inline f now (and eliminate g).

Report this thread to moderator Post Follow-up to this message
Old Post
John Max Skaller
09-08-04 08:57 AM


Re: Program flow analysis and Invariants.
"Nick Roberts" <nick.roberts@acm.org> wrote
> No-one else seems to have answered this one.
>
> I think that program flow analysis is used to provide a basis for
> further analyses to be done, including loop-invariant code motion.
>
> Are you able to obtain a good text on the subject, Neal?

Nick,

I have one which is "Editor :Steven S. Muchnick, Neil D. Jones,
Program Flow Analysis -- Theory and Applications".

What I'm curious is what the results of program flow analyses *in
general* are. My conclusion is all program flow analyses producing
some sort of invariants.

Invariants are predicates which are true for all program executions.
Those invariants are used to drive semantic-based program
manipulation, such as optimization. loop-invariant code motion is one
example.

Neal

Report this thread to moderator Post Follow-up to this message
Old Post
Neal Wang
09-13-04 09:00 PM


Re: Program flow analysis and Invariants.
"John Max Skaller" <skaller@nospam.com.au> wrote
> Control or data flow?
I mean dataflow analysis.

> There are some obvious optimisations based on control
> flow -- for example dead code elimination and tail
> recursion optimisation.

IMHO, dead code elimination is based on dataflow analysis.
define-use chains are used to drive dead code elimination.

Yes, some optimizations are based on control flow analysis.
One example might be "Instruction scheduling", but we still need to use
data flow analysis to discover data dependency while we use control flow
analysis to discover control dependency.

> Just as an example of data flow: consider
>
> 	function f() ... return f();
>
> Well that's clearly tail recursive but so is this:
>
> 	function f() .. val x = f(); return x;
> but you need data flow to discover this fact. My compiler

Yes, it's one example of reach definition.

> has a lot of heuristic optimisations based on pattern
> matching such as
>
> 	return f x;
>
> generates the body of f, with x substituted, but I also
> unravel expressions to 3 address code .. which defeats
> detection by simple pattern matching, for example;
>
> 	g = f;
> 	return g x;
>
> Now 'g' is a variable not a function, so we again need data
> flow to discover it is always equal to f, and thus we can
> inline f now (and eliminate g).

I think the purpose of dataflow analysis is to discover invariants.

Let me modify your example and make it more general:

g = f;
..    ;no further assignment of g
assert (g == f) <-- this is the invariant.
return g x;

Neal

Report this thread to moderator Post Follow-up to this message
Old Post
Neal Wang
09-13-04 09:00 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Compilers archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:45 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.