Chapter 7 Code Optimization
AutoCode Reference 7-14 ni.com
All of the blocks can accept constants as inputs. If any input is available
during code generation time as a constant, the constant is used instead of a
symbol name (or variable name). This applies to blocks of both categories.
One limitation to this optimization is that a block cannot propagate
constants or even accept constants as inputs if its inputs or outputs contain
vectors. Such blocks with vector inputs or outputs use only the variable
name (or symbol name) and hence force the source blocks to generate code
for computing the value of output variables.
Example 7-9 shows code generated without constant propagation, and
Example 7-10 shows code generated with constant propagation.
Example 7-9 Code Generated without the Constant Propagation Option
void subsys_1(Y)
struct _Subsys_1_out *Y;
{
static RT_INTEGER iinfo[4];
/***** Local Block Outputs. *****/
RT_FLOAT const_1_1;
RT_FLOAT const_11_1;
RT_FLOAT const_2_1;
/******* Initialization. *******/
if (SUBSYS_PREINIT[1]) {
iinfo[0] = 0;
iinfo[1] = 1;
iinfo[2] = 1;
iinfo[3] = 1;
SUBSYS_PREINIT[1] = FALSE;
return;
}
/***** Output Update. *****/
/* ---------------------------- Algebraic Expression */
/* {const..1} */
const_1_1 = 5.0;
/* ---------------------------- Algebraic Expression */
/* {const..11} */
const_11_1 = 3.0;
/* ---------------------------- Sum of Vectors */
/* {const..2} */
const_2_1 = const_1_1 - const_11_1;
/* ---------------------------- Gain Block */