All instructions

08 SVE · gather load

Gather load

Each lane reads the word its own index selects — anywhere in the window, duplicates included.

Instruction
ld1w { z0.s }, p0/z, [x0, z1.s, sxtw #2]

Types: z0.s — 32-bit float, 4 lanes; z1.s — 32-bit signed indices, scaled ×4; mem words are 32 bits. Drawn at SVL = 128 bits; at SVL = 512 sixteen lanes each read their chosen word.

mem

[x0]5
[x0,#4]2
[x0,#8]9
[x0,#12]7
[x0,#16]4
[x0,#20]8

p0/z

z1.s

z0.s

3 6 1 5

z0.s[i] ← mem[x0 + 4 × z1.s[i]]

Ready. Each lane will read the word its index in z1.s selects.

Arrow keys step, space plays or pauses.

Reading the picture

  1. Every lane picks its own address

    The contiguous ld1w walks memory in step with the lanes. The gather form hands the offsets to a vector: lane i reads mem[x0 + 4 × z1.s[i]], wherever that lands. sxtw #2 is the sign-extension and ×4 scale.

  2. Duplicates are fine

    Two lanes may carry the same index. When they do, watch one word light up twice — each lane still gets its own copy of it.

  3. /z, and nothing extra

    As on the ld1w page, an inactive lane is filled with zero and reads nothing. Only the words actually indexed are touched, however scattered the indices are — that is the whole point of a gather. Toggle a predicate bit to see a lane stop reading.

This pass reads {5, 2, 9, 7, 4, 8} with indices z1.s = {0, 3, 0, 4}.