Skip to content

adding conservative constant folding #172

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

Closed
wants to merge 8 commits into from
Closed

Conversation

nevakrien
Copy link

this is currently just a rough sketch however it does already work for very simple cases (like minus_2.b)
I believe this specific way of doing it is guaranteed to be 100% correct for all b code everywhere although i might have messed up some of the actual computations

@nevakrien
Copy link
Author

this attempts to solve #154

@nevakrien
Copy link
Author

i went ahead and also added some dead code elimination to solve #155
it covers the case in the test code and again 100% conservative I am even letting users do some cursed things with asm if they want (labels within user asm are considered potentially jumpble and thus not dead)

@nevakrien nevakrien force-pushed the opts branch 3 times, most recently from d370b9e to 98d58e4 Compare June 24, 2025 08:10
@rexim
Copy link
Member

rexim commented Jul 3, 2025

This is a rather unsatisfactory state of affairs. I'd expect a bit more from a PR that introduces constant folding. I'd expect at least the level I demonstrated on the stream where I prototyped it https://www.youtube.com/watch?v=L-IzN9-fqWg

2025-07-03-133329_1513x840_scrot

@nevakrien
Copy link
Author

Yes that kinda requires playing with refrences to auto at least a little bit.

The dead code elimination is actually pretty good but for the constant folding I do need to start tracking the autovars which is more of a pain.

@rexim
Copy link
Member

rexim commented Jul 12, 2025

Yes that kinda requires playing with refrences to auto at least a little bit.

The dead code elimination is actually pretty good but for the constant folding I do need to start tracking the autovars which is more of a pain.

Understandable

@rexim rexim closed this Jul 12, 2025
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

Successfully merging this pull request may close these issues.

2 participants