-
Notifications
You must be signed in to change notification settings - Fork 396
More DCE wrt case object equality test #2396
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
Comments
Another instance of use that could be eliminated is Will update head comment. |
What happens if you mark |
@sjrd I guess we could teach the optimizer to check for existence of instances when doing |
Well here the thing the optimizer sees is |
Just gave it a try with
I don't know if this is a naive view but I imagine this optimisation could be implemented by something like:
Would that work? Is the reason you foresee this being hard due to logic (in that above is too naive) or in implementation? |
Not really. What we want to get rid of is After a round of optimization, |
Note to self: It seems like
Will give us the optimization we'd want. But the second step comes too late (Emitter would be our earliest phase). We can optimize the expression, but we cannot eliminate code that is unused because of it, providing limited value. (Yes, this is what sjrd has been saying all along) |
I've had another (unsuccessful) pass at this. Sharing a negative result. IIUC, as an approximation, the IR trees we are interested in are: x.equals;Ljava.lang.Object;Z(y) where
My thought was to special case this in the Analyzer (in This seems to be possible; however, it does not solve the problem: It seems like the only other option (short of adding another optimizer-like phase) |
I was pleasantly surprised to see that entire
case objects
are eliminated when unused.DCE doesn't reduce this snippet however:
Because we know that
XYZ
is unused ignoring the following exceptions of use...XYZ.unapply
in acase
clause, givenXYZ.unapply
isn't overridden or overloaded._: XYZ.type
in acase
clause....I believe DCE could eliminate:
XYZ
obejct itself.case
clauses referencingXYZ
.Thereby reducing the above snippet to:
The text was updated successfully, but these errors were encountered: