[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


================
@@ -878,13 +879,17 @@ Instruction *InstCombinerImpl::foldAddWithConstant(BinaryOperator &Add) {
     return BinaryOperator::CreateAdd(Builder.CreateNot(Y), X);
 
   // zext(bool) + C -> bool ? C + 1 : C
+  SelectInst *SI = nullptr;
   if (match(Op0, m_ZExt(m_Value(X))) &&
       X->getType()->getScalarSizeInBits() == 1)
-    return SelectInst::Create(X, InstCombiner::AddOne(Op1C), Op1);
+    SI = createSelectInst(X, InstCombiner::AddOne(Op1C), Op1);
   // sext(bool) + C -> bool ? C - 1 : C
-  if (match(Op0, m_SExt(m_Value(X))) &&
+  if (!SI && match(Op0, m_SExt(m_Value(X))) &&
       X->getType()->getScalarSizeInBits() == 1)
-    return SelectInst::Create(X, InstCombiner::SubOne(Op1C), Op1);
+    SI = createSelectInst(X, InstCombiner::SubOne(Op1C), Op1);
+  if (SI) {
----------------
nikic wrote:

No longer need this change, can directly return.

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


More information about the llvm-commits mailing list