cpu: accept FTZ and DAZ in the host-MXCSR profile's denormals opt-in #1050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1057"
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-23T23:39:15Z.
Change
As agreed in #1048, the host-MXCSR profile from #1009 gets a denormals opt-in,
Mxcsr(reject, denormals=True)withmxcsr_entry(..., denormals=True). It accepts FTZ and DAZ where the host supports them. The default and the existing statuses are unchanged: without the opt-in, FTZ and DAZ are still refused with status 3, and the generated code is byte-identical to before.MXCSR_MASKonce, with_fxsave64into a 16-byte-aligned 512-byte area, at offset 28. A stored 0 counts as the architectural default0xFFBF. The mask is passed to the lowered body asmxcsr_mask.Tests
cpu_aot_mxcsr_denormals(mxcsr_denormals.asm) loads the four combinations (none, FTZ, DAZ, both), each under round to nearest and toward negative infinity, from the non-default caller word0x7FA0.FTZ case. Normal operands with exact sums of -2^-127 and +2^-127. The sums are
0x80400000and0x00400000; with FTZ they are0x80000000and0x00000000.DAZ case. Signed subnormal operands, each lane with a fixed raw word per combination:
0x007FFE000x000000000x008000000x807FFE000x800000000x808000000x800002000x800000000x00000000to nearest,0x80000000toward negative infinityThe raw words were measured with the native instructions on this host, then fixed in the test. Translated results must equal them and native execution.
Also checked, as in
cpu_aot_mxcsr: STMXCSR reads back the control bits; adjacent bytes stay unchanged; a refusal marker shows guest work runs only after an accepted word; and the caller's word is restored after return and after a guest fault.Capability.
mxcsr_mask_of). Here it reports0xFFFF.nodazas not measurable, and exits 77.simtranslation. The output isskip: this host's MXCSR_MASK has no DAZ; the FTZ checks above passed, then exit 77.Variants:
simreplaces only the probed capability with0xFFBF. It must keep every rule: DAZ is refused before LDMXCSR with every output unchanged, FTZ still works, and the caller's word is restored.noftzandnodazclear the bit before loading, and must fail.nomaskremoves the capability check on the simulated host, so DAZ loads anyway. It must fail:den_add(0x1fc0) on a host without DAZ: return 7, status 0./O2: the translation is also built withcl /O2and keeps every rule.Verification
At
2a7f1b7(onmaind4cbfcd) on Windows 11 Pro (build 26100), Intel Core i7-6820HQ (MXCSR_MASK0xFFFF), MSVC 19.52, Python 3.12:ctest --preset dev --no-tests=error -R '^cpu_aot_mxcsr_denormals$' -V: passes.cpu_aot_mxcsrstill passes.ctest --preset release --no-tests=error -R '^cpu_aot_mxcsr(_denormals)?$': 2/2 pass. Only these tests' targets were built inrelease.ctest --preset dev --no-tests=error -R '^cpu_' -j 4: 202 of 203 pass, with three capability skips.cpu_shim_shadow_hardwarein its native run, independent of this change and reported in #799.tests/docs_links_check.py,tests/bidi_controls_check.pyandtests/form_coverage_check.pypass.docs/experiments.mdgains a paragraph after the MXCSR one. The MXCSR paragraph now says FTZ and DAZ are outside the default profile.Not run: an AMD host, or a physical host without DAZ (only simulated).
Refs #1048
AI-assisted: written with Claude Code; diff reviewed by a fresh agent; checked and submitted by the account owner.
🤖 Generated with Claude Code