Browse Prior Art Database

Computer Code Path Optimixation Via Source Code Embedded Pragma

IP.com Disclosure Number: IPCOM000106226D
Original Publication Date: 1993-Oct-01
Included in the Prior Art Database: 2005-Mar-20
Document File: 4 page(s) / 134K

Publishing Venue

IBM

Related People

Kreitzer, SS: AUTHOR

Abstract

Described is a software implementation to provide code path optimization for high level language (HLL) compilers via a source code embedded pragma. The optimization allows a programmer to instruct a compiler code generator as to which decision branch is best for optimization. The optimization results in a compiler that can direct a path using the most efficient assembly code possible.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 42% of the total text.

Computer Code Path Optimixation Via Source Code Embedded Pragma

      Described is a software implementation to provide code path
optimization for high level language (HLL) compilers via a source
code embedded pragma.  The optimization allows a programmer to
instruct a compiler code generator as to which decision branch is
best for optimization.  The optimization results in a compiler that
can direct a path using the most efficient assembly code possible.

      In prior art, a code generator randomly picked a branch or
ignored a branch that would be better than another.  For example, a
common construct in structured HLL programs is the IF-THEN-ELSE
block.  Based on the results of a Boolean expression, this construct
would cause HLL statements following either the THEN keyword or the
ELSE keyword to be executed.  Since the architecture of many
processors is such that one path can execute faster than another, if
the HLL compiler knew which code path was most likely to be executed
it could optimize code generation so that the most likely path (MLP)
would also be the quickest path of execution.

      The concept described herein provides a compiler directive
which permits the programmer to specify the MLP of an IF-THEN-ELSE
construct and thereby increase program execution and efficiency.  The
MLP directive provides a means for the programmer to specify
statistically the MLP of an IF statement and to enable the HLL
compiler to generate code which will optimize the execution time of
this path.  This capability provides a degree of code optimization
which is not usually possible with HLL so as to improve programming
performance.

      In prior art, for example, in the following Pascal language
code segment, the value of the variable 'return code' is evaluated
such that if 'return code' is ZERO, the code statement following the
THEN keyword is executed as a written operation, otherwise the
statement following the ELSE clause is executed (retry_operation
procedure):

(1)
        if (return_code = 0) then
            writeln('Operation completed successfully')
        else
            retry_operation();

      From a high-level perspective, it would appear that once the
expression "return_code" = 0" is evaluated, an equal amount of time
would elapse before execution of either the THEN or ELSE clause would
begin.  An inspection of the object code generated by a typical HLL
compiler shows that this is not the case, but rather one leg of the
IF-THEN-ELSE construct will execute more rapidly than the other.
This can be seen in the following example of an un-optimized IF
statement where a segment of the 80186 assembly language code of a
typical HLL compiler can be produced from the source code in (1):

(2)
      cmp  return_code,#0        ;is return_code = 0 ? (10 cycles)
      je   label_1               ;jump to label 1 if rc = 0 (16/4
cyc)
      call re...