[Mips] R3000A: shared select diamonds and branchless i64 orderings #23

Merged
techwritescode merged 3 commits from r3000a-delay-slots into r3000a-load-delay 2026-10-16 19:51:05 +00:00

Stacked on r3000a-load-delay (#22). Both changes are gated on isR3000A().

  • Consecutive selects on the same condition (the halves of an i64 select) share one branch diamond with several PHIs, instead of one diamond each.
  • i64 orderings (lt/le/gt/ge, signed and unsigned) lower through custom SETCCCARRY and USUBO using a borrow chain, with no branches. mips1 is unchanged.

Lit tests: r3000a-select-pair.ll, r3000a-i64-compare.ll. Full CodeGen/Mips and MC/Mips lit pass.

Measured on the console rig (minimum over 3 boots), checksums identical across builds. Ticks, #22 vs this branch: crc 79375/79375, sort 153696/153696, decode 84630/84630, div 38650/38650, state 69029/69029, str 135796/135796, lba (new i64 select and compare kernel) 121845/96122. Nothing is slower than #22. The IRX total over the 89 sdk-core IRXs is 1,216 bytes smaller.

Not fixed, because only a generic pass or a new delay-slot filler feature would close them: sort loop strength reduction, remaining load-delay and branch-slot nops, and the lw $ra; nop; jr epilogue (a real load-use dependency). i64 == via xor/xor/or is the same size as GCC's per-word branches.

🤖 Generated with Claude Code

Stacked on r3000a-load-delay (#22). Both changes are gated on isR3000A(). - Consecutive selects on the same condition (the halves of an i64 select) share one branch diamond with several PHIs, instead of one diamond each. - i64 orderings (lt/le/gt/ge, signed and unsigned) lower through custom SETCCCARRY and USUBO using a borrow chain, with no branches. mips1 is unchanged. Lit tests: r3000a-select-pair.ll, r3000a-i64-compare.ll. Full CodeGen/Mips and MC/Mips lit pass. Measured on the console rig (minimum over 3 boots), checksums identical across builds. Ticks, #22 vs this branch: crc 79375/79375, sort 153696/153696, decode 84630/84630, div 38650/38650, state 69029/69029, str 135796/135796, lba (new i64 select and compare kernel) 121845/96122. Nothing is slower than #22. The IRX total over the 89 sdk-core IRXs is 1,216 bytes smaller. Not fixed, because only a generic pass or a new delay-slot filler feature would close them: sort loop strength reduction, remaining load-delay and branch-slot nops, and the `lw $ra; nop; jr` epilogue (a real load-use dependency). i64 `==` via xor/xor/or is the same size as GCC's per-word branches. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Without conditional moves each select becomes a branch diamond. Consecutive
selects on one condition, such as the halves of an i64 select, now use a
single diamond with several PHIs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
[Mips] Lower R3000A i64 orderings without branches
Some checks failed
action.yml / [Mips] Lower R3000A i64 orderings without branches (push) Failing after 0s
release-binaries-all.yml / [Mips] Lower R3000A i64 orderings without branches (push) Failing after 0s
release-binaries.yml / [Mips] Lower R3000A i64 orderings without branches (push) Failing after 0s
release-documentation.yml / [Mips] Lower R3000A i64 orderings without branches (push) Failing after 0s
release-sources.yml / [Mips] Lower R3000A i64 orderings without branches (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [Mips] Lower R3000A i64 orderings without branches (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [Mips] Lower R3000A i64 orderings without branches (pull_request) Failing after 0s
release-binaries.yml / [Mips] Lower R3000A i64 orderings without branches (pull_request) Failing after 0s
release-documentation.yml / [Mips] Lower R3000A i64 orderings without branches (pull_request) Failing after 0s
release-sources.yml / [Mips] Lower R3000A i64 orderings without branches (pull_request) Failing after 0s
Labelling new pull requests / greeter (pull_request_target) Has been cancelled
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been cancelled
90831b04b5
The generic expansion compares the high words and selects between the low and
high results, which costs two branches. Expand through SETCCCARRY instead:
(Hi1 < Hi2) | ((Hi1 - Hi2) <u LoBorrow), with the low borrow as a plain sltu.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
[Mips] Drop explanatory comments from the R3000A select and compare lowering
Some checks failed
action.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (push) Failing after 0s
release-binaries-all.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (push) Failing after 0s
Labelling new pull requests / greeter (pull_request_target) Has been skipped
Labelling new pull requests / automate-prs-labels (pull_request_target) Has been skipped
action.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (pull_request) Failing after 0s
Check LLVM ABI annotations / Check LLVM_ABI annotations with ids (pull_request) Has been skipped
CI Checks / Build and Test Linux (pull_request) Has been skipped
CI Checks / Build and Test Windows (pull_request) Has been skipped
CI Checks / Compute macOS Projects (pull_request) Has been skipped
CI Checks / Build and Test macOS arm64 (pull_request) Has been skipped
release-binaries-all.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (pull_request) Failing after 0s
release-binaries.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (pull_request) Failing after 0s
release-documentation.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (pull_request) Failing after 0s
release-sources.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (pull_request) Failing after 0s
release-binaries.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (push) Failing after 0s
release-documentation.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (push) Failing after 0s
release-sources.yml / [Mips] Drop explanatory comments from the R3000A select and compare lowering (push) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
3d1f4b5e16
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
techwritescode merged commit 3d1f4b5e16 into r3000a-load-delay 2026-10-16 19:51:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ps2/llvm!23
No description provided.