cpu: complete NEG, ADD and INC/DEC flag conditions in switch lifter #725
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/731"
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 Ammmae0x on 2026-11-22T23:46:50Z.
Change
Complete arithmetic flag condition lowering in
tools/cpu_switch_aot.pyand expandcpu_aot_flag_conditionsanddocs/experiments.md:NEGflag production & all 16 conditions: AddM.NEGtoFLAG_PRODUCERSand enablesets_flagsinLifter.lower()(fa = static_cast<uN>(0u - a);evaluated once before storing, reusingmemfromload_alwaysfor memory operands). Lower all 16 conditions inLifter.condition()(CF = (flag_result != 0),OF = (flag_result == sign_bit),be = "true",a = "false", pluse/ne/s/ns/l/ge/le/g/o/no/p/np).ADDcarry and signed conditions: Addb/ae/be/a(flag_result < a, etc.) andl/ge/le/galongside existinge/ne/s/ns/o/no/p/np.INCandDECsigned conditions: Addl/ge/le/gwhile preserving rejection of carry conditions (b/ae/be/a,unsupported condition after ...) becauseINCandDECpreserveCF.tests/cpu/flag_conditions.{asm,def}andtests/cpu/flag_conditions_check.pyfrom 160 to 289 exports (8/16/32/64-bitJcc/SETcc/CMOVcc,flags_neg_mem_32_bsingle-readload_alwaysverification,SHL RAX, CL, 12INC/DECCF-condition rejections, andNOTrejection controls). Updatetests/cpu/switch_check.pydummy flag-clobbering patch fromNEG EAX(f7 d8) toSHL EAX, 1(d1 e0).Verification
Commit:
4656a4216bbf55c12b61cdfe041bb9ed63e23ffcon Windows 11 (26100.7623), MSVC19.50.35727(x64), ML6414.50.35727.0, Python3.12.8:devDebug &release/O2):cmake --build --preset dev --target cpu_flag_conditions cpu_flag_conditions_lifted cpu_switch_original_lifted cpu_switch_swapped_lifted cpu_register_probeandcmake --build --preset release --target ...— 0 errors, 0 warnings.devtargeted flag/jump-table tests:ctest --preset dev --no-tests=error -R "^(cpu_aot_flag_conditions|cpu_aot_jump_tables)$" -V— 2 passed, 0 skipped, 0 failed (289 exports, 532,140 native/AOT/reference comparisons + 1,860NEG [mem]comparisons + rejection controls).devCPU AOT/lower/leaf/bink/shim-warp suite:ctest --preset dev --no-tests=error -R "^cpu_(aot_|lower_|leaf_|working_|bink_)|^cpu_shim_" -E "_hardware$"— 97 passed, 0 skipped, 0 failed.releasetargeted flag/jump-table tests:ctest --preset release --no-tests=error -R "^(cpu_aot_flag_conditions|cpu_aot_jump_tables)$" -V— 2 passed, 0 skipped, 0 failed.releaseCPU AOT/lower/leaf/bink/shim-warp suite:ctest --preset release --no-tests=error -R "^cpu_(aot_|lower_|leaf_|working_|bink_)|^cpu_shim_" -E "_hardware$"— 97 passed, 0 skipped, 0 failed.-E "_hardware$") on bothdevandrelease: 239 passed, 2 capability-skipped (exit 77:bvh_wave64_warp,wave_shuffle_warp), 2 failed (cpu_native_archive_reader,cpu_native_archive_blast— optionalziglangmodule not installed locally)..\out\pe-env\Scripts\python.exe -B):tests/form_coverage_check.py,tests/docs_links_check.py, andtests/bidi_controls_check.py— all passed.Evidence and follow-up
tests/cpu/flag_conditions.asmandtests/cpu/switch.asmare original source-built MASM fixtures verified differentially against native DLL execution and an independent Python reference.SHL RAX, CL,INC/DECfollowed byJB/JAE/JBE/JA/SETB/CMOVB, andNOTas a flag producer or without a preceding producer.CMakeLists.txtchanges were needed (cpu_aot_flag_conditionsruns all exports fromtests/cpu/flag_conditions.defand emitsFORM_COVERAGE_RECORD).Checklist
This change was AI-assisted.