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

Fix example LVN pass's copy propagation on block inputs #77

Open
sampsyo opened this issue Sep 16, 2020 · 0 comments
Open

Fix example LVN pass's copy propagation on block inputs #77

sampsyo opened this issue Sep 16, 2020 · 0 comments

Comments

@sampsyo
Copy link
Owner

sampsyo commented Sep 16, 2020

In the examples, lvn.py -p currently fails for this example:

@main {
  a: int = const 42;
.lbl:
  b: int = id a;
  a: int = const 5;
  print b;
}

The optimization incorrectly changes the last line to print a.

The problem is the interaction between copy (id) propagation and basic block inputs (i.e., the fact that a is read before it is written in the second block). One annoying but cleanish solution would be to copy a to a fresh variable right as the block begins because it is read before it is written. Another, much less clean solution would be to detect the first overwrite of a and do the renaming at that point, or to somehow avoid doing copy propagation for the id because the value will be clobbered later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant