[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optimizations (was Re: [DotGNU]All my tests work)

From: Rhys Weatherley
Subject: Optimizations (was Re: [DotGNU]All my tests work)
Date: Wed, 20 Nov 2002 12:52:09 +1000

Gopal V wrote:

> Now that it works , let's make it work better ?  Is it time to start
> -O3 work ? ... I don't think *I* want to see a peephole optimiser from
> inside .. :-)

Peephole optimisation isn't terribly effective on IL code.  Doing
optimizations of jumps to jumps might be useful in the assembler
(the compiler cannot handle it easily).  Look at "FinishLabels"
in "ilasm_output.c".  But most of the simple cases of instruction
replacement (e.g. "ldloc 3" => "ldloc.3") are already handled by
the compiler or the assembler.

There are some possibilities for "reduction in strength" and
"arithmetic equivalence" optimizations.  e.g. converting "x * 2"
into "x << 1" if "x" is an integer type.  This would probably need
to be handled in "", as the assembler doesn't have enough
information to know that it should only do it for integer types
and not floats.  Also, such optimizations shouldn't be done in
"overflow" mode, as "<<" doesn't check for overflow like "*".

The more complex optimizations, such as common sub-expression
elimination and moving invariants outside loops, will have to wait
until we have better dynamic flow analysis in the compiler (right
now we have none).

If someone wants to look into optimizations, I suggest adding an
"optimize_flag" to "ILGenInfo" (cg_gen.h), and then start looking
into simple arithmetic reduction in strength optimizations.  That
will be a good starting point to get experience before thinking
about the more complex cases.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]