-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Avoid creating a result temp for is-expressions #68694
Conversation
@alrz It looks like there are legitimate test failures and Correctness leg errors. |
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_IsPatternOperator.cs
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_IsPatternOperator.cs
Show resolved
Hide resolved
Done with review pass (commit 2), tests are not looked at. |
I am not feeling comfortable with the taken approach. I suggest to look for an alternatives. |
The
|
Short-circuiting is probably best to be done as a rewrite to expression (which doesn't always work because we may have a SwitchDispatch that could turn to an expression in emitter for range checks, which makes me wonder if this optimization should be done in a later pass), for any other case I think Optimizer should be taught to inline the temp when possible. Would that need a new node? |
If we are talking about an optimization as a special pass post regular rewrite (BTW, we already have a pass like that), I hope the optimization could be implemented as looking for a pattern in the bound tree and rewriting portion of the tree. That, generally, shouldn't need a new node. But, who knows, complexity could be so high that having a some sort of hint might help. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
5735b22
to
5f13ffe
Compare
@AlekseyTs Took a different approach to address avoiding spilling temps and including destinations in the same node. |
Done with review pass (commit 24) |
@AlekseyTs @dotnet/roslyn-compiler for review, thanks. |
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.
LGTM (commit 26)
@dotnet/roslyn-compiler For the second review |
Opened follow-up for switch-expressions: #69194 |
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.
LGTM Thanks (iteration 26)
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
This reverts commit e1031a7.
This reverts commit e1031a7.
…" (dotnet#69582) This reverts commit b4a9c62.
Closes #59615
Closes #55334
The idea is that while the expression is still spilled, the expression is no longer spilled by default and the boolean result will be pushed to the stack. The input expression will be evaluated as sequence side effects which will in turn spill if necessary. As a result, codegen is now closer to binary expressions' (but not quite).The same optimization could be applied to switch expression - looking at conditionals, we will have to merge stack type for that to work. I'll leave it out of this PR for now, I'm new to this so there may be a better way to accomplish the same.
Thanks.