08 SVE · gather load
Gather load
Each lane reads the word its own index selects — anywhere in the window, duplicates included.
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
p0/z
z1.s
z0.s
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.
This browser prefers reduced motion. Play still runs the instruction and jumps straight to the result.
Reading the picture
-
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.
-
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.
-
/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}.