[fpc-devel] Not really a bug...

Marcel Martin mm10 at ellipsa.net
Mon Jul 4 04:49:29 CEST 2005


Hello,

I am using FPC 2.0.0, Win32.

When subtracting a longword from a longword, FPC codes the
operation as if it were a 64-bit operation. This is not really
a bug since the code is correct but this uselessly increases
the running times and the sizes of the executables.

(I found no bug report about that)

For instance, with u, v and w Longwords, the following subtraction

   u := v - w;

is coded as

   movl  U_P$TEST2_V,%eax
   movl  $0,%ebx
   movl  U_P$TEST2_W,%ecx
   movl  $0,%edx
   subl  %ecx,%eax
   sbbl  %edx,%ebx
   movl  %eax,U_P$TEST2_U

Here, not only 2 movl's and 1 sbbl are useless but FPC also wastes
time to save/use/restore extra register(s).

At the moment, the only work around I found to make a subtraction
with Longwords is to write the operation this way:

   u := Longword(Longint(v) - Longint(w));

coded as

   movl  U_P$TEST2_V,%eax
   subl  U_P$TEST2_W,%eax
   movl  %eax,U_P$TEST2_U

notice that

   u := v;
   Dec(u,w);

   movl  U_P$TEST2_V,%eax
   movl  %eax,U_P$TEST2_U
   movl  U_P$TEST2_W,%eax
   subl  %eax,U_P$TEST2_U

shows there is no problem with Dec (the same with Pred(), if u is
a Longword, writing "u-1" is not ok but writing "Pred(u)" is ok).

mm




More information about the fpc-devel mailing list