shader: lower scalar add-with-carry and subtract-with-borrow in pixel_aot #623
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/629"
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 descent81 on 2026-11-22T16:29:47Z.
Change
pixel_aotnow lowerss_addc_u32ands_subb_u32. Each instruction consumes the prior SCC, returns a wrapping 32-bit word, and writes the resulting carry or borrow back to SCC. The lowering evaluates the binary operation and incoming flag as two unsigned steps so that wrap in either step is detected. Translation refuses the instruction if SCC has no tracked producer. This fills the carry-in and borrow-in gap documented in #257. AMD RDNA 2 ISA referenceVerification
Tested
3020b5don2f1f832. The fixture runs a low-words_add_u32ors_sub_u32followed by the corresponding carry/borrow instruction on the high word, using the first high source as its destination. The integer render target exposes both 32-bit result words and both SCC values. Python computes the expected values from the full-width operation and the separate low-word operation.The inputs distinguish carry/borrow from the two operands alone and carry/borrow caused only by the incoming SCC. The subtraction cases also include a high subtrahend of
0xffffffffwith borrow-in set, which catches an implementation that wraps the subtrahend before checking the borrow. Replacing either new instruction with its ordinary add/subtract counterpart must producepixel_mismatchon the unchanged reference.Evidence and follow-up
The tests use source-written assembly and synthetic operand words under the repository's MIT license. The coverage counts above describe the binary fixture suite.
AI-assisted.