25 if (
auto ret_var = old->ret_var(); ret_var && app->args().back() == ret_var) {
26 if (
auto [i, ins] = old2rec_loop_.emplace(old, std::pair<Lam*, Lam*>(
nullptr,
nullptr)); ins) {
27 auto& [rec, loop] = i->second;
28 rec = old->stub(old->type());
29 auto doms = rec->doms();
30 auto loop_dom = doms.view().rsubspan(1);
31 loop = rec->stub(
world().cn(loop_dom));
32 world().DLOG(
"old {} -> (rec: {}, loop: {})", old, rec, loop);
34 auto n = rec->num_doms();
37 for (
size_t i = 0; i != n - 1; ++i) {
38 loop_args[i] = rec->var(i);
39 loop_vars[i] = loop->var(i);
41 loop_vars.back() = rec->vars().back();
43 loop->set(old->reduce(
world().tuple(loop_vars)));
44 rec->app(
false, loop, loop_args);