Vax performance V-008 SP User's Guide Page 93

  • Download
  • Add to my manuals
  • Print
  • Page
    / 176
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 92
Improving the Performance of Ported Code
4.2 Code Flow and Branch Prediction
4.2.5 Forward Jumps into Loops
Because of the way that the compiler follows the code flow, a particular case that
may not compile well is a forward unconditional branch into a loop. The code
generated for this case usually splits the loop into two widely separated pieces.
For example, consider the following macro coding construct:
(Allocate a data block and set up initial pointer)
BRB 20$
10$: (Move block pointer to next section to be moved)
20$: (Move block of data)
(Test - is there more to move?)
(Yes, branch to 10$)
(Remainder of routine)
The MACRO compiler will follow the BRB instruction when generating the
code flow and will then fall through the subsequent conditional branch to 10$.
However, because the code at 10$ was skipped over by the BRB instruction, it
will not be generated until after the end of the routine. This will convert the
conditional branch into a forward branch instead of a backward branch. The
generated code layout will look like the following:
(Allocate a data block and set up initial pointer)
20$: (Move block of data)
(Test - is there more to move?)
(Yes, branch to 10$)
.
.
(Remainder of routine)
(Routine exit)
.
.
10$: (Move block pointer to next section to be moved)
BRB 20$
This results in the loop being very slow because the branch to 10$ is always
predicted not taken, and the code flow has to keep going back and forth between
the two locations. This situation can be fixed by inserting a .BRANCH_LIKELY
directive before the conditional branch back to 10$. This will result in the
following code flow:
(Allocate a data block and set up initial pointer)
20$: (Move block of data)
(Test - is there more to move?)
(No, branch to $L1)
10$: (Move block pointer to next section to be moved)
BRB 20$
$L1:
(Remainder of routine)
4.3 Code Optimization
The MACRO compiler performs several optimizations on the generated code. It
performs all of them by default except VAXREGS. (VAXREGS is OpenVMS Alpha
systems only.) You can change these default values with the /OPTIMIZE switch
on the command line. The valid options are:
ADDRESSES
The compiler recognizes that the same address is referenced multiple times,
and only loads the address once for use by multiple references.
Improving the Performance of Ported Code 4–7
Page view 92
1 2 ... 88 89 90 91 92 93 94 95 96 97 98 ... 175 176

Comments to this Manuals

No comments