[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Compiler Optimizations
- From: Mark Hamburg <mhamburg@...>
- Date: Fri, 31 Aug 2007 08:53:51 -0700
I suspect that the reasoning is:
* Things that can be evaluated statically could be handled by the developer.
* For almost everything else, the metatable semantics make optimization
That said, I could see arguments for things like folding away the code in an
"if false" because this form might get used for turning code on and off.
That in turn perhaps argues for syntax for declaring constants in the code
that the compiler can then exploit as constants.
on 8/31/07 1:24 AM, David Jones at email@example.com wrote:
> On 30 Aug 2007, at 19:16, Patrick Donnelly wrote:
>> I'm curious what kind of compiler optimizations Lua does when creating
>> the byte code, if any?
>> x = 5 * 32 * i
>> x = 160 * i
> Well, the answer is obviously going to vary a bit. But the answer is
> approximately "almost none".
> It does do (some) constant folding. Constants are also pooled. It
> mostly eliminates redundant branching in conditional forms.
> No code-motion (but there's an opcode for for loops); no dead code
> elimination (the "if false" example you give); no common sub-
> expression elimination (in the presence of correctly preserving
> metatable semantics this wouldn't come up very often anyway); no
> strength reduction; no data-flow analysis.