Instruction
VGATHERQPS
Loads singles from memory at addresses formed with a vector of 64-bit indices, for the elements a mask selects.
VGATHERQPS loads singles from scattered addresses, each a base plus a signed 64-bit index times a scale of 1, 2, 4 or 8. VGATHERDPS explains what all gathers share: the mask that selects the elements and is cleared as they load, the register rules that raise #UD, the faults it can resume after, and why compiled code rebuilds the mask before each gather.
A destination half as wide
A 64-bit index fetching a 32-bit element means the destination needs half the width of the index register: four indices in a YMM register fill an XMM destination, and eight in a ZMM register a YMM one, so there is no 512-bit destination. The 128-bit form has two indices and fills only the low half of its XMM destination, zeroing bits 127:64. The cases recorded on Zen 5 show each width:
vgatherqps xmm4, dword ptr [base + ymm9*4], xmm11loaded elements 0 and 3, from indices -10 and 6, whose mask elements had their sign bits set; elements 1 and 2 kept their old values, and XMM11 was cleared, as was everything above bit 127 of both registers;vgatherqps xmm1, dword ptr [base + xmm14*4], xmm8had a sign bit only in mask element 1: it loaded that element, from index -5, kept element 0 and zeroed the upper half of XMM1;vgatherqps ymm17{k5}, dword ptr [base + zmm30*1]read seven of its eight elements, those K5 selected, from the byte offsets 21 and 32, several times each, and 54, two of them not multiples of 4; element 3, whose mask bit was clear, kept its value, and K5 ended as zero.
In compiled code
In our builds at -O2, and at -O3 with -march=znver5, neither GCC 14
nor Clang 23 vectorized d[i] = t[idx[i]] over float data with
int64_t indices for -march=x86-64-v3, x86-64-v4, skylake or
znver5: only the intrinsics give the instruction. For
_mm256_i64gather_ps, Clang makes the all-ones mask with VPCMPEQD and
zeroes the destination with VXORPS first; GCC makes the mask with
VCMPEQPS. For _mm512_i64gather_ps with -march=x86-64-v4, both make
an all-ones K1 with KXNORB, eight bits for eight
elements; for znver5, GCC loads it from a constant with KMOVB instead.
AMD’s latency spreadsheet for Zen 5 lists VGATHERQPS as microcoded, as it does every gather. VGATHERQPD loads doubles with 64-bit indices and fills its whole destination.
In the optimization guide
What the optimization guide says about VGATHERQPS, a line per claim. Each links to the claim in the guide, with its sources and where they differ.
Vectors
- Gathers and scatters: Where the layout of the data is known, vector loads and shuffles usually beat a gather.
- Gathers and scatters: Issue gathers early, gather many elements at once, use doubleword indices for 32-bit data and zero the destination first.
- Gathers and scatters: Gathers beat scalar loads on Skylake, while AMD lists them as microcode on Zen 3, Zen 4 and Zen 5.
Crestmont and Gracemont
- Vectors and AVX2: Gathers are microcoded on these cores and take about 50 cycles.
Golden Cove and Raptor Cove
- Vectors, AVX-512 and AMX: A gather is a load micro-op for each element plus a few more: LLVM’s models give an eight-element VPGATHERDD 12 micro-ops and a latency of 30 cycles, and the 16-element one of Sapphire Rapids 19 micro-ops.
Haswell and Broadwell
- Gathers: Haswell is the first core with gathers, and each one runs as many micro-ops; Broadwell runs them much faster.
Skylake to Cooper Lake
- Vectors on all parts: Gathers are faster than on Broadwell and beat a sequence of scalar loads unless they fetch only two elements or the data comes from memory rather than the caches.
Zen 2
- Vectors and floating point: Gathers such as VPGATHERDD are microcoded, in AMD’s spreadsheet and LLVM’s model, so vector loads and shuffles beat them when the indices are known in advance.
Zen 3
- Vectors and floating point: Gathers such as VPGATHERDD are microcoded, and a register loaded in pieces is slower than one full-width load, so vector loads and shuffles beat both when the indices are known in advance.
Zen 4
- Vectors and floating point: A gather is slower than vector loads and shuffles when the indices are known in advance, and a register loaded in pieces is slower than one full-width load.
Zen 5
- Vectors and floating point: A gather is slower than vector loads and shuffles when the indices are known in advance.
Forms
| Instruction | Encoding | Requires |
|---|---|---|
VGATHERQPS xmm, vm64y, xmm
VGATHERQPS_XMMf32_MEMf32_XMMi32_VL256 | VEX.256.66.0F38.W0 93 /r | AVX2 |
VGATHERQPS xmm, vm64x, xmm
VGATHERQPS_XMMf32_MEMf32_XMMi32_VL128 | VEX.128.66.0F38.W0 93 /r | AVX2 |
VGATHERQPS ymm {k}, vm64z
VGATHERQPS_YMMf32_MASKmskw_MEMf32_AVX512_VL512 | EVEX.512.66.0F38.W0 93 /r | AVX10.1 or AVX512F |
VGATHERQPS xmm {k}, vm64x
VGATHERQPS_XMMf32_MASKmskw_MEMf32_AVX512_VL128 | EVEX.128.66.0F38.W0 93 /r | AVX10.1 or AVX512F + AVX512VL |
VGATHERQPS xmm {k}, vm64y
VGATHERQPS_XMMf32_MASKmskw_MEMf32_AVX512_VL256 | EVEX.256.66.0F38.W0 93 /r | AVX10.1 or AVX512F + AVX512VL |
Latency and throughput
| Model | xmm, vm64y, xmm | xmm, vm64x, xmm | ymm {k}, vm64z | xmm {k}, vm64x | xmm {k}, vm64y |
|---|---|---|---|---|---|
| Haswell | 17 / 5p0156 | 16 / 3.67p0156 | |||
| Broadwell | 19 / 4p0156 | 19 / 5p0156 | |||
| Skylake | 20 / 2p015 | 18 / 1p015 | |||
| Skylake-SP, Ice Lake | 20 / 2p015 | 18 / 1p015 | 21 / 4p0156 | 17 / 1p0156 | 19 / 2p0156 |
| Alder Lake | 29 / 1.33p015 | 20 / 1p015 | |||
| Sapphire Rapids | 29 / 1.33p015 | 20 / 1p015 | 28 / 2.67p05 | 20 / 1p015 | 28 / 1.33p015 |
| Lunar Lake | 29 / 1.33V0 V1 V2 V3 p1 p3 p5 | 20 / 0.67V0 V1 V2 V3 p1 p3 p5 | |||
| Zen, Zen 2 | 100 / 0.25 | 100 / 0.25 | |||
| Zen 3 | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | |||
| Zen 4 | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load | 5 / 0.33AGU0 AGU1 AGU2 LSU Load |
Data flow
Where the elements of the sources go, element 0 on the right; results that depend on a control value are drawn for an example. How to read.
Example: indices 0, 11, 2, 5 from element 3 down, mask xmm3 = 0x0F; memory elements are numbered from the base address in units of the scale. The other forms gather 2 elements, one for each index. The AVX2 forms take the mask from the sign bits of a vector register; the mask is cleared as the elements complete.
With the example indices (m followed by the memory element), result singles 3 to 0: m0, m11, m2, m5.
Example: indices 3, 14, 7, 7, 0, 11, 2, 5 from element 7 down, mask k1 = 0xDF; memory elements are numbered from the base address in units of the scale. The other forms gather 2 and 4 elements, one for each index. The mask is cleared as the elements complete.
With the example indices (m followed by the memory element), result singles 7 to 0: m3, m14, unchanged, m7, m0, m11, m2, m5.
Operation
What the forms do, in pseudocode that our tests run against results recorded on real processors. How to read.
x = mem.index.number
if x in (xmm1.number, xmm3.number):
fault(UD)
if xmm1.number == xmm3.number:
fault(UD)
for i in range(VL // 64):
if xmm3.sd[i] < 0:
a = mem.index.sq[i] * mem.scale
xmm1.d[i] = load(mem.base + a, 32)
for i in range(VL // 64, 4):
xmm1.d[i] = 0
xmm3.write(0)
# xmm1 is zeroed from bit 128 upRun on AMD Zen 5 (EPYC 9645): 2 cases.
if mem.index.number == ymm1.number:
fault(UD)
for i in range(VL // 64):
if k1[i]:
a = mem.index.sq[i] * mem.scale
ymm1.d[i] = load(mem.base + a, 32)
for i in range(VL // 64, 4):
ymm1.d[i] = 0
k1.write(0) # all of it
# ymm1 is zeroed from bit 128 (xmm) or 256 (ymm) upRun on AMD Zen 5 (EPYC 9645): 3 cases.
Operands
| Operand | Kind | Action |
|---|---|---|
VGATHERQPS xmm, vm64y, xmm VGATHERQPS xmm, vm64x, xmm | ||
xmm | explicit | conditional read, write |
vm64y, vm64x | explicit | read |
xmm | explicit | read, write |
VGATHERQPS xmm {k}, vm64x VGATHERQPS xmm {k}, vm64y VGATHERQPS ymm {k}, vm64z | ||
xmm, ymm | explicit | write (masked) |
{k} | explicit | read, write (write mask) |
vm64x, vm64y, vm64z | explicit | read |
Flags
None: XED records no flag that the forms test or change.
Exceptions
The exception class is XED's name for the set of exception conditions that a form follows. How to read.
- VEX forms
avx-type-12- EVEX forms
AVX512-E12
Attributes
What else XED records about the forms. How to read.
- All forms
- gather
- EVEX forms
- write masking; memory fault suppression
Intrinsics
The C intrinsics of Clang 23.1.2 that compile to VGATHERQPS, each with the form it compiles to and the Clang options it needs. The forms come from compiling every intrinsic and decoding the result with Intel XED; all intrinsics A–Z explains the method.
| Intrinsic | Compiles to |
|---|---|
_mm_i64gather_ps
__m128 _mm_i64gather_ps(float const *m, __m128i i, const int s) |
|
_mm_mask_i64gather_ps
__m128 _mm_mask_i64gather_ps(__m128 a, float const *m, __m128i i, __m128 mask, const int s) |
|
_mm_mmask_i64gather_ps
__m128 _mm_mmask_i64gather_ps(__m128 v1_old, __mmask8 mask, __m128i index, void const *addr, const int scale) |
|
_mm256_i64gather_ps
__m128 _mm256_i64gather_ps(float const *m, __m256i i, const int s) |
|
_mm256_mask_i64gather_ps
__m128 _mm256_mask_i64gather_ps(__m128 a, float const *m, __m256i i, __m128 mask, const int s) |
|
_mm256_mmask_i64gather_ps
__m128 _mm256_mmask_i64gather_ps(__m128 v1_old, __mmask8 mask, __m256i index, void const *addr, const int scale) |
|
_mm512_i64gather_ps
__m256 _mm512_i64gather_ps(__m512i index, void const *addr, const int scale) |
|
_mm512_mask_i64gather_ps
__m256 _mm512_mask_i64gather_ps(__m256 v1_old, __mmask8 mask, __m512i index, void const *addr, const int scale) |
|
CPUID and processors
Each form belongs to an XED ISA set. A form can be used when the processor reports every CPUID bit of one of its ISA set's alternatives.
More AVX2 instructions
- VBROADCASTI128
- VBROADCASTSD
- VBROADCASTSS
- VEXTRACTI128
- VGATHERDPD
- VGATHERDPS
- VGATHERQPD
- VINSERTI128
- VMOVNTDQA
- VMPSADBW
- VPABSB
- VPABSD
- VPABSW
- VPACKSSDW
- VPACKSSWB
- VPACKUSDW
- VPACKUSWB
- VPADDB
- VPADDD
- VPADDQ
- VPADDSB
- VPADDSW
- VPADDUSB
- VPADDUSW
- VPADDW
- VPALIGNR
- VPAND
- VPANDN
- VPAVGB
- VPAVGW
- VPBLENDD
- VPBLENDVB
- VPBLENDW
- VPBROADCASTB
- VPBROADCASTD
- VPBROADCASTQ
- VPBROADCASTW
- VPCMPEQB
- VPCMPEQD
- VPCMPEQQ
More AVX10.1 instructions
- VFNMSUB213PH
- VFNMSUB213PS
- VFNMSUB213SD
- VFNMSUB213SH
- VFNMSUB213SS
- VFNMSUB231PD
- VFNMSUB231PH
- VFNMSUB231PS
- VFNMSUB231SD
- VFNMSUB231SH
- VFNMSUB231SS
- VFPCLASSPD
- VFPCLASSPH
- VFPCLASSPS
- VFPCLASSSD
- VFPCLASSSH
- VFPCLASSSS
- VGATHERDPD
- VGATHERDPS
- VGATHERQPD
- VGETEXPPD
- VGETEXPPH
- VGETEXPPS
- VGETEXPSD
- VGETEXPSH
- VGETEXPSS
- VGETMANTPD
- VGETMANTPH
- VGETMANTPS
- VGETMANTSD
- VGETMANTSH
- VGETMANTSS
- VGF2P8AFFINEINVQB
- VGF2P8AFFINEQB
- VGF2P8MULB
- VINSERTF32X4
- VINSERTF32X8
- VINSERTF64X2
- VINSERTF64X4
- VINSERTI32X4
Sources
- Intel XED v2026.08.23 (commit
0bcb6237345c): forms, encodings, operands, flags, exception classes, attributes, ISA sets, CPUID bits and chip model. - The CPU data of x86-64.net: Zen 3 to Zen 6, from GCC’s
-marchfeature sets and AMD’s Processor Programming References, which the page of each processor cites. - Clang's x86 intrinsic headers, LLVM 23.1.2 (commit
85ac56026243): the intrinsics, their signatures and doc comments, and the Clang of that release, which compiled each of them. - LLVM 23.1.2's x86 scheduling models (commit
85ac56026243): the latency, reciprocal throughput and ports of each form, as llvm-mca reports them. - Intel 64 and IA-32 Architectures Software Developer's Manual, Volume 2 (325383-093, September 2026): Volume 2C, page 5-365 (VGATHERDPS/
VGATHERQPS) ; Volume 2C, page 5-369 (VGATHERQPS/VGATHERQPD) - Intel Advanced Vector Extensions 10.2 Architecture Specification, revision 7.0 (361050-007, April 2026)
- Software Optimization Guide for the AMD Zen5 Microarchitecture (58455, rev. 1.00, August 2024), Wayback Machine copy of AMD's ZIP
The tables are derived from Intel XED, Copyright Intel Corporation, licensed under the Apache License 2.0; x86-64.net converted and reformatted them. The intrinsics and their signatures come from Clang and the timings from LLVM's scheduling models, both part of the LLVM Project, licensed under the Apache License 2.0 with LLVM Exceptions. The text is our own.