effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Missing reset-and-immediately-shift-abort optimisation

Open jiribenes opened this issue 7 months ago • 2 comments

effect fail(): Nothing
def main() = try {
  do fail();
  println("after")
} with fail { println("failed") }

produces the following optimised core with a reset immediately followed by a shift:

interface fail_3421 {}

def main_3422() = reset { {p_3561} => 
  shift(p_3561) { {k_3584} => 
    let tmp_3586 = println_1("failed")
    return tmp_3586
  }
}

But we can clearly eliminate this, right?

// ~>
def main_3422() = {
  let tmp_3586 = println_1("failed")
  return tmp_3586
}

jiribenes avatar May 14 '25 12:05 jiribenes

I'd like to see a less trivial version of this, where statically known continuations are "inlined" as functions, and resumes become calls. In this case k_3584 would become id (and get eliminated as unused function).

serkm avatar May 15 '25 08:05 serkm

All of this is on the optimizer-wishlist and achievable by NbE :)

b-studios avatar May 15 '25 10:05 b-studios