-
Notifications
You must be signed in to change notification settings - Fork 233
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
Block scoped store/load -> folding simplifcation #1353
Comments
Tagging @jfecher to check I've documented the issue correctly |
Right, the ssa refactor doesn't have a load/store/mem2reg pass at all yet which is one of the passes it will need to be able to compile to ACIR. Your proposed solution is pretty much what I had in mind as well regarding the basic flow of the pass - though we should also remove unnecessary store instructions. So the final IR would be:
A pass to remove unused instructions afterwards would be nice as well, but it is lower priority since it isn't strictly necessary to generate ACIR. |
It precisely is - since I merely copy and pasted from chat ;)
By which I suppose you're referring to stores to the same address (without a function call in between)? I think anything else would require analysis beyond the scope of the block in question. |
Right, and to elaborate on goals a bit my goal for structuring this pass with the simple "separate/fresh context for each block" approach was to have the pass:
I think we may be able to count the loads that we failed to remove (per-allocation if possible) and then if this is 0 we can remove the allocate instruction and all stores to the array as well since it is never loaded from. We could also add this in a later PR though since it is functionally separate from the original pass of removing known loads. |
Since I was short of time I've focused on the last SSA pass use case. The PR could probably be adapted to handle both cases without too much work. Feel free to modify if you need this work merged before I get back (I'm off Thursday/Friday). |
Problem
The following contains an unnecessary load instruction:
This could be simplified to:
Proposed solution
For each block:
Alternatives considered
No response
Additional context
No response
Submission Checklist
The text was updated successfully, but these errors were encountered: