home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1996 December / CD_shareware_12-96.iso / DOS / Programa / CCDL122.ZIP / DOC / OPTIMIZE.DOC < prev    next >
Encoding:
Text File  |  1996-06-19  |  1.3 KB  |  39 lines

  1. the compiler performs the following optimizations:
  2.  
  3. 1) Constant folding.  When common math is done with constants, the 
  4. compiler will evaluate the expression and replace it with a constant.
  5.  
  6. Constant folding includes turning multiplies and divides into shifts
  7. when appropriate.  It also includes optimizing array calculations.
  8.  
  9. 2) Static register loading.  Arguments and local data may be loaded 
  10. into registers for the scope of a function for faster access.  Global 
  11. data is never optimized into a register; however a pointer to it may 
  12. be.
  13.  
  14. Register usage:
  15.  
  16. 386        m68k        usage
  17. ebx            d3-d7          variables and constants
  18. ebp,esi,edi     a2-a4        pointers (also vars and consts on 386)
  19. eax,ecx,edx     d0-d2,a0-a1    scratch.
  20. esp        a5,a6,a7    special-purpose regs
  21.  
  22. If you call an assembly language function, all registers except the
  23. scratch registers must be preserved through the call.
  24.  
  25. 3) statements of the form:
  26.     a = a + b;
  27.  
  28. are optimized to:
  29.  
  30.     a += b;
  31.  
  32. As this results in slightly better code generation.  The optimization 
  33. only takes effect when the first variable access to the right of the
  34. equal sign matches the assignment on the left.
  35.  
  36. 4) Peepgen optimizer
  37.  
  38. When possible, the code generator will optimize inidividual 
  39. instructions in simple ways to improve the code.