Skip to content

OptimizeInstructions: Use min/max bits in comparisons - #5035

Merged
kripken merged 19 commits into
mainfrom
usebits
Sep 13, 2022
Merged

kripken merged 19 commits into
mainfrom
usebits

Conversation

@kripken

@kripken kripken commented Sep 12, 2022

Copy link
Copy Markdown
Member

When we see e.g. x < y and x has fewer bits set, we can infer a result.

Helps #5010. As mentioned there, this is one of the top superoptimizer findings.
On j2wasm it ends up removing a few hundred binary operations for example.

@kripken
kripken requested review from aheejin and tlively September 12, 2022 19:15
Comment thread src/ir/bits.h Resolved
Comment thread src/passes/OptimizeInstructions.cpp Outdated
if (leftMaxBits < getBitsForType(type)) {
using namespace Abstract;
auto rightMinBits = Bits::getMinBits(curr->right);
auto rightIsSigned = rightMinBits == getBitsForType(type);

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.

Maybe rightIsNegative instead?

kripken and others added 2 commits September 13, 2022 08:06
Co-authored-by: Thomas Lively <7121787+tlively@users.noreply.github.com>
@kripken
kripken enabled auto-merge (squash) September 13, 2022 15:07
@kripken
kripken merged commit a2773e5 into main Sep 13, 2022
@kripken
kripken deleted the usebits branch September 13, 2022 15:39
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.

3 participants