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

Made Equality Tests Smarter #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NCGThompson
Copy link
Contributor

Currently, == compares the underlying arrays. This compiles to memcmp in llvm. memcmp is then optimized to bcmp. The problem with this is that llvm-opt doesn't do much with bcmp during the instcombine pass. It will also sometimes write to memory just to read it back again.

What I did to work around this in div-rem was use unreachable_unchecked() calls to tell the compiler that the bcmp is equivalent to two icmps. I have considered overloading the == operator with a bcmp plus hints, but now I believe it is best to not use bcmp at all. Ethnum's integers have public fields, so the current equality operation can always be called with a.0 == b.0.

I compared and annotated a few alternatives on Compiler Explorer. Note that I have not considered adding an llvm intrinsic.

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.

1 participant