-
Notifications
You must be signed in to change notification settings - Fork 444
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
Local Copy Propogation issue #4926
Comments
It is not incorrect, just inefficient. The copy is introduced by inlining which is not smart enough to determine that LocalCopyProp is likewise not smart enough to do this. It might propagate the |
From an end user's perspective, there's currently an inconsistency between how controls and functions are inlined. Compiling the code referenced by @komaljai yields this at the end of FrontEnd:
But if we change the
The core of the inlining is performed by |
This is because controls cannot be nested in controls (or functions) and functions cannot be nested in functions, but functions CAN be nested in controls. So the code to not introduce the copies would have to have an extra check that the function was not nested in the control. |
Do you have a short example of P4 code that p4c compiles today, where a function is nested in a control? I tried to create one, but get an error if I attempt to define a function inside the body of a control. Maybe a so-called "abstract function" that has support, originally for associating a behavior with TNA register actions? Example: https://github.com/p4lang/p4app-switchML/blob/main/dev_root/p4/workers_counter.p4#L27-L39 |
The IR representation at end of frontend looks like -
The issue is copy propogation, 'hdr' is assigned to 'hdr1' in beginning and 'hdr1' is assigned to 'hdr' back at the end, Shouldn't this be optimized?
The text was updated successfully, but these errors were encountered: