Skip to content
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

Optimize code by using De Morgan laws #670

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

einar-polygon
Copy link
Contributor

No description provided.

@einar-polygon einar-polygon added the enhancement New feature or request label Sep 29, 2024
@einar-polygon einar-polygon self-assigned this Sep 29, 2024
@github-actions github-actions bot added the crate: evm_arithmetization Anything related to the evm_arithmetization crate. label Sep 29, 2024
Copy link
Collaborator

@Nashtare Nashtare left a comment

Choose a reason for hiding this comment

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

Thanks Einar! Unfortunately it is not improving the current KERNEL code (most likely because this would only possibly apply to the hash precompiles, where we already improved the binary ops combinations), but good to have nonetheless for the future!
I've left a light comment inline to expand the covering further

evm_arithmetization/src/cpu/kernel/optimizer.rs Outdated Show resolved Hide resolved
evm_arithmetization/src/cpu/kernel/optimizer.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@Nashtare Nashtare left a comment

Choose a reason for hiding this comment

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

Thanks Einar, just a couple nits, but LGTM!
Would also need to pull latest develop for CI to run properly.

@@ -157,6 +159,65 @@ fn remove_ignored_values(code: &mut Vec<Item>) {
});
}

/// Helper predicate for the De Morgan rules.
fn is_push_or_dup(op: &Item) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we could use this new helper above in remove_ignored_values, but the pattern matching may be clearer, so non-blocking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

It is not worse, but I don't know if it is better.

evm_arithmetization/src/cpu/kernel/optimizer.rs Outdated Show resolved Hide resolved
evm_arithmetization/src/cpu/kernel/optimizer.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot added crate: trace_decoder Anything related to the trace_decoder crate. crate: mpt_trie Anything related to the mpt_trie crate. crate: zero_bin Anything related to the zero-bin subcrates. ci crate: common labels Oct 1, 2024
@github-actions github-actions bot removed crate: trace_decoder Anything related to the trace_decoder crate. crate: mpt_trie Anything related to the mpt_trie crate. crate: zero_bin Anything related to the zero-bin subcrates. ci crate: common labels Oct 1, 2024
@Nashtare Nashtare added this to the Performance Tuning milestone Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crate: evm_arithmetization Anything related to the evm_arithmetization crate. enhancement New feature or request
Projects
Status: Ready to Review
Development

Successfully merging this pull request may close these issues.

2 participants