[llvm-branch-commits] [llvm] [InstCombine] Set !prof metadata on selects (PR #157599)

Mircea Trofin via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 9 22:01:59 PDT 2025


================
@@ -6008,6 +6009,15 @@ static bool combineInstructionsOverFunction(
     if (!MadeChangeInThisIteration)
       break;
 
+    // Issue #147390: InstCombine emits `select` as rewrites of instructions
+    // without metadata. It may be possible to synthesize some more meaningful
+    // profiles in some cases (based on operands or based on the pattern)
+    if (auto EC = F.getEntryCount(); EC.has_value() && EC->getCount() > 0)
+      for (auto &BB : F)
+        for (auto &I : BB)
+          if (isa<SelectInst>(I) && !I.getMetadata(LLVMContext::MD_prof))
----------------
mtrofin wrote:

Nitpicking: the profcheck verifier doesn't run after every pass, i.e. it doesn't affect compile time. It runs around every .ll test (on the profcheck bot). Meaning, it's possible selects would arrive here without `!prof` _if_ they get inserted in a pass with that behavior left untested.

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


More information about the llvm-branch-commits mailing list