Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization techniques #81

Closed
3 of 4 tasks
lhmouse opened this issue Dec 23, 2019 · 4 comments
Closed
3 of 4 tasks

Optimization techniques #81

lhmouse opened this issue Dec 23, 2019 · 4 comments

Comments

@lhmouse
Copy link
Owner

lhmouse commented Dec 23, 2019

Optimizer Wish List

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

  • 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 #137

@FrankHB
Copy link
Contributor

FrankHB commented Dec 24, 2019

Metacompilation

@FrankHB
Copy link
Contributor

FrankHB commented Dec 24, 2019

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

@lhmouse
Copy link
Owner Author

lhmouse commented Dec 24, 2019

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
Copy link
Owner Author

lhmouse commented Mar 8, 2022

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

@lhmouse lhmouse changed the title Optimizer Plans of optimizations Nov 5, 2023
@lhmouse lhmouse changed the title Plans of optimizations Optimization techniques Nov 5, 2023
@lhmouse lhmouse closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants