[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Compiler Optimizations
- From: David Jones <drj@...>
- Date: Fri, 31 Aug 2007 09:24:32 +0100
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.