On 11/04/2015 20:07, Kevin O'Connor wrote:
With a few additional checks it's possible to emulate all the leal cases without requiring a function call. Although this makes the vgafixup.py code a little more complex it eliminates the need for the "emulate_leal" function and it produces better code. In my tests, almost all "leal" instructions are replaced with 4 (or fewer) instructions.
Maybe it is possible to tell gcc to not produce this instruction in the first place?
That would certainly be better. Any idea how to do that?
Not really. IIRC, GCC really likes having a way to do additions that doesn't modify the flags.
When porting to an architectures that does not support that (e.g. some old CISC ones), you have to use a completely different mechanism to describe conditional branches and stores---which is legacy and much less optimizable than the newer mechanism. x86 uses the new one.
Paolo