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.
Optimize binary operators with equal children even if side effect #7460
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
base: main
Are you sure you want to change the base?
Optimize binary operators with equal children even if side effect #7460
Changes from 7 commits
c3d265b
4362844
b684076
f7b9d49
9010408
256ce96
844ec20
e491494
1b76476
4a3bdf0
3967445
b240e1d
53c9116
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
This optimization looks wrong - perhaps related to the issue with
binary
in my other comment?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'll check this as soon as possible.
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've updated the code and tests as you suggested. However, it still the same for the
test/lit/ctor-eval/return_call.wast
. Thus this looks-wrong optimization is not related to the issue you mentioned (already fixed now). Is there any way to make it clear?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.
One way to debug it is to see which part of this PR causes that change. Try doing just one part of the PR and seeing if it happens. Sort of like bisection. Once we know the specific part of the PR, figuring it out may be simpler.
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.
After debugging, the issue was caused by the logic handling the case
EqInt32
:In more detail, the issue lies in the logic dealing with the
EqInt32 (side_effect, pure)
.The following is the debugging process code for
EqInt32
, please focus on line6-11:The logic in the
else
block (lines6-11) appears to be the cause of the issue. Replacing it withreturn nullptr
resolves the problem, and everything works as expected. However, I’m unclear that why the patternEqInt32 (side_effect, pure)
specifically causes failures in thewasm2js
checks.In my understanding, the code logic
is able to handle all the other cases, such as
EqInt64
. Why doesn’t it work forEqInt32 (side_effect, pure)
?Is it my PR that is wrong, or does the wasm2js check really need to be updated? Could you please check it carefully?
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'm not sure what's wrong. Your code looks right.
Perhaps see if the optimizations in ctor-eval matter,
binaryen/src/tools/wasm-ctor-eval.cpp
Lines 1467 to 1479 in c528c7e
I would check if removing them makes a difference.