Page 139 - A Practical Guide from Design Planning to Manufacturing
P. 139

112   Chapter Four

        TABLE 4-14  Control Flow Relative Frequency
         Instruction     Integer programs    Floating-point programs
        Branch                75%                    82%
        Jump                   6%                    10%
        Call & return         19%                     8%




          Unconditional jumps always direct execution to a new point in the pro-
        gram. Conditional jumps, also called branches, redirect or not based on
        defined conditions. The same subroutines may be needed by many dif-
        ferent parts of a program. To make it easy to transfer control and then
        later resume execution at the same point, most architectures define call
        and return instructions. A call instruction saves temporary values and
        the instruction pointer (IP), which points to next instruction address,
        before transferring control. The return instruction uses this informa-
        tion to continue execution at the instruction after the call, with the same
        architectural state. When requesting services of the operating system,
        the program needs to transfer control to a subroutine that is part of the
        operating system. An interrupt instruction allows this without requiring
        the program to be aware of the location of the needed subroutine.
          The distribution of control flow instructions measured on the SpecInt
        2000 and SpecFP2000 benchmarks for the DEC Alpha architecture is
                           6
        shown in Table 4-14. Branches are by far the most common control flow
        instruction and therefore the most important for performance.
          The performance of a branch is affected by how it determines whether
        it will be taken or not. Branches must have a way of explicitly or implic-
        itly specifying what value is to be tested in order to decide the outcome
        of the branch. The most common methods of evaluating branch condi-
        tions are shown in Table 4-15.
          Many architectures provide an implicit condition code register that con-
        tains flags specifying important information about the most recently
        calculated result. Typical flags would show whether the results were
        positive or negative, zero, an overflow, or other conditions. By having all
        computation instructions set the condition codes based on their result,
        the comparison needed for a branch is often performed automatically. If
        needed, an explicit compare instruction is used to set the condition codes
        based on the comparison. The disadvantage of condition codes is they
        make reordering of instructions for better performance more difficult
        because every branch now depends upon the value of the condition codes.
          Allowing branches to explicitly specify a condition register makes
        reordering easier since different branches test different registers.

          6
          Hennessy and Patterson, p. 113.
   134   135   136   137   138   139   140   141   142   143   144