User`s guide
Preparing to Port Macro-32 Code
1.2 Differences Between the Compiler and the Assembler
$ASSIGN_S DEVNAM=DEVICE,CHAN=CHANNEL
BLBS R0,10$
JSB PROCESS ERROR
HALT
10$:
In this example, the compiler will treat the HALT as an unlikely code path
and detect that the two code streams do not rejoin at 10$. Because of these
conditions, it will determine that the branch is likely to be taken. It will then
move the intervening instructions out of line to the end of the module, change the
BLBS instruction to a BLBC that branches to the moved code, and continue with
in-line code generation at the label 10$, as follows:
$ASSIGN_S DEVNAM=DEVICE,CHAN=CHANNEL
BLBC L1$
10$: .
.
.
(routine exit)
L1$: JSB PROCESS ERROR
HALT
You can change the compiler’s determination of the likelihood of
conditional branches with the compiler directives .BRANCH_LIKELY and
.BRANCH_UNLIKELY (see Section 4.2).
1.2.2 Replicating Code
The compiler might replicate small sections of code multiple times to eliminate
excessive branching. For example, when compiling branches to the following VAX
code, the compiler will replicate the MOVL at each branch to ERROR1 and then
branch directly to COMMON_ERROR.
ERROR1: MOVL #ERROR1,R0
BRW COMMON_ERROR
1.2.3 Removing Code
The compiler’s optimizations might determine that some instructions do not
contribute to the code flow. In such instances, the instructions might be removed.
An example of this is a CMP or TST instruction with no subsequent conditional
branch, such as the following:
CMPB (R2),511(R2)
JSB EXE$SENDMSG
Removal of this CMPB instruction could cause a problem if its purpose was to
touch two memory locations to ensure that the memory pages were faulted in
before calling the routine. This would likely have to be changed in porting to
OpenVMS Alpha or OpenVMS I64 anyway because of the different page sizes of
VAX and Alpha or I64 systems. In addition to changing the page size, you should
replace the instruction with MOVx instructions, such as the following:
MOVB (R2),R1
MOVB 8191(R2),R0
JSB EXE$SENDMSG
Note that the two MOVB instructions operated on two different registers. The
compiler does not currently remove instructions that load values into a register
which is never subsequently read before being overwritten. However, this
optimization might be done in the future.
Preparing to Port Macro-32 Code 1–3