Live Range Splitting

Live range splitting attempts to reduce the number of variables used in a function. This optimization reduces a function's runtime stack size, requiring fewer instructions to invoke the function. This optimization potentially improves execution speed.

The following table explains how to control the optimization for live range splitting.
Table 1. Controlling live range splitting
Turn control this option from here... use this setting
CodeWarrior IDE Choose Level 3 or Level 4 in the Optimization Level settings panel.
source code There is no pragma to control this optimization.
command line -opt level=3, -opt level=4

For example, in the following listing three variables, a, b, and c, are defined. Although each variable is eventually used, each of their uses is exclusive to the others. In other words, a is not referred to in the same expressions as b or c, b are not referred to with a or c, and c is not used with a or b.

Listing: Before live range splitting

void func_from(int x, int y)

{

    int a;

    int b;

    int c;

    a = x * y;

    otherfunc(a);

    b = x + y;

    otherfunc(b);

    c = x - y;

    otherfunc(c);

}

In the following listing, the compiler has replaced a, b, and c, with a single variable. This optimization reduces the number of registers that the object code uses to store variables, allowing more variables to be stored in registers instead of slower memory. This optimization also reduces a function's stack memory.

Listing: After live range splitting

void func_to(int x, int y)

{

    int a_b_or_c;

    a_b_or_c = x * y;

    otherfunc(temp);

    a_b_or_c = x + y;

    otherfunc(temp);

    a_b_or_c = x - y;

    otherfunc(temp);

}