Skip to content

Commit 58e63cc

Browse files
committed
Use WalkResult::interrupt() for early exit in hasCallWithDynamicVeq
Replace boolean flag pattern with idiomatic MLIR WalkResult for cleaner early termination when a dynamic veq type is found.
1 parent d214b8d commit 58e63cc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lib/Optimizer/Transforms/ApplyOpSpecialization.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,19 @@ using ApplyOpAnalysisInfo = DenseMap<Operation *, ApplyVariants>;
7676
/// accept the concrete veq size, propagating type info deeper for better
7777
/// optimization but increasing code size.
7878
static bool hasCallWithDynamicVeq(func::FuncOp func, ModuleOp module) {
79-
bool found = false;
80-
func.walk([&](func::CallOp callOp) {
81-
if (found)
82-
return;
79+
auto result = func.walk([&](func::CallOp callOp) {
8380
auto callee = module.lookupSymbol<func::FuncOp>(callOp.getCallee());
8481
if (!callee)
85-
return;
82+
return WalkResult::advance();
8683
for (auto inputTy : callee.getFunctionType().getInputs()) {
8784
if (auto veqTy = dyn_cast<quake::VeqType>(inputTy)) {
88-
if (!veqTy.hasSpecifiedSize()) {
89-
found = true;
90-
return;
91-
}
85+
if (!veqTy.hasSpecifiedSize())
86+
return WalkResult::interrupt();
9287
}
9388
}
89+
return WalkResult::advance();
9490
});
95-
return found;
91+
return result.wasInterrupted();
9692
}
9793

9894
/// This analysis scans the IR for `ApplyOp`s to see which ones need to have

0 commit comments

Comments
 (0)