-
Notifications
You must be signed in to change notification settings - Fork 785
O3's late condition deduction and missing DCE prevent dead br_if elimination #7454
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
Comments
I'm not sure this is an issue in OptimizeInstructions, or at least I can't see what to change there to make this better? On the other hand, adding If we had a "keep optimizing til fixed point" mode then this would be optimized fully, but we run a fixed pipeline for simplicity, which works most of the time, and avoids unpredictable compilation times. |
I understand what you mean. It’s probably a case where wasm-opt doesn't handle this well due to the ordering and interaction of passes. It's tricky to fully grasp, and as you said, some optimizations might just need more cycles to reach an "optimal state" properly. |
My question about is the ordering and interaction: I've see the wasm-opt use |
"global" passes operate on the entire module, while "function" passes operate on each function independently. "global" ones are used for things that need to look at multiple functions at a time, like inlining. In theory if there was a benefit to running In general, we want |
Yeah, I understand what you mean, especially the tradeoffs here. I think it is of low priority and we might be better to leave this for later. |
Given the following code:
wasm-opt (16dbac1) can eliminate the dead
br_if
body by-all -O2
but cannot by-all -O3
.Analysis
The most probable issue lies in the optimize-instructions pass:
optimize-instructions
fails to deduce the condition to zero:updateAfterInlining
ofinlining-optimizing
in O2.inlining-optimizing
, but no further DCE (likevacuum
) is performed.In short, there appears to be a missed optimization in
optimize-instructions
for O3.The text was updated successfully, but these errors were encountered: