[M3devel] optimizing for size or speed?

Jay K jay.krell at cornell.edu
Thu Feb 11 09:53:08 CET 2010


There are all kinds of equivalent code sequences.
 For the maintainer of m3back to chose among.


Given for example:

 


int F(int a) { return a << 2; }

 


Visual C++ optimizing for size uses:
 shl     eax, 2 ; 3 bytes


optimizing for speed gives:
 add eax, eax ; 2 bytes
 add eax, eax ; 2 bytes


 

given a << 3, the choices are, obviously:
  shl eax, 3 ; 3 bytes
or
  add eax, eax
  add eax, eax
  add eax, eax
 6 bytes, double the size


 

thoughts?


 

I think go for size over speed.
 Smaller files, less I/O, both in the
 build and less code to pagein at runtime.

 


At some point higher instruction counts saturate the ability
of the processors to "run ahead"?

 


However it might be nice to give the user a choice?

 But then you invite increased testing cost.

  Though maybe not too prohibitive.

 


(for shift by one, size/speed both give add eax, eax; I'll do that)

 


 - Jay

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100211/eedaa54e/attachment-0001.html>


More information about the M3devel mailing list