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

Aiden Grossman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Sep 9 19:59:18 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))
----------------
boomanaiden154 wrote:

Ah, forgot that the verifier runs after every pass. This seems reasonable enough to me then.

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


More information about the llvm-branch-commits mailing list