Skip to content

[IRGen] Use condbrs for big int switches. #42186

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

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

nate-chandler
Copy link
Contributor

Previously, switches over extremely large integers (e.g. i832) were emitted when emitting switches with many spare bits. Such switches result in unfortunate downstream codegen.

Here, for large enums (currently, more than two words) the preexisting EnumPayload::emitCompare function is used to compare each of the enum cases in turn with the payload's value. The result is a series of cond_br where the conditional is made by anding together word-size chunks of the payload value with word-size chunks of each enum case's tag, subject to masking.

rdar://83158525

Previously, switches over extremely large integers (e.g. i832) were
emitted when emitting switches with many spare bits.  Such switches
result in unfortunate downstream codegen.

Here, for large enums (currently, more than two words) the preexisting
EnumPayload::emitCompare function is used to compare each of the enum
cases in turn with the payload's value.  The result is a series of
cond_br where the conditional is made by anding together word-size
chunks of the payload value with word-size chunks of each enum case's
tag, subject to masking.

rdar://83158525
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test compiler performance

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

LGTM.

Thank you!

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macOS platform

@nate-chandler
Copy link
Contributor Author

Same source compatibility UPASSes in compiler performance run as in baseline. Merging.

@nate-chandler nate-chandler merged commit de0e227 into swiftlang:main Apr 6, 2022
@nate-chandler nate-chandler deleted the rdar83158525 branch April 6, 2022 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants