asteria icon indicating copy to clipboard operation
asteria copied to clipboard

Optimizer

Open lhmouse opened this issue 5 years ago • 4 comments

Optimizer Wish List

  • [x] Tail and Sibling Call Optimization (abbr. mistakenly TCO) Note that proper tail calls are a core language feature that cannot be disabled.

  • [x] Dead Code Elimination (abbr. DCE) This had been implemented naively but was withdrawn. It can be added back easily. But before that, rather than having individual interfaces for varieties of optimization techniques, I would prefer to have a uniformed interface for cow_vector<AIR_Node>, which may be invoked recursively.

  • [ ] Constant Folding Ideally this pass should precede DCE. We may also support constant expressions (such as 1+2*3) in the future. Arithmetic overflows (such as 1<<100), if not folded, result in exceptions, so we must not fold such expressions.

  • [ ] Constant Propagation

lhmouse avatar Dec 23 '19 15:12 lhmouse

Metacompilation

FrankHB avatar Dec 24 '19 00:12 FrankHB

What is the state of PTC support on mutual recursive calls?

FrankHB avatar Dec 24 '19 00:12 FrankHB

What is the state of PTC support on mutual recursive calls?

A function call is flattened if it occurs in a PTC context, regardless of being recursive or not.

Examples:

func foo() {
  if(something)
    return other(1, 2, 3);  // PTC by value (the result is an rvalue or void)

  if(something)
    return& other(4, 5, 6);  // PTC by reference (the result is forwarded as is)

  if(something) {
    other(true, false);  // PTC by voidification (the result is discarded)
    return;
  }

  other("hello");  // PTC by voidification, too
}

lhmouse avatar Dec 24 '19 02:12 lhmouse

info: According to profiling results by callgrind, the most hot piece of code seems to be copying References.

lhmouse avatar Mar 08 '22 16:03 lhmouse