[llvm] [Mips][BranchFolding] Enable safe tail merging (PR #225382)
Jiaxun Yang via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 22 05:33:12 PDT 2026
================
@@ -754,11 +754,13 @@ unsigned BranchFolder::ComputeSameTails(unsigned CurHash,
for (MPIterator I = std::prev(CurMPIter); I->getHash() == CurHash; --I) {
unsigned CommonTailLen;
if (ProfitableToMerge(CurMPIter->getBlock(), I->getBlock(),
- MinCommonTailLength,
- CommonTailLen, TrialBBI1, TrialBBI2,
- SuccBB, PredBB,
- EHScopeMembership,
- AfterBlockPlacement, MBBFreqInfo, PSI)) {
+ MinCommonTailLength, CommonTailLen, TrialBBI1,
+ TrialBBI2, SuccBB, PredBB, EHScopeMembership,
+ AfterBlockPlacement, MBBFreqInfo, PSI) &&
+ // Check both tails even if one is an entire block: replacing the
+ // other tail can introduce a branch at its start.
+ TII->isLegalToSplitMBBAt(*CurMPIter->getBlock(), TrialBBI1) &&
+ TII->isLegalToSplitMBBAt(*I->getBlock(), TrialBBI2)) {
----------------
FlyGoat wrote:
@arsenm Could you please help me review the BranchFolding change? I think this is valid for any target using the generic tail merging implementation.
https://github.com/llvm/llvm-project/pull/225382
More information about the llvm-commits
mailing list