User Tools

Site Tools


spo600:compiler_optimizations

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
spo600:compiler_optimizations [2025/02/06 03:43] – [LLVM Optimization Options] chrisspo600:compiler_optimizations [2025/02/06 03:44] (current) – [Examples of Common Optimizations] chris
Line 21: Line 21:
 =====  LLVM Optimization Options  ===== =====  LLVM Optimization Options  =====
  
-LLVM, an alternate open source compiler project, can perform an extensive set of analysis and transform operations (optimizations). See the llvm documentation for details.+LLVM, an alternative open source compiler project, can perform an extensive set of analysis and transform operations (optimizations). See the llvm documentation for details.
  
 =====  Examples of Common Optimizations  ===== =====  Examples of Common Optimizations  =====
Line 29: Line 29:
 Important notes: Important notes:
   * There are many other kinds of optimizations, some of which operate at the [[Machine Language|object code]] level.   * There are many other kinds of optimizations, some of which operate at the [[Machine Language|object code]] level.
-  * Many of these optimizations cannot be performed when code has a side effect -- for example, the direction of a loop can sometimes be reversed without impact if the loop contains only calculations, but cannot be reversed if the loop contains I/O operations (such as printf()) or if a calculation depends on the result of a previous calculation (common in cryptography). Tracking these conditions can become complex!+  * Many of these optimizations cannot be performed when code has a side effect -- for example, the direction of a loop can sometimes be reversed without impact if the loop contains only calculations, but cannot be reversed if the loop contains I/O operations (such as ''printf()'') or if a calculation depends on the result of a previous calculation (common in cryptography). Tracking these conditions can become complex!
   * To make decisions on whether to apply some specific optimizations, as well as to provide information (such as code for inlining) required to apply optimizations, the compiler requires visibility into all of the code in the program. This is often not available if some of the code exists in a library that was previously compiled, or is contained in another compilation unit (e.g., compiled into a .o file by a separate compilation step). To enable more extensive optimization, [[Link Time Optimization|Link Time Optimization (LTO)]] can be used.   * To make decisions on whether to apply some specific optimizations, as well as to provide information (such as code for inlining) required to apply optimizations, the compiler requires visibility into all of the code in the program. This is often not available if some of the code exists in a library that was previously compiled, or is contained in another compilation unit (e.g., compiled into a .o file by a separate compilation step). To enable more extensive optimization, [[Link Time Optimization|Link Time Optimization (LTO)]] can be used.
   * Many optimization decisions are based on a cost-benefit analysis. For example, optimizations such as loop unrolling will often increase performance at the cost of larger code size. In some cases, the usage pattern of the code, such as loop counts and procedure call frequency, is relevant to optimization decisions. [[Profile-Guided Optimization|Profile-Guided Optimization (PGO)]] can assist in making these determinations.   * Many optimization decisions are based on a cost-benefit analysis. For example, optimizations such as loop unrolling will often increase performance at the cost of larger code size. In some cases, the usage pattern of the code, such as loop counts and procedure call frequency, is relevant to optimization decisions. [[Profile-Guided Optimization|Profile-Guided Optimization (PGO)]] can assist in making these determinations.
spo600/compiler_optimizations.1738813396.txt.gz · Last modified: 2025/02/06 03:43 by chris

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki