What is the usage of optimization pragmas in VisualDSP?
The optimization pragmas apply the same optimization techniques that occur on source files using the -O procedural optimisation compiler switch.
If no optimization is applied the compiled code will produced a literal line-by-line translation of the source code. When optimization is applied the compiler is free to rearrange the code as necessary to obtain the desired optimisation result. Adding the pragma to a function will cause the chosen optimization settings to be applied to all following functions until another optimization pragma (optimize_for_space, optimize_as_cmd_line) changes the setting.
If optimizing for speed this may include changes such as discarding local variables, implementing hardware loops and rearranging memory accesses to achieve multiple read/writes or operations per cycle. Any changes made will of course be dependent upon the source code. More detailed information about the optimization techniques that may applied by the compiler can be found throughout the 'Achieving Optimal Performance From C/C++ Source Code' chapter in the VisualDSP++ C/C++ Compiler Manual.
To determine exactly what optimisations the compiler has performed the generated assembly can be examined by building using the -S switch or by checking the Project Options->Compile->General->Save temporary files option in the VisualDSP++ IDDE. Refer to the subsection 'Assembly Optimizer Annotations' in 'Achieving Optimal Performance From C/C++ Source Code' for more information.