dcbz

Data Cache Block Set to Zero

dcbz RA, RB

Zeros out an entire cache block (usually 128 bytes) in memory. Critical for optimizing memory clears (memset).

Details

The dcbz instruction sets all bytes in the block containing the byte addressed by the effective address (EA) to zero. The EA is calculated as the sum of RA and RB. If the specified block is in storage that is neither Write Through Required nor Caching Inhibited, establishing the block in the data cache without fetching it from main storage may provide the best performance.

Pseudocode Operation

if RA = 0 then
    b ← 0
else
    b ← (RA)
ea ← b + (RB)
n ← block size (bytes)
m ← log2(n)
ea ← EA0:63-m || m0
MEM(ea, n) ← n0x00

Programming Note

dcbz does not cause the block to exist in the data cache if the block is in storage that is Caching Inhibited. For storage that is neither Write Through Required nor Caching Inhibited, dcbz provides an efficient means of setting blocks of storage to zero. It can be used to initialize large areas of such storage, in a manner that is likely to consume less memory bandwidth than an equivalent sequence of Store instructions. For storage that is either Write Through Required or Caching Inhibited, dcbz is likely to take significantly longer to execute than an equivalent sequence of Store instructions.

Example

dcbz 0, r3

Encoding

Binary Layout
31
0
/
6
RA
11
RB
16
1014
/
 
Format X-form
Opcode 0x7C0007EC
Extension Base

Operands

  • RA
    Base Address
  • RB
    Index Address