summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/lit/passes/inlining-optimizing_optimize-level=3.wast46
-rw-r--r--test/lit/passes/merge-blocks.wast207
-rw-r--r--test/passes/converge_O3_metrics.bin.txt90
-rw-r--r--test/passes/remove-unused-names_merge-blocks_all-features.txt106
4 files changed, 306 insertions, 143 deletions
diff --git a/test/lit/passes/inlining-optimizing_optimize-level=3.wast b/test/lit/passes/inlining-optimizing_optimize-level=3.wast
index 11eea40ff..980075d14 100644
--- a/test/lit/passes/inlining-optimizing_optimize-level=3.wast
+++ b/test/lit/passes/inlining-optimizing_optimize-level=3.wast
@@ -6478,34 +6478,32 @@
;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (loop $while-in66
- ;; CHECK-NEXT: (i32.store
- ;; CHECK-NEXT: (local.get $11)
- ;; CHECK-NEXT: (call $___uremdi3
- ;; CHECK-NEXT: (block (result i32)
- ;; CHECK-NEXT: (global.set $tempRet0
- ;; CHECK-NEXT: (i32.add
- ;; CHECK-NEXT: (i32.gt_u
- ;; CHECK-NEXT: (local.tee $20
- ;; CHECK-NEXT: (call $_bitshift64Shl
- ;; CHECK-NEXT: (i32.load
- ;; CHECK-NEXT: (local.get $11)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: (local.get $17)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.tee $12
- ;; CHECK-NEXT: (i32.add
- ;; CHECK-NEXT: (local.get $12)
- ;; CHECK-NEXT: (local.get $20)
- ;; CHECK-NEXT: )
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (global.set $tempRet0
+ ;; CHECK-NEXT: (i32.add
+ ;; CHECK-NEXT: (i32.gt_u
+ ;; CHECK-NEXT: (local.tee $20
+ ;; CHECK-NEXT: (call $_bitshift64Shl
+ ;; CHECK-NEXT: (i32.load
+ ;; CHECK-NEXT: (local.get $11)
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (global.get $tempRet0)
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: (local.get $17)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.tee $12
+ ;; CHECK-NEXT: (i32.add
+ ;; CHECK-NEXT: (local.get $12)
+ ;; CHECK-NEXT: (local.get $20)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
- ;; CHECK-NEXT: (local.get $12)
;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (global.get $tempRet0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.store
+ ;; CHECK-NEXT: (local.get $11)
+ ;; CHECK-NEXT: (call $___uremdi3
+ ;; CHECK-NEXT: (local.get $12)
;; CHECK-NEXT: (local.tee $20
;; CHECK-NEXT: (global.get $tempRet0)
;; CHECK-NEXT: )
diff --git a/test/lit/passes/merge-blocks.wast b/test/lit/passes/merge-blocks.wast
index 3d931690b..d6ff8b3d8 100644
--- a/test/lit/passes/merge-blocks.wast
+++ b/test/lit/passes/merge-blocks.wast
@@ -127,15 +127,13 @@
;; CHECK: (func $array.set-no-1 (param $foo (ref $array))
;; CHECK-NEXT: (local $bar i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (array.set $array
;; CHECK-NEXT: (local.get $foo)
- ;; CHECK-NEXT: (block (result i32)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (local.tee $bar
- ;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.tee $bar
+ ;; CHECK-NEXT: (i32.const 0)
;; CHECK-NEXT: )
;; CHECK-NEXT: (i32.const 37)
;; CHECK-NEXT: )
@@ -159,16 +157,14 @@
;; CHECK: (func $array.set-no-2 (param $foo (ref $array))
;; CHECK-NEXT: (local $bar i32)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (nop)
+ ;; CHECK-NEXT: (nop)
;; CHECK-NEXT: (array.set $array
;; CHECK-NEXT: (local.get $foo)
;; CHECK-NEXT: (i32.const 0)
- ;; CHECK-NEXT: (block (result i32)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (nop)
- ;; CHECK-NEXT: (local.tee $bar
- ;; CHECK-NEXT: (i32.const 37)
- ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (local.tee $bar
+ ;; CHECK-NEXT: (i32.const 37)
;; CHECK-NEXT: )
;; CHECK-NEXT: )
;; CHECK-NEXT: )
@@ -226,4 +222,187 @@
)
)
)
+
+ ;; CHECK: (func $subsequent-children (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $subsequent-children
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $subsequent-children (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; Both of the calls to helper can be moved outside. Those calls remain in
+ ;; order after doing so, so there is no problem, and none of them are moved
+ ;; across anything with side effects. This leaves only consts in the call to
+ ;; $subsequent-children.
+ (call $subsequent-children
+ (block (result i32)
+ (drop (call $helper (i32.const 0)))
+ (i32.const 1)
+ )
+ (i32.const 2)
+ (block (result i32)
+ (drop (call $helper (i32.const 3)))
+ (i32.const 4)
+ )
+ )
+ )
+
+ ;; CHECK: (func $subsequent-children-1 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $subsequent-children-1
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $subsequent-children-1 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ (call $subsequent-children-1
+ (block (result i32)
+ (drop (call $helper (i32.const 0)))
+ (call $helper (i32.const 1)) ;; Compared to before, this is now a call, so
+ ;; it has side effects, and the call with arg
+ ;; 3 cannot be moved past it.
+ )
+ (i32.const 2)
+ (block (result i32)
+ (drop (call $helper (i32.const 3)))
+ (i32.const 4)
+ )
+ )
+ )
+
+ ;; CHECK: (func $subsequent-children-2 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $subsequent-children-2
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $subsequent-children-2 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ (call $subsequent-children-2
+ (block (result i32)
+ (drop (call $helper (i32.const 0)))
+ (call $helper (i32.const 1))
+ )
+ ;; Similar to the above, but with the main call's last two arguments flipped.
+ ;; This should not have an effect on the output: we still can't pull out the
+ ;; call with arg 3.
+ (block (result i32)
+ (drop (call $helper (i32.const 3)))
+ (i32.const 4)
+ )
+ (i32.const 2)
+ )
+ )
+
+ ;; CHECK: (func $subsequent-children-3 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $subsequent-children-3
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (block (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $subsequent-children-3 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ (call $subsequent-children-3
+ (block (result i32)
+ (drop (i32.const 0)) ;; Similar to the above, but this is just a const now
+ ;; and not a call. We still can't pull out the call
+ ;; with arg 3, due to the call with arg 1.
+ (call $helper (i32.const 1))
+ )
+ (block (result i32)
+ (drop (call $helper (i32.const 3)))
+ (i32.const 4)
+ )
+ (i32.const 2)
+ )
+ )
+
+ ;; CHECK: (func $subsequent-children-4 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (i32.const 0)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (drop
+ ;; CHECK-NEXT: (call $helper
+ ;; CHECK-NEXT: (i32.const 3)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: (call $subsequent-children-4
+ ;; CHECK-NEXT: (i32.const 1)
+ ;; CHECK-NEXT: (i32.const 4)
+ ;; CHECK-NEXT: (i32.const 2)
+ ;; CHECK-NEXT: )
+ ;; CHECK-NEXT: )
+ (func $subsequent-children-4 (param $x i32) (param $y i32) (param $z i32) (result i32)
+ (call $subsequent-children-4
+ (block (result i32)
+ (drop (i32.const 0))
+ ;; Similar to the above, but remove the call on arg 1 as well. Now we *can*
+ ;; pull out the call with arg 3.
+ (i32.const 1)
+ )
+ (block (result i32)
+ (drop (call $helper (i32.const 3)))
+ (i32.const 4)
+ )
+ (i32.const 2)
+ )
+ )
+
+ ;; CHECK: (func $helper (param $x i32) (result i32)
+ ;; CHECK-NEXT: (unreachable)
+ ;; CHECK-NEXT: )
+ (func $helper (param $x i32) (result i32)
+ (unreachable)
+ )
)
diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt
index 48cc55541..8b17e64f5 100644
--- a/test/passes/converge_O3_metrics.bin.txt
+++ b/test/passes/converge_O3_metrics.bin.txt
@@ -54,21 +54,6 @@ total
(func $_main (; has Stack IR ;) (result i32)
(local $0 i32)
(local $1 i32)
- (local.set $1
- (i32.load offset=24
- (i32.add
- (i32.load
- (i32.sub
- (i32.load
- (i32.const 18100)
- )
- (i32.const 12)
- )
- )
- (i32.const 18100)
- )
- )
- )
(local.set $0
(i32.const 10888)
)
@@ -84,6 +69,21 @@ total
)
)
)
+ (local.set $1
+ (i32.load offset=24
+ (i32.add
+ (i32.load
+ (i32.sub
+ (i32.load
+ (i32.const 18100)
+ )
+ (i32.const 12)
+ )
+ )
+ (i32.const 18100)
+ )
+ )
+ )
(if
(local.tee $0
(i32.sub
@@ -278,21 +278,6 @@ total
(func $_main (; has Stack IR ;) (result i32)
(local $0 i32)
(local $1 i32)
- (local.set $1
- (i32.load offset=24
- (i32.add
- (i32.load
- (i32.sub
- (i32.load
- (i32.const 18100)
- )
- (i32.const 12)
- )
- )
- (i32.const 18100)
- )
- )
- )
(local.set $0
(i32.const 10888)
)
@@ -308,6 +293,21 @@ total
)
)
)
+ (local.set $1
+ (i32.load offset=24
+ (i32.add
+ (i32.load
+ (i32.sub
+ (i32.load
+ (i32.const 18100)
+ )
+ (i32.const 12)
+ )
+ )
+ (i32.const 18100)
+ )
+ )
+ )
(if
(local.tee $0
(i32.sub
@@ -497,21 +497,6 @@ total
(func $_main (; has Stack IR ;) (result i32)
(local $0 i32)
(local $1 i32)
- (local.set $1
- (i32.load offset=24
- (i32.add
- (i32.load
- (i32.sub
- (i32.load
- (i32.const 18100)
- )
- (i32.const 12)
- )
- )
- (i32.const 18100)
- )
- )
- )
(local.set $0
(i32.const 10888)
)
@@ -527,6 +512,21 @@ total
)
)
)
+ (local.set $1
+ (i32.load offset=24
+ (i32.add
+ (i32.load
+ (i32.sub
+ (i32.load
+ (i32.const 18100)
+ )
+ (i32.const 12)
+ )
+ )
+ (i32.const 18100)
+ )
+ )
+ )
(if
(local.tee $0
(i32.sub
diff --git a/test/passes/remove-unused-names_merge-blocks_all-features.txt b/test/passes/remove-unused-names_merge-blocks_all-features.txt
index ab1837ef7..e92d2ab9b 100644
--- a/test/passes/remove-unused-names_merge-blocks_all-features.txt
+++ b/test/passes/remove-unused-names_merge-blocks_all-features.txt
@@ -300,15 +300,15 @@
)
)
(drop
- (block (result i32)
- (unreachable)
- (drop
- (i32.const 20)
- )
- (i32.add
+ (i32.const 20)
+ )
+ (drop
+ (i32.add
+ (block (result i32)
+ (unreachable)
(i32.const 10)
- (i32.const 30)
)
+ (i32.const 30)
)
)
)
@@ -417,19 +417,19 @@
)
)
(drop
- (block (result i32)
- (unreachable)
- (drop
- (i32.const 30)
- )
- (drop
- (i32.const 50)
- )
- (select
+ (i32.const 30)
+ )
+ (drop
+ (i32.const 50)
+ )
+ (drop
+ (select
+ (block (result i32)
+ (unreachable)
(i32.const 20)
- (i32.const 40)
- (i32.const 60)
)
+ (i32.const 40)
+ (i32.const 60)
)
)
(drop
@@ -454,24 +454,25 @@
(i32.const 10)
)
(drop
+ (i32.const 50)
+ )
+ (drop
(select
(i32.const 20)
(block (result i32)
(unreachable)
(i32.const 40)
)
- (block (result i32)
- (drop
- (i32.const 50)
- )
- (i32.const 60)
- )
+ (i32.const 60)
)
)
(drop
(i32.const 10)
)
(drop
+ (i32.const 50)
+ )
+ (drop
(select
(i32.const 20)
(block (result i32)
@@ -480,12 +481,7 @@
)
(unreachable)
)
- (block (result i32)
- (drop
- (i32.const 50)
- )
- (i32.const 60)
- )
+ (i32.const 60)
)
)
(drop
@@ -604,17 +600,18 @@
(i32.const 20)
(i32.const 40)
)
+ (drop
+ (i32.const 20)
+ )
(call $call-ii
(block (result i32)
(unreachable)
(i32.const 10)
)
- (block (result i32)
- (drop
- (i32.const 20)
- )
- (i32.const 30)
- )
+ (i32.const 30)
+ )
+ (drop
+ (i32.const 20)
)
(call $call-ii
(block (result i32)
@@ -623,12 +620,7 @@
)
(unreachable)
)
- (block (result i32)
- (drop
- (i32.const 20)
- )
- (i32.const 30)
- )
+ (i32.const 30)
)
(drop
(i32.const 10)
@@ -691,33 +683,27 @@
(i32.const 40)
(i32.const 60)
)
+ (drop
+ (i32.const 30)
+ )
+ (drop
+ (i32.const 50)
+ )
(call_indirect $0 (type $ii)
(unreachable)
- (block (result i32)
- (drop
- (i32.const 30)
- )
- (i32.const 40)
- )
- (block (result i32)
- (drop
- (i32.const 50)
- )
- (i32.const 60)
- )
+ (i32.const 40)
+ (i32.const 60)
)
(drop
(i32.const 31)
)
+ (drop
+ (i32.const 51)
+ )
(call_indirect $0 (type $ii)
(i32.const 41)
(unreachable)
- (block (result i32)
- (drop
- (i32.const 51)
- )
- (i32.const 61)
- )
+ (i32.const 61)
)
(drop
(i32.const 32)