-
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
allow disabling of subtraction transform #4633
Conversation
2dc3f63
to
aaab525
Compare
Add mechanism to allow the the tranform that changes `a - const` -> `a + (-const)` to be disabled
aaab525
to
3734460
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think GCC/CLang-style feature flags might be preferable over adding a policy to each compiler pass.
@grg, out of curiosity can you share motivation for disabling this rewriting? These changes are increasingly showing that the current frontend/midend split is not really working. Indeed even which frontend optiomizations disabled, it does actually a lot of optimizations and not really necessary rewriting (constant folding, parser-if elimination, control flow simplications). One path forward I could see would be to start definting a "minimal frontend" that would be basically responsible of checking validity of the program, including type checking but would not very little rewriting. It might be tricky to say where the limits should be (inserting casts explicitly is probably OK, expanding the What could get tricky is that some midend passes may have implict preconditions that the current frontend (some pass from it) had already executed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this affect constant folding, is the pass able to handle subtract of constants?
Otherwise the code looks good to me ✅.
@vlstill A simple array reference of this form (where
is translated to:
The Intel IPU compiler reports an error after this translation is applied. Without knowing the history, my guess is that the original code author wanted to prevent access beyond the current depth by disallowing any addition to the depth. After the frontend has executed and applied this transformation, we don't know whether the P4 author wrote I agree that defining a new minimal front-end is a good way to proceed. Some existing passes will neatly fit either in-or-out of the minimal front-end, but I suspect that there will be some passes that need splitting. |
The genesis of this (doing "too much" in the frontend) is allowing One possibility is that we set things up to do these passes that should not be in the frontend only in limited contexts (like type arguments) when running in the frontend, so as to allow proper typechecking, without doing everything that any target might not like. Then targets could run them (or not) in the midend as desired.
This is already a general problem -- many passes depend on some other pass having been run first, and it is not well documented. Passes that have preconditions should at least document those preconditions. |
Add mechanism to allow the the transform that changes
a - const
->a + (-const)
to be disabled.This change adds a new function to the FrontEndPolicy object to control this optimization. We may eventually want to change to some other mechanism (e.g., breaking out some of the optimizations that aren't universally useful), but for now this provides the ability to turn the optimization off.