diff options
Diffstat (limited to 'test/lit/passes/monomorphize-mvp.wast')
-rw-r--r-- | test/lit/passes/monomorphize-mvp.wast | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/test/lit/passes/monomorphize-mvp.wast b/test/lit/passes/monomorphize-mvp.wast new file mode 100644 index 000000000..567a4c2ce --- /dev/null +++ b/test/lit/passes/monomorphize-mvp.wast @@ -0,0 +1,94 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. + +;; As in monomorphize-types.wast, test in both "always" mode, which always +;; monomorphizes, and in "careful" mode which does it only when it appears to +;; actually help. + +;; This file specifically tests that we optimize constants in MVP mode (most +;; of the pass benefits from other features, but we should still do work in +;; MVP). + +;; RUN: foreach %s %t wasm-opt --monomorphize-always -S -o - | filecheck %s --check-prefix ALWAYS +;; RUN: foreach %s %t wasm-opt --monomorphize -S -o - | filecheck %s --check-prefix CAREFUL + +(module + ;; ALWAYS: (type $0 (func (result i32))) + + ;; ALWAYS: (type $1 (func (param i32 i32) (result i32))) + + ;; ALWAYS: (type $2 (func (param i32) (result i32))) + + ;; ALWAYS: (func $call (result i32) + ;; ALWAYS-NEXT: (call $target_2 + ;; ALWAYS-NEXT: (i32.eqz + ;; ALWAYS-NEXT: (i32.const 2) + ;; ALWAYS-NEXT: ) + ;; ALWAYS-NEXT: ) + ;; ALWAYS-NEXT: ) + ;; CAREFUL: (type $0 (func (result i32))) + + ;; CAREFUL: (type $1 (func (param i32 i32) (result i32))) + + ;; CAREFUL: (type $2 (func (param i32) (result i32))) + + ;; CAREFUL: (func $call (result i32) + ;; CAREFUL-NEXT: (call $target_2 + ;; CAREFUL-NEXT: (i32.eqz + ;; CAREFUL-NEXT: (i32.const 2) + ;; CAREFUL-NEXT: ) + ;; CAREFUL-NEXT: ) + ;; CAREFUL-NEXT: ) + (func $call (result i32) + ;; The second parameter can be monomorphized. + (call $target + (i32.eqz + (i32.const 2) + ) + (i32.const 1) + ) + ) + + ;; ALWAYS: (func $target (param $x i32) (param $y i32) (result i32) + ;; ALWAYS-NEXT: (select + ;; ALWAYS-NEXT: (local.get $x) + ;; ALWAYS-NEXT: (i32.const 42) + ;; ALWAYS-NEXT: (local.get $y) + ;; ALWAYS-NEXT: ) + ;; ALWAYS-NEXT: ) + ;; CAREFUL: (func $target (param $0 i32) (param $1 i32) (result i32) + ;; CAREFUL-NEXT: (select + ;; CAREFUL-NEXT: (local.get $0) + ;; CAREFUL-NEXT: (i32.const 42) + ;; CAREFUL-NEXT: (local.get $1) + ;; CAREFUL-NEXT: ) + ;; CAREFUL-NEXT: ) + (func $target (param $x i32) (param $y i32) (result i32) + ;; The monomorphized copies of this function will be able to remove the + ;; select, in CAREFUL (which optimizes). + (select + (local.get $x) + (i32.const 42) + (local.get $y) + ) + ) +) + +;; ALWAYS: (func $target_2 (param $0 i32) (result i32) +;; ALWAYS-NEXT: (local $x i32) +;; ALWAYS-NEXT: (local $y i32) +;; ALWAYS-NEXT: (local.set $x +;; ALWAYS-NEXT: (local.get $0) +;; ALWAYS-NEXT: ) +;; ALWAYS-NEXT: (local.set $y +;; ALWAYS-NEXT: (i32.const 1) +;; ALWAYS-NEXT: ) +;; ALWAYS-NEXT: (select +;; ALWAYS-NEXT: (local.get $x) +;; ALWAYS-NEXT: (i32.const 42) +;; ALWAYS-NEXT: (local.get $y) +;; ALWAYS-NEXT: ) +;; ALWAYS-NEXT: ) + +;; CAREFUL: (func $target_2 (param $0 i32) (result i32) +;; CAREFUL-NEXT: (local.get $0) +;; CAREFUL-NEXT: ) |