[llvm] Fix profile metadata propagation in InstCombine select folding (PR #179743)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 8 23:02:02 PDT 2026


================
@@ -3594,11 +3574,15 @@ Instruction *InstCombinerImpl::foldSelectOfBools(SelectInst &SI) {
     if (match(CondVal, m_OneUse(m_Select(m_Value(A), m_One(), m_Value(B)))) &&
         impliesPoisonOrCond(FalseVal, B, /*Expected=*/false)) {
       // (A || B) || C --> A || (B | C)
-      return replaceInstUsesWith(
-          SI, Builder.CreateLogicalOr(A, Builder.CreateOr(B, FalseVal), "",
-                                      ProfcheckDisableMetadataFixes
-                                          ? nullptr
-                                          : cast<SelectInst>(CondVal)));
+      Value *LOr = Builder.CreateLogicalOr(A, Builder.CreateOr(B, FalseVal));
+      if (!ProfcheckDisableMetadataFixes) {
+        if (auto *I = dyn_cast<Instruction>(LOr)) {
+          // FIXME 183864: We could improve the profile if P((A || B) || C) <
----------------
snehasish wrote:

Done.

https://github.com/llvm/llvm-project/pull/179743


More information about the llvm-commits mailing list