WIP: [Mips] Partially unroll small loops on the R5900 #12

Closed
techwritescode wants to merge 6 commits from r5900-unroll into r5900-ee

Adds an R5900 getUnrollingPreferences enabling partial and runtime unrolling (PartialThreshold 64), with a lit test. Also renames the split-hi16 pass argument, which collided with the -mips-split-hi16 option and made opt abort.

Console cycles (-O2): packet_build 61,559 to 55,734; raster 7.36M to 7.50M (+2%); decompress, physics flat. At -O3: packet_build flat, raster +3%.

Mips CodeGen and MC lit tests pass.

🤖 Generated with Claude Code

Adds an R5900 getUnrollingPreferences enabling partial and runtime unrolling (PartialThreshold 64), with a lit test. Also renames the split-hi16 pass argument, which collided with the -mips-split-hi16 option and made opt abort. Console cycles (-O2): packet_build 61,559 to 55,734; raster 7.36M to 7.50M (+2%); decompress, physics flat. At -O3: packet_build flat, raster +3%. Mips CodeGen and MC lit tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The pass argument matched the -mips-split-hi16 option, so opt aborted with a duplicate option registration.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
[Mips] Partially unroll small loops on the R5900
Some checks failed
action.yml / [Mips] Partially unroll small loops on the R5900 (push) Failing after 0s
release-binaries-all.yml / [Mips] Partially unroll small loops on the R5900 (push) Failing after 0s
release-binaries.yml / [Mips] Partially unroll small loops on the R5900 (push) Failing after 0s
release-documentation.yml / [Mips] Partially unroll small loops on the R5900 (push) Failing after 0s
release-sources.yml / [Mips] Partially unroll small loops on the R5900 (push) Failing after 0s
Check for private emails used in PRs / validate_email (pull_request) Has been skipped
action.yml / [Mips] Partially unroll small loops on the R5900 (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] Partially unroll small loops on the R5900 (pull_request) Failing after 0s
release-binaries.yml / [Mips] Partially unroll small loops on the R5900 (pull_request) Failing after 0s
release-documentation.yml / [Mips] Partially unroll small loops on the R5900 (pull_request) Failing after 0s
release-sources.yml / [Mips] Partially unroll small loops on the R5900 (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
7bb528e86e
Enable partial and runtime unrolling with a threshold of 64. On the console this cuts packet_build 9% at -O2 and leaves other kernels within 3%.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
techwritescode changed title from [Mips] Partially unroll small loops on the R5900 to WIP: [Mips] Partially unroll small loops on the R5900 2026-10-14 22:48:46 +00:00
Mips never enabled unroll-and-jam, so the pass did nothing. For the R5900:
set UP.UnrollAndJam, allow multi-block inner loops, and prefer a jam count
of 6. The 16 KB data cache thrashes when an outer loop sweeps a larger array
once per iteration; jamming several outer iterations per sweep cuts the
misses (a 1024-particle physics step: 14.7M -> 6.6M cycles on hardware).

The jam clones the inner induction variable, so the R5900 pipeline runs
instcombine, indvars, early-cse and GVN after it to forward the copies'
loads and stores.

Adds TTI::UnrollingPreferences::UnrollAndJamMultiBlock and
UnrollAndJamPreferredCount (defaults off).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Unswitching the loop-invariant triangle-area test out of the raster pixel loop
cuts bench_raster at -O2 from 7.49M to 6.84M cycles (GCC: 6.87M).

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
R5900: unroll and jam at -O1
Some checks failed
action.yml / R5900: unroll and jam at -O1 (push) Failing after 0s
release-binaries-all.yml / R5900: unroll and jam at -O1 (push) Failing after 0s
release-binaries.yml / R5900: unroll and jam at -O1 (push) Failing after 0s
release-documentation.yml / R5900: unroll and jam at -O1 (push) Failing after 0s
release-sources.yml / R5900: unroll and jam at -O1 (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 / R5900: unroll and jam at -O1 (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 / R5900: unroll and jam at -O1 (pull_request) Failing after 0s
release-binaries.yml / R5900: unroll and jam at -O1 (pull_request) Failing after 0s
release-documentation.yml / R5900: unroll and jam at -O1 (pull_request) Failing after 0s
release-sources.yml / R5900: unroll and jam at -O1 (pull_request) Failing after 0s
734ca8cdd6
Enable loop unrolling by default at -O1 for r5900, and run
AggressiveInstCombine and GVN before unroll-and-jam there so the sqrtf call
and redundant loads no longer fail the jam dependence check. bench physics
-O1 goes from 14.9M to 7.59M cycles, raster from 8.03M to 7.49M.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
[Mips] Move R5900 pass pipeline tuning into the Mips target
Some checks failed
action.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-binaries-all.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-binaries.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-documentation.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-sources.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (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] Move R5900 pass pipeline tuning into the Mips target (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] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-binaries.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-documentation.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-sources.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped
455c9cd951
Register the R5900 unswitch, unroll-and-jam and cleanup passes through
MipsTargetMachine::registerPassBuilderCallbacks instead of branching on
the CPU in PassBuilderPipelines.cpp, and set the -O1 unroll default in
the MIPS driver args instead of CompilerInvocation.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Author
Owner

Closing: superseded by #13. The split-hi16 rename went in there. The rest changes generic LLVM passes (LoopUnrollAndJam, LoopUnrollPass, TargetTransformInfo.h), adds an R5900 pass pipeline, adds -funroll-loops at -O1 in the clang driver, and uses unroll thresholds tuned to the benchmark, which UPDATING.md now keeps out of the fork. Partial unroll alone made -O2 bench code 1.70x GCC's size on the console. The branch stays on the remote for reference.

Closing: superseded by #13. The split-hi16 rename went in there. The rest changes generic LLVM passes (LoopUnrollAndJam, LoopUnrollPass, TargetTransformInfo.h), adds an R5900 pass pipeline, adds -funroll-loops at -O1 in the clang driver, and uses unroll thresholds tuned to the benchmark, which UPDATING.md now keeps out of the fork. Partial unroll alone made -O2 bench code 1.70x GCC's size on the console. The branch stays on the remote for reference.
techwritescode closed this pull request 2026-10-15 16:58:29 +00:00
Some checks failed
action.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-binaries-all.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-binaries.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-documentation.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (push) Failing after 0s
release-sources.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (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] Move R5900 pass pipeline tuning into the Mips target (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] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-binaries.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-documentation.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
release-sources.yml / [Mips] Move R5900 pass pipeline tuning into the Mips target (pull_request) Failing after 0s
Add buildbot information to first PRs from new contributors / buildbot_comment (pull_request_target) Has been skipped

Pull request closed

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!12
No description provided.