-
Notifications
You must be signed in to change notification settings - Fork 223
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
Consider adding a no-op instruction to SSA #6842
Comments
Just looked at To make sure I understand correctly, what you're suggesting is not only to replace the original result with a constant, but to replace the call instruction itself with a different IIUC the DIE pass would not eliminate |
The general idea is this no-op instruction is a way that we can tell compiler that we don't care about the results. The compiler can then whenever it starts reinserting instructions ignore this instruction and so we automatically filter them out without needing a whole pass devoted to that. The current situation where the instructions persist until die is a method but not ideal as we have to keep these instructions through all the other SSA passes |
What you say in your comment is correct. We would want the diepass to assert that any noop instructions are used however - it would be a compiler bug if this instruction had its results used by other instructions. |
You mean assert that they are not used? |
Ah yeah, typo there. "are not used" is correct. |
Tom is right, but I thought I'd add my own clarifications:
I originally made this issue while working on the remove value ids PR in which I had to rewrite the resolve_is_unconstrained pass so that it didn't need to call this replace results method which was no longer possible in this PR. I'd still like to remove replace results because I don't think it should be needed if we're already calling I mentioned a Nop instruction returning possibly any dummy values but maybe what we'd want instead is for the instruction to always return nothing, since if you insert a Nop you should always be relying on the return values being mapped away already. This'd provide us a bit greater guarantee that these return values which should be removed aren't sticking around I think. resolve_is_unconstrained also isn't the only PR which has this "touch only a few things, then call These Nop instructions would be expected to be removed automatically in a few cases:
|
Problem
Certain passes like
resolve_is_unconstrained
go through the ssa to handle only a few instructions (in this case onlyvN = call is_unconstrained()
) but don't have a good way to remove these instructions without re-inserting every instruction into the block as they go (and choosing not to re-insert these handled instructions) or iterating through the block again afterward and retaining only the non-handled instructions.Happy Case
We can consider adding an
Instruction::Nop { result_types }
instruction which conceptually "returns" value(s) of any type but in practice will always be removed from the program or skipped over in acir-gen.This Nop instruction can be used to replace instructions like
call is_unconstrained()
with so that they will later automatically be removed by callingInstruction::Nop { ... }.simplify()
which will always returnSimplifyResult::Remove
.Workaround
None
Workaround Description
No response
Additional Context
No response
Project Impact
None
Blocker Context
No response
Would you like to submit a PR for this Issue?
None
Support Needs
No response
The text was updated successfully, but these errors were encountered: