[llvm] [Mips][BranchFolding] Enable safe tail merging (PR #225382)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 05:21:37 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-mips
Author: Jiaxun Yang (FlyGoat)
<details>
<summary>Changes</summary>
MIPS disables tail merging when the long-branch pass is enabled because branch expansion may clobber $at. This also blocks merges where $at is dead at the new branch.
Use physical-register liveness to reject tails that need $at, allowing safe merges for standard MIPS and microMIPS. Keep MIPS16 tail merging disabled because its far branches clobber $ra.
Check both candidate tails before selecting a common tail. The existing split check is only reached when creating a new block; reusing an entire block can still introduce a branch without passing that check.
Assisted-by: chatgpt-5.6-luna # Testcases
---
Full diff: https://github.com/llvm/llvm-project/pull/225382.diff
11 Files Affected:
- (modified) llvm/lib/CodeGen/BranchFolding.cpp (+5-1)
- (modified) llvm/lib/Target/Mips/MipsInstrInfo.cpp (+19)
- (modified) llvm/lib/Target/Mips/MipsInstrInfo.h (+3)
- (modified) llvm/lib/Target/Mips/MipsTargetMachine.cpp (-5)
- (modified) llvm/test/CodeGen/Mips/compact-branch-combine-never.ll (+3-2)
- (modified) llvm/test/CodeGen/Mips/compact-branch-combine.ll (+3-2)
- (removed) llvm/test/CodeGen/Mips/disable-tail-merge.ll (-33)
- (modified) llvm/test/CodeGen/Mips/llvm-ir/forbidden-slot-ir.ll (+2-1)
- (modified) llvm/test/CodeGen/Mips/mips1-load-in-delay-slot.ll (+2-1)
- (modified) llvm/test/CodeGen/Mips/pseudo-jump-fill.ll (+4-7)
- (added) llvm/test/CodeGen/Mips/tail-merge.ll (+88)
``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````
</details>
https://github.com/llvm/llvm-project/pull/225382
More information about the llvm-commits
mailing list