Skip to content
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

Remove optimization for memory.copy(x, x, C) #3073

Merged
merged 1 commit into from
Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/passes/OptimizeInstructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,16 +1399,6 @@ struct OptimizeInstructions
}

Expression* optimizeMemoryCopy(MemoryCopy* memCopy) {
FeatureSet features = getModule()->features;

// memory.copy(x, x, sz) ==> nop
if (!EffectAnalyzer(getPassOptions(), features, memCopy->dest)
.hasSideEffects() &&
!EffectAnalyzer(getPassOptions(), features, memCopy->size)
.hasSideEffects() &&
ExpressionAnalyzer::equal(memCopy->dest, memCopy->source)) {
return ExpressionManipulator::nop(memCopy);
}
// memory.copy(dst, src, C) ==> store(dst, load(src))
if (auto* csize = memCopy->size->dynCast<Const>()) {
auto bytes = csize->value.geti32();
Expand Down Expand Up @@ -1444,7 +1434,7 @@ struct OptimizeInstructions
if (getPassOptions().shrinkLevel == 0) {
// This adds an extra 2 bytes so apply it only for
// minimal shrink level
if (features.hasSIMD()) {
if (getModule()->features.hasSIMD()) {
return builder.makeStore(
bytes, // bytes
0, // offset
Expand Down
6 changes: 5 additions & 1 deletion test/passes/optimize-instructions_all-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3729,7 +3729,11 @@
)
)
(func $optimize-bulk-memory-copy (param $dst i32) (param $src i32) (param $sz i32)
(nop)
(memory.copy
(local.get $dst)
(local.get $dst)
(local.get $sz)
)
(block
(drop
(local.get $dst)
Expand Down
2 changes: 1 addition & 1 deletion test/passes/optimize-instructions_all-features.wast
Original file line number Diff line number Diff line change
Expand Up @@ -4234,7 +4234,7 @@
))
)
(func $optimize-bulk-memory-copy (param $dst i32) (param $src i32) (param $sz i32)
(memory.copy ;; nop
(memory.copy ;; skip
(local.get $dst)
(local.get $dst)
(local.get $sz)
Expand Down