cpu: lift VEX.128 16-bit packed-integer leaf functions #314
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows#314
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Leyukaka on GitHub · 2026-11-21 21:47 UTC · original
Problem
docs/coverage/x64_zen2.tsvlists 256 AVX forms. The only VEX forms in a fixture with a translation test are the seven intests/cpu/heap_layout.asm:vmovd,vmovdqu,vmovups,vpaddd,vpsrldq,vpxorandvzeroupper.tools/ffx_version_query.pylowers them. No translator or open PR handles the 16-bit packed-integer forms:vpaddw,vpsubw;vpsraw,vpsllw;vpunpcklbw,vpunpckhbw,vpunpcklwd,vpunpckhwd;vpackuswb;vpmaxsw,vpminsw;vpmulhw,vpavgw.Proposal
I'd like to take this group, as a new translator
tools/cpu_vex_aot.pyfor Windows x64 leaf functions that use VEX.128 packed-integer forms on 16-byte buffers. The signature is fixed: RCX and RDX point to two 16-byte inputs, R8 to a 16-byte output, and there is no return value.ffx_version_query.pyemits SSE intrinsics for its dword forms; this translator avoids them, so that the reference spells out the lane semantics instead of relying on the host compiler's mapping.vmovdqu/vmovdqaloads and stores,vpxor/vpand/vporandvzeroupper. Any other instruction, a VEX.256 form or another operand kind is rejected with its RVA, as the existing translators do.CPU_FIXTURES.Interfaces touched: a new tool and a new fixture, plus the registration points in
CMakeLists.txtandtools/form_coverage.py, adocs/experiments.mdsection and aREADME.mdrow. The registration points are shared with:I'll rebase around whichever lands first. No translator code is shared with any of them.
Alternatives
ffx_version_query.py. Its vector model is three fixed registers with dword lanes, which suits its call site and the integer fixtures that reuselower. Word lanes, saturation and unpack/pack would widen that model for every caller.Verification
The CTest test calls the native and lifted DLLs on the same 4096 input pairs. These include:
vpavgw;It compares the 16 output bytes and the guard bytes around them. A rebuilt fixture with
vpsrawturned intovpsrlwmust fail the comparison. Translation must reject a VEX.256 form and an unsupported mnemonic.AI-assisted.
@R0Y00 on GitHub · 2026-11-21 21:57 UTC · original
The separate bounded VEX.128 integer leaf fixture is approved. Its ABI is specific to this profile: RCX and RDX point to 16-byte inputs, R8 points to a 16-byte output, and no return bits are guaranteed. Document alignment and allowed aliases; cover read-before-write order for supported alias cases and test
vmovdqaunder its alignment precondition. Reject unmodeled forms and widths. Verify lane-boundary values, guard bytes and mutation controls bit-for-bit. Reuse existing decoding/range-reading logic where appropriate and coordinate the registration sites with #269.@MarlomMedeiros on GitHub · 2026-11-21 22:17 UTC · original
Coordination note: working the broader AVX packed-integer slice now — all ~118 VEX.128 vp* forms plus vmpsadbw/vzeroall/vzeroupper in a dedicated tools/cpu_avx_int_aot.py (same leaf ABI and Vec256 model as the AVX2 translator in #323, disjoint file from cpu_sse_aot.py so #269 registration is unaffected). This issue's approved 16-bit profile lands inside that coverage; will cite #314 in the PR and keep the alias/alignment and read-before-write order guidance.
@Leyukaka on GitHub · 2026-11-21 22:27 UTC · original
@MarlomMedeiros, thanks for the note. Here is where this issue stands:
tools/cpu_vex_aot.pyand thecpu_aot_vex_wordsfixture for the 16-bit forms.vpavgb,vpshufbandvpmaddubsw;vpaddsw,vpmullwandvpandn;vpsrad,vpsrldq,vpslldqandvpshufd;vmovups/vmovaps;vmovq/vmovd, with 8- and 4-byte loads and stores.To avoid two translators for the same forms, could
cpu_avx_int_aot.pyleave these out and take the remainingvp*forms? If you would rather cover everything in one tool, say so, and I'll hold the follow-up until we agree which lands first.AI-assisted.
@MarlomMedeiros on GitHub · 2026-11-21 22:32 UTC · original
Agreed on the split — you were in the VEX.128 space first. cpu_avx_int_aot.py and cpu_avx_move_aot.py will leave the whole #325 scope plus your listed follow-up to cpu_vex_aot.py:
#325 already covers: vmovdqa, vmovdqu, vpackuswb, vpaddd, vpaddw, vpand, vpor, vpxor, vpavgw, vpmaxsw, vpminsw, vpmulhw, vpsllw, vpsraw, vpsrlw, vpsubw, vpunpckhbw, vpunpckhwd, vpunpcklbw, vpunpcklwd, vzeroupper
Follow-up adds: vpavgb, vpshufb, vpmaddubsw, vpaddsw, vpmullw, vpandn, vpsrad, vpsrldq, vpslldq, vpshufd, vmovups, vmovaps, vmovq, vmovd
Our tools take the remaining vp* and AVX bit-move forms (~139) and will explicitly reject the carved-out set so there is exactly one translator per form and no double-counted coverage rows. If your follow-up scope changes, ping the thread and I will adjust the exclusion list before opening.
@Leyukaka on GitHub · 2026-11-21 22:36 UTC · original
Thanks, that split works. One correction to the list:
vpadddis not in #325.cpu_vex_aot.pyrejects it, and the test uses avpaddwpatched intovpadddas a rejection control, so please keepvpadddin your tools. Everything else in both lists matches. I'll open the follow-up after #325 lands, and ping here if its scope changes.AI-assisted.