2 ACHIEVING OPTIMAL
PERFORMANCE FROM
C/C++ SOURCE CODE
This chapter provides guidance to help you to tune your application to
achieve the best possible code from the compiler. Some implementation
choices are available when coding an algorithm, and understanding their
impact is crucial to attaining optimal performance.
The focus of what follows is on how to obtain maximal code performance
from the compiler. Most of these guidelines also apply when optimizing
for minimum code size, although some techniques specific to that goal are
also discussed. The first section looks at some general principles, and how
the compiler can lend the most help to your optimization effort. Optimal
coding styles are then considered in detail. Special features such as com-
piler switches, built-in functions, and pragmas are also discussed. The
chapter ends with a short example to demonstrate how the optimizer
works.
Small examples are included throughout this chapter to demonstrate
points being made. Some show recommended coding styles, others iden-
tify styles to be avoided or code that it may be possible to improve. These
are marked as "Good" and "Bad", respectively.
This chapter contains:
•
"General Guidelines" on page 2-3
•
"Loop Guidelines" on page 2-17
•
"Using Built-In Functions in Code Optimization" on page 2-25
•
"Smaller Applications: Optimizing for Code Size" on page 2-29
VisualDSP++ 3.5 C/C++ Compiler and Library Manual
for ADSP-219x DSPs
2-1
Need help?
Do you have a question about the VISUALDSP++ 3.5 and is the answer not in the manual?
Questions and answers