Use `depends_on_any` in more places
diff --git a/slinky/builder/optimizations.cc b/slinky/builder/optimizations.cc index 607054f..2036758 100644 --- a/slinky/builder/optimizations.cc +++ b/slinky/builder/optimizations.cc
@@ -1834,7 +1834,7 @@ // If we don't know about a buffer, we assume we cannot mutate it in place. This covers input and output buffers. bool can_mutate_src = can_mutate[op->src] && *can_mutate[op->src]; // TODO: This mutator has quadratic complexity. It's hard to do this in one pass... - if (can_mutate_src && !depends_on(body, op->src).any()) { + if (can_mutate_src && !depends_on_any(body, op->src)) { // We can re-use the src because the body doesn't use it, and it will not create a data race. sym = op->src; body = substitute(body, op->sym, sym);
diff --git a/slinky/builder/simplify.cc b/slinky/builder/simplify.cc index cc167e7..3e9b650 100644 --- a/slinky/builder/simplify.cc +++ b/slinky/builder/simplify.cc
@@ -57,12 +57,12 @@ std::vector<stmt> result; result.reserve(b->stmts.size()); for (auto i = b->stmts.begin(); i != b->stmts.end();) { - if (depends_on(*i, sym).any()) { + if (depends_on_any(*i, sym)) { std::vector<stmt> result_i; result_i.reserve(b->stmts.size()); do { result_i.push_back(*i++); - } while (i != b->stmts.end() && depends_on(*i, sym).any()); + } while (i != b->stmts.end() && depends_on_any(*i, sym)); if (result.empty() && i == b->stmts.end()) { // Every stmt in the body depended on the decl, we aren't changing it. return make_decl(std::move(body)); @@ -1371,7 +1371,7 @@ if (!body.defined()) { set_result(stmt()); return; - } else if (!depends_on(body, op->sym).any()) { + } else if (!depends_on_any(body, op->sym)) { // The body does not depend on the loop, drop the loop. set_result(std::move(body)); return; @@ -1614,7 +1614,7 @@ stmt before, after; if (const block* b = body.as<block>()) { // Split the body into 3 parts: the part that depends on the allocation, and anything before or after that. - const auto depends_on_alloc = [=](const stmt& s) { return depends_on(s, op->sym).any(); }; + const auto depends_on_alloc = [=](const stmt& s) { return depends_on_any(s, op->sym); }; auto end_before = std::find_if(b->stmts.begin(), b->stmts.end(), depends_on_alloc); if (end_before != b->stmts.end()) { before = block::make({b->stmts.begin(), end_before}); @@ -2261,7 +2261,7 @@ } stmt body = mutate_with_buffer(op, op_body, op_sym, op_src, std::move(info)); - if (!depends_on(body, op_sym).any()) { + if (!depends_on_any(body, op_sym)) { set_result(std::move(body)); return; }
diff --git a/slinky/builder/substitute.cc b/slinky/builder/substitute.cc index 207ffdc..ecf085a 100644 --- a/slinky/builder/substitute.cc +++ b/slinky/builder/substitute.cc
@@ -879,7 +879,7 @@ } stmt terminate(const stmt& s) override { - if (depends_on(s, target).any()) { + if (depends_on_any(s, target)) { return let_stmt::make(target, replacement, s); } else { return s;