-Or: Allocate Local Variables into Registers

Group

OPTIMIZATIONS

Scope

Function

Syntax
  -Or
  
  
Arguments

None

Default

None

Defines

__OPTIMIZE_REG__

Pragmas

None

Description

Allocate local variables ( char or int) in registers. The number of local variables allocated in registers depends on the number of available registers. Use this option when using variables as loop counters or switch selectors or when the processor requires register operands for multiple operations (for example, RISC processors). Compiling with this option may increase your code size (spill and merge code).

Note: This optimization may increase code complexity when using High-Level Languages, making debugging more difficult.
Note: For some backends this option has no effect and code does not change.
Listing: Allocate Local Variables into Registers Example


-Or
int main(void) {

  int a,b;

  return a + b;

}

Case (1) without option -Or (pseudo code):

tmp1 LD    a

tmp2 LD    b

tmp3 ADD   tmp1,tmp2

     RET   tmp3

Case (2)with option -Or (pseudo code):

tmp1 ADD a,b

RET tmp1