Repository navigation
cpu: lower PF consumers after VEX scalar compares - #1188
Merged
Merged
Conversation
tedin7
reviewed
Nov 24, 2026
tedin7
left a comment
Collaborator
There was a problem hiding this comment.
Audited diff (e132e457) and ran platform-independent checks on Linux (no Windows/MSVC build or iced_x86 environment locally, so cpu_aot_vex_parity and form_coverage_check.py were 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_parity and form_coverage_check.py results remain unverified locally.
Owner
|
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. |
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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