Skip to content

Commit d61e0c4

Browse files
committed
[mlir][inliner] Return early if the inliningThreshold is 0U or -1U.
Computing the inlinling profitability can be costly due to walking the graph when counting the number of operations. This PR addresses that by returning early if the threshold is set to never or always inline.
1 parent f82d018 commit d61e0c4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mlir/lib/Transforms/InlinerPass.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,17 @@ InlinerPass::InlinerPass(std::function<void(OpPassManager &)> defaultPipeline,
9393
// Return true if the inlining ratio does not exceed the threshold.
9494
static bool isProfitableToInline(const Inliner::ResolvedCall &resolvedCall,
9595
unsigned inliningThreshold) {
96+
if (inliningThreshold == 0U)
97+
return false;
98+
if (inliningThreshold == -1U)
99+
return true;
100+
96101
Region *callerRegion = resolvedCall.sourceNode->getCallableRegion();
97102
Region *calleeRegion = resolvedCall.targetNode->getCallableRegion();
98103

99104
// We should not get external nodes here, but just return true
100105
// for now to preserve the original behavior of the inliner pass.
101-
if (!calleeRegion || !calleeRegion)
106+
if (!callerRegion || !calleeRegion)
102107
return true;
103108

104109
auto countOps = [](Region *region) {

0 commit comments

Comments
 (0)