-
Notifications
You must be signed in to change notification settings - Fork 758
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
Push struct.new
down to make it more likely that heap stores can be optimized.
#6584
Conversation
@gkdn Reproed the case with the string constructor that had some inline code that prevented the |
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 % last comments
src/passes/OptimizeInstructions.cpp
Outdated
auto* tmp = list[i]; | ||
list[i] = list[j]; | ||
list[j] = tmp; |
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.
auto* tmp = list[i]; | |
list[i] = list[j]; | |
list[j] = tmp; | |
std::swap(list[i], list[j]); |
@@ -1,5 +1,5 @@ | |||
;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. | |||
;; RUN: wasm-opt %s --remove-unused-names --optimize-instructions -all -S -o - \ | |||
;; RUN: wasm-opt %s --remove-unused-names --optimize-instructions -all -S -o - \ |
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.
unneeded space?
;; RUN: wasm-opt %s --remove-unused-names --optimize-instructions -all -S -o - \ | |
;; RUN: wasm-opt %s --remove-unused-names --optimize-instructions -all -S -o - \ |
(nop) | ||
;; |
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.
;; | |
;; We do not swap with another local.set of struct.new. |
Heap stores (
struct.set
) are optimized into thestruct.new
when they are adjacent in a statement list.Pushing
struct.new
down when they are not adjacent increases the likelihood for heap stores to be optimized. Optimizing heap stores is a beneficial step in making struct fields immutable which in turn helps other various optimziations.