summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/optimize-instructions_all-features.txt11
-rw-r--r--test/passes/optimize-instructions_all-features.wast13
2 files changed, 20 insertions, 4 deletions
diff --git a/test/passes/optimize-instructions_all-features.txt b/test/passes/optimize-instructions_all-features.txt
index f223cb838..31c1afbfc 100644
--- a/test/passes/optimize-instructions_all-features.txt
+++ b/test/passes/optimize-instructions_all-features.txt
@@ -10,11 +10,11 @@
(type $i64_=>_i64 (func (param i64) (result i64)))
(type $i32_i64_f32_=>_none (func (param i32 i64 f32)))
(type $i32_i64_f32_f64_=>_none (func (param i32 i64 f32 f64)))
+ (type $none_=>_anyref (func (result anyref)))
(type $i32_i32_i32_=>_none (func (param i32 i32 i32)))
(type $i32_i32_f64_f64_=>_none (func (param i32 i32 f64 f64)))
(type $i32_i64_f64_i32_=>_none (func (param i32 i64 f64 i32)))
(type $none_=>_f64 (func (result f64)))
- (type $none_=>_anyref (func (result anyref)))
(memory $0 0)
(export "load-off-2" (func $load-off-2))
(func $f (param $i1 i32) (param $i2 i64)
@@ -3712,9 +3712,16 @@
(unreachable)
)
)
- (func $if-arms-subtype (result anyref)
+ (func $if-arms-subtype-fold (result anyref)
(ref.null extern)
)
+ (func $if-arms-subtype-nofold (result anyref)
+ (if (result anyref)
+ (i32.const 0)
+ (ref.null extern)
+ (ref.null func)
+ )
+ )
(func $optimize-boolean-context (param $x i32) (param $y i32)
(if
(local.get $x)
diff --git a/test/passes/optimize-instructions_all-features.wast b/test/passes/optimize-instructions_all-features.wast
index 6e106ad1b..c2fa16e35 100644
--- a/test/passes/optimize-instructions_all-features.wast
+++ b/test/passes/optimize-instructions_all-features.wast
@@ -4207,8 +4207,17 @@
(unreachable)
)
)
- ;; Tests when if arms are subtype of if's type
- (func $if-arms-subtype (result anyref)
+ ;; These functions test if an `if` with subtyped arms is correctly folded
+ ;; 1. if its `ifTrue` and `ifFalse` arms are identical (can fold)
+ (func $if-arms-subtype-fold (result anyref)
+ (if (result anyref)
+ (i32.const 0)
+ (ref.null extern)
+ (ref.null extern)
+ )
+ )
+ ;; 2. if its `ifTrue` and `ifFalse` arms are not identical (cannot fold)
+ (func $if-arms-subtype-nofold (result anyref)
(if (result anyref)
(i32.const 0)
(ref.null extern)