I've recently made a decompiler for AVM2/AS3, and I've noticed that Flash compiler tends to emit a lot of unneccessary code. For example, for a certain application I've removed circa 10% of the code without any impairment to functionality. It was just a certainly dead code not referenced by conditional opcodes nor by exception handling blocks.
Also, look at this snippet:
...
313 setproperty y
315 getlocal 12
317 returnvalue
318 jump L9
L3:
322 getlocal 8
324 returnvalue
L9:
325 jump L10 ; L10 (opcode #331) does not ever exist.
; Technically, it is a jump beyond
; the end of function. This is invalid code!
L2:
329 pushnull
330 returnvalue
Well, of course this is invalid code, which is also dead and hence won't cause any adverse effects (except of codebase bloating). But why does it ever emit that code? And why does verifier accepts that?
ASC or compc do not optimize. This is unfortunate, but the theory is that the JIT does all the optimization work. You can come up with even worse examples like adding two constants. So the answer is: Sorry, it just does not optimize. There might be a better compiler in the future. Right now you have to rely on the AS3 JIT to do the optimization work at runtime (which it does a decent job at!) or use a different compiler.