User`s guide

How the MACRO Compiler Functions on Different Platforms
2.11 Preserving VAX Atomicity and Granularity
For example, the instruction MOVB R1, (R2) generates the following Alpha code
sequence:
LDQ_U R23, (R2)
INSBL R1, R2, R22
MSKBL R23, R2, R23
BIS R23, R22, R23
STQ_U R23, (R2)
If any other code thread modifies part of the data pointed to by (R2) between the
LDQ_U and the STQ_U instructions, that data will be overwritten and lost.
The following Itanium code sequence is generated:
st1 [r28] = r9
If you have specified that granularity be preserved for the same instruction, by
either the command qualifier or the directive, the Alpha code sequence becomes
the following:
BIC R2,#^B0111,R24
RETRY: LDQ_L R28,(R24)
MSKBL R28,R2,R28
INSBL R1,R2,R25
BIS R25,R28,R25
STQ_C R25,(R24)
BEQ R25, FAIL
.
.
.
FAIL: BR RETRY
In this case, if the data pointed to by (R2) is modified by another code thread, the
operation will be retried.
The Itanium code sequence would be unchanged, because the code is already only
writing to the affected memory locations.
For a MOVW R1,(R2) instruction, the Alpha code generated to preserve
granularity depends on whether the register R2 is currently assumed to be
aligned by the compilers register alignment tracking. If R2 is assumed to be
aligned, the compiler generates essentially the same code as in the preceding
MOVB example, except that it uses INSWL and MSKWL instructions instead of
INSBL and MSKBL, and it uses #^B0110 in the BIC of the R2 address. If R2
is assumed to be unaligned, the compiler generates two separate LDQ_L/STQ_C
pairs to ensure that the word is correctly written even if it crosses a quadword
boundary.
Similarly, for Itanium, the compiler will simply generate
st2 [r28] = r9
if the
address is word aligned.
Caution
The code generated for an aligned word write, with granularity
preservation enabled, will cause a fatal reserved operand fault at run
time if the address is not aligned. If the address being written to could
ever be unaligned, inform the compiler that it should generate code that
can write to an unaligned word by using the compiler directive .SET_
REGISTERS UNALIGNED=Rn immediately before the write instruction.
How the MACRO Compiler Functions on Different Platforms 2–25