[llvm] [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (PR #162726)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 9 14:58:00 PDT 2025


================
@@ -108,6 +109,11 @@ static Value *simplifyShiftSelectingPackedElement(Instruction *I,
       IC.Builder.CreateICmpEQ(ShrAmt, Constant::getNullValue(ShrAmt->getType()),
                               ShrAmt->getName() + ".z");
   Value *Select = IC.Builder.CreateSelect(ShrAmtZ, Lower, Upper);
+  // There is no existing !prof metadata we can derive the !prof metadata for
+  // this select.
+  if (auto *SI = dyn_cast<SelectInst>(Select))
+    setExplicitlyUnknownBranchWeightsIfProfiled(
+        *SI, *SI->getParent()->getParent(), DEBUG_TYPE);
----------------
nikic wrote:

Can we use https://github.com/llvm/llvm-project/blob/6fe878a0e26d9e3a27f7c90a35e7487fd9edd705/llvm/lib/Transforms/InstCombine/InstCombineInternal.h#L473 here instead?

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


More information about the llvm-commits mailing list