cpu: observe the CF that ANDN and BEXTR clear, and the BEXTR length mask #331
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/336"
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 Leyukaka on 2026-11-21T22:36:52Z.
Change
Refs #286. This closes two gaps in the
cpu_aot_bmi1checks merged with that PR. Only the fixture and the test change; the translator does not.carry = false, so a lowering that kept the incoming CF still passed. In all four exports (andn32/andn64/bextr32/bextr64),xor r9d, r9dandcmp r9, 1now set CF to 1 just before the instruction. The exported(CF << 1) | ZFthen shows whether CF was cleared. The expected values are unchanged.& 0xffuon the length was not exercised. Three controls with bits above 15 are added:0x10100,0x232008and0xfe0410.Verification
On
c2ccfa6(branch onb860dd5), Windows 11 build 26300.9974, MSVC 14.44.35207, Python 3.14:The full suite passes 146 of 146 tests.
Mutations of the lowering in
tools/ffx_version_query.py, each run against this branch's tests and against the tests onmain:mainlifted andn32(0x0, 0x0) = (0x0, 0x3), expected (0x0, 0x1)lifted bextr32(0x0, 0x0) = (0x0, 0x3), expected (0x0, 0x1)& 0xfflifted bextr32(0x2, 0x10100) = (0x2, 0x0), expected (0x0, 0x1)Evidence and follow-up
The new compare uses R9, which each export overwrites with its flag word right after the instruction, so no other result changes. No open PR touches
tests/cpu/bmi1.*.Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-21T22:51:53Z.
Added
33abca1, which closes four more gaps in the same test. Each one was alower()mutation that passed the suite before this commit; I ran each to confirm it survives, and each now fails:0x7fbextr32(0x1, 0x8000) = (0x0, 0x1), expected(0x1, 0x0)0x7fbextr32(0x1, 0x180) = (0x1, 0x0), expected(0x0, 0x1)len >= bits - 1bextr32(0x80000000, 0x1f00) = (0x80000000, 0x0), expected(0x0, 0x1)blsmsk32(0x0) = (0xffffffff, 0x3), expected(0xffffffff, 0x2)The change:
blsmsk32andblsmsk64now followcmp ecx, ecx, which sets ZF.controlsgains0x8000,0x0180,0x1f00and0x3f00.The three mutations from the description still fail.
cpu_aot_bmi1now reports 1292 binary and 136 unary cases, and the full suite passes 146 of 146 tests on Windows 11 build 26300.9974.AI-assisted.