According to my tests, using a for loop instead of a while loop is about 28% faster with Lua and 67% faster with LuaJit. Therefore, emitting for loops wherever possible would be a pretty significant performance win for the generated code, and would lead to slightly smaller code size too.