Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Simplify some S.L.Expressions branch compilation methods - #22166

Merged
VSadov merged 3 commits into
dotnet:masterfrom
JonHanna:sle_branch_compilation
Jul 20, 2017
Merged

VSadov merged 3 commits into
dotnet:masterfrom
JonHanna:sle_branch_compilation

Conversation

@JonHanna

Copy link
Copy Markdown
Contributor

Simplify EmitExpressionAndBranch method

EmitExpressionAndBranch is called from non-lifted non-method AndAlso and OrElse expressions, from Conditional and from Switch expressions' use of Equal, and from calls which originate with itself, all of which mean the node's type is boolean. Removing the test for node.Type == typeof(bool) allows for the rest of the method to be simplified and no longer need a try…finally.

Also include tests covering the EmitBranchNot case. Contributes to #11409

Reduce if-else ladders in EmitAndAlsoBinaryExpression and EmitOrElseBinaryExpression

Handle all cases in 2 tests, instead of between 2 and 4.

Simplify IL produced for EmitMethodAndAlso and EmitMethodOrElse

These methods dup the lhs operand, then if not short-circuiting store it, then obtain the rhs and store than, the retrieve lhs and rhs and call the method.

Instead just dup the lhs and if not short-circuiting leave it on the stack, obtain the rhs and call the method.

JonHanna added 3 commits July 12, 2017 17:34
EmitExpressionAndBranch is called from non-lifted non-method AndAlso
and OrElse, from Conditional and from Switch's use of Equal, and from
calls which originate with itself, all of which mean the node's type is
boolean. Removing the test for node.Type == typeof(bool) allows for the
rest of the method to be simplified.

Also include tests covering the EmitBranchNot case.
Contributes to #11409
…inaryExpression

Handle all cases in 2 tests, instead of between 2 and 4.
These methods dup the lhs, then if not short-circuiting store it, then
obtain the rhs and store than, the retrieve lhs and rhs and call
the method.

Instead dup the lhs and if not short-circuiting leave it on the stack,
obtain the rhs and call the method.

@VSadov VSadov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@VSadov
VSadov merged commit 77df4aa into dotnet:master Jul 20, 2017
@JonHanna
JonHanna deleted the sle_branch_compilation branch July 20, 2017 22:27
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…fx#22166)

* Simplify EmitExpressionAndBranch method.

EmitExpressionAndBranch is called from non-lifted non-method AndAlso
and OrElse, from Conditional and from Switch's use of Equal, and from
calls which originate with itself, all of which mean the node's type is
boolean. Removing the test for node.Type == typeof(bool) allows for the
rest of the method to be simplified.

Also include tests covering the EmitBranchNot case.
Contributes to dotnet/corefx#11409

* Reduce if-else ladders in EmitAndAlsoBinaryExpression and EmitOrElseBinaryExpression

Handle all cases in 2 tests, instead of between 2 and 4.

* Simplify IL produced for EmitMethodAndAlso/OrElse

These methods dup the lhs, then if not short-circuiting store it, then
obtain the rhs and store than, the retrieve lhs and rhs and call
the method.

Instead dup the lhs and if not short-circuiting leave it on the stack,
obtain the rhs and call the method.


Commit migrated from dotnet/corefx@77df4aa
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants