RAD Studio (Common)
ContentsIndex
PreviousUpNext
C++ Compiler Optimizations

ProjectOptionsC++ CompilerOptimizations 

Use this dialog box to set C++ Compiler Optimization options.

Build Configuration options 
Description 
Build Configuration 
Displays the name of the current build configuration associated with the options on this page. There are three default build configurations: Base, Debug, and Release.  
Apply Options... 
Displays the Apply Option Set dialog box to apply the options in a named option set to the current configuration.  

 

Common items 
Description 
Value from <parent configuration or option set> 
Indicates the value in the parent build configuration or referenced option set. If you change this value here, the change will potentially affect the Base configuration (that is, if you click OK on the Project->Options dialog and subsequently build your project).  
<any item in red print> 
Indicates that this option has secondary options available. To view the secondary options, click the + sign in front of the option in red.  
<any item in boldface print> 
Indicates that the value of this option has been changed from the value in the parent configuration or referenced option set.  
Down Arrow Pop-Up Button 
Appears after you click an option that has a set of available choices (such as True, False). Click Down Arrow to display and choose the value you want from the available choices.  

 

Optimizations options 
Description 
Disable all optimizations (-Od)* 
Disables all optimization settings, including ones which you may have specifically set and those that would normally be performed as part of the speed/size trade-off.
Because this disables code compaction (tail merging) and cross-jump optimizations, using this option can keep the debugger from jumping around or returning from a function without warning, which makes stepping through code easier to follow.
Default = True  
Enable selected optimizations 
Enables only the optimizations that you select from the secondary list of optimizations. Default = False  
Dead store elimination (-Ob) 
Click the down-arrow to select from the possible values (True, False). Default = False  
Eliminate duplicate expressions within basic blocks and functions (-Oc) 
Instructs the compiler to eliminate common subexpressions within groups of statements unbroken by jumps (basic blocks) and functions. This option globally eliminates duplicate expressions within the target scope and stores the calculated value of those expressions once (instead of recalculating the expression). Use this option if you prefer to reuse expressions rather than create explicit stack locations for them.
Default = False  
Enable loop induction variable and strength reduction (-Ov)  
Instructs the compiler to create induction variables and perform strength reduction, which optimizes for loops speed. Use this option when you're compiling for speed and your code contains loops.
The optimizer uses induction to create new variables (induction variables) from expressions used in loops. The optimizer assures that the operations performed on these new variables are computationally less expensive (reduced in strength) than those used by the original variables.
Optimizations are common if you use array indexing inside loops, because a multiplication operation is required to calculate the position in the array that is indicated by the index. For example, the optimizer creates an induction variable out of the operation v[i] in the following code because the v[i] operation requires multiplication. This optimization also eliminates the need to preserve the value of i:
int v[10]; void f(int x, int y, int z) { int i; for (i = 0; i < 10; i++) v[i] = x * y * z; }
With induction variables set, the code changes:
int v[10]; void f(int x, int y, int z) { int i, *p; for (p = v; p < &v[9]; p++) *p = x * y * z; }
Default = False  
Enable Pentium instruction scheduling (-5) 
Generates Pentium instructions.
While this option increases the speed at which the application runs on Pentium machines, expect the program to be a bit larger than when compiled with the 80386 or i486 options. In addition, Pentium-compiled code sustains a performance hit on non-Pentium systems. Default = False  
Expand common intrinsic functions (-Oi) 
Instructs the compiler to generate the code for common memory functions like strcpy() within your function's scope. This eliminates the need for a function call. The resulting code executes faster, but it is larger.
The following functions are inlined with this option:
alloca, fabs, memchr, memcmp, memcpy, memset, rotl, rotr, stpcpy, strcat, strchr, strcmp, strcpy, strlen, strncat, strncmp, strncpy, strnset, strrchr.
You can control the inlining of these functions with the pragma intrinsic. For example, #pragma intrinsic strcpy causes the compiler to generate inline code for all subsequent calls to strcpy in your function, and #pragma intrinsic -strcpy prevents the compiler from inlining strcpy. Using these pragmas in a file overrides any compiler option settings.
Default = False  
Optimize jumps (-O) 
Instructs the compiler to reduce the code size by eliminating redundant jumps and reorganizing loops and switch statements. When this option is set, the sequences of stepping in the debugger can be confusing because of the reordering and elimination of instructions. If you are debugging at the assembly level, you might want to disable this option.
Default = False  
Use register variables (-r) 
Instructs the compiler to automatically assign register variables if possible, even when you do not specify a register variable by using the register keyword.
Default = False  
 
 
Generate fastest possible code (-O2) 
This switch sets an aggregate of optimization options that tells the compiler to optimize your code for speed. Default = False  
Generate smallest possible code (-O1) 
Sets an aggregate of optimization options that tells the compiler to optimize your code for size. For example, the compiler scans the generated code for duplicate sequences. When such sequences warrant, the optimizer replaces one sequence of code with a jump to the other and eliminates the first piece of code. This occurs most often with switch statements. The compiler optimizes for size by choosing the smallest code sequence possible. Default = True  

 

General option 
Description 
Default 
Saves the current settings as the default for each new project.  
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!