[llvm] [InstCombine] Propagate profile metadata when combining selects (PR #177883)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 26 07:21:45 PST 2026
================
@@ -4522,18 +4523,24 @@ Instruction *InstCombinerImpl::visitSelectInst(SelectInst &SI) {
Value *And = nullptr, *OtherVal = nullptr;
// select(C0, select(C1, a, b), b) -> select(C0&&C1, a, b)
if (TrueSI->getFalseValue() == FalseVal) {
- And = Builder.CreateLogicalAnd(CondVal, TrueSI->getCondition());
+ And = Builder.CreateLogicalAnd(CondVal, TrueSI->getCondition(), "",
+ ProfcheckDisableMetadataFixes ? nullptr
+ : &SI);
OtherVal = TrueSI->getTrueValue();
}
// select(C0, select(C1, b, a), b) -> select(C0&&!C1, a, b)
else if (TrueSI->getTrueValue() == FalseVal) {
Value *InvertedCond = Builder.CreateNot(TrueSI->getCondition());
- And = Builder.CreateLogicalAnd(CondVal, InvertedCond);
+ And = Builder.CreateLogicalAnd(CondVal, InvertedCond, "",
+ ProfcheckDisableMetadataFixes ? nullptr
+ : &SI);
OtherVal = TrueSI->getFalseValue();
}
if (And && OtherVal) {
replaceOperand(SI, 0, And);
replaceOperand(SI, 1, OtherVal);
+ if (!ProfcheckDisableMetadataFixes)
----------------
mtrofin wrote:
you can `setExplicitlyUnknownBranchWeightsIfProfiled` unconditionally.
https://github.com/llvm/llvm-project/pull/177883
More information about the llvm-commits
mailing list