-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[FuncSpec] Handle ssa_copy intrinsic calls in InstCostVisitor #114247
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
Conversation
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-function-specialization Author: Hari Limaye (hazzlim) ChangesLook through ssa_copy intrinsic calls when computing codesize bonus for a specialization. Also remove redundant logic to skip computing codesize bonus for ssa_copy intrinsics, now these are considered zero-cost by TTI (in PR#75294). Full diff: https://github.com/llvm/llvm-project/pull/114247.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
index 919d3143a13f7e..1efec22624dd4f 100644
--- a/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -120,10 +120,6 @@ Cost InstCostVisitor::estimateBasicBlocks(
continue;
for (Instruction &I : *BB) {
- // Disregard SSA copies.
- if (auto *II = dyn_cast<IntrinsicInst>(&I))
- if (II->getIntrinsicID() == Intrinsic::ssa_copy)
- continue;
// If it's a known constant we have already accounted for it.
if (KnownConstants.contains(&I))
continue;
@@ -402,6 +398,14 @@ Constant *InstCostVisitor::visitFreezeInst(FreezeInst &I) {
}
Constant *InstCostVisitor::visitCallBase(CallBase &I) {
+ assert(LastVisited != KnownConstants.end() && "Invalid iterator!");
+
+ // Look through calls to ssa_copy intrinsics.
+ if (auto *II = dyn_cast<IntrinsicInst>(&I);
+ II && II->getIntrinsicID() == Intrinsic::ssa_copy) {
+ return LastVisited->second;
+ }
+
Function *F = I.getCalledFunction();
if (!F || !canConstantFoldCallTo(&I, F))
return nullptr;
|
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.
Great thanks! Unit/regression test?
Look through ssa_copy intrinsic calls when computing codesize bonus for a specialization. Also remove redundant logic to skip computing codesize bonus for ssa_copy intrinsics, now these are considered zero-cost by TTI (in PR#75294).
64b91de
to
301880c
Compare
Added a regression test, as a prior commit so it's more obvious how this change affects things :) As additional context for this change, this improves the estimation of the CodeSize bonus for a specialization of the function |
…14247) Look through ssa_copy intrinsic calls when computing codesize bonus for a specialization. Also remove redundant logic to skip computing codesize bonus for ssa_copy intrinsics, now these are considered zero-cost by TTI (in PR llvm#75294).
Look through ssa_copy intrinsic calls when computing codesize bonus for a specialization.
Also remove redundant logic to skip computing codesize bonus for ssa_copy intrinsics, now these are considered zero-cost by TTI (in PR #75294).