-
Notifications
You must be signed in to change notification settings - Fork 786
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
Open
xuruiyang2002
wants to merge
13
commits into
WebAssembly:main
Choose a base branch
from
xuruiyang2002:refactor_binary_same_ops
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c3d265b
tests
xuruiyang2002 4362844
opt for 7440
xuruiyang2002 b684076
Format the code
xuruiyang2002 f7b9d49
Update
xuruiyang2002 9010408
Update
xuruiyang2002 256ce96
Format the code
xuruiyang2002 844ec20
Format the code (I HATE CLANG-FORMAT)
xuruiyang2002 e491494
Fix
xuruiyang2002 1b76476
Revert "tests"
xuruiyang2002 4a3bdf0
Fix replaceCurrent: avoid self-replacement
xuruiyang2002 3967445
Fix
xuruiyang2002 b240e1d
Update test
xuruiyang2002 53c9116
Remove unused include
xuruiyang2002 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
Update test
- Loading branch information
commit b240e1da2c87b09da711ed6a18365bdc49795fcb
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
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.
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.