-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[InstCombine] Mark as unknown the branch weights of packed integer selecting shifts #162726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[InstCombine] Mark as unknown the branch weights of packed integer selecting shifts #162726
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-transforms Author: Mircea Trofin (mtrofin) ChangesFollow up from PR #162147. Full diff: https://github.com/llvm/llvm-project/pull/162726.diff 1 Files Affected:
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;
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. No existing data to pull from, and there's no way to have a reasonable guess about which why the select goes without instrumentation.
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
Outdated
Show resolved
Hide resolved
// this select. | ||
if (auto *SI = dyn_cast<SelectInst>(Select)) | ||
setExplicitlyUnknownBranchWeightsIfProfiled( | ||
*SI, *SI->getParent()->getParent(), DEBUG_TYPE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use
SelectInst *createSelectInst(Value *C, Value *S1, Value *S2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup - just had to make it public (plus the change before in the stack)
eda40bc
to
8ce46b2
Compare
4d706b2
to
7be6926
Compare
ac32705
to
73e18c0
Compare
8ce46b2
to
f1efbcc
Compare
73e18c0
to
12cae82
Compare
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