[llvm] [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (PR #162726)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 12:59:18 PDT 2025
https://github.com/mtrofin created https://github.com/llvm/llvm-project/pull/162726
None
>From 4d706b2ee75d3775db5babea7ead73e39a92c988 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Thu, 9 Oct 2025 12:57:39 -0700
Subject: [PATCH] [InstCombine] Mark as unknown the branch weights of packed
integer selecting shifts
---
.../Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 127a506e440b7..eb03f16e89e03 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -16,6 +16,7 @@
#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/PatternMatch.h"
+#include "llvm/IR/ProfDataUtils.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Transforms/InstCombine/InstCombiner.h"
@@ -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);
Select->takeName(I);
return Select;
}
More information about the llvm-commits
mailing list