[llvm] [InstCombine] Set !prof metadata on Selects identified by add.ll test (PR #158743)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 27 13:35:09 PDT 2025


================
@@ -1735,7 +1736,8 @@ Instruction *InstCombinerImpl::foldBinopOfSextBoolToSelect(BinaryOperator &BO) {
   Constant *Zero = ConstantInt::getNullValue(BO.getType());
   Value *TVal = Builder.CreateBinOp(BO.getOpcode(), Ones, C);
   Value *FVal = Builder.CreateBinOp(BO.getOpcode(), Zero, C);
-  return SelectInst::Create(X, TVal, FVal);
+  return createSelectInstMaybeWithUnknownBranchWeights(X, TVal, FVal,
+                                                       BO.getFunction());
----------------
nikic wrote:

So the idea is that we'd use createSelectInst() both for the case of unknown metadata and for the case where we inherit metadata from an existing select?

I'm okay with that, though a separate function would make it clearer that using unknown weights is intentional. No strong opinion though.

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


More information about the llvm-commits mailing list