-Oncn: Disable Constant Folding in Case of a New Constant

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -Oncn
  
  
Arguments

None

Default

None

Defines

None

Pragmas

None

Description

This option prevents the Compiler from folding constants when the resulting constant is new. The option affects only those processors where constants are difficult to load (for example, RISC processors). On other processors this option makes no change.

Listing: Example (Pseudo Code)


void main(void) {
  int a = 1, b = 2, c, d;

  c = a + b;

  d = a * b;

}

Case (1) without the -Oncn option (pseudo code):

  a MOVE  1

  
  b MOVE  2

  
  c MOVE  3

  
  d MOVE  2

  

Case (2) with the -Oncn option (pseudo code):

  a MOVE  1

  
  b MOVE  2

  
  c ADD   a,b

  
  d MOVE  2

  

The constant 3 is a new constant that does not appear in the source. The constant 2 is already present, so it is still propagated.

Example
  -Oncn