cpu: lower PF consumers after VEX scalar compares #1181
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1188"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by Batushn on 2026-11-24T02:59:34Z.
Change
Fixes #1153.
Allow PF consumers (
SETP,SETNP,CMOVP,CMOVNPalongsideJP,JNP,FCMOVU,FCMOVNU) after modeled PF producers, including the four scalar VEX compares (VCOMISS,VUCOMISS,VCOMISD,VUCOMISD), wheneverx87_lower.check_flagsproves a reaching modeled PF definition at every use.SETP,SETNP,CMOVP,CMOVNPtoGATED; addedVEX_SCALAR_COMPARES(VCOMISS,VUCOMISS,VCOMISD,VUCOMISD) and already-loweredPF_CLEAREDinstructions (RDRAND,RDSEED,PTEST,VPTEST,VTESTPS,VTESTPD,PCMPESTRI,PCMPESTRM,PCMPISTRI,PCMPISTRM) toassigns_parity(i); threadedskip_lahfandhost_opsinto_after,states, andcheck_flags; preserved existing error prefixes (reads PF, which the integer lowering models only after ...).SETP/SETNP/CMOVP/CMOVNPonx87_lower.check_flags(rejecting indirect branches and wrapping non-x87ValueErrorin"unsupported query operation: ..."sointeger_flags_checkstays intact) and loweredCMOVP/CMOVNPandSETP/SETNPusing existingwrite/guesteager-read & 32-bit zero-extension paths. Functions without PF consumers keep unchanged parity-free C++.cpu_aot_vex_paritydifferential fixture comparing native, translated, and/O2DLLs across 14 exports and 1618 cases.setp/cmovpexpectations afterfucomiand documentedcpu_aot_vex_parity.Verification
Commit
e132e45(based onmain063df2c) onAMD64 Family 25 Model 116 Stepping 1, AuthenticAMD(Windows, VS 2022 BuildToolscl19.44.35229.0):ctest --preset dev --no-tests=error -R "^cpu_aot_(vex_parity|x87_parity|x87_compare|x87_status|x87_fcmov|integer_flags|avx_scalar_fp|cmov_setcc|lower_dead_reads)$" --output-on-failure: 9/9 passed (cpu_aot_vex_parity+ all related flag/parity/AVX/CMOV/fault tests).ctest --preset release --no-tests=error -R "^cpu_aot_vex_parity$" -V: 1/1 passed:rejected 13 negative PF cases, accepted 4 positive sequences, and preserved parity-free loweringcontrol stalepf: caught 3 deliberate PF mismatchescontrol swap: caught 5 deliberate PF mismatches1618 VEX scalar compare / PF consumer cases (masked MXCSR 0x1f80, qNaN/sNaN in both operands, 32/64/16-bit CMOVP/CMOVNP, fault checks, CFG joins) matched native, translated, and /O2 DLLs.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py: passed..\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py:Checked 15 Markdown files and 255 links..\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py:Checked 951 tracked source, script and build/CI files: no bidirectional controls.Evidence and follow-up
; coverage: source cpu_aot_vex_parity).vcomiss,vucomiss,vcomisd,vucomisdare checked under documented maskedMXCSR = 0x1F80(saved/restored viahost_exchange_mxcsr), with quiet and signaling NaNs in each operand,+/-0.0,+/-inf, subnormals, and ordered pairs (<,==,>). Floating-point exception behavior outsidevex_parityis unchanged.cmovp/cmovnpare verified for both PF outcomes at 32-bit (upper 32 bits cleared even when condition is false), 64-bit, and 16-bit widths, plus unconditional memory reads (0xC0000005onPAGE_NOACCESSandNULLviacpu_guarded_call) for bothPF=0andPF=1in Debug, Release, and/O2.stalepfdroppingparity = unordered;,swapreversing PF consumer conditions) both fail as required, and 13 negative lowering cases (entry/no writer,add,cmp,inc, 32-bittest,shl,call, ambiguous/uninitialized joins, indirect branch,host_ops) remain rejected.Checklist
AI-assisted: yes
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:15:33Z.
Review: COMMENTED
Audited diff (
e132e457) and ran platform-independent checks on Linux (no Windows/MSVC build oriced_x86environment locally, socpu_aot_vex_parityandform_coverage_check.pywere not executed).Linux checks run on
e132e457:python3 -B tests/docs_links_check.py: passed (Checked 15 Markdown files and 255 links.)python3 -B tests/bidi_controls_check.py: passed (Checked 951 tracked source, script and build/CI files: no bidirectional controls.)python3 -B tests/rdna2_tools_check.py: passed (Ran 109 tests in 2.398s,OK (skipped=10))Code audit:
tools/x87_lower.py:SETP,SETNP,CMOVP,CMOVNPare gated,VEX_SCALAR_COMPARES(VCOMISS,VUCOMISS,VCOMISD,VUCOMISD) andPF_CLEARED(RDRAND,RDSEED,PTEST,VPTEST,VTESTPS,VTESTPD,PCMPESTRI,PCMPESTRM,PCMPISTRI,PCMPISTRM) are recognized byassigns_parity, andhost_opsinvalidates tracked flags/PF in_after.tools/ffx_version_query.py: Confirmed that allPF_CLEAREDinstructions already emitparity = false;whenparityis enabled,VCOMISS/VUCOMISS/VCOMISD/VUCOMISDcomputeunorderedfrom operand bits and assignzero,carry,parityaccordingly,SETP/SETNPpreserve upper bits viawrite, andCMOVP/CMOVNPeagerly read memory operands viaguest()and zero-extend 32-bit register destinations viawrite_registereven when not taken.AGENTS.mdcompliance: title-neutral wording,docs/experiments.mdupdated, and negative controls (stalepf,swap, and 13 rejected lowering cases) are present.Windows
cpu_aot_vex_parityandform_coverage_check.pyresults remain unverified locally.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T03:42:52Z.
Thanks for this work. The shared PF lowering landed in #1193 along with the native and optimized comparisons. Your distinct source-built cases are welcome as a focused follow-up against current main. Please keep the existing shared proof in place and point out any accepted or refused case the landed fixture does not exercise.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-24T13:51:21Z.
At
64d451e3this PR builds on the #1193 lowering already in main and retains the independent MASM/native/optimized test, adjusted to exercise current PF refusals. Windows Release matched all 1,618 native and lifted cases and detected the stale-PF and swapped-operand controls.