From e6f6d700054ce30e9455697a39328f5366543096 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 5 May 2016 12:18:45 -0700 Subject: note defaults of switches in SimplifyLocals --- src/passes/SimplifyLocals.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/passes/SimplifyLocals.cpp') diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index 785bccf06..dfefd515d 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -126,6 +126,7 @@ struct SimplifyLocals : public WalkerPasstargets) { self->unoptimizableBlocks.insert(target); } + self->unoptimizableBlocks.insert(sw->default_); // TODO: we could use this info to stop gathering data on these blocks } self->sinkables.clear(); -- cgit v1.2.3 From f81355b2750717584e309699dfcae3c814167578 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 5 May 2016 12:25:44 -0700 Subject: clear sinkables on unoptimizable blocks, as they have a control flow merge --- src/passes/SimplifyLocals.cpp | 16 ++++++++++------ test/passes/simplify-locals.txt | 19 +++++++++++++++++++ test/passes/simplify-locals.wast | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) (limited to 'src/passes/SimplifyLocals.cpp') diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index dfefd515d..fbd1e7e57 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -162,12 +162,16 @@ struct SimplifyLocals : public WalkerPassname.is()) { - unoptimizableBlocks.erase(curr->name); - } - if (hasBreaks) { - // more than one path to here, so nonlinear - sinkables.clear(); - blockBreaks.erase(curr->name); + if (unoptimizableBlocks.count(curr->name)) { + sinkables.clear(); + unoptimizableBlocks.erase(curr->name); + } + + if (hasBreaks) { + // more than one path to here, so nonlinear + sinkables.clear(); + blockBreaks.erase(curr->name); + } } } diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt index cc84c35d5..d97e8fc33 100644 --- a/test/passes/simplify-locals.txt +++ b/test/passes/simplify-locals.txt @@ -517,4 +517,23 @@ (get_local $m) (get_local $t) ) + (func $switch-def (param $i3 i32) (result i32) + (local $i1 i32) + (set_local $i1 + (i32.const 10) + ) + (block $switch$def + (block $switch-case$1 + (br_table $switch-case$1 $switch$def + (get_local $i3) + ) + ) + (set_local $i1 + (i32.const 1) + ) + ) + (return + (get_local $i1) + ) + ) ) diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast index 5f1db4bdb..521e8bac4 100644 --- a/test/passes/simplify-locals.wast +++ b/test/passes/simplify-locals.wast @@ -451,5 +451,24 @@ (get_local $s) (get_local $t) ) + (func $switch-def (param $i3 i32) (result i32) + (local $i1 i32) + (set_local $i1 + (i32.const 10) + ) + (block $switch$def + (block $switch-case$1 + (br_table $switch-case$1 $switch$def + (get_local $i3) + ) + ) + (set_local $i1 + (i32.const 1) + ) + ) + (return + (get_local $i1) + ) + ) ) -- cgit v1.2.3