[llvm] PPCBranchCoalescing: Fix invalid branch weights (PR #67211)
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 16:41:43 PDT 2023
https://github.com/MatzeB created https://github.com/llvm/llvm-project/pull/67211
Re-normalize branch-weights after removing a block successor to avoid branch-weights not adding up to 100%. This changes MIR for the `test/CodeGen/PowerPC/branch_coalesce.ll` test like this:
```diff
- successors: %bb.6(0x40000000); %bb.6(50.00%)
+ successors: %bb.6(0x80000000); %bb.6(100.00%)
```
This doesn't affect codegen on its own but fixing this helps with fluctuations I have with some of my upcoming changes.
>From 9066a88af1cf10c5aa3f79553b341c55d80455f2 Mon Sep 17 00:00:00 2001
From: Matthias Braun <matze at braunis.de>
Date: Fri, 22 Sep 2023 16:34:36 -0700
Subject: [PATCH] PPCBranchCoalescing: Fix invalid branch weights
Re-normalize branch-weights after removing a block successor to avoid
branch-weights not adding up to 100%. This changes MIR for the
`test/CodeGen/PowerPC/branch_coalesce.ll` test like this:
```diff
- successors: %bb.6(0x40000000); %bb.6(50.00%)
+ successors: %bb.6(0x80000000); %bb.6(100.00%)
```
This doesn't affect codegen on its own but fixing this helps with
fluctuations I have with some of my upcoming changes.
---
llvm/lib/Target/PowerPC/PPCBranchCoalescing.cpp | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/lib/Target/PowerPC/PPCBranchCoalescing.cpp b/llvm/lib/Target/PowerPC/PPCBranchCoalescing.cpp
index 9d580ff5747181d..afaee2ca7ea0c0c 100644
--- a/llvm/lib/Target/PowerPC/PPCBranchCoalescing.cpp
+++ b/llvm/lib/Target/PowerPC/PPCBranchCoalescing.cpp
@@ -702,6 +702,7 @@ bool PPCBranchCoalescing::mergeCandidates(CoalescingCandidateInfo &SourceRegion,
TargetRegion.FallThroughBlock->transferSuccessorsAndUpdatePHIs(
SourceRegion.FallThroughBlock);
TargetRegion.FallThroughBlock->removeSuccessor(SourceRegion.BranchBlock);
+ TargetRegion.FallThroughBlock->normalizeSuccProbs();
// Remove the blocks from the function.
assert(SourceRegion.BranchBlock->empty() &&
More information about the llvm-commits
mailing list