Hello,

I was wondering why Pascal statements like
"Inc(SomePointer, sizeof(WideChar))" are compiled into two assembler commands (mov ecx,2; add [location],ecx). I found out that tcginlinenode.second_incdec checks second argument to be an ordinal constant. In my case, however, the second argument is being converted into pointer constant somewhere earlier, therefore
tcginlinenode.second_incdec forces it into register.
I added a check (see the patch attached) and now it is compiled into
"add [location],2", thus saving the register for other usage.

Regards,
Sergei
Index: ncginl.pas
===================================================================
--- ncginl.pas  (revision 9325)
+++ ncginl.pas  (working copy)
@@ -435,6 +435,8 @@
               { when constant, just multiply the addvalue }
               if 
is_constintnode(tcallparanode(tcallparanode(left).right).left) then
                  
addvalue:=addvalue*get_ordinal_value(tcallparanode(tcallparanode(left).right).left)
+              else if (tcallparanode(tcallparanode(left).right).left.nodetype 
= pointerconstn) then
+                 addvalue := 
addvalue*tpointerconstnode(tcallparanode(tcallparanode(left).right).left).value
               else
                 begin
                   
location_force_reg(current_asmdata.CurrAsmList,tcallparanode(tcallparanode(left).right).left.location,cgsize,addvalue<=1);
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to