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

Optimiser Fix/Improvement for goto #47

Open
Woccz opened this issue Jun 14, 2021 · 4 comments
Open

Optimiser Fix/Improvement for goto #47

Woccz opened this issue Jun 14, 2021 · 4 comments
Labels
enhancement New feature or request optimisation Everything regarding better code

Comments

@Woccz
Copy link
Contributor

Woccz commented Jun 14, 2021

Given the following code:

a> goto b

b> x = 5
goto a

in NOLOL, it compiles to:

goto2
b=5 goto2

There is no need for a goto pointing to the next line.

I suggest during optimisation to search and remove all gotos that point to the next line.

Thank you.

@Woccz Woccz changed the title Compiler Fix/Improvement Optimiser Fix/Improvement Jun 14, 2021
@dbaumgarten
Copy link
Owner

Does this happen "by accident" during compilation, or does the programmer need to deliberatly place a goto ?

@Woccz
Copy link
Contributor Author

Woccz commented Jun 14, 2021

The compiled code has not been changed.
What is your question exactly?

@dbaumgarten dbaumgarten added the enhancement New feature or request label Jun 14, 2021
@Woccz Woccz changed the title Optimiser Fix/Improvement Optimiser Fix/Improvement for goto Jun 15, 2021
@dbaumgarten dbaumgarten added the optimisation Everything regarding better code label Jun 15, 2021
@dbaumgarten
Copy link
Owner

I just wondered if the compiler would generate such inefficient code when using if and while blocks, or if this only happens if the user is doing it himself.

At least for label-gotos this should be relatively simple to detect and remove. There is already code to remove useless gotos, which could just be extended to handle this.

@Woccz
Copy link
Contributor Author

Woccz commented Jun 15, 2021

Well it's smart enough to replace the goto a > goto b with just a goto b, just missed the goto next line(after empty lines removed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimisation Everything regarding better code
Projects
None yet
Development

No branches or pull requests

2 participants