[fpc-pascal] i386: strange code generated in simple for loop
Jonas Maebe
jonas.maebe at elis.ugent.be
Sat Dec 3 21:48:11 CET 2011
On 03 Dec 2011, at 21:41, Bernd wrote:
> Hello, I have observed something I do not understand. The following is
> a series of for-loops and the generated code looks strange to me.
> There always appears an inc followed by a dec
Note that the "inc" comes before the loop body and the "dec" is inside it. It's only necessary in case the loop counter may potentially include the upper boundary of the loop counter type, but the compiler indeed does not catch several cases where it could be left out.
> and what is even more
> bizarre is the code in between it: sometimes it inserts a mov
> %esi,%esi, sometimes lea 0x0(%esi),%esi and sometimes just a simple
> nop, although the loop looks exactly the same.
That's for code alignment.
Jonas
More information about the fpc-pascal
mailing list