HPlogo Getting Started as an MPE/iX Programmer Programmer's Guide: HP 3000 Computer MPE/iX Computer Systems > Chapter 5 Optimizing a Program

Optimizer Assumptions

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

During compilation, a compiler gathers information about the use of variables and passes it to the Optimizer. The MPE/iX Optimizer uses the information to ensure that each code transformation it performs maintains the correctness of the program (at least to the extent that the original unoptimized program is correct).

The compiler assumes that inside a subroutine or function, only the following variables can be accessed directly, indirectly, or by another function call:

  • Common variables declared in this routine.

  • Local variables (static and dynamic).

  • Parameters to this routine.

  • Global variables visible in this routine.

If you have code that violates these assumptions, Optimizer can change the behavior of the program in an undesirable way. Avoid the following coding practices to ensure correct program execution in optimized code:

  • Referencing outside the described bounds of an array. This can cause address corruption or cause the program to abort when it is run.

  • Using variables that can be accessed by a process other than the program, such as shared common variables. The compiler assumes that the program is the only process accessing the data. (HP FORTRAN 77/iX has some exceptions.) HP C/iX, HP Pascal/iX, and HP FORTRAN 77/iX provide compiler options to change the assumptions about a routine.

  • Avoid using variables before they have been initialized. The optimized version of a program may run differently than the unoptimized version.

For detailed information, refer to HP FORTRAN 77/iX Programmer's Guide Supplement (31501-90002) and HP Pascal/iX Programmer's Guide (31502-90002).

Feedback to webmaster