Fix upper ZMM clearing for EVEX.512 VGATHERQPS and VPGATHERQD #852
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.45) × (1 − Review Confidence (0.30)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 412 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 27% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.360
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #852"
general
weight: 0.35
stlintel
Problem
The shared handler for
VGATHERQPSandVPGATHERQDuses the encodedvector-length value to clear the portion of the architectural destination
above its logical dword result:
The vector-length constants are encoded as
BX_VL128 = 1,BX_VL256 = 2, andBX_VL512 = 4. Decrementing the 256-bit value mapsit to
BX_VL128, but decrementing the 512-bit value produces3.BX_CLEAR_AVX_REGZrecognizes only the 128- and 256-bit constants, soit performs no clearing for that value.
Consequently, EVEX.512
VGATHERQPSandVPGATHERQDleave destinationbits 511:256 unchanged after successful completion. These instructions
produce eight dword results from eight qword indices, so their logical
result occupies only the low 256 bits of the ZMM destination.
Fix
Shift the vector-length value right by one instead of decrementing it.
This maps each index-vector length to the corresponding dword-result
length:
BX_VL256becomesBX_VL128BX_VL512becomesBX_VL256The existing special handling for
BX_VL128remains unchanged. Theshared handler therefore clears the correct upper destination portion
for both instruction families and all supported vector lengths.
Architectural reference
The Intel® 64 and IA-32 Architectures Software Developer's Manual,
Volume 2, sections “VGATHERQPS—Gather Packed Single Precision
Floating-Point Values Using Signed Qword Indices” and
“VPGATHERQD—Gather Packed Dword Values Using Signed Qword Indices,”
specifies
DEST[MAXVL-1:VL/2] := 0for these forms.For an EVEX.512 operation, the eight gathered dwords occupy destination
bits 255:0 and bits 511:256 must be zero after successful completion.
Validation
A standalone 64-bit CPL3 guest exercised the gather forms on the Bochs
tigerlakeCPU model with AVX-512 state enabled (XCR0=0xe7).Destinations were initialized with distinctive nonzero values so that
retained upper bits were directly observable.
The zero-mask cases complete without reading memory and isolate the
architectural merge and upper-clearing behavior. The active-mask
VPGATHERQDcase used ordinary mapped memory, verified the gathereddwords and preserved inactive low lanes, and then checked that bits
511:256 were cleared.
| Instruction | Vector length | Mask | Before | After |
|---|---:|---:|---:|---:|
|
VPGATHERQD| 512 | zero | FAIL | PASS ||
VPGATHERQD| 512 | active (0xa5) | FAIL | PASS ||
VGATHERQPS| 512 | zero | FAIL | PASS ||
VPGATHERQD| 256 | zero | PASS | PASS ||
VPGATHERQD| 128 | zero | PASS | PASS ||
VPGATHERQQ| 512 | zero | PASS | PASS |The 128- and 256-bit
VPGATHERQDcases verify the neighboring logicalresult widths. The 512-bit
VPGATHERQQcontrol verifies that a gatherwhose qword results fill the complete ZMM destination remains unchanged.
The source file used by the patched test build exactly matches the
committed source. The patched tree builds successfully with
make -j2,and
git diff --checkpasses.