From daeac1e0735452d54c8b16b51cac88165d0d4eab Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 3 Nov 2022 09:25:23 -0700 Subject: RedundantSetElimination: Look at fallthrough values (#5213) This can help in rare cases in MVP wasm, say for the return value of a block. But for wasm GC it is very important due to casts. Similar logic was added as part of #5194 for SimplifyLocals. It should probably have been in a separate PR then. This does the right thing for RedundantSetElimination, as a separate PR. Full tests will appear in that later PR (it is not really possible to test the GC side yet - we need the logic in the later PR that actually switches to a more refined local index when available). --- src/passes/RedundantSetElimination.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/passes/RedundantSetElimination.cpp b/src/passes/RedundantSetElimination.cpp index 9a60331dd..3d21b7d71 100644 --- a/src/passes/RedundantSetElimination.cpp +++ b/src/passes/RedundantSetElimination.cpp @@ -298,7 +298,9 @@ struct RedundantSetElimination auto& setps = curr->contents.setps; for (auto** setp : setps) { auto* set = (*setp)->cast(); - currValues[set->index] = getValue(set->value, currValues); + auto* value = Properties::getFallthrough( + set->value, getPassOptions(), *getModule()); + currValues[set->index] = getValue(value, currValues); } if (currValues == curr->contents.end) { // nothing changed, so no more work to do @@ -335,7 +337,9 @@ struct RedundantSetElimination for (auto** setp : setps) { auto* set = (*setp)->cast(); auto oldValue = currValues[set->index]; - auto newValue = getValue(set->value, currValues); + auto* value = Properties::getFallthrough( + set->value, getPassOptions(), *getModule()); + auto newValue = getValue(value, currValues); auto index = set->index; if (newValue == oldValue) { remove(setp); -- cgit v1.2.3