-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: add optimization rules for bitwise operations #5423
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
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2ed544e
feat: add optimization rules for bitwise operations
izveigor 1add43f
fix: cargo fmt
izveigor febd022
fix: comments, determining data type of an int literal, additional tests
izveigor ef983ae
fix: add "get_data_type" to impl SimplifyInfo for MyInfo
izveigor 35f741e
fix: add behavior of the function "get_data_type"
izveigor 59efc92
add information about "get_data_type" to the docs
izveigor 34208c9
fix: doc tests for "expr_simplifier.rs"
izveigor f792392
fix: delete_xor_in_complex_expr
izveigor c7312a5
fix: some bitwise optimization rules, that can work even if an expr i…
izveigor d2779df
fix: prefer ScalarValue methods over "new_int_by_expr_data_type"
izveigor 9d71417
fix: resolve merge conflict
izveigor 336aa4b
fix: ScalarValue::new_negative_one
izveigor a2a6706
fix: get_data_type
izveigor 5ee2f5b
fix: cargo clippy and fmt style
izveigor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -639,6 +639,31 @@ impl Expr { | |
| binary_expr(self, Operator::Or, other) | ||
| } | ||
|
|
||
| /// Return `self & other` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| pub fn bitwise_and(self, other: Expr) -> Expr { | ||
| binary_expr(self, Operator::BitwiseAnd, other) | ||
| } | ||
|
|
||
| /// Return `self | other` | ||
| pub fn bitwise_or(self, other: Expr) -> Expr { | ||
| binary_expr(self, Operator::BitwiseOr, other) | ||
| } | ||
|
|
||
| /// Return `self ^ other` | ||
| pub fn bitwise_xor(self, other: Expr) -> Expr { | ||
| binary_expr(self, Operator::BitwiseXor, other) | ||
| } | ||
|
|
||
| /// Return `self >> other` | ||
| pub fn bitwise_shift_right(self, other: Expr) -> Expr { | ||
| binary_expr(self, Operator::BitwiseShiftRight, other) | ||
| } | ||
|
|
||
| /// Return `self << other` | ||
| pub fn bitwise_shift_left(self, other: Expr) -> Expr { | ||
| binary_expr(self, Operator::BitwiseShiftLeft, other) | ||
| } | ||
|
|
||
| /// Return `!self` | ||
| #[allow(clippy::should_implement_trait)] | ||
| pub fn not(self) -> Expr { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 this can be expressed slightly more concisely -- see #5510
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.
Agree, this code is redundant.