cpu: lower SETP, SETNP, CMOVP and CMOVNP where the reaching PF definition is modeled #1186
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1193"
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 legacy-code-archaeologist on 2026-11-24T03:20:12Z.
Refs #1153
What
The shared lowering (
tools/ffx_version_query.py) now lowers SETP, SETNP, CMOVP and CMOVNP, next to JP and JNP, when the reaching PF definition is modeled on every path from the entry (check_parity):lahf_sources).x87_lower.check_flagskeeps deciding.GATEDnow includes the new readers, andassigns_paritycounts the four VEX compares.parity.Existing tests changed (please check)
Three refusal cases pinned "SETP/CMOVP unsupported", which this change lowers on purpose. Each now inserts a PF writer the lowering does not model, so it still tests a refusal, now with the PF message:
tests/cpu/x87_compare.py:fucomi then setp/cmovp→fucomi and inc eax, then setp/cmovp, needle "reads PF, which the integer lowering models only after".tests/cpu/x87_parity.py: "SETP after FUCOMI" → "SETP after FUCOMI and INC", PF needle.tests/cpu/integer_flags_check.py:out_of_scope_setpdrops the LAHF, so SETP reads PF of an ADD that no LAHF reads; needle "reads PF".These adjusted controls found a bug: before
GATEDwas extended, x87 functions skippedcheck_flagsfor SETP and CMOVP.Evidence
cpu_aot_parity(parity.asm, parity.py) runs SETNP, SETP, SETE, SETB, CMOVP (register), CMOVNP (memory) and JP after each VEX compare and after FUCOMIP (x87 profile), for twelve operand pairs: ordered, equal, ±0, infinities, and QNaN and SNaN in either operand. MXCSR is 0x1F80, set and restored by the harness. Native and translated must both match the fixed flags.The test also checks:
setnp; sete; andequality idiom;Two controls must break:
staledrops the compare's PF assignment, andreversedswaps every PF condition. An/O2build must pass.Under masked exceptions VCOMISS and VUCOMISS set the same flags, so this fixture does not tell them apart. FLD quiets a signaling NaN, so the FUCOMIP case compares it as a quiet NaN.
Windows 11 Pro 26100, Intel i7-6820HQ (AVX), MSVC 19.52, commit
416df060on645b9697:passes: five refusals; native and lifted match for all exports;
stalefails onpf_ucomiss(qnan, 1)andreversedonpf_ucomiss(1, 2);/O2keeps every rule. The release preset passescpu_aot_parity,cpu_aot_integer_flags,cpu_aot_x87_compareandcpu_aot_x87_parity.The full dev suite without
_hardwarepassed 482/482 before the rebase; after the rebase,ctest --preset dev -R '^cpu_' -E '_hardware$'passes 210/210. Run one at a time,cpu_*_hardwareandcompute_store_aot*_hardwarepass, exceptcpu_shim_shadow_hardware, which already fails on main (reported on #799).tools/form_coverage.py --gaps x64_zen2no longer lists setnp, cmovp or cmovnp.🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T03:27:42Z.
Review: COMMENTED
Reviewed
416df060(diff + Linux doc/bidi checks; Windows build/MASM/MSVC tests and Python checks requiringpefile/iced_x86were not run locally).Findings
#1188(cpu: lower PF consumers after VEX scalar compares) also targets#1153and modifies the same core files (tools/ffx_version_query.py,tools/x87_lower.py,tests/cpu/x87_compare.py,tests/cpu/x87_parity.py,CMakeLists.txt,docs/experiments.md). Merging either one will require coordinating or rebasing the other.tools/ffx_version_query.py(check_parity): sound forward dataflow overx87_lower._successors(i)starting withknown[entry] = False, intersecting at joins (known[target] and after), resetting toFalseonhost_ops, calls, undefinedPF, or unmodeledPFwriters, and rejecting both unmodeled and unreachablePFreaders.CMOVP/CMOVNPandSETP/SETNPmatch the existingCMOVcc/SETcclowering (including eager evaluation of memory operands and 32-bit zero-extension).tools/x87_lower.py: extendsGATEDwithSETP,SETNP,CMOVP,CMOVNPandassigns_paritywith the four VEX scalar compares so x87-profile functions still go throughcheck_flags.tests/cpu/parity.{asm,def,py}anddocs/experiments.md: title-neutral, include negative controls (stale,reversed) and 5 refusal cases.Checks run on Linux
python3 -B tests/docs_links_check.py: passed (15 Markdown files, 266 links).python3 -B tests/bidi_controls_check.py: passed (974 tracked files).tests/cpu/integer_flags_check.py,tests/cpu/x87_compare.py,tests/cpu/x87_parity.py: not runnable here becausepefile/iced_x86are not installed in this Linux Python environment.cpu_aot_parity,cl /O2) was not run locally.