-Ous, -Ou, and -Onu: Optimize Dead Assignments

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -O(us|u|nu)
  
  
Arguments

us: yes, but never if HLI present in function (default)

u: always (even if HLI is present in function)

nu: never

Default

-Ous: Optimization enabled for functions containing no inline assembler code

Defines

None

Pragmas

None

Description

Optimizes dead assignments. The Compiler removes assignments to unused local variables.

There are three possible settings for this option: -Ou is given, -Onu is given, or -Ous is given:

-Ou: Always optimize dead assignments (even if HLI is present in current function). The Compiler does not consider inline assembler accesses.

Note: This option is unsafe when inline assembler code contains accesses to local variables.

-Onu: No optimization occurs. This generates the best possible debug information, and produces larger and slower code.

-Ous: Optimize dead assignments if HLI is not present in the current function.

Note: The compiler is not aware of longjmp() or setjmp() calls. These and similar functions may generate a control flow which the Compiler does not recognize. Therefore, either do not use local variables in functions using longjmp() or setjmp() or use -Onu to switch this optimization off.
Note: Dead assignments to volatile declared global objects are never optimized.
Example
  void main(int x) {

  
    f(x);

  
    x = 1; /* this assignment is dead and is

  
              removed if -Ou is active */

  
  }