mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SILInliner: Critical edges have no code size impact.
I think unconditional branches should be free, period. They will mostly be removed during LLVM code gen. However, fixing this requires signficant adjustments to inlining heuristics to avoid microbenchmark regressions at -Osize. So, instead I am just making this less sensitive to critical edges for the sake of pipeline stability.
This commit is contained in:
@@ -802,10 +802,12 @@ static int getThreadingCost(SILInstruction *I) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int maxBranchRecursionDepth = 6;
|
||||
/// couldSimplifyUsers - Check to see if any simplifications are possible if
|
||||
/// "Val" is substituted for BBArg. If so, return true, if nothing obvious
|
||||
/// is possible, return false.
|
||||
static bool couldSimplifyEnumUsers(SILArgument *BBArg, int Budget) {
|
||||
static bool couldSimplifyEnumUsers(SILArgument *BBArg, int Budget,
|
||||
int recursionDepth = 0) {
|
||||
SILBasicBlock *BB = BBArg->getParent();
|
||||
int BudgetForBranch = 100;
|
||||
|
||||
@@ -833,6 +835,9 @@ static bool couldSimplifyEnumUsers(SILArgument *BBArg, int Budget) {
|
||||
}
|
||||
|
||||
if (auto *BI = dyn_cast<BranchInst>(User)) {
|
||||
if (recursionDepth >= maxBranchRecursionDepth) {
|
||||
return false;
|
||||
}
|
||||
if (BudgetForBranch > Budget) {
|
||||
BudgetForBranch = Budget;
|
||||
for (SILInstruction &I : *BB) {
|
||||
@@ -844,7 +849,8 @@ static bool couldSimplifyEnumUsers(SILArgument *BBArg, int Budget) {
|
||||
if (BudgetForBranch > 0) {
|
||||
SILBasicBlock *DestBB = BI->getDestBB();
|
||||
unsigned OpIdx = UI->getOperandNumber();
|
||||
if (couldSimplifyEnumUsers(DestBB->getArgument(OpIdx), BudgetForBranch))
|
||||
if (couldSimplifyEnumUsers(DestBB->getArgument(OpIdx), BudgetForBranch,
|
||||
recursionDepth + 1))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user