[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
Fri Sep 26 02:24:20 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:

```suggestion
  return createSelectInstWithUnknownBranchWeights(X, TVal, FVal);
```
This is a bit of a mouthful, I don't think the "maybe" adds anything here.

InstCombine always works on a single function, so there really shouldn't be a need to explicitly pass it anywhere. If InstCombiner doesn't store the Function yet, it's fine to add a member for it.

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


More information about the llvm-commits mailing list