[llvm] [InstCombine] Preserve profile data with select instructions and binary operators (PR #158375)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 12 15:27:37 PDT 2025


================
@@ -1427,6 +1436,8 @@ Value *InstCombinerImpl::SimplifySelectsFeedingBinaryOp(BinaryOperator &I,
 
   Value *SI = Builder.CreateSelect(Cond, True, False);
   SI->takeName(&I);
+  if (!ProfcheckDisableMetadataFixes)
+    cast<SelectInst>(SI)->setMetadata(LLVMContext::MD_prof, ProfileData);
----------------
nikic wrote:

You should pass the original select to the MDFrom argument of CreateSelect instead. This will also handle !unpredictable metadata properly.

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


More information about the llvm-commits mailing list