Real Time Systems Design And Analysis

Chapter 7.6 - Results From Complier Optimization

7.6   RESULTS FROM COMPILER OPTIMIZATION

It is important to experiment with the compiler and to know how it will react
to certain high-order language constructs such as case statements versus nested
if-then-else statements, integer versus character variables, and so on. As
discussed in Chapter 6, a set of extensive test cases should be prepared for the
high-order language in question to expose the intricacies of the compiler.

Moreover, many of the techniques used in code optimization underscore the
fact that in any arithmetic expression there is no substitute for sound mathematical
technique. And it is important to reformulate any algorithm or express to
eliminate time-consuming function calls such as those that compute exponentials,
square roots, and transcendental functions, where possible, to enhance real-time
performance.

Finally, most of the code optimization techniques used by compilers can
be exploited to improve real-time performance. Often these strategies will be
employed invisibly by the compiler, or can be turned on or off with compiler
directives or switches, but it should be known which ones are available. If a
particular strategy is not being used, it can therefore be implemented at the
high-order or assembly language level.

Consider some commonly used optimization techniques and their impact on
real-time performance. These techniques include:

  • Use of arithmetic identities
  • Reduction in strength
  • Common subexpression elimination
  • Use of intrinsic functions
  • Constant folding
  • Loop invariant removal
  • Loop induction elimination
  • Use of revisers and caches
  • Dead-code removal
  • Flow-of-control optimization
  • Constant propagation
  • Dead-store elimination
  • Dead-variable elimination
  • Short-circuit Boolean code
  • Loop unrolling
  • Loop jamming
  • Cross-jump elimination

Many of these techniques are facilitated through the use of peephole optimization.
In peephole optimization a small window or peephole of assembly language code
is compared against known patterns that yield optimization opportunities. These
types of optimizers are easy to implement and allow for multiple optimization
passes to be performed.

7.6.1   Use of Arithmetic Identifies

Good compilers should use arithmetic identities to eliminate useless code. For
example, multiplication by the constant “1” or addition by the constant “0” should
be eliminated from executable code, although the use of symbolic constants can
obscure these situations.

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: PCMCIA Memory Cards
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.