[llvm] 01e19e8 - [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (#162726)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 10 10:30:35 PDT 2025
Author: Mircea Trofin
Date: 2025-10-10T10:30:30-07:00
New Revision: 01e19e850ff40c2642da811c4dde58f323b1af1a
URL: https://github.com/llvm/llvm-project/commit/01e19e850ff40c2642da811c4dde58f323b1af1a
DIFF: https://github.com/llvm/llvm-project/commit/01e19e850ff40c2642da811c4dde58f323b1af1a.diff
LOG: [InstCombine] Mark as unknown the branch weights of packed integer selecting shifts (#162726)
Follow up from PR #162147. We do not have existing !prof metadata to synthesize one for the new `select` .
Fixes https://lab.llvm.org/staging/#/builders/221/builds/3091
Issue #147390
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineInternal.h
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 943c223e516fb..70718766e8ec5 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -471,6 +471,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
Value *simplifyNonNullOperand(Value *V, bool HasDereferenceable,
unsigned Depth = 0);
+public:
/// Create `select C, S1, S2`. Use only when the profile cannot be calculated
/// from existing profile metadata: if the Function has profiles, this will
/// set the profile of this select to "unknown".
@@ -483,7 +484,6 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
return Sel;
}
-public:
/// Create and insert the idiom we use to indicate a block is unreachable
/// without having to rewrite the CFG from within InstCombine.
void CreateNonTerminatorUnreachable(Instruction *InsertAt) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
index 127a506e440b7..63e24a0e90853 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"
@@ -107,7 +108,10 @@ static Value *simplifyShiftSelectingPackedElement(Instruction *I,
Value *ShrAmtZ =
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.
+ Value *Select = IC.createSelectInstWithUnknownProfile(ShrAmtZ, Lower, Upper);
+ IC.Builder.Insert(Select);
Select->takeName(I);
return Select;
}
More information about the llvm-commits
mailing list