summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ast_utils.h3
-rw-r--r--test/passes/simplify-locals.txt29
-rw-r--r--test/passes/simplify-locals.wast20
3 files changed, 52 insertions, 0 deletions
diff --git a/src/ast_utils.h b/src/ast_utils.h
index b81413d78..0bb0a821e 100644
--- a/src/ast_utils.h
+++ b/src/ast_utils.h
@@ -130,6 +130,9 @@ struct EffectAnalyzer : public PostWalker<EffectAnalyzer, Visitor<EffectAnalyzer
bool checkPost(Expression* curr) {
visit(curr);
+ if (curr->is<Loop>()) {
+ branches = true;
+ }
return hasAnything();
}
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
index 60e07f3fb..ee4418953 100644
--- a/test/passes/simplify-locals.txt
+++ b/test/passes/simplify-locals.txt
@@ -7,6 +7,7 @@
(type $4 (func (param i32)))
(type $5 (func (param i32) (result i32)))
(type $6 (func (param i32 i32 i32 i32 i32 i32)))
+ (type $7 (func (param i32 i32)))
(import $waka "env" "waka")
(import $waka_int "env" "waka_int" (result i32))
(import $_i64Subtract "env" "i64sub" (param i32 i32 i32 i32) (result i32))
@@ -673,4 +674,32 @@
(get_local $i1)
)
)
+ (func $no-out-of-label (type $7) (param $x i32) (param $y i32)
+ (loop $moar
+ (set_local $x
+ (block $block0
+ (br_if $moar
+ (get_local $x)
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ (drop
+ (get_local $x)
+ )
+ (block $moar
+ (set_local $y
+ (block $block1
+ (br_if $moar
+ (get_local $y)
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ (drop
+ (get_local $y)
+ )
+ )
)
diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast
index d74ebe054..2b5b84a5f 100644
--- a/test/passes/simplify-locals.wast
+++ b/test/passes/simplify-locals.wast
@@ -731,4 +731,24 @@
(get_local $i1)
)
)
+ (func $no-out-of-label (param $x i32) (param $y i32)
+ (loop $moar
+ (set_local $x
+ (block
+ (br_if $moar (get_local $x))
+ (i32.const 0)
+ )
+ )
+ )
+ (drop (get_local $x))
+ (block $moar
+ (set_local $y
+ (block
+ (br_if $moar (get_local $y))
+ (i32.const 0)
+ )
+ )
+ )
+ (drop (get_local $y))
+ )
)