Skip to content

Commit 1458d31

Browse files
authored
[SLU][profcheck] Propagate profile for branches on injected conditions. (#164476)
This patch addresses the profile of 2 branches: - one that compares the 2 limits, for which we have no information (the C1, C2, see https://reviews.llvm.org/D136233) - one that is conditioned on a condition for which we have a profile, so we reuse it Issue #147390
1 parent 3974157 commit 1458d31

File tree

2 files changed

+79
-72
lines changed

2 files changed

+79
-72
lines changed

llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,10 +3203,15 @@ injectPendingInvariantConditions(NonTrivialUnswitchCandidate Candidate, Loop &L,
32033203
Builder.SetInsertPoint(TI);
32043204
auto *InvariantBr =
32053205
Builder.CreateCondBr(InjectedCond, InLoopSucc, CheckBlock);
3206+
// We don't know anything about the relation between the limits.
3207+
setExplicitlyUnknownBranchWeightsIfProfiled(
3208+
*InvariantBr, *InvariantBr->getParent()->getParent(), DEBUG_TYPE);
32063209

32073210
Builder.SetInsertPoint(CheckBlock);
3208-
Builder.CreateCondBr(TI->getCondition(), TI->getSuccessor(0),
3209-
TI->getSuccessor(1));
3211+
Builder.CreateCondBr(
3212+
TI->getCondition(), TI->getSuccessor(0), TI->getSuccessor(1),
3213+
!ProfcheckDisableMetadataFixes ? TI->getMetadata(LLVMContext::MD_prof)
3214+
: nullptr);
32103215
TI->eraseFromParent();
32113216

32123217
// Fixup phis.

0 commit comments

Comments
 (0)