Chapter 7
Code Optimization
©
National Instruments Corporation
7-15
/* {const..4} */
Y->const_4_1 = 2.0*const_2_1;
..
..
Example 7-10
Code Generated with the Constant Propagation Option
void subsys_1(Y)
struct _Subsys_1_out *Y;
{
static RT_INTEGER iinfo[4];
/***** Local Block Outputs. *****/
/******* 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} */
/* ---------------------------- Algebraic Expression */
/* {const..11} */
/* ---------------------------- Sum of Vectors */
/* {const..2} */
/* ---------------------------- Gain Block */
/* {const..4} */
Y->const_4_1 = 4.0;
..
..
In Example 7-10, during code generation time, AutoCode figures out that
the outputs of both the algebraic expressions are constants and feeds them
to the summation block. As all of the inputs to the summation block are
constants (5 and 3), AutoCode computes the output of the summation block
at code generation time (
const_2_1 = 5 - 3 = 2
). This becomes the