summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/flatten-control-flow.txt7
-rw-r--r--test/passes/flatten-control-flow.wast7
-rw-r--r--test/passes/merge-blocks.txt14
-rw-r--r--test/passes/merge-blocks.wast14
-rw-r--r--test/passes/optimize-instructions.txt9
-rw-r--r--test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt38
-rw-r--r--test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast38
-rw-r--r--test/passes/precompute.txt32
-rw-r--r--test/passes/precompute.wast31
-rw-r--r--test/passes/remove-unused-brs.txt44
-rw-r--r--test/passes/remove-unused-brs.wast41
-rw-r--r--test/passes/remove-unused-names.txt10
-rw-r--r--test/passes/remove-unused-names.wast4
-rw-r--r--test/passes/remove-unused-names_merge-blocks.txt8
-rw-r--r--test/passes/remove-unused-names_merge-blocks.wast12
-rw-r--r--test/passes/simplify-locals.txt18
-rw-r--r--test/passes/vacuum.txt13
-rw-r--r--test/passes/vacuum.wast19
18 files changed, 267 insertions, 92 deletions
diff --git a/test/passes/flatten-control-flow.txt b/test/passes/flatten-control-flow.txt
index d94536712..65e7196fb 100644
--- a/test/passes/flatten-control-flow.txt
+++ b/test/passes/flatten-control-flow.txt
@@ -1174,4 +1174,11 @@
(get_local $2)
)
)
+ (func $switch-unreachable (type $1)
+ (block $label$3
+ (block
+ (unreachable)
+ )
+ )
+ )
)
diff --git a/test/passes/flatten-control-flow.wast b/test/passes/flatten-control-flow.wast
index 69f3146c0..97ecf74c7 100644
--- a/test/passes/flatten-control-flow.wast
+++ b/test/passes/flatten-control-flow.wast
@@ -773,4 +773,11 @@
(i32.const 1)
)
)
+ (func $switch-unreachable
+ (block $label$3
+ (br_table $label$3
+ (unreachable)
+ )
+ )
+ )
)
diff --git a/test/passes/merge-blocks.txt b/test/passes/merge-blocks.txt
index f9ca7c3c1..be6906f0a 100644
--- a/test/passes/merge-blocks.txt
+++ b/test/passes/merge-blocks.txt
@@ -77,16 +77,12 @@
)
(func $drop-unreachable-br_if (type $2) (result i32)
(block $label$0 (result i32)
- (drop
- (block $label$2
- (drop
- (br_if $label$2
- (br $label$0
- (i32.const 538976371)
- )
- (i32.const 1918987552)
- )
+ (block $label$2 (result i32)
+ (br_if $label$2
+ (br $label$0
+ (i32.const 538976371)
)
+ (i32.const 1918987552)
)
)
)
diff --git a/test/passes/merge-blocks.wast b/test/passes/merge-blocks.wast
index d73612735..7cba9bf90 100644
--- a/test/passes/merge-blocks.wast
+++ b/test/passes/merge-blocks.wast
@@ -55,16 +55,12 @@
)
(func $drop-unreachable-br_if (result i32)
(block $label$0 (result i32)
- (drop
- (block $label$2
- (drop
- (br_if $label$2
- (br $label$0
- (i32.const 538976371)
- )
- (i32.const 1918987552)
- )
+ (block $label$2 (result i32)
+ (br_if $label$2
+ (br $label$0
+ (i32.const 538976371)
)
+ (i32.const 1918987552)
)
)
)
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt
index 55501dfb8..6a99ee106 100644
--- a/test/passes/optimize-instructions.txt
+++ b/test/passes/optimize-instructions.txt
@@ -355,8 +355,8 @@
)
(drop
(i32.and
- (unreachable)
(i32.const 1)
+ (unreachable)
)
)
(drop
@@ -2064,8 +2064,11 @@
)
(func $shifts-square-unreachable (type $3) (param $x i32) (result i32)
(i32.shr_u
- (unreachable)
- (i32.const 9)
+ (i32.shr_u
+ (unreachable)
+ (i32.const 1031)
+ )
+ (i32.const 4098)
)
)
(func $mix-shifts (type $2) (result i32)
diff --git a/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt
index 922f64008..85e0dd6d8 100644
--- a/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt
+++ b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt
@@ -1,5 +1,6 @@
(module
(type $0 (func (param i32 i32) (result i32)))
+ (type $1 (func (result f64)))
(memory $0 0)
(func $conditionals (type $0) (param $0 i32) (param $1 i32) (result i32)
(local $2 i32)
@@ -321,4 +322,41 @@
(get_local $1)
)
)
+ (func $conditionalize-if-type-change (type $1) (result f64)
+ (local $0 i32)
+ (drop
+ (loop $label$1 (result f32)
+ (block $label$2 (result f32)
+ (drop
+ (block $label$3 (result f32)
+ (br_if $label$1
+ (i32.or
+ (f32.gt
+ (br_if $label$3
+ (f32.const 1)
+ (get_local $0)
+ )
+ (br $label$2
+ (f32.const 71)
+ )
+ )
+ (i64.eqz
+ (select
+ (i64.const 58)
+ (i64.const -982757)
+ (i64.eqz
+ (i64.const 0)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (f32.const 1)
+ )
+ )
+ )
+ (f64.const -nan:0xfffffffffffff)
+ )
)
diff --git a/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast
index 7e8365812..6e19255ed 100644
--- a/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast
+++ b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast
@@ -323,5 +323,43 @@
)
(return (get_local $1))
)
+
+ (func $conditionalize-if-type-change (result f64)
+ (local $0 i32)
+ (drop
+ (loop $label$1 (result f32)
+ (block $label$2 (result f32)
+ (drop
+ (block $label$3 (result f32)
+ (br_if $label$1
+ (i32.or ;; this turns into an if, but then the if might not be unreachable
+ (f32.gt
+ (br_if $label$3
+ (f32.const 1)
+ (get_local $0)
+ )
+ (br $label$2
+ (f32.const 71)
+ )
+ )
+ (i64.eqz
+ (select
+ (i64.const 58)
+ (i64.const -982757)
+ (i64.eqz
+ (i64.const 0)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (f32.const 1)
+ )
+ )
+ )
+ (f64.const -nan:0xfffffffffffff)
+ )
)
diff --git a/test/passes/precompute.txt b/test/passes/precompute.txt
index 74e4989dc..ad5b74e83 100644
--- a/test/passes/precompute.txt
+++ b/test/passes/precompute.txt
@@ -117,7 +117,7 @@
)
(func $br_if-condition-is-block-i32-but-unreachable-so-refinalize-tricky (type $2)
(drop
- (block $label$1
+ (block $label$1 (result i32)
(drop
(br_if $label$1
(i32.const 100)
@@ -157,4 +157,34 @@
(f64.const 4776014875438170098655851e156)
)
)
+ (func $refinalize-two-breaks-one-unreachable (type $2)
+ (drop
+ (block $label$0 (result i64)
+ (br_if $label$0
+ (select
+ (i64.const 1)
+ (block $block
+ (set_global $global$0
+ (i32.const 1)
+ )
+ (br $label$0
+ (i64.const -22)
+ )
+ )
+ (i32.const 0)
+ )
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $one-break-value-and-it-is-unreachable (type $3) (result f64)
+ (local $var$0 i32)
+ (block $label$6 (result f64)
+ (br_if $label$6
+ (unreachable)
+ (i32.const 0)
+ )
+ )
+ )
)
diff --git a/test/passes/precompute.wast b/test/passes/precompute.wast
index 3eb2683bf..b339a55d4 100644
--- a/test/passes/precompute.wast
+++ b/test/passes/precompute.wast
@@ -249,4 +249,35 @@
(f64.const 4776014875438170098655851e156)
)
)
+ (func $refinalize-two-breaks-one-unreachable
+ (drop
+ (block $label$0 (result i64)
+ (br_if $label$0
+ (select
+ (i64.const 1)
+ (block (result i64)
+ (set_global $global$0
+ (i32.const 1)
+ )
+ (br_if $label$0
+ (i64.const -22)
+ (i32.const -1)
+ )
+ )
+ (i32.const 0)
+ )
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $one-break-value-and-it-is-unreachable (result f64)
+ (local $var$0 i32)
+ (block $label$6 (result f64)
+ (br_if $label$6
+ (unreachable)
+ (i32.const 0)
+ )
+ )
+ )
)
diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt
index 7951cf18f..6991680f7 100644
--- a/test/passes/remove-unused-brs.txt
+++ b/test/passes/remove-unused-brs.txt
@@ -332,7 +332,7 @@
)
)
(if
- (block $block6
+ (block $block6 (result i32)
(block $block15
(drop
(i32.const 2)
@@ -1037,11 +1037,23 @@
)
)
)
- (func $untaken-br-with-concrete-last-element (type $2) (result i32)
- (block $label$8 (result i32)
- (block $label$11 (result i32)
+ (func $untaken-br-with-concrete-last-element (type $1)
+ (block $label$8
+ (block $label$11
(block $label$14
(br_if $label$8
+ (br $label$8)
+ )
+ )
+ )
+ )
+ )
+ (func $untaken-br-with-concrete-last-element2 (type $2) (result i32)
+ (block $label$8 (result i32)
+ (block $label$11 (result i32)
+ (block $label$14 (result i32)
+ (br_if $label$14
+ (i32.const 102)
(br $label$11
(i32.const 103)
)
@@ -1062,25 +1074,29 @@
)
)
(func $unreachable-if-that-could-be-a-br_if (type $7) (result i64)
- (loop $label$3
- (if
- (unreachable)
- (f64.const 1)
- (br $label$3)
+ (loop $label$3 (result i64)
+ (drop
+ (if (result f64)
+ (unreachable)
+ (f64.const 1)
+ (br $label$3)
+ )
)
(i64.const 1)
)
)
(func $nop-br-might-update-type (type $1)
(block $label$39
- (if
- (unreachable)
+ (drop
(if (result i32)
- (i32.const 1)
- (br $label$39)
+ (unreachable)
+ (if (result i32)
+ (i32.const 1)
+ (br $label$39)
+ (i32.const 0)
+ )
(i32.const 0)
)
- (i32.const 0)
)
)
)
diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast
index 20441d9e4..5c6776226 100644
--- a/test/passes/remove-unused-brs.wast
+++ b/test/passes/remove-unused-brs.wast
@@ -919,11 +919,24 @@
)
)
)
- (func $untaken-br-with-concrete-last-element (result i32)
+ (func $untaken-br-with-concrete-last-element
+ (block $label$8
+ (block $label$11
+ (block $label$14
+ (br_if $label$14
+ (br $label$11
+ )
+ )
+ )
+ )
+ )
+ )
+ (func $untaken-br-with-concrete-last-element2 (result i32)
(block $label$8 (result i32)
(block $label$11 (result i32)
- (block $label$14
+ (block $label$14 (result i32)
(br_if $label$14
+ (i32.const 102)
(br $label$11
(i32.const 103)
)
@@ -944,25 +957,29 @@
)
)
(func $unreachable-if-that-could-be-a-br_if (result i64)
- (loop $label$3
- (if
- (unreachable)
- (f64.const 1)
- (br $label$3)
+ (loop $label$3 (result i64)
+ (drop
+ (if (result f64)
+ (unreachable)
+ (f64.const 1)
+ (br $label$3)
+ )
)
(i64.const 1)
)
)
(func $nop-br-might-update-type
(block $label$39
- (if
- (unreachable)
+ (drop
(if (result i32)
- (i32.const 1)
- (br $label$39) ;; if we nop this, then the parent type must change
+ (unreachable)
+ (if (result i32)
+ (i32.const 1)
+ (br $label$39) ;; if we nop this, then the parent type must change
+ (i32.const 0)
+ )
(i32.const 0)
)
- (i32.const 0)
)
)
)
diff --git a/test/passes/remove-unused-names.txt b/test/passes/remove-unused-names.txt
index 894e07165..6fd0f4e51 100644
--- a/test/passes/remove-unused-names.txt
+++ b/test/passes/remove-unused-names.txt
@@ -66,15 +66,13 @@
)
(func $merge-typed-with-unreachable-child (type $2) (result i32)
(local $0 f32)
- (block $label$0 (result i32)
- (block $label$1
+ (block $label$1 (result i32)
+ (br_if $label$1
+ (i32.const 1)
(br_if $label$1
(i32.const 0)
- (br_if $label$0
+ (br $label$1
(i32.const 0)
- (br $label$0
- (i32.const 0)
- )
)
)
)
diff --git a/test/passes/remove-unused-names.wast b/test/passes/remove-unused-names.wast
index dc882cf4c..a4c240f02 100644
--- a/test/passes/remove-unused-names.wast
+++ b/test/passes/remove-unused-names.wast
@@ -80,9 +80,9 @@
(func $merge-typed-with-unreachable-child (result i32)
(local $0 f32)
(block $label$0 (result i32)
- (block $label$1
+ (block $label$1 (result i32)
(br_if $label$1
- (i32.const 0)
+ (i32.const 1)
(br_if $label$0
(i32.const 0)
(br $label$0
diff --git a/test/passes/remove-unused-names_merge-blocks.txt b/test/passes/remove-unused-names_merge-blocks.txt
index 19f03c662..c170a6c99 100644
--- a/test/passes/remove-unused-names_merge-blocks.txt
+++ b/test/passes/remove-unused-names_merge-blocks.txt
@@ -853,9 +853,11 @@
(unreachable)
)
(func $concrete_finale_in_unreachable (type $5) (result f64)
- (unreachable)
(drop
- (f64.const 6.322092475576799e-96)
+ (block (result f64)
+ (unreachable)
+ (f64.const 6.322092475576799e-96)
+ )
)
(f64.const -1)
)
@@ -897,7 +899,7 @@
)
(func $drop-unreachable-block-with-concrete-final (type $3)
(drop
- (block
+ (block (result i32)
(drop
(block
(drop
diff --git a/test/passes/remove-unused-names_merge-blocks.wast b/test/passes/remove-unused-names_merge-blocks.wast
index 6f6dd92b9..67a1f2762 100644
--- a/test/passes/remove-unused-names_merge-blocks.wast
+++ b/test/passes/remove-unused-names_merge-blocks.wast
@@ -1007,9 +1007,11 @@
)
(func $concrete_finale_in_unreachable (result f64)
(block $label$0 (result f64)
- (block ;; this block is unreachable
- (unreachable)
- (f64.const 6.322092475576799e-96)
+ (drop
+ (block (result f64)
+ (unreachable)
+ (f64.const 6.322092475576799e-96)
+ )
)
(f64.const -1)
)
@@ -1056,7 +1058,7 @@
)
(func $drop-unreachable-block-with-concrete-final
(drop
- (block
+ (block (result i32)
(drop
(block
(drop
@@ -1070,7 +1072,7 @@
)
(func $merging-with-unreachable-in-middle (result i32)
(block $label$1 (result i32)
- (block
+ (block (result i32)
(return
(i32.const 21536)
)
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
index 39fc1d97d..15d8b21e5 100644
--- a/test/passes/simplify-locals.txt
+++ b/test/passes/simplify-locals.txt
@@ -877,17 +877,13 @@
)
)
(func $if-return-but-unreachable (type $10) (param $var$0 i64)
- (tee_local $var$0
- (if
- (unreachable)
- (block (result i64)
- (nop)
- (get_local $var$0)
- )
- (block (result i64)
- (nop)
- (i64.const 1)
- )
+ (if
+ (unreachable)
+ (set_local $var$0
+ (get_local $var$0)
+ )
+ (set_local $var$0
+ (i64.const 1)
)
)
)
diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt
index 011fb99f5..b254179cd 100644
--- a/test/passes/vacuum.txt
+++ b/test/passes/vacuum.txt
@@ -223,7 +223,7 @@
)
)
(func $leave-block-even-if-br-not-taken (type $6) (result f64)
- (block $label$0
+ (block $label$0 (result f64)
(f64.store align=1
(i32.const 879179022)
(br_if $label$0
@@ -276,12 +276,11 @@
(func $unreachable-if-with-nop-arm-that-leaves-a-concrete-value-if-nop-is-removed (type $0)
(block $label$0
(loop $label$1
- (br_if $label$0
- (i32.load8_s
- (i32.const 1634541608)
- )
- (loop $label$9
- (br $label$9)
+ (drop
+ (br_if $label$0
+ (loop $label$9
+ (br $label$9)
+ )
)
)
)
diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast
index 3b5b22e9c..dbbffee41 100644
--- a/test/passes/vacuum.wast
+++ b/test/passes/vacuum.wast
@@ -502,7 +502,7 @@
(local $2 i32)
(block $label$0
(drop
- (block
+ (block (result i32)
(br $label$0)
(get_local $2)
)
@@ -596,17 +596,16 @@
(func $unreachable-if-with-nop-arm-that-leaves-a-concrete-value-if-nop-is-removed
(block $label$0
(loop $label$1
- (if
- (br_if $label$0
- (i32.load8_s
- (i32.const 1634541608)
- )
- (loop $label$9
- (br $label$9)
+ (drop
+ (if (result i32)
+ (br_if $label$0
+ (loop $label$9
+ (br $label$9)
+ )
)
+ (unreachable)
+ (i32.const 1920103026)
)
- (nop)
- (i32.const 1920103026)
)
)
)