[llvm] Fix profile metadata propagation in InstCombine select folding (PR #179743)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 20 06:46:54 PST 2026
================
@@ -3717,28 +3717,32 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
// select (~a | c), a, b -> select a, (select c, true, b), false
if (match(CondVal,
m_OneUse(m_c_Or(m_Not(m_Specific(TrueVal)), m_Value(C))))) {
- Value *OrV = Builder.CreateSelect(C, One, FalseVal);
- return SelectInst::Create(TrueVal, OrV, Zero);
+ Instruction *MDFrom = ProfcheckDisableMetadataFixes ? nullptr : &SI;
+ Value *OrV = Builder.CreateSelect(C, One, FalseVal, "", MDFrom);
+ return SelectInst::Create(TrueVal, OrV, Zero, "", nullptr, MDFrom);
----------------
mtrofin wrote:
`unknown` makes most sense. We could think briefly if knowing `P(~a|c)` tells us anything about the bounds of either `P(a)` or `P(c)`... I guess if `P(~a|c)` < 0.5, neither probabilities `P(~a)` nor `P(c)` could be greater, so maybe under that condition we could copy the original probability to `c` and (flipped) to `a` as it's more accurate.
https://github.com/llvm/llvm-project/pull/179743
More information about the llvm-commits
mailing list