-
Notifications
You must be signed in to change notification settings - Fork 757
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
More optimizations for pow of two and pos/neg one const on the right #2870
Conversation
This comment has been minimized.
This comment has been minimized.
I think it's an unupdated test output? Building binaryen_js locally and running |
Please add a summary in the PR description of what this does (we'll need it for the landed commit's description, and also for review it helps to read it before reading the code) - thanks! |
Done! Added description for current PR |
Thanks! Done! |
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.
Nice work!
It might be better to have smaller PRs than this one, in general. But if it's hard to split up now, this one is ok.
In addition to the comments, please run the fuzzer for a while as I mentioned in another PR.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
lgtm with minor comments fixed, and if you've fuzzed it for a while.
Running the fuzzer+reducer I found this: (module
(type $i32_f64_i32_f64_i32_i32_f64_f64_=>_none (func (param i32 f64 i32 f64 i32 i32 f64 f64)))
(func $0 (param $0 i32) (param $1 f64) (param $2 i32) (param $3 f64) (param $4 i32) (param $5 i32) (param $6 f64) (param $7 f64)
(if
(i32.const 0)
(block
(drop
(i64.extend_i32_s
(i64.gt_u
(i64.const 0)
(i64.const -1)
)
)
)
(unreachable)
)
(nop)
)
)
) That fails with
|
This comment has been minimized.
This comment has been minimized.
So tested during 2.5 hours (last ITERATION: 25037) and seems everything ok. Only issue related to Asyncify which already existed before. |
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.
lgtm (and I did some fuzzing locally).
Does this have tests for everything? For example I don't think I saw a test for x * -1 ==> 0 - x
on floats.
Added more tests |
As discussed in the other issue, it's very hard to review these complex PRs in parallel. Let's focus on one at a time, which I think is first your canonicalization PR. Once that is landed please ping me in the next PR after it. |
Got it! |
(Btw, if it's not clear, that was for me personally - if other devs in this project have time to review other PRs in parallel that would be great of course.) |
I agree that focusing on one thing at a time is helpful. @kripken Do you want to review request me into some particular PR you haven't looked at yet so I can help balance the load? |
I don't have a particular one in mind (I haven't looked at them in detail) - feel free to pick any of them. |
This comment has been minimized.
This comment has been minimized.
Will refuzz tomorrow |
Ok, refuzzed until Could somebody review / look at this PR again? |
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.
LGTM besides that one comment 👍
Thanks! |
optimizePowerOf2UDiv
which completeoptimizePowerOf2URem
/optimizePowerOf2Mul
set.optimizePowerOf2UDiv
and friends now define as template functions for handlingi32
andi64
types.(integer)x * -1
==>0 - x
(signed)x % -1
==>0
(signed)x % 1
==>0
(uint32_t)x / -1
==>x != -1
(unsigned)x > -1
==>0
(unsigned)x < -1
==>x != -1
(unsigned)x <= -1
==>1
(signed)x <= -1
==>(unsigned)x >> sizeof(bits) - 1