diff --git a/scripts/port_passes_tests_to_lit.py b/scripts/port_passes_tests_to_lit.py index 4a71f741fff..b4b8e587d67 100755 --- a/scripts/port_passes_tests_to_lit.py +++ b/scripts/port_passes_tests_to_lit.py @@ -57,8 +57,11 @@ def port_test(args, test): for bad in ['noprint', 'metrics', 'fuzz', 'print', 'emit', 'dump']: if bad in joined_passes: - warn('Skipping due to nonstandard output') - return + if args.force: + warn('Porting despite possible nonstandard output') + else: + warn('Skipping due to nonstandard output') + return passes = joined_passes.split('_') opts = [('--' + p if not p.startswith('O') and p != 'g' else '-' + p) diff --git a/test/lit/passes/fpcast-emu_pass-arg=max-func-params@5.wast b/test/lit/passes/fpcast-emu_pass-arg=max-func-params@5.wast new file mode 100644 index 00000000000..da03bf0be38 --- /dev/null +++ b/test/lit/passes/fpcast-emu_pass-arg=max-func-params@5.wast @@ -0,0 +1,63 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --fpcast-emu --pass-arg=max-func-params@5 -S -o - | filecheck %s + +(module + ;; CHECK: (type $i64_i64_i64_i64_i64_=>_i64 (func (param i64 i64 i64 i64 i64) (result i64))) + + ;; CHECK: (type $vijfd (func (param i32 i64 f32 f64))) + (type $vijfd (func (param i32) (param i64) (param f32) (param f64))) + (table 10 10 funcref) + (elem (i32.const 0) $a) + ;; CHECK: (table $0 10 10 funcref) + + ;; CHECK: (elem (i32.const 0) $byn$fpcast-emu$a) + + ;; CHECK: (func $a (param $x i32) (param $y i64) (param $z f32) (param $w f64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call_indirect (type $i64_i64_i64_i64_i64_=>_i64) + ;; CHECK-NEXT: (i64.extend_i32_u + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i64.const 2) + ;; CHECK-NEXT: (i64.extend_i32_u + ;; CHECK-NEXT: (i32.reinterpret_f32 + ;; CHECK-NEXT: (f32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i64.reinterpret_f64 + ;; CHECK-NEXT: (f64.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i64.const 0) + ;; CHECK-NEXT: (i32.const 1337) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $a (param $x i32) (param $y i64) (param $z f32) (param $w f64) + (call_indirect (type $vijfd) + (i32.const 1) + (i64.const 2) + (f32.const 3) + (f64.const 4) + (i32.const 1337) + ) + ) +) +;; CHECK: (func $byn$fpcast-emu$a (param $0 i64) (param $1 i64) (param $2 i64) (param $3 i64) (param $4 i64) (result i64) +;; CHECK-NEXT: (call $a +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (local.get $1) +;; CHECK-NEXT: (f32.reinterpret_i32 +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $2) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (f64.reinterpret_i64 +;; CHECK-NEXT: (local.get $3) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.const 0) +;; CHECK-NEXT: ) diff --git a/test/lit/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast b/test/lit/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast new file mode 100644 index 00000000000..8ffa14290fa --- /dev/null +++ b/test/lit/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast @@ -0,0 +1,1353 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --generate-stack-ir --optimize-stack-ir --print-stack-ir --optimize-level=3 -S -o - | filecheck %s + +(module + ;; CHECK: (type $FUNCSIG$v (func)) + + ;; CHECK: (type $5 (func (result i32))) + + ;; CHECK: (type $6 (func (param i32) (result i32))) + + ;; CHECK: (type $FUNCSIG$vf (func (param f32))) + (type $FUNCSIG$vf (func (param f32))) + (type $FUNCSIG$v (func)) + ;; CHECK: (type $4 (func (result f64))) + + ;; CHECK: (type $FUNCSIG$ddd (func (param f64 f64) (result f64))) + + ;; CHECK: (type $FUNCSIG$id (func (param f64) (result i32))) + (type $FUNCSIG$id (func (param f64) (result i32))) + (type $FUNCSIG$ddd (func (param f64 f64) (result f64))) + (type $4 (func (result f64))) + (type $5 (func (result i32))) + (type $6 (func (param i32) (result i32))) + ;; CHECK: (type $7 (func (param f64) (result f64))) + (type $7 (func (param f64) (result f64))) + ;; CHECK: (type $8 (func (result i64))) + (type $8 (func (result i64))) + ;; CHECK: (type $9 (func (param i32 i64))) + (type $9 (func (param i32 i64))) + ;; CHECK: (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) + (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) + ;; CHECK: (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) + (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) + ;; CHECK: (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) + (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) + (table 10 funcref) + (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) + ;; CHECK: (memory $0 4096 4096) + (memory $0 4096 4096) + (data (i32.const 1026) "\14\00") + ;; CHECK: (data (i32.const 1026) "\14\00") + + ;; CHECK: (table $0 10 funcref) + + ;; CHECK: (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) + + ;; CHECK: (export "big_negative" (func $big_negative)) + (export "big_negative" (func $big_negative)) + ;; CHECK: (func $big_negative + ;; CHECK-NEXT: (local $temp f64) + ;; CHECK-NEXT: f64.const -2147483648 + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: f64.const -2147483648 + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: f64.const -21474836480 + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: f64.const 0.039625 + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: f64.const -0.039625 + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: ) + (func $big_negative (type $FUNCSIG$v) + (local $temp f64) + (block $block0 + (local.set $temp + (f64.const -2147483648) + ) + (local.set $temp + (f64.const -2147483648) + ) + (local.set $temp + (f64.const -21474836480) + ) + (local.set $temp + (f64.const 0.039625) + ) + (local.set $temp + (f64.const -0.039625) + ) + ) + ) + ;; CHECK: (func $importedDoubles (result f64) + ;; CHECK-NEXT: (local $temp f64) + ;; CHECK-NEXT: block $topmost (result f64) + ;; CHECK-NEXT: i32.const 8 + ;; CHECK-NEXT: f64.load + ;; CHECK-NEXT: i32.const 16 + ;; CHECK-NEXT: f64.load + ;; CHECK-NEXT: f64.add + ;; CHECK-NEXT: i32.const 16 + ;; CHECK-NEXT: f64.load + ;; CHECK-NEXT: f64.neg + ;; CHECK-NEXT: f64.add + ;; CHECK-NEXT: i32.const 8 + ;; CHECK-NEXT: f64.load + ;; CHECK-NEXT: f64.neg + ;; CHECK-NEXT: f64.add + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: i32.const 24 + ;; CHECK-NEXT: i32.load + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.gt_s + ;; CHECK-NEXT: if + ;; CHECK-NEXT: f64.const -3.4 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 32 + ;; CHECK-NEXT: f64.load + ;; CHECK-NEXT: f64.const 0 + ;; CHECK-NEXT: f64.gt + ;; CHECK-NEXT: if + ;; CHECK-NEXT: f64.const 5.6 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: f64.const 1.2 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $importedDoubles (type $4) (result f64) + (local $temp f64) + (block $topmost (result f64) + (local.set $temp + (f64.add + (f64.add + (f64.add + (f64.load + (i32.const 8) + ) + (f64.load + (i32.const 16) + ) + ) + (f64.neg + (f64.load + (i32.const 16) + ) + ) + ) + (f64.neg + (f64.load + (i32.const 8) + ) + ) + ) + ) + (if + (i32.gt_s + (i32.load + (i32.const 24) + ) + (i32.const 0) + ) + (br $topmost + (f64.const -3.4) + ) + ) + (if + (f64.gt + (f64.load + (i32.const 32) + ) + (f64.const 0) + ) + (br $topmost + (f64.const 5.6) + ) + ) + (f64.const 1.2) + ) + ) + ;; CHECK: (func $doubleCompares (param $x f64) (param $y f64) (result f64) + ;; CHECK-NEXT: (local $t f64) + ;; CHECK-NEXT: (local $Int f64) + ;; CHECK-NEXT: (local $Double i32) + ;; CHECK-NEXT: block $topmost (result f64) + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: f64.const 0 + ;; CHECK-NEXT: f64.gt + ;; CHECK-NEXT: if + ;; CHECK-NEXT: f64.const 1.2 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: local.get $Int + ;; CHECK-NEXT: f64.const 0 + ;; CHECK-NEXT: f64.gt + ;; CHECK-NEXT: if + ;; CHECK-NEXT: f64.const -3.4 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: local.get $Double + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.gt_s + ;; CHECK-NEXT: if + ;; CHECK-NEXT: f64.const 5.6 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: local.get $y + ;; CHECK-NEXT: f64.lt + ;; CHECK-NEXT: if + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: local.get $y + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $doubleCompares (type $FUNCSIG$ddd) (param $x f64) (param $y f64) (result f64) + (local $t f64) + (local $Int f64) + (local $Double i32) + (block $topmost (result f64) + (if + (f64.gt + (local.get $x) + (f64.const 0) + ) + (br $topmost + (f64.const 1.2) + ) + ) + (if + (f64.gt + (local.get $Int) + (f64.const 0) + ) + (br $topmost + (f64.const -3.4) + ) + ) + (if + (i32.gt_s + (local.get $Double) + (i32.const 0) + ) + (br $topmost + (f64.const 5.6) + ) + ) + (if + (f64.lt + (local.get $x) + (local.get $y) + ) + (br $topmost + (local.get $x) + ) + ) + (local.get $y) + ) + ) + ;; CHECK: (func $intOps (result i32) + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.eq + ;; CHECK-NEXT: ) + (func $intOps (type $5) (result i32) + (local $x i32) + (i32.eq + (local.get $x) + (i32.const 0) + ) + ) + ;; CHECK: (func $hexLiterals + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.const 313249263 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: i32.const -19088752 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $hexLiterals (type $FUNCSIG$v) + (drop + (i32.add + (i32.add + (i32.const 0) + (i32.const 313249263) + ) + (i32.const -19088752) + ) + ) + ) + ;; CHECK: (func $conversions + ;; CHECK-NEXT: (local $i i32) + ;; CHECK-NEXT: (local $d f64) + ;; CHECK-NEXT: local.get $d + ;; CHECK-NEXT: call $f64-to-int + ;; CHECK-NEXT: local.set $i + ;; CHECK-NEXT: local.get $i + ;; CHECK-NEXT: f64.convert_i32_s + ;; CHECK-NEXT: local.set $d + ;; CHECK-NEXT: local.get $i + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.shr_u + ;; CHECK-NEXT: f64.convert_i32_u + ;; CHECK-NEXT: local.set $d + ;; CHECK-NEXT: ) + (func $conversions (type $FUNCSIG$v) + (local $i i32) + (local $d f64) + (block $block0 + (local.set $i + (call $f64-to-int + (local.get $d) + ) + ) + (local.set $d + (f64.convert_i32_s + (local.get $i) + ) + ) + (local.set $d + (f64.convert_i32_u + (i32.shr_u + (local.get $i) + (i32.const 0) + ) + ) + ) + ) + ) + ;; CHECK: (func $seq + ;; CHECK-NEXT: (local $J f64) + ;; CHECK-NEXT: f64.const 0.1 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f64.const 5.1 + ;; CHECK-NEXT: f64.const 3.2 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f64.const 4.2 + ;; CHECK-NEXT: f64.sub + ;; CHECK-NEXT: local.set $J + ;; CHECK-NEXT: ) + (func $seq (type $FUNCSIG$v) + (local $J f64) + (local.set $J + (f64.sub + (block $block0 (result f64) + (drop + (f64.const 0.1) + ) + (f64.const 5.1) + ) + (block $block1 (result f64) + (drop + (f64.const 3.2) + ) + (f64.const 4.2) + ) + ) + ) + ) + ;; CHECK: (func $switcher (param $x i32) (result i32) + ;; CHECK-NEXT: block $topmost (result i32) + ;; CHECK-NEXT: block $switch-default$3 + ;; CHECK-NEXT: block $switch-case$2 + ;; CHECK-NEXT: block $switch-case$1 + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: i32.sub + ;; CHECK-NEXT: br_table $switch-case$1 $switch-case$2 $switch-default$3 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: block $switch-default$7 + ;; CHECK-NEXT: block $switch-case$6 + ;; CHECK-NEXT: block $switch-case$5 + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: i32.const 5 + ;; CHECK-NEXT: i32.sub + ;; CHECK-NEXT: br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 121 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 51 + ;; CHECK-NEXT: br $topmost + ;; CHECK-NEXT: end + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: block $label$break$Lout + ;; CHECK-NEXT: block $switch-default$16 + ;; CHECK-NEXT: block $switch-case$15 + ;; CHECK-NEXT: block $switch-case$12 + ;; CHECK-NEXT: block $switch-case$9 + ;; CHECK-NEXT: block $switch-case$8 + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: i32.sub + ;; CHECK-NEXT: br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: br $label$break$Lout + ;; CHECK-NEXT: end + ;; CHECK-NEXT: br $label$break$Lout + ;; CHECK-NEXT: end + ;; CHECK-NEXT: block $while-out$10 + ;; CHECK-NEXT: loop $while-in$11 + ;; CHECK-NEXT: br $while-out$10 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: end + ;; CHECK-NEXT: end + ;; CHECK-NEXT: loop $while-in$14 + ;; CHECK-NEXT: br $label$break$Lout + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: end + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $switcher (type $6) (param $x i32) (result i32) + (block $topmost (result i32) + (block $switch$0 + (block $switch-default$3 + (block $switch-case$2 + (block $switch-case$1 + (br_table $switch-case$1 $switch-case$2 $switch-default$3 + (i32.sub + (local.get $x) + (i32.const 1) + ) + ) + ) + (br $topmost + (i32.const 1) + ) + ) + (br $topmost + (i32.const 2) + ) + ) + (nop) + ) + (block $switch$4 + (block $switch-default$7 + (block $switch-case$6 + (block $switch-case$5 + (br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7 + (i32.sub + (local.get $x) + (i32.const 5) + ) + ) + ) + (br $topmost + (i32.const 121) + ) + ) + (br $topmost + (i32.const 51) + ) + ) + (nop) + ) + (block $label$break$Lout + (block $switch-default$16 + (block $switch-case$15 + (block $switch-case$12 + (block $switch-case$9 + (block $switch-case$8 + (br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16 + (i32.sub + (local.get $x) + (i32.const 2) + ) + ) + ) + (br $label$break$Lout) + ) + (br $label$break$Lout) + ) + (block $while-out$10 + (loop $while-in$11 + (block $block1 + (br $while-out$10) + (br $while-in$11) + ) + ) + (br $label$break$Lout) + ) + ) + (block $while-out$13 + (loop $while-in$14 + (block $block3 + (br $label$break$Lout) + (br $while-in$14) + ) + ) + (br $label$break$Lout) + ) + ) + (nop) + ) + (i32.const 0) + ) + ) + ;; CHECK: (func $blocker + ;; CHECK-NEXT: block $label$break$L + ;; CHECK-NEXT: br $label$break$L + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $blocker (type $FUNCSIG$v) + (block $label$break$L + (br $label$break$L) + ) + ) + ;; CHECK: (func $frem (result f64) + ;; CHECK-NEXT: f64.const 5.5 + ;; CHECK-NEXT: f64.const 1.2 + ;; CHECK-NEXT: call $f64-rem + ;; CHECK-NEXT: ) + (func $frem (type $4) (result f64) + (call $f64-rem + (f64.const 5.5) + (f64.const 1.2) + ) + ) + ;; CHECK: (func $big_uint_div_u (result i32) + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: i32.const -1 + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: i32.div_u + ;; CHECK-NEXT: i32.const -1 + ;; CHECK-NEXT: i32.and + ;; CHECK-NEXT: ) + (func $big_uint_div_u (type $5) (result i32) + (local $x i32) + (block $topmost (result i32) + (local.set $x + (i32.and + (i32.div_u + (i32.const -1) + (i32.const 2) + ) + (i32.const -1) + ) + ) + (local.get $x) + ) + ) + ;; CHECK: (func $fr (param $x f32) + ;; CHECK-NEXT: (local $y f32) + ;; CHECK-NEXT: (local $z f64) + ;; CHECK-NEXT: local.get $z + ;; CHECK-NEXT: f32.demote_f64 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $y + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f32.const 5 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f32.const 0 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f32.const 5 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: f32.const 0 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $fr (type $FUNCSIG$vf) (param $x f32) + (local $y f32) + (local $z f64) + (block $block0 + (drop + (f32.demote_f64 + (local.get $z) + ) + ) + (drop + (local.get $y) + ) + (drop + (f32.const 5) + ) + (drop + (f32.const 0) + ) + (drop + (f32.const 5) + ) + (drop + (f32.const 0) + ) + ) + ) + ;; CHECK: (func $negZero (result f64) + ;; CHECK-NEXT: f64.const -0 + ;; CHECK-NEXT: ) + (func $negZero (type $4) (result f64) + (f64.const -0) + ) + ;; CHECK: (func $abs + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y f64) + ;; CHECK-NEXT: (local $z f32) + ;; CHECK-NEXT: (local $asm2wasm_i32_temp i32) + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: local.set $asm2wasm_i32_temp + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: local.get $asm2wasm_i32_temp + ;; CHECK-NEXT: i32.sub + ;; CHECK-NEXT: local.get $asm2wasm_i32_temp + ;; CHECK-NEXT: local.get $asm2wasm_i32_temp + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.lt_s + ;; CHECK-NEXT: select + ;; CHECK-NEXT: local.set $x + ;; CHECK-NEXT: f64.const 0 + ;; CHECK-NEXT: f64.abs + ;; CHECK-NEXT: local.set $y + ;; CHECK-NEXT: f32.const 0 + ;; CHECK-NEXT: f32.abs + ;; CHECK-NEXT: local.set $z + ;; CHECK-NEXT: ) + (func $abs (type $FUNCSIG$v) + (local $x i32) + (local $y f64) + (local $z f32) + (local $asm2wasm_i32_temp i32) + (block $block0 + (local.set $x + (block $block1 (result i32) + (local.set $asm2wasm_i32_temp + (i32.const 0) + ) + (select + (i32.sub + (i32.const 0) + (local.get $asm2wasm_i32_temp) + ) + (local.get $asm2wasm_i32_temp) + (i32.lt_s + (local.get $asm2wasm_i32_temp) + (i32.const 0) + ) + ) + ) + ) + (local.set $y + (f64.abs + (f64.const 0) + ) + ) + (local.set $z + (f32.abs + (f32.const 0) + ) + ) + ) + ) + ;; CHECK: (func $neg + ;; CHECK-NEXT: (local $x f32) + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: f32.neg + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: i32.const 7 + ;; CHECK-NEXT: i32.and + ;; CHECK-NEXT: i32.const 8 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: call_indirect $0 (type $f32_=>_none) + ;; CHECK-NEXT: ) + (func $neg (type $FUNCSIG$v) + (local $x f32) + (block $block0 + (local.set $x + (f32.neg + (local.get $x) + ) + ) + (call_indirect (type $FUNCSIG$vf) + (local.get $x) + (i32.add + (i32.and + (i32.const 1) + (i32.const 7) + ) + (i32.const 8) + ) + ) + ) + ) + ;; CHECK: (func $cneg (param $x f32) + ;; CHECK-NEXT: local.get $x + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: i32.const 7 + ;; CHECK-NEXT: i32.and + ;; CHECK-NEXT: i32.const 8 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: call_indirect $0 (type $f32_=>_none) + ;; CHECK-NEXT: ) + (func $cneg (type $FUNCSIG$vf) (param $x f32) + (call_indirect (type $FUNCSIG$vf) + (local.get $x) + (i32.add + (i32.and + (i32.const 1) + (i32.const 7) + ) + (i32.const 8) + ) + ) + ) + ;; CHECK: (func $___syscall_ret + ;; CHECK-NEXT: (local $$0 i32) + ;; CHECK-NEXT: local.get $$0 + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: i32.shr_u + ;; CHECK-NEXT: i32.const -4096 + ;; CHECK-NEXT: i32.gt_u + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $___syscall_ret (type $FUNCSIG$v) + (local $$0 i32) + (drop + (i32.gt_u + (i32.shr_u + (local.get $$0) + (i32.const 0) + ) + (i32.const -4096) + ) + ) + ) + ;; CHECK: (func $z + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: ) + (func $z (type $FUNCSIG$v) + (nop) + ) + ;; CHECK: (func $w + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: ) + (func $w (type $FUNCSIG$v) + (nop) + ) + ;; CHECK: (func $block_and_after (result i32) + ;; CHECK-NEXT: block $waka + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: br $waka + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: ) + (func $block_and_after (type $5) (result i32) + (block $waka + (drop + (i32.const 1) + ) + (br $waka) + ) + (i32.const 0) + ) + ;; CHECK: (func $loop-roundtrip (param $0 f64) (result f64) + ;; CHECK-NEXT: loop $loop-in1 (result f64) + ;; CHECK-NEXT: local.get $0 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $0 + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $loop-roundtrip (type $7) (param $0 f64) (result f64) + (loop $loop-in1 (result f64) + (drop + (local.get $0) + ) + (local.get $0) + ) + ) + ;; CHECK: (func $big-i64 (result i64) + ;; CHECK-NEXT: i64.const -9218868437227405313 + ;; CHECK-NEXT: ) + (func $big-i64 (type $8) (result i64) + (i64.const -9218868437227405313) + ) + ;; CHECK: (func $i64-store32 (param $0 i32) (param $1 i64) + ;; CHECK-NEXT: local.get $0 + ;; CHECK-NEXT: local.get $1 + ;; CHECK-NEXT: i64.store32 + ;; CHECK-NEXT: ) + (func $i64-store32 (type $9) (param $0 i32) (param $1 i64) + (i64.store32 + (local.get $0) + (local.get $1) + ) + ) + ;; CHECK: (func $return-unreachable (result i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: ) + (func $return-unreachable (result i32) + (return (i32.const 1)) + ) + ;; CHECK: (func $unreachable-block (result i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: ) + (func $unreachable-block (result i32) + (f64.abs + (block ;; note no type - valid in binaryen IR, in wasm must be i32 + (drop (i32.const 1)) + (return (i32.const 2)) + ) + ) + ) + ;; CHECK: (func $unreachable-block-toplevel (result i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: ) + (func $unreachable-block-toplevel (result i32) + (block ;; note no type - valid in binaryen IR, in wasm must be i32 + (drop (i32.const 1)) + (return (i32.const 2)) + ) + ) + ;; CHECK: (func $unreachable-block0 (result i32) + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: ) + (func $unreachable-block0 (result i32) + (f64.abs + (block ;; note no type - valid in binaryen IR, in wasm must be i32 + (return (i32.const 2)) + ) + ) + ) + ;; CHECK: (func $unreachable-block0-toplevel (result i32) + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: ) + (func $unreachable-block0-toplevel (result i32) + (block ;; note no type - valid in binaryen IR, in wasm must be i32 + (return (i32.const 2)) + ) + ) + ;; CHECK: (func $unreachable-block-with-br (result i32) + ;; CHECK-NEXT: block $block + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: br $block + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: ) + (func $unreachable-block-with-br (result i32) + (block $block ;; unreachable type due to last element having that type, but the block is exitable + (drop (i32.const 1)) + (br $block) + ) + (i32.const 1) + ) + ;; CHECK: (func $unreachable-if (result i32) + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: else + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-if (result i32) + (f64.abs + (if ;; note no type - valid in binaryen IR, in wasm must be i32 + (i32.const 3) + (return (i32.const 2)) + (return (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $unreachable-if-toplevel (result i32) + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: else + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-if-toplevel (result i32) + (if ;; note no type - valid in binaryen IR, in wasm must be i32 + (i32.const 3) + (return (i32.const 2)) + (return (i32.const 1)) + ) + ) + ;; CHECK: (func $unreachable-loop (result i32) + ;; CHECK-NEXT: loop $loop-in + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-loop (result i32) + (f64.abs + (loop ;; note no type - valid in binaryen IR, in wasm must be i32 + (nop) + (return (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $unreachable-loop0 (result i32) + ;; CHECK-NEXT: loop $loop-in + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-loop0 (result i32) + (f64.abs + (loop ;; note no type - valid in binaryen IR, in wasm must be i32 + (return (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $unreachable-loop-toplevel (result i32) + ;; CHECK-NEXT: loop $loop-in + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-loop-toplevel (result i32) + (loop ;; note no type - valid in binaryen IR, in wasm must be i32 + (nop) + (return (i32.const 1)) + ) + ) + ;; CHECK: (func $unreachable-loop0-toplevel (result i32) + ;; CHECK-NEXT: loop $loop-in + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: return + ;; CHECK-NEXT: end + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-loop0-toplevel (result i32) + (loop ;; note no type - valid in binaryen IR, in wasm must be i32 + (return (i32.const 1)) + ) + ) + ;; CHECK: (func $unreachable-ifs + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: ) + (func $unreachable-ifs + (if (unreachable) (nop)) + (if (unreachable) (unreachable)) + (if (unreachable) (nop) (nop)) + (if (unreachable) (unreachable) (nop)) + (if (unreachable) (nop) (unreachable)) + (if (unreachable) (unreachable) (unreachable)) + ;; + (if (i32.const 1) (unreachable) (nop)) + (if (i32.const 1) (nop) (unreachable)) + (if (i32.const 1) (unreachable) (unreachable)) + ) + ;; CHECK: (func $unreachable-if-arm + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: else + ;; CHECK-NEXT: unreachable + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $unreachable-if-arm + (if + (i32.const 1) + (block + (nop) + ) + (block + (unreachable) + (drop + (i32.const 1) + ) + ) + ) + ) + ;; CHECK: (func $local-to-stack (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $local-to-stack (param $x i32) (result i32) + (local $temp i32) + (local.set $temp (call $local-to-stack (i32.const 1))) ;; this set could just be on the stack + (drop (call $local-to-stack (i32.const 2))) + (local.get $temp) + ) + ;; CHECK: (func $local-to-stack-1 (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.eqz + ;; CHECK-NEXT: ) + (func $local-to-stack-1 (param $x i32) (result i32) + (local $temp i32) + (local.set $temp (call $local-to-stack (i32.const 1))) + (drop (call $local-to-stack (i32.const 2))) + (i32.eqz + (local.get $temp) + ) + ) + ;; CHECK: (func $local-to-stack-1b (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-1b (param $x i32) (result i32) + (local $temp i32) + (local.set $temp (call $local-to-stack (i32.const 1))) + (drop (call $local-to-stack (i32.const 2))) + (i32.add + (local.get $temp) + (i32.const 3) + ) + ) + ;; CHECK: (func $local-to-stack-1c-no (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: local.get $temp + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-1c-no (param $x i32) (result i32) + (local $temp i32) + (local.set $temp (call $local-to-stack (i32.const 1))) + (drop (call $local-to-stack (i32.const 2))) + (i32.add + (i32.const 3) ;; this is in the way + (local.get $temp) + ) + ) + ;; CHECK: (func $local-to-stack-2-no (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $temp + ;; CHECK-NEXT: local.get $temp + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-2-no (param $x i32) (result i32) + (local $temp i32) + (local.set $temp (call $local-to-stack (i32.const 1))) + (drop (call $local-to-stack (i32.const 2))) + (i32.add + (local.get $temp) + (local.get $temp) ;; a second use - so cannot stack it + ) + ) + ;; CHECK: (func $local-to-stack-3-no (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: else + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: local.set $temp + ;; CHECK-NEXT: end + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $temp + ;; CHECK-NEXT: ) + (func $local-to-stack-3-no (param $x i32) (result i32) + (local $temp i32) + (if (i32.const 1) + (local.set $temp (call $local-to-stack (i32.const 1))) + (local.set $temp (call $local-to-stack (i32.const 2))) ;; two sets for that get + ) + (drop (call $local-to-stack (i32.const 3))) + (local.get $temp) + ) + ;; CHECK: (func $local-to-stack-multi-4 (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 4 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $local-to-stack-multi-4 (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 2))) + (drop (local.get $temp1)) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 3))) ;; same local, used later + (drop (call $local-to-stack-multi-4 (i32.const 4))) + (local.get $temp1) + ) + ;; CHECK: (func $local-to-stack-multi-5 (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 4 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $local-to-stack-multi-5 (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 2))) + (drop (local.get $temp1)) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later + (drop (call $local-to-stack-multi-4 (i32.const 4))) + (local.get $temp2) + ) + ;; CHECK: (func $local-to-stack-multi-6-justone (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: local.set $temp2 + ;; CHECK-NEXT: i32.const 4 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $temp2 + ;; CHECK-NEXT: local.get $temp2 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-multi-6-justone (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 2))) + (drop (local.get $temp1)) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later + (drop (call $local-to-stack-multi-4 (i32.const 4))) + (i32.add + (local.get $temp2) + (local.get $temp2) + ) + ) + ;; CHECK: (func $local-to-stack-multi-7-justone (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: local.set $temp1 + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $temp1 + ;; CHECK-NEXT: local.get $temp1 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 4 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $local-to-stack-multi-7-justone (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 2))) + (drop + (i32.add + (local.get $temp1) + (local.get $temp1) + ) + ) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later + (drop (call $local-to-stack-multi-4 (i32.const 4))) + (local.get $temp2) + ) + ;; CHECK: (func $local-to-stack-overlapping-multi-8-no (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: local.set $temp1 + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: local.get $temp1 + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-overlapping-multi-8-no (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 3))) + (i32.add + (local.get $temp2) ;; the timing + (local.get $temp1) ;; it sucks + ) + ) + ;; CHECK: (func $local-to-stack-overlapping-multi-9-yes (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 3 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $local-to-stack-overlapping-multi-9-yes (param $x i32) (result i32) + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (call $local-to-stack-multi-4 (i32.const 3))) + (i32.add + (local.get $temp1) ;; the stars align + (local.get $temp2) ;; and a time presents itself + ) + ) + ;; CHECK: (func $local-to-stack-through-control-flow + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: (local $temp2 i32) + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: nop + ;; CHECK-NEXT: end + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: block $block + ;; CHECK-NEXT: br $block + ;; CHECK-NEXT: end + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: ) + (func $local-to-stack-through-control-flow + (local $temp1 i32) + (local $temp2 i32) + (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 0))) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (if (i32.const 0) (nop)) + (drop (local.get $temp1)) + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 2))) + (block $block (br $block)) + (drop (local.get $temp1)) + (drop (local.get $temp2)) + ) + ;; CHECK: (func $local-to-stack-in-control-flow + ;; CHECK-NEXT: (local $temp1 i32) + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: if + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: else + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $local-to-stack-multi-4 + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: end + ;; CHECK-NEXT: ) + (func $local-to-stack-in-control-flow + (local $temp1 i32) + (if (i32.const 0) + (block + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 0))) + (drop (local.get $temp1)) + ) + (block + (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) + (drop (local.get $temp1)) + ) + ) + ) + ;; CHECK: (func $remove-block (param $x i32) (result i32) + ;; CHECK-NEXT: (local $temp i32) + ;; CHECK-NEXT: i32.const 0 + ;; CHECK-NEXT: call $remove-block + ;; CHECK-NEXT: i32.const 1 + ;; CHECK-NEXT: call $remove-block + ;; CHECK-NEXT: i32.const 2 + ;; CHECK-NEXT: call $remove-block + ;; CHECK-NEXT: drop + ;; CHECK-NEXT: i32.eqz + ;; CHECK-NEXT: i32.add + ;; CHECK-NEXT: ) + (func $remove-block (param $x i32) (result i32) + (local $temp i32) + (i32.add + (call $remove-block (i32.const 0)) + (i32.eqz + (block (result i32) ;; after we use the stack instead of the local, we can remove this block + (local.set $temp (call $remove-block (i32.const 1))) + (drop (call $remove-block (i32.const 2))) + (local.get $temp) + ) + ) + ) + ) +) diff --git a/test/lit/passes/interesting-pass-mix.wast b/test/lit/passes/interesting-pass-mix.wast new file mode 100644 index 00000000000..98cdfd1fc4e --- /dev/null +++ b/test/lit/passes/interesting-pass-mix.wast @@ -0,0 +1,420 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --flatten --rereloop --dce --remove-unused-brs --remove-unused-names --coalesce-locals --simplify-locals --reorder-locals --remove-unused-brs --merge-blocks --vacuum -S -o - | filecheck %s + +(module + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32))) + + ;; CHECK: (func $trivial + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $trivial + (nop) + ) + ;; CHECK: (func $trivial2 + ;; CHECK-NEXT: (call $trivial) + ;; CHECK-NEXT: (call $trivial) + ;; CHECK-NEXT: ) + (func $trivial2 + (call $trivial) + (call $trivial) + ) + ;; CHECK: (func $return-void + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $return-void + (return) + ) + ;; CHECK: (func $return-val (result i32) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + (func $return-val (result i32) + (return (i32.const 1)) + ) + ;; CHECK: (func $ifs (param $0 i32) (result i32) + ;; CHECK-NEXT: (select + ;; CHECK-NEXT: (select + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (select + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $ifs (param $x i32) (result i32) + (if + (local.get $x) + (if + (local.get $x) + (return (i32.const 2)) + (return (i32.const 3)) + ) + ) + (if + (local.get $x) + (return (i32.const 4)) + ) + (return (i32.const 5)) + ) + ;; CHECK: (func $loops (param $0 i32) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (loop $shape$2$continue + ;; CHECK-NEXT: (call $trivial) + ;; CHECK-NEXT: (br $shape$2$continue) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $shape$4$continue + ;; CHECK-NEXT: (call $trivial) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (br $shape$4$continue) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $shape$6$continue + ;; CHECK-NEXT: (call $trivial) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (br $shape$6$continue) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loops (param $x i32) + (if (local.get $x) + (loop $top + (call $trivial) + (br $top) + ) + ) + (loop $top2 + (call $trivial) + (br_if $top2 (local.get $x)) + ) + (loop $top3 + (call $trivial) + (if (local.get $x) (br $top3)) + ) + ) + ;; CHECK: (func $br-out (param $0 i32) + ;; CHECK-NEXT: (call $br-out + ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $br-out (param $x i32) + (block $out + (call $br-out (i32.const 5)) + (br $out) + ) + ) + ;; CHECK: (func $unreachable (param $0 i32) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $unreachable + ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (return) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $unreachable + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $unreachable + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $unreachable (param $x i32) + (if (local.get $x) + (if (local.get $x) + (block + (call $unreachable (i32.const 1)) + (unreachable) + (call $unreachable (i32.const 2)) + ) + (block + (call $unreachable (i32.const 3)) + (return) + (call $unreachable (i32.const 4)) + ) + ) + ) + (block $out + (call $unreachable (i32.const 5)) + (br $out) + (call $unreachable (i32.const 6)) + ) + ) + ;; CHECK: (func $empty-blocks (param $0 i32) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $empty-blocks (param $x i32) + (block) + (block) + ) + ;; CHECK: (func $before-and-after (param $0 i32) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 6) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $shape$4$continue + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 9) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (br $shape$4$continue) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 11) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 12) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 13) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 14) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 15) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 16) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 17) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 18) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 19) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 21) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 22) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 23) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 24) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $before-and-after + ;; CHECK-NEXT: (i32.const 25) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $before-and-after (param $x i32) + (call $before-and-after (i32.const 1)) + (block + (call $before-and-after (i32.const 2)) + ) + (call $before-and-after (i32.const 3)) + (block $out + (call $before-and-after (i32.const 4)) + (br_if $out (local.get $x)) + (call $before-and-after (i32.const 5)) + ) + (call $before-and-after (i32.const 6)) + (loop) + (call $before-and-after (i32.const 7)) + (loop $top) + (call $before-and-after (i32.const 8)) + (loop $top2 + (call $before-and-after (i32.const 9)) + (br_if $top2 (local.get $x)) + (call $before-and-after (i32.const 10)) + ) + (call $before-and-after (i32.const 11)) + (if (local.get $x) + (call $before-and-after (i32.const 12)) + ) + (call $before-and-after (i32.const 13)) + (if (local.get $x) + (call $before-and-after (i32.const 14)) + (call $before-and-after (i32.const 15)) + ) + (if (local.get $x) + (block + (call $before-and-after (i32.const 16)) + ) + ) + (call $before-and-after (i32.const 17)) + (block + (call $before-and-after (i32.const 18)) + (block + (call $before-and-after (i32.const 19)) + ) + (call $before-and-after (i32.const 20)) + ) + (call $before-and-after (i32.const 21)) + (block + (block + (call $before-and-after (i32.const 22)) + ) + ) + (call $before-and-after (i32.const 23)) + (block $no1 + (block $no2 + (call $before-and-after (i32.const 24)) + ) + ) + (call $before-and-after (i32.const 25)) + ) + ;; CHECK: (func $switch (param $0 i32) + ;; CHECK-NEXT: (call $switch + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $block$7$break + ;; CHECK-NEXT: (block $switch$3$default + ;; CHECK-NEXT: (block $switch$3$case$7 + ;; CHECK-NEXT: (br_table $switch$3$case$7 $switch$3$case$7 $switch$3$case$7 $switch$3$default + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br $block$7$break) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $switch + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $switch + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $switch (param $x i32) + (block $out + (block $a + (br_table $a $a (local.get $x)) + ) + (call $switch (i32.const 1)) + (block $b + (block $c + (br_table $b $b $b $c (local.get $x)) + ) + (call $switch (i32.const 2)) + ) + (call $switch (i32.const 3)) + ) + ) + ;; CHECK: (func $no-return + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $no-return + (if (i32.const 1) + (drop (i32.const 2)) + (drop (i32.const 3)) + ) + ) + ;; CHECK: (func $if-br-wat (param $0 i32) + ;; CHECK-NEXT: (call $if-br-wat + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $block$2$break + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (call $if-br-wat + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (local.get $0) + ;; CHECK-NEXT: (br $block$2$break) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $if-br-wat + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $if-br-wat + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $if-br-wat (param $x i32) + (call $if-br-wat + (i32.const 0) + ) + (block $label$2 + (if + (local.get $x) + (call $if-br-wat + (i32.const 1) + ) + (if + (local.get $x) + (br $label$2) ;; waka + ) + ) + (call $if-br-wat + (i32.const 2) + ) + ) + (call $if-br-wat + (i32.const 3) + ) + ) +) + diff --git a/test/lit/passes/legalize-js-interface-minimally.wast b/test/lit/passes/legalize-js-interface-minimally.wast new file mode 100644 index 00000000000..5f34c56e8ac --- /dev/null +++ b/test/lit/passes/legalize-js-interface-minimally.wast @@ -0,0 +1,84 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --legalize-js-interface-minimally -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_i64 (func (result i64))) + + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (type $i64_=>_none (func (param i64))) + + ;; CHECK: (type $i32_i32_=>_none (func (param i32 i32))) + + ;; CHECK: (import "env" "imported" (func $imported (result i64))) + (import "env" "imported" (func $imported (result i64))) + ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + (import "env" "invoke_vj" (func $invoke_vj (param i64))) + ;; CHECK: (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32))) + + ;; CHECK: (export "func" (func $func)) + (export "func" (func $func)) + ;; CHECK: (export "dynCall_foo" (func $legalstub$dyn)) + (export "dynCall_foo" (func $dyn)) + ;; CHECK: (func $func (result i64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $imported) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $legalfunc$invoke_vj + ;; CHECK-NEXT: (i64.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func (result i64) + (drop (call $imported)) + (call $invoke_vj (i64.const 0)) + (unreachable) + ) + ;; CHECK: (func $dyn (result i64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $imported) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $dyn (result i64) + (drop (call $imported)) + (unreachable) + ) +) +;; CHECK: (func $legalstub$dyn (result i32) +;; CHECK-NEXT: (local $0 i64) +;; CHECK-NEXT: (local.set $0 +;; CHECK-NEXT: (call $dyn) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (call $setTempRet0 +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalfunc$invoke_vj (param $0 i64) +;; CHECK-NEXT: (call $legalimport$invoke_vj +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +(module) + diff --git a/test/lit/passes/legalize-js-interface_all-features.wast b/test/lit/passes/legalize-js-interface_all-features.wast new file mode 100644 index 00000000000..e35d61c9236 --- /dev/null +++ b/test/lit/passes/legalize-js-interface_all-features.wast @@ -0,0 +1,195 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --legalize-js-interface --all-features -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (type $none_=>_i64 (func (result i64))) + + ;; CHECK: (type $i32_i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32 i32))) + + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (type $i32_i64_i64_=>_none (func (param i32 i64 i64))) + + ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + (import "env" "imported" (func $imported (result i64))) + ;; CHECK: (import "env" "getTempRet0" (func $getTempRet0 (result i32))) + (import "env" "other" (func $other (param i32) (param i64) (param i64))) + ;; CHECK: (import "env" "imported" (func $legalimport$imported (result i32))) + (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) + ;; CHECK: (import "env" "other" (func $legalimport$other (param i32 i32 i32 i32 i32))) + + ;; CHECK: (import "env" "ref-func-arg" (func $legalimport$ref-func-arg (result i32))) + + ;; CHECK: (elem declare func $legalfunc$ref-func-arg) + + ;; CHECK: (export "func" (func $legalstub$func)) + (export "func" (func $func)) + ;; CHECK: (export "ref-func-test" (func $ref-func-test)) + (export "ref-func-test" (func $ref-func-test)) + ;; CHECK: (export "imported" (func $legalstub$imported)) + (export "imported" (func $imported)) + ;; CHECK: (export "imported_again" (func $legalstub$imported)) + (export "imported_again" (func $imported)) + ;; CHECK: (export "other" (func $legalstub$other)) + (export "other" (func $other)) + ;; CHECK: (func $func (result i64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $legalfunc$imported) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $legalfunc$other + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (i64.const 0) + ;; CHECK-NEXT: (i64.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func (result i64) + (drop (call $imported)) + (call $other + (i32.const 0) + (i64.const 0) + (i64.const 0) + ) + (unreachable) + ) + + ;; ref.func must also be updated. + ;; CHECK: (func $ref-func-test + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (call $legalfunc$ref-func-arg) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (ref.func $legalfunc$ref-func-arg) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $ref-func-test + (drop + (call $ref-func-arg) + ) + (drop + (ref.func $ref-func-arg) + ) + ) +) +;; CHECK: (func $legalstub$func (result i32) +;; CHECK-NEXT: (local $0 i64) +;; CHECK-NEXT: (local.set $0 +;; CHECK-NEXT: (call $func) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (call $setTempRet0 +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalstub$imported (result i32) +;; CHECK-NEXT: (local $0 i64) +;; CHECK-NEXT: (local.set $0 +;; CHECK-NEXT: (call $legalfunc$imported) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (call $setTempRet0 +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalstub$other (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) +;; CHECK-NEXT: (call $legalfunc$other +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.or +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (local.get $1) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.shl +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (local.get $2) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.or +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (local.get $3) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.shl +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (local.get $4) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalfunc$imported (result i64) +;; CHECK-NEXT: (i64.or +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (call $legalimport$imported) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.shl +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (call $getTempRet0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalfunc$other (param $0 i32) (param $1 i64) (param $2 i64) +;; CHECK-NEXT: (call $legalimport$other +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $1) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $1) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $2) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $2) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) + +;; CHECK: (func $legalfunc$ref-func-arg (result i64) +;; CHECK-NEXT: (i64.or +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (call $legalimport$ref-func-arg) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.shl +;; CHECK-NEXT: (i64.extend_i32_u +;; CHECK-NEXT: (call $getTempRet0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +(module) diff --git a/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast new file mode 100644 index 00000000000..47ab4c460bb --- /dev/null +++ b/test/lit/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast @@ -0,0 +1,43 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --legalize-js-interface --pass-arg=legalize-js-interface-export-originals -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_i64 (func (result i64))) + + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (import "env" "setTempRet0" (func $setTempRet0 (param i32))) + + ;; CHECK: (export "func" (func $legalstub$func)) + (export "func" (func $func)) + ;; CHECK: (export "orig$func" (func $func)) + + ;; CHECK: (func $func (result i64) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $func (result i64) + (unreachable) + ) +) + +;; CHECK: (func $legalstub$func (result i32) +;; CHECK-NEXT: (local $0 i64) +;; CHECK-NEXT: (local.set $0 +;; CHECK-NEXT: (call $func) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (call $setTempRet0 +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (i64.shr_u +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: (i64.const 32) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) +;; CHECK-NEXT: (i32.wrap_i64 +;; CHECK-NEXT: (local.get $0) +;; CHECK-NEXT: ) +;; CHECK-NEXT: ) diff --git a/test/lit/passes/licm.wast b/test/lit/passes/licm.wast new file mode 100644 index 00000000000..f7768e9d233 --- /dev/null +++ b/test/lit/passes/licm.wast @@ -0,0 +1,1105 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --licm -S -o - | filecheck %s + +(module + (memory 1) + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (type $none_=>_i64 (func (result i64))) + + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (type $i32_=>_i32 (func (param i32) (result i32))) + + ;; CHECK: (global $glob (mut i32) (i32.const 1)) + (global $glob (mut i32) (i32.const 1)) + ;; CHECK: (memory $0 1) + + ;; CHECK: (func $loop1 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop1 + (loop $loop + (drop (i32.const 10)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop2 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop2 + (loop $loop + (drop (i32.const 10)) + (drop (i32.const 20)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop3 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop2) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop3 + (loop $loop + (drop (i32.const 10)) + (call $loop2) + (drop (i32.const 20)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop4 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop4 + (loop $loop + (drop (i32.load (i32.const 1))) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop3-4 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $loop2) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop3-4 + (loop $loop + (drop (i32.load (i32.const 10))) + (call $loop2) ;; may have global side effects which alter a load! + (drop (i32.load (i32.const 20))) ;; this load must stay put + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop3-4-b + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop3-4-b (; 4 ;) + (loop $loop + (drop + (i32.load + (i32.const 10) + ) + ) + (drop + (i32.load + (i32.const 20) + ) + ) + (br_if $loop + (i32.const 1) + ) + ) + ) + ;; CHECK: (func $loop5 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop5 + (loop $loop + (i32.store (i32.const 1) (i32.const 2)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop6 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop6 + (loop $loop + (i32.store (i32.const 1) (i32.const 2)) + (i32.store (i32.const 2) (i32.const 3)) + ) + ) + ;; CHECK: (func $loop7 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop7 + (loop $loop + (i32.store (i32.const 1) (i32.const 2)) + (i32.store (i32.const 2) (i32.const 3)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop8 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop8 + (loop $loop + (i32.store (i32.const 1) (i32.const 2)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop9 + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop9 + (loop $loop + (drop (i32.load (i32.const 1))) + (i32.store (i32.const 1) (i32.const 2)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop10 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop10 + (loop $loop + (drop (i32.load (i32.const 1))) + (drop (i32.load (i32.const 2))) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop11 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (local.tee $x + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop11 + (local $x i32) + (local $y i32) + (loop $loop + (drop (local.get $x)) + (br_if $loop (local.tee $x (i32.const 2))) + ) + ) + ;; CHECK: (func $loop12 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (local.tee $y + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop12 + (local $x i32) + (local $y i32) + (loop $loop + (drop (local.get $x)) + (br_if $loop (local.tee $y (i32.const 2))) + ) + ) + ;; CHECK: (func $loop13 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop13 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop14 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $y + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop14 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (br_if $loop (i32.const 1)) + (local.set $y (local.get $x)) ;; not actually in the loop! + ) + ) + ;; CHECK: (func $loop14-1 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (local.set $y + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop14-1 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (local.set $y (local.get $x)) ;; in the loop + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop15 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop15 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (br_if $loop (i32.const 1)) + (drop (local.get $y)) + ) + ) + ;; CHECK: (func $loop15-1 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop15-1 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (drop (local.get $y)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop16 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop16 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (br_if $loop (i32.const 1)) + (drop (local.get $x)) + ) + ) + ;; CHECK: (func $loop16-1 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop16-1 + (local $x i32) + (local $y i32) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (drop (local.get $x)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop16-2 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop16-2 + (local $x i32) + (local $y i32) + (local.set $x (i32.const 2)) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (drop (local.get $x)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $loop16-3 + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local.set $y + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.eqz + ;; CHECK-NEXT: (local.get $y) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (call $loop12) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loop16-3 + (local $x i32) + (local $y i32) + (local.set $y (i32.const 2)) + (loop $loop + (local.set $x (i32.eqz (local.get $y))) + (call $loop12) + (drop (local.get $x)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $nop + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $nop + (loop $loop + (nop) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $nested-blocks + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (block $block + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $x + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $a + ;; CHECK-NEXT: (block $b + ;; CHECK-NEXT: (block $c + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $nested-blocks + (loop $loop + (block + (nop) + ) + (block $x + (nop) + ) + (block $a + (block $b + (block $c + (nop) + ) + ) + ) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $nested-unhoistable-blocks + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (block $block + ;; CHECK-NEXT: (call $nested-unhoistable-blocks) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $x + ;; CHECK-NEXT: (call $nested-unhoistable-blocks) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block $a + ;; CHECK-NEXT: (block $b + ;; CHECK-NEXT: (block $c + ;; CHECK-NEXT: (call $nested-unhoistable-blocks) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $nested-unhoistable-blocks + (loop $loop + (block + (call $nested-unhoistable-blocks) + ) + (block $x + (call $nested-unhoistable-blocks) + ) + (block $a + (block $b + (block $c + (call $nested-unhoistable-blocks) + ) + ) + ) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $conditional + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $conditional + (loop $loop + (if (i32.const 0) + (drop (i32.const 10)) ;; cannot be hoisted - might never be reached + ) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $conditional1 (result i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (call $conditional1) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + (func $conditional1 (result i32) + (loop $loop + (if (call $conditional1) + (drop (i32.const 10)) ;; cannot be hoisted - might never be reached + ;; also anyhow the whole if also cannot, due to the call + ) + (br_if $loop (i32.const 1)) + ) + (unreachable) + ) + ;; CHECK: (func $conditional2 + ;; CHECK-NEXT: (block $out + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (br_if $out + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $conditional2 + (block $out + (loop $loop + (br_if $out (i32.const 1)) + (drop (i32.const 10)) ;; cannot be hoisted - might never be reached + (br_if $loop (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $conditional3 + ;; CHECK-NEXT: (block $out + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $out + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $conditional3 + (block $out + (loop $loop + (drop (i32.const 10)) ;; *CAN* be hoisted - will definitely be reached + (br_if $out (i32.const 1)) + (br_if $loop (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $after + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $after + (loop $loop) + (drop (i32.const 10)) ;; may be part of the loop's basic block, logically, but is not nested in it + ) + ;; CHECK: (func $loops + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop2 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (loop $loop1 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop1 + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loops + (loop $loop2 + (loop $loop1 + (drop (i32.const 10)) + (br_if $loop1 (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $loops2 + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop2 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (loop $loop1 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop2 + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loops2 + (loop $loop2 + (loop $loop1 + (drop (i32.const 10)) + (br_if $loop2 (i32.const 1)) + ) + ) + ) + ;; CHECK: (func $fuzz1 (result i64) + ;; CHECK-NEXT: (local $var$1 i64) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (block (result i32) + ;; CHECK-NEXT: (local.set $var$1 + ;; CHECK-NEXT: (block $label$5 (result i64) + ;; CHECK-NEXT: (local.set $var$1 + ;; CHECK-NEXT: (i64.const -29585) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i64.const -70) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $label$4 (result i32) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $label$1 (result i64) + ;; CHECK-NEXT: (block $label$2 + ;; CHECK-NEXT: (block $label$3 + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br $label$2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (unreachable) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $var$1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $fuzz1 (result i64) + (local $var$1 i64) + (loop $label$1 (result i64) ;; multiple loops here require us to be careful not to Nop out stuff before we finalize things + (block $label$2 + (block $label$3 + (drop + (loop $label$4 (result i32) + (local.set $var$1 + (block $label$5 (result i64) + (local.set $var$1 + (i64.const -29585) + ) + (i64.const -70) + ) + ) + (i32.const 1) + ) + ) + (br $label$2) + ) + (unreachable) + ) + (local.get $var$1) + ) + ) + ;; CHECK: (func $self (result i32) + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.add + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + (func $self (result i32) + (local $x i32) + (loop $loop + (local.set $x (i32.add (local.get $x) (i32.const 1))) + (br_if $loop (i32.const 1)) + ) + (local.get $x) + ) + ;; CHECK: (func $nested-set + ;; CHECK-NEXT: (local $var$0 i32) + ;; CHECK-NEXT: (local $var$1 i64) + ;; CHECK-NEXT: (loop $label$1 + ;; CHECK-NEXT: (local.set $var$0 + ;; CHECK-NEXT: (block $label$3 (result i32) + ;; CHECK-NEXT: (local.set $var$1 + ;; CHECK-NEXT: (i64.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $var$0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $var$1 + ;; CHECK-NEXT: (i64.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $label$1 + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $nested-set + (local $var$0 i32) + (local $var$1 i64) + (loop $label$1 + (local.set $var$0 + (block $label$3 (result i32) + (local.set $var$1 ;; cannot be moved out (in current position - other opts would help), and invalidates moving out the set below + (i64.const 0) + ) + (local.get $var$0) + ) + ) + (local.set $var$1 + (i64.const 1) + ) + (br_if $label$1 + (i32.const 0) + ) + ) + ) + ;; CHECK: (func $load-store (param $x i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.load + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.store + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $load-store (param $x i32) + (loop $loop + (drop (i32.load (i32.const 0))) ;; can't move this out, the store might affect it for later iterations + (i32.store (local.get $x) (local.get $x)) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $set-set (param $x i32) (result i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + (func $set-set (param $x i32) (result i32) + (loop $loop + (local.set $x (i32.const 1)) + (br_if $loop (i32.const 2)) + (local.set $x (i32.const 3)) + (br_if $loop (i32.const 4)) + ) + (local.get $x) + ) + ;; CHECK: (func $copies-no + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $y i32) + ;; CHECK-NEXT: (local $z i32) + ;; CHECK-NEXT: (local $a i32) + ;; CHECK-NEXT: (local $b i32) + ;; CHECK-NEXT: (local $c i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $y + ;; CHECK-NEXT: (local.get $z) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $a + ;; CHECK-NEXT: (local.tee $b + ;; CHECK-NEXT: (local.get $c) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $copies-no + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (local $c i32) + (loop $loop + (local.set $x (local.get $x)) + (local.set $y (local.get $z)) + (local.set $a (local.tee $b (local.get $c))) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $consts-no + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local $a i32) + ;; CHECK-NEXT: (local $b i32) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (local.set $a + ;; CHECK-NEXT: (local.tee $b + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $consts-no + (local $x i32) + (local $a i32) + (local $b i32) + (loop $loop + (local.set $x (i32.const 0)) + (local.set $a (local.tee $b (i32.const 1))) + (br_if $loop (i32.const 1)) + ) + ) + ;; CHECK: (func $global + ;; CHECK-NEXT: (local $x i32) + ;; CHECK-NEXT: (local.set $x + ;; CHECK-NEXT: (global.get $glob) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: (br_if $loop + ;; CHECK-NEXT: (local.get $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $global + (local $x i32) + (loop $loop + (local.set $x (global.get $glob)) + (drop (local.get $x)) + (br_if $loop (local.get $x)) + ) + ) +) diff --git a/test/lit/passes/log-execution.wast b/test/lit/passes/log-execution.wast new file mode 100644 index 00000000000..f3f93ed0835 --- /dev/null +++ b/test/lit/passes/log-execution.wast @@ -0,0 +1,141 @@ +;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. +;; NOTE: This test was ported using port_test.py and could be cleaned up. + +;; RUN: foreach %s %t wasm-opt --log-execution -S -o - | filecheck %s + +(module + ;; CHECK: (type $none_=>_none (func)) + + ;; CHECK: (type $none_=>_i32 (func (result i32))) + + ;; CHECK: (type $i32_=>_none (func (param i32))) + + ;; CHECK: (import "env" "func" (func $import)) + (import "env" "func" (func $import)) + ;; CHECK: (import "env" "log_execution" (func $log_execution (param i32))) + + ;; CHECK: (func $nopp + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + (func $nopp + (nop) + ) + ;; CHECK: (func $intt (result i32) + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + (func $intt (result i32) + (i32.const 10) + ) + ;; CHECK: (func $workk + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 3) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (i32.const 0) + ;; CHECK-NEXT: (nop) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 2) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 1) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $workk + (if (i32.const 0) (nop)) + (drop (i32.const 1)) + ) + ;; CHECK: (func $loops + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 8) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (loop $x + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 4) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $loops) + ;; CHECK-NEXT: (br $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (if + ;; CHECK-NEXT: (call $intt) + ;; CHECK-NEXT: (loop $y + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 5) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (call $loops) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 7) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $loop-in + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 6) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 20) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (drop + ;; CHECK-NEXT: (i32.const 30) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loops + (loop $x + (call $loops) + (br $x) + ) + (if (call $intt) + (loop $y + (call $loops) + ) + ) + (loop + (drop (i32.const 10)) + (drop (i32.const 20)) + (drop (i32.const 30)) + ) + ) + ;; CHECK: (func $loops-similar + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 10) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (loop $x + ;; CHECK-NEXT: (call $log_execution + ;; CHECK-NEXT: (i32.const 9) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: (block + ;; CHECK-NEXT: (call $loops) + ;; CHECK-NEXT: (br $x) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + ;; CHECK-NEXT: ) + (func $loops-similar + (loop $x + (call $loops) + (br $x) + ) + ) +) + diff --git a/test/passes/fpcast-emu_pass-arg=max-func-params@5.txt b/test/passes/fpcast-emu_pass-arg=max-func-params@5.txt deleted file mode 100644 index dd3d5abe758..00000000000 --- a/test/passes/fpcast-emu_pass-arg=max-func-params@5.txt +++ /dev/null @@ -1,43 +0,0 @@ -(module - (type $i64_i64_i64_i64_i64_=>_i64 (func (param i64 i64 i64 i64 i64) (result i64))) - (type $vijfd (func (param i32 i64 f32 f64))) - (table $0 10 10 funcref) - (elem (i32.const 0) $byn$fpcast-emu$a) - (func $a (param $x i32) (param $y i64) (param $z f32) (param $w f64) - (drop - (call_indirect (type $i64_i64_i64_i64_i64_=>_i64) - (i64.extend_i32_u - (i32.const 1) - ) - (i64.const 2) - (i64.extend_i32_u - (i32.reinterpret_f32 - (f32.const 3) - ) - ) - (i64.reinterpret_f64 - (f64.const 4) - ) - (i64.const 0) - (i32.const 1337) - ) - ) - ) - (func $byn$fpcast-emu$a (param $0 i64) (param $1 i64) (param $2 i64) (param $3 i64) (param $4 i64) (result i64) - (call $a - (i32.wrap_i64 - (local.get $0) - ) - (local.get $1) - (f32.reinterpret_i32 - (i32.wrap_i64 - (local.get $2) - ) - ) - (f64.reinterpret_i64 - (local.get $3) - ) - ) - (i64.const 0) - ) -) diff --git a/test/passes/fpcast-emu_pass-arg=max-func-params@5.wast b/test/passes/fpcast-emu_pass-arg=max-func-params@5.wast deleted file mode 100644 index b1b0369c4b7..00000000000 --- a/test/passes/fpcast-emu_pass-arg=max-func-params@5.wast +++ /dev/null @@ -1,14 +0,0 @@ -(module - (type $vijfd (func (param i32) (param i64) (param f32) (param f64))) - (table 10 10 funcref) - (elem (i32.const 0) $a) - (func $a (param $x i32) (param $y i64) (param $z f32) (param $w f64) - (call_indirect (type $vijfd) - (i32.const 1) - (i64.const 2) - (f32.const 3) - (f64.const 4) - (i32.const 1337) - ) - ) -) diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.txt b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.txt deleted file mode 100644 index e94bc35318d..00000000000 --- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.txt +++ /dev/null @@ -1,1600 +0,0 @@ -(module - (type $FUNCSIG$v (func)) - (type $5 (func (result i32))) - (type $6 (func (param i32) (result i32))) - (type $FUNCSIG$vf (func (param f32))) - (type $4 (func (result f64))) - (type $FUNCSIG$ddd (func (param f64 f64) (result f64))) - (type $FUNCSIG$id (func (param f64) (result i32))) - (type $7 (func (param f64) (result f64))) - (type $8 (func (result i64))) - (type $9 (func (param i32 i64))) - (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) - (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) - (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) - (memory $0 4096 4096) - (data (i32.const 1026) "\14\00") - (table $0 10 funcref) - (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) - (export "big_negative" (func $big_negative)) - (func $big_negative - (local $temp f64) - f64.const -2147483648 - local.set $temp - f64.const -2147483648 - local.set $temp - f64.const -21474836480 - local.set $temp - f64.const 0.039625 - local.set $temp - f64.const -0.039625 - local.set $temp - ) - (func $importedDoubles (result f64) - (local $temp f64) - block $topmost (result f64) - i32.const 8 - f64.load - i32.const 16 - f64.load - f64.add - i32.const 16 - f64.load - f64.neg - f64.add - i32.const 8 - f64.load - f64.neg - f64.add - local.set $temp - i32.const 24 - i32.load - i32.const 0 - i32.gt_s - if - f64.const -3.4 - br $topmost - end - i32.const 32 - f64.load - f64.const 0 - f64.gt - if - f64.const 5.6 - br $topmost - end - f64.const 1.2 - end - ) - (func $doubleCompares (param $x f64) (param $y f64) (result f64) - (local $t f64) - (local $Int f64) - (local $Double i32) - block $topmost (result f64) - local.get $x - f64.const 0 - f64.gt - if - f64.const 1.2 - br $topmost - end - local.get $Int - f64.const 0 - f64.gt - if - f64.const -3.4 - br $topmost - end - local.get $Double - i32.const 0 - i32.gt_s - if - f64.const 5.6 - br $topmost - end - local.get $x - local.get $y - f64.lt - if - local.get $x - br $topmost - end - local.get $y - end - ) - (func $intOps (result i32) - (local $x i32) - local.get $x - i32.const 0 - i32.eq - ) - (func $hexLiterals - i32.const 0 - i32.const 313249263 - i32.add - i32.const -19088752 - i32.add - drop - ) - (func $conversions - (local $i i32) - (local $d f64) - local.get $d - call $f64-to-int - local.set $i - local.get $i - f64.convert_i32_s - local.set $d - local.get $i - i32.const 0 - i32.shr_u - f64.convert_i32_u - local.set $d - ) - (func $seq - (local $J f64) - f64.const 0.1 - drop - f64.const 5.1 - f64.const 3.2 - drop - f64.const 4.2 - f64.sub - local.set $J - ) - (func $switcher (param $x i32) (result i32) - block $topmost (result i32) - block $switch-default$3 - block $switch-case$2 - block $switch-case$1 - local.get $x - i32.const 1 - i32.sub - br_table $switch-case$1 $switch-case$2 $switch-default$3 - end - i32.const 1 - br $topmost - end - i32.const 2 - br $topmost - end - nop - block $switch-default$7 - block $switch-case$6 - block $switch-case$5 - local.get $x - i32.const 5 - i32.sub - br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7 - end - i32.const 121 - br $topmost - end - i32.const 51 - br $topmost - end - nop - block $label$break$Lout - block $switch-default$16 - block $switch-case$15 - block $switch-case$12 - block $switch-case$9 - block $switch-case$8 - local.get $x - i32.const 2 - i32.sub - br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16 - end - br $label$break$Lout - end - br $label$break$Lout - end - block $while-out$10 - loop $while-in$11 - br $while-out$10 - end - unreachable - end - end - loop $while-in$14 - br $label$break$Lout - end - unreachable - end - nop - end - i32.const 0 - end - ) - (func $blocker - block $label$break$L - br $label$break$L - end - ) - (func $frem (result f64) - f64.const 5.5 - f64.const 1.2 - call $f64-rem - ) - (func $big_uint_div_u (result i32) - (local $x i32) - i32.const -1 - i32.const 2 - i32.div_u - i32.const -1 - i32.and - ) - (func $fr (param $x f32) - (local $y f32) - (local $z f64) - local.get $z - f32.demote_f64 - drop - local.get $y - drop - f32.const 5 - drop - f32.const 0 - drop - f32.const 5 - drop - f32.const 0 - drop - ) - (func $negZero (result f64) - f64.const -0 - ) - (func $abs - (local $x i32) - (local $y f64) - (local $z f32) - (local $asm2wasm_i32_temp i32) - i32.const 0 - local.set $asm2wasm_i32_temp - i32.const 0 - local.get $asm2wasm_i32_temp - i32.sub - local.get $asm2wasm_i32_temp - local.get $asm2wasm_i32_temp - i32.const 0 - i32.lt_s - select - local.set $x - f64.const 0 - f64.abs - local.set $y - f32.const 0 - f32.abs - local.set $z - ) - (func $neg - (local $x f32) - local.get $x - f32.neg - i32.const 1 - i32.const 7 - i32.and - i32.const 8 - i32.add - call_indirect $0 (type $f32_=>_none) - ) - (func $cneg (param $x f32) - local.get $x - i32.const 1 - i32.const 7 - i32.and - i32.const 8 - i32.add - call_indirect $0 (type $f32_=>_none) - ) - (func $___syscall_ret - (local $$0 i32) - local.get $$0 - i32.const 0 - i32.shr_u - i32.const -4096 - i32.gt_u - drop - ) - (func $z - nop - ) - (func $w - nop - ) - (func $block_and_after (result i32) - block $waka - i32.const 1 - drop - br $waka - end - i32.const 0 - ) - (func $loop-roundtrip (param $0 f64) (result f64) - loop $loop-in1 (result f64) - local.get $0 - drop - local.get $0 - end - ) - (func $big-i64 (result i64) - i64.const -9218868437227405313 - ) - (func $i64-store32 (param $0 i32) (param $1 i64) - local.get $0 - local.get $1 - i64.store32 - ) - (func $return-unreachable (result i32) - i32.const 1 - return - ) - (func $unreachable-block (result i32) - i32.const 1 - drop - i32.const 2 - return - ) - (func $unreachable-block-toplevel (result i32) - i32.const 1 - drop - i32.const 2 - return - ) - (func $unreachable-block0 (result i32) - i32.const 2 - return - ) - (func $unreachable-block0-toplevel (result i32) - i32.const 2 - return - ) - (func $unreachable-block-with-br (result i32) - block $block - i32.const 1 - drop - br $block - end - i32.const 1 - ) - (func $unreachable-if (result i32) - i32.const 3 - if - i32.const 2 - return - else - i32.const 1 - return - end - unreachable - ) - (func $unreachable-if-toplevel (result i32) - i32.const 3 - if - i32.const 2 - return - else - i32.const 1 - return - end - unreachable - ) - (func $unreachable-loop (result i32) - loop $loop-in - nop - i32.const 1 - return - end - unreachable - ) - (func $unreachable-loop0 (result i32) - loop $loop-in - i32.const 1 - return - end - unreachable - ) - (func $unreachable-loop-toplevel (result i32) - loop $loop-in - nop - i32.const 1 - return - end - unreachable - ) - (func $unreachable-loop0-toplevel (result i32) - loop $loop-in - i32.const 1 - return - end - unreachable - ) - (func $unreachable-ifs - unreachable - ) - (func $unreachable-if-arm - i32.const 1 - if - nop - else - unreachable - end - ) - (func $local-to-stack (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - call $local-to-stack - i32.const 2 - call $local-to-stack - drop - ) - (func $local-to-stack-1 (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - call $local-to-stack - i32.const 2 - call $local-to-stack - drop - i32.eqz - ) - (func $local-to-stack-1b (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - call $local-to-stack - i32.const 2 - call $local-to-stack - drop - i32.const 3 - i32.add - ) - (func $local-to-stack-1c-no (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - call $local-to-stack - local.set $temp - i32.const 2 - call $local-to-stack - drop - i32.const 3 - local.get $temp - i32.add - ) - (func $local-to-stack-2-no (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - call $local-to-stack - local.set $temp - i32.const 2 - call $local-to-stack - drop - local.get $temp - local.get $temp - i32.add - ) - (func $local-to-stack-3-no (param $x i32) (result i32) - (local $temp i32) - i32.const 1 - if - i32.const 1 - call $local-to-stack - local.set $temp - else - i32.const 2 - call $local-to-stack - local.set $temp - end - i32.const 3 - call $local-to-stack - drop - local.get $temp - ) - (func $local-to-stack-multi-4 (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - i32.const 2 - call $local-to-stack-multi-4 - drop - drop - i32.const 3 - call $local-to-stack-multi-4 - i32.const 4 - call $local-to-stack-multi-4 - drop - ) - (func $local-to-stack-multi-5 (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - i32.const 2 - call $local-to-stack-multi-4 - drop - drop - i32.const 3 - call $local-to-stack-multi-4 - i32.const 4 - call $local-to-stack-multi-4 - drop - ) - (func $local-to-stack-multi-6-justone (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - i32.const 2 - call $local-to-stack-multi-4 - drop - drop - i32.const 3 - call $local-to-stack-multi-4 - local.set $temp2 - i32.const 4 - call $local-to-stack-multi-4 - drop - local.get $temp2 - local.get $temp2 - i32.add - ) - (func $local-to-stack-multi-7-justone (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - local.set $temp1 - i32.const 2 - call $local-to-stack-multi-4 - drop - local.get $temp1 - local.get $temp1 - i32.add - drop - i32.const 3 - call $local-to-stack-multi-4 - i32.const 4 - call $local-to-stack-multi-4 - drop - ) - (func $local-to-stack-overlapping-multi-8-no (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - local.set $temp1 - i32.const 1 - call $local-to-stack-multi-4 - i32.const 3 - call $local-to-stack-multi-4 - drop - local.get $temp1 - i32.add - ) - (func $local-to-stack-overlapping-multi-9-yes (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - i32.const 1 - call $local-to-stack-multi-4 - i32.const 1 - call $local-to-stack-multi-4 - i32.const 3 - call $local-to-stack-multi-4 - drop - i32.add - ) - (func $local-to-stack-through-control-flow - (local $temp1 i32) - (local $temp2 i32) - i32.const 0 - call $local-to-stack-multi-4 - i32.const 1 - call $local-to-stack-multi-4 - i32.const 0 - if - nop - end - drop - i32.const 2 - call $local-to-stack-multi-4 - block $block - br $block - end - drop - drop - ) - (func $local-to-stack-in-control-flow - (local $temp1 i32) - i32.const 0 - if - i32.const 0 - call $local-to-stack-multi-4 - drop - else - i32.const 1 - call $local-to-stack-multi-4 - drop - end - ) - (func $remove-block (param $x i32) (result i32) - (local $temp i32) - i32.const 0 - call $remove-block - i32.const 1 - call $remove-block - i32.const 2 - call $remove-block - drop - i32.eqz - i32.add - ) -) -(module - (type $FUNCSIG$v (func)) - (type $5 (func (result i32))) - (type $6 (func (param i32) (result i32))) - (type $FUNCSIG$vf (func (param f32))) - (type $4 (func (result f64))) - (type $FUNCSIG$ddd (func (param f64 f64) (result f64))) - (type $FUNCSIG$id (func (param f64) (result i32))) - (type $7 (func (param f64) (result f64))) - (type $8 (func (result i64))) - (type $9 (func (param i32 i64))) - (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) - (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) - (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) - (memory $0 4096 4096) - (data (i32.const 1026) "\14\00") - (table $0 10 funcref) - (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) - (export "big_negative" (func $big_negative)) - (func $big_negative (; has Stack IR ;) - (local $temp f64) - (block $block0 - (local.set $temp - (f64.const -2147483648) - ) - (local.set $temp - (f64.const -2147483648) - ) - (local.set $temp - (f64.const -21474836480) - ) - (local.set $temp - (f64.const 0.039625) - ) - (local.set $temp - (f64.const -0.039625) - ) - ) - ) - (func $importedDoubles (; has Stack IR ;) (result f64) - (local $temp f64) - (block $topmost (result f64) - (local.set $temp - (f64.add - (f64.add - (f64.add - (f64.load - (i32.const 8) - ) - (f64.load - (i32.const 16) - ) - ) - (f64.neg - (f64.load - (i32.const 16) - ) - ) - ) - (f64.neg - (f64.load - (i32.const 8) - ) - ) - ) - ) - (if - (i32.gt_s - (i32.load - (i32.const 24) - ) - (i32.const 0) - ) - (br $topmost - (f64.const -3.4) - ) - ) - (if - (f64.gt - (f64.load - (i32.const 32) - ) - (f64.const 0) - ) - (br $topmost - (f64.const 5.6) - ) - ) - (f64.const 1.2) - ) - ) - (func $doubleCompares (; has Stack IR ;) (param $x f64) (param $y f64) (result f64) - (local $t f64) - (local $Int f64) - (local $Double i32) - (block $topmost (result f64) - (if - (f64.gt - (local.get $x) - (f64.const 0) - ) - (br $topmost - (f64.const 1.2) - ) - ) - (if - (f64.gt - (local.get $Int) - (f64.const 0) - ) - (br $topmost - (f64.const -3.4) - ) - ) - (if - (i32.gt_s - (local.get $Double) - (i32.const 0) - ) - (br $topmost - (f64.const 5.6) - ) - ) - (if - (f64.lt - (local.get $x) - (local.get $y) - ) - (br $topmost - (local.get $x) - ) - ) - (local.get $y) - ) - ) - (func $intOps (; has Stack IR ;) (result i32) - (local $x i32) - (i32.eq - (local.get $x) - (i32.const 0) - ) - ) - (func $hexLiterals (; has Stack IR ;) - (drop - (i32.add - (i32.add - (i32.const 0) - (i32.const 313249263) - ) - (i32.const -19088752) - ) - ) - ) - (func $conversions (; has Stack IR ;) - (local $i i32) - (local $d f64) - (block $block0 - (local.set $i - (call $f64-to-int - (local.get $d) - ) - ) - (local.set $d - (f64.convert_i32_s - (local.get $i) - ) - ) - (local.set $d - (f64.convert_i32_u - (i32.shr_u - (local.get $i) - (i32.const 0) - ) - ) - ) - ) - ) - (func $seq (; has Stack IR ;) - (local $J f64) - (local.set $J - (f64.sub - (block $block0 (result f64) - (drop - (f64.const 0.1) - ) - (f64.const 5.1) - ) - (block $block1 (result f64) - (drop - (f64.const 3.2) - ) - (f64.const 4.2) - ) - ) - ) - ) - (func $switcher (; has Stack IR ;) (param $x i32) (result i32) - (block $topmost (result i32) - (block $switch$0 - (block $switch-default$3 - (block $switch-case$2 - (block $switch-case$1 - (br_table $switch-case$1 $switch-case$2 $switch-default$3 - (i32.sub - (local.get $x) - (i32.const 1) - ) - ) - ) - (br $topmost - (i32.const 1) - ) - ) - (br $topmost - (i32.const 2) - ) - ) - (nop) - ) - (block $switch$4 - (block $switch-default$7 - (block $switch-case$6 - (block $switch-case$5 - (br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7 - (i32.sub - (local.get $x) - (i32.const 5) - ) - ) - ) - (br $topmost - (i32.const 121) - ) - ) - (br $topmost - (i32.const 51) - ) - ) - (nop) - ) - (block $label$break$Lout - (block $switch-default$16 - (block $switch-case$15 - (block $switch-case$12 - (block $switch-case$9 - (block $switch-case$8 - (br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16 - (i32.sub - (local.get $x) - (i32.const 2) - ) - ) - ) - (br $label$break$Lout) - ) - (br $label$break$Lout) - ) - (block $while-out$10 - (loop $while-in$11 - (block $block1 - (br $while-out$10) - (br $while-in$11) - ) - ) - (br $label$break$Lout) - ) - ) - (block $while-out$13 - (loop $while-in$14 - (block $block3 - (br $label$break$Lout) - (br $while-in$14) - ) - ) - (br $label$break$Lout) - ) - ) - (nop) - ) - (i32.const 0) - ) - ) - (func $blocker (; has Stack IR ;) - (block $label$break$L - (br $label$break$L) - ) - ) - (func $frem (; has Stack IR ;) (result f64) - (call $f64-rem - (f64.const 5.5) - (f64.const 1.2) - ) - ) - (func $big_uint_div_u (; has Stack IR ;) (result i32) - (local $x i32) - (block $topmost (result i32) - (local.set $x - (i32.and - (i32.div_u - (i32.const -1) - (i32.const 2) - ) - (i32.const -1) - ) - ) - (local.get $x) - ) - ) - (func $fr (; has Stack IR ;) (param $x f32) - (local $y f32) - (local $z f64) - (block $block0 - (drop - (f32.demote_f64 - (local.get $z) - ) - ) - (drop - (local.get $y) - ) - (drop - (f32.const 5) - ) - (drop - (f32.const 0) - ) - (drop - (f32.const 5) - ) - (drop - (f32.const 0) - ) - ) - ) - (func $negZero (; has Stack IR ;) (result f64) - (f64.const -0) - ) - (func $abs (; has Stack IR ;) - (local $x i32) - (local $y f64) - (local $z f32) - (local $asm2wasm_i32_temp i32) - (block $block0 - (local.set $x - (block $block1 (result i32) - (local.set $asm2wasm_i32_temp - (i32.const 0) - ) - (select - (i32.sub - (i32.const 0) - (local.get $asm2wasm_i32_temp) - ) - (local.get $asm2wasm_i32_temp) - (i32.lt_s - (local.get $asm2wasm_i32_temp) - (i32.const 0) - ) - ) - ) - ) - (local.set $y - (f64.abs - (f64.const 0) - ) - ) - (local.set $z - (f32.abs - (f32.const 0) - ) - ) - ) - ) - (func $neg (; has Stack IR ;) - (local $x f32) - (block $block0 - (local.set $x - (f32.neg - (local.get $x) - ) - ) - (call_indirect (type $FUNCSIG$vf) - (local.get $x) - (i32.add - (i32.and - (i32.const 1) - (i32.const 7) - ) - (i32.const 8) - ) - ) - ) - ) - (func $cneg (; has Stack IR ;) (param $x f32) - (call_indirect (type $FUNCSIG$vf) - (local.get $x) - (i32.add - (i32.and - (i32.const 1) - (i32.const 7) - ) - (i32.const 8) - ) - ) - ) - (func $___syscall_ret (; has Stack IR ;) - (local $$0 i32) - (drop - (i32.gt_u - (i32.shr_u - (local.get $$0) - (i32.const 0) - ) - (i32.const -4096) - ) - ) - ) - (func $z (; has Stack IR ;) - (nop) - ) - (func $w (; has Stack IR ;) - (nop) - ) - (func $block_and_after (; has Stack IR ;) (result i32) - (block $waka - (drop - (i32.const 1) - ) - (br $waka) - ) - (i32.const 0) - ) - (func $loop-roundtrip (; has Stack IR ;) (param $0 f64) (result f64) - (loop $loop-in1 (result f64) - (drop - (local.get $0) - ) - (local.get $0) - ) - ) - (func $big-i64 (; has Stack IR ;) (result i64) - (i64.const -9218868437227405313) - ) - (func $i64-store32 (; has Stack IR ;) (param $0 i32) (param $1 i64) - (i64.store32 - (local.get $0) - (local.get $1) - ) - ) - (func $return-unreachable (; has Stack IR ;) (result i32) - (return - (i32.const 1) - ) - ) - (func $unreachable-block (; has Stack IR ;) (result i32) - (f64.abs - (block $block - (drop - (i32.const 1) - ) - (return - (i32.const 2) - ) - ) - ) - ) - (func $unreachable-block-toplevel (; has Stack IR ;) (result i32) - (block $block - (drop - (i32.const 1) - ) - (return - (i32.const 2) - ) - ) - ) - (func $unreachable-block0 (; has Stack IR ;) (result i32) - (f64.abs - (block $block - (return - (i32.const 2) - ) - ) - ) - ) - (func $unreachable-block0-toplevel (; has Stack IR ;) (result i32) - (block $block - (return - (i32.const 2) - ) - ) - ) - (func $unreachable-block-with-br (; has Stack IR ;) (result i32) - (block $block - (drop - (i32.const 1) - ) - (br $block) - ) - (i32.const 1) - ) - (func $unreachable-if (; has Stack IR ;) (result i32) - (f64.abs - (if - (i32.const 3) - (return - (i32.const 2) - ) - (return - (i32.const 1) - ) - ) - ) - ) - (func $unreachable-if-toplevel (; has Stack IR ;) (result i32) - (if - (i32.const 3) - (return - (i32.const 2) - ) - (return - (i32.const 1) - ) - ) - ) - (func $unreachable-loop (; has Stack IR ;) (result i32) - (f64.abs - (loop $loop-in - (nop) - (return - (i32.const 1) - ) - ) - ) - ) - (func $unreachable-loop0 (; has Stack IR ;) (result i32) - (f64.abs - (loop $loop-in - (return - (i32.const 1) - ) - ) - ) - ) - (func $unreachable-loop-toplevel (; has Stack IR ;) (result i32) - (loop $loop-in - (nop) - (return - (i32.const 1) - ) - ) - ) - (func $unreachable-loop0-toplevel (; has Stack IR ;) (result i32) - (loop $loop-in - (return - (i32.const 1) - ) - ) - ) - (func $unreachable-ifs (; has Stack IR ;) - (if - (unreachable) - (nop) - ) - (if - (unreachable) - (unreachable) - ) - (if - (unreachable) - (nop) - (nop) - ) - (if - (unreachable) - (unreachable) - (nop) - ) - (if - (unreachable) - (nop) - (unreachable) - ) - (if - (unreachable) - (unreachable) - (unreachable) - ) - (if - (i32.const 1) - (unreachable) - (nop) - ) - (if - (i32.const 1) - (nop) - (unreachable) - ) - (if - (i32.const 1) - (unreachable) - (unreachable) - ) - ) - (func $unreachable-if-arm (; has Stack IR ;) - (if - (i32.const 1) - (block $block - (nop) - ) - (block $block12 - (unreachable) - (drop - (i32.const 1) - ) - ) - ) - ) - (func $local-to-stack (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (drop - (call $local-to-stack - (i32.const 2) - ) - ) - (local.get $temp) - ) - (func $local-to-stack-1 (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (drop - (call $local-to-stack - (i32.const 2) - ) - ) - (i32.eqz - (local.get $temp) - ) - ) - (func $local-to-stack-1b (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (drop - (call $local-to-stack - (i32.const 2) - ) - ) - (i32.add - (local.get $temp) - (i32.const 3) - ) - ) - (func $local-to-stack-1c-no (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (drop - (call $local-to-stack - (i32.const 2) - ) - ) - (i32.add - (i32.const 3) - (local.get $temp) - ) - ) - (func $local-to-stack-2-no (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (drop - (call $local-to-stack - (i32.const 2) - ) - ) - (i32.add - (local.get $temp) - (local.get $temp) - ) - ) - (func $local-to-stack-3-no (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (if - (i32.const 1) - (local.set $temp - (call $local-to-stack - (i32.const 1) - ) - ) - (local.set $temp - (call $local-to-stack - (i32.const 2) - ) - ) - ) - (drop - (call $local-to-stack - (i32.const 3) - ) - ) - (local.get $temp) - ) - (func $local-to-stack-multi-4 (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 2) - ) - ) - (drop - (local.get $temp1) - ) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 4) - ) - ) - (local.get $temp1) - ) - (func $local-to-stack-multi-5 (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 2) - ) - ) - (drop - (local.get $temp1) - ) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 4) - ) - ) - (local.get $temp2) - ) - (func $local-to-stack-multi-6-justone (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 2) - ) - ) - (drop - (local.get $temp1) - ) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 4) - ) - ) - (i32.add - (local.get $temp2) - (local.get $temp2) - ) - ) - (func $local-to-stack-multi-7-justone (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 2) - ) - ) - (drop - (i32.add - (local.get $temp1) - (local.get $temp1) - ) - ) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 4) - ) - ) - (local.get $temp2) - ) - (func $local-to-stack-overlapping-multi-8-no (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (i32.add - (local.get $temp2) - (local.get $temp1) - ) - ) - (func $local-to-stack-overlapping-multi-9-yes (; has Stack IR ;) (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (call $local-to-stack-multi-4 - (i32.const 3) - ) - ) - (i32.add - (local.get $temp1) - (local.get $temp2) - ) - ) - (func $local-to-stack-through-control-flow (; has Stack IR ;) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp2 - (call $local-to-stack-multi-4 - (i32.const 0) - ) - ) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (if - (i32.const 0) - (nop) - ) - (drop - (local.get $temp1) - ) - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 2) - ) - ) - (block $block - (br $block) - ) - (drop - (local.get $temp1) - ) - (drop - (local.get $temp2) - ) - ) - (func $local-to-stack-in-control-flow (; has Stack IR ;) - (local $temp1 i32) - (if - (i32.const 0) - (block $block - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 0) - ) - ) - (drop - (local.get $temp1) - ) - ) - (block $block13 - (local.set $temp1 - (call $local-to-stack-multi-4 - (i32.const 1) - ) - ) - (drop - (local.get $temp1) - ) - ) - ) - ) - (func $remove-block (; has Stack IR ;) (param $x i32) (result i32) - (local $temp i32) - (i32.add - (call $remove-block - (i32.const 0) - ) - (i32.eqz - (block $block (result i32) - (local.set $temp - (call $remove-block - (i32.const 1) - ) - ) - (drop - (call $remove-block - (i32.const 2) - ) - ) - (local.get $temp) - ) - ) - ) - ) -) diff --git a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast b/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast deleted file mode 100644 index 3fa184124f0..00000000000 --- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast +++ /dev/null @@ -1,712 +0,0 @@ -(module - (type $FUNCSIG$vf (func (param f32))) - (type $FUNCSIG$v (func)) - (type $FUNCSIG$id (func (param f64) (result i32))) - (type $FUNCSIG$ddd (func (param f64 f64) (result f64))) - (type $4 (func (result f64))) - (type $5 (func (result i32))) - (type $6 (func (param i32) (result i32))) - (type $7 (func (param f64) (result f64))) - (type $8 (func (result i64))) - (type $9 (func (param i32 i64))) - (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi)) - (import "asm2wasm" "f64-to-int" (func $f64-to-int (param f64) (result i32))) - (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64))) - (table 10 funcref) - (elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg) - (memory $0 4096 4096) - (data (i32.const 1026) "\14\00") - (export "big_negative" (func $big_negative)) - (func $big_negative (type $FUNCSIG$v) - (local $temp f64) - (block $block0 - (local.set $temp - (f64.const -2147483648) - ) - (local.set $temp - (f64.const -2147483648) - ) - (local.set $temp - (f64.const -21474836480) - ) - (local.set $temp - (f64.const 0.039625) - ) - (local.set $temp - (f64.const -0.039625) - ) - ) - ) - (func $importedDoubles (type $4) (result f64) - (local $temp f64) - (block $topmost (result f64) - (local.set $temp - (f64.add - (f64.add - (f64.add - (f64.load - (i32.const 8) - ) - (f64.load - (i32.const 16) - ) - ) - (f64.neg - (f64.load - (i32.const 16) - ) - ) - ) - (f64.neg - (f64.load - (i32.const 8) - ) - ) - ) - ) - (if - (i32.gt_s - (i32.load - (i32.const 24) - ) - (i32.const 0) - ) - (br $topmost - (f64.const -3.4) - ) - ) - (if - (f64.gt - (f64.load - (i32.const 32) - ) - (f64.const 0) - ) - (br $topmost - (f64.const 5.6) - ) - ) - (f64.const 1.2) - ) - ) - (func $doubleCompares (type $FUNCSIG$ddd) (param $x f64) (param $y f64) (result f64) - (local $t f64) - (local $Int f64) - (local $Double i32) - (block $topmost (result f64) - (if - (f64.gt - (local.get $x) - (f64.const 0) - ) - (br $topmost - (f64.const 1.2) - ) - ) - (if - (f64.gt - (local.get $Int) - (f64.const 0) - ) - (br $topmost - (f64.const -3.4) - ) - ) - (if - (i32.gt_s - (local.get $Double) - (i32.const 0) - ) - (br $topmost - (f64.const 5.6) - ) - ) - (if - (f64.lt - (local.get $x) - (local.get $y) - ) - (br $topmost - (local.get $x) - ) - ) - (local.get $y) - ) - ) - (func $intOps (type $5) (result i32) - (local $x i32) - (i32.eq - (local.get $x) - (i32.const 0) - ) - ) - (func $hexLiterals (type $FUNCSIG$v) - (drop - (i32.add - (i32.add - (i32.const 0) - (i32.const 313249263) - ) - (i32.const -19088752) - ) - ) - ) - (func $conversions (type $FUNCSIG$v) - (local $i i32) - (local $d f64) - (block $block0 - (local.set $i - (call $f64-to-int - (local.get $d) - ) - ) - (local.set $d - (f64.convert_i32_s - (local.get $i) - ) - ) - (local.set $d - (f64.convert_i32_u - (i32.shr_u - (local.get $i) - (i32.const 0) - ) - ) - ) - ) - ) - (func $seq (type $FUNCSIG$v) - (local $J f64) - (local.set $J - (f64.sub - (block $block0 (result f64) - (drop - (f64.const 0.1) - ) - (f64.const 5.1) - ) - (block $block1 (result f64) - (drop - (f64.const 3.2) - ) - (f64.const 4.2) - ) - ) - ) - ) - (func $switcher (type $6) (param $x i32) (result i32) - (block $topmost (result i32) - (block $switch$0 - (block $switch-default$3 - (block $switch-case$2 - (block $switch-case$1 - (br_table $switch-case$1 $switch-case$2 $switch-default$3 - (i32.sub - (local.get $x) - (i32.const 1) - ) - ) - ) - (br $topmost - (i32.const 1) - ) - ) - (br $topmost - (i32.const 2) - ) - ) - (nop) - ) - (block $switch$4 - (block $switch-default$7 - (block $switch-case$6 - (block $switch-case$5 - (br_table $switch-case$6 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-default$7 $switch-case$5 $switch-default$7 - (i32.sub - (local.get $x) - (i32.const 5) - ) - ) - ) - (br $topmost - (i32.const 121) - ) - ) - (br $topmost - (i32.const 51) - ) - ) - (nop) - ) - (block $label$break$Lout - (block $switch-default$16 - (block $switch-case$15 - (block $switch-case$12 - (block $switch-case$9 - (block $switch-case$8 - (br_table $switch-case$15 $switch-default$16 $switch-default$16 $switch-case$12 $switch-default$16 $switch-default$16 $switch-default$16 $switch-default$16 $switch-case$9 $switch-default$16 $switch-case$8 $switch-default$16 - (i32.sub - (local.get $x) - (i32.const 2) - ) - ) - ) - (br $label$break$Lout) - ) - (br $label$break$Lout) - ) - (block $while-out$10 - (loop $while-in$11 - (block $block1 - (br $while-out$10) - (br $while-in$11) - ) - ) - (br $label$break$Lout) - ) - ) - (block $while-out$13 - (loop $while-in$14 - (block $block3 - (br $label$break$Lout) - (br $while-in$14) - ) - ) - (br $label$break$Lout) - ) - ) - (nop) - ) - (i32.const 0) - ) - ) - (func $blocker (type $FUNCSIG$v) - (block $label$break$L - (br $label$break$L) - ) - ) - (func $frem (type $4) (result f64) - (call $f64-rem - (f64.const 5.5) - (f64.const 1.2) - ) - ) - (func $big_uint_div_u (type $5) (result i32) - (local $x i32) - (block $topmost (result i32) - (local.set $x - (i32.and - (i32.div_u - (i32.const -1) - (i32.const 2) - ) - (i32.const -1) - ) - ) - (local.get $x) - ) - ) - (func $fr (type $FUNCSIG$vf) (param $x f32) - (local $y f32) - (local $z f64) - (block $block0 - (drop - (f32.demote_f64 - (local.get $z) - ) - ) - (drop - (local.get $y) - ) - (drop - (f32.const 5) - ) - (drop - (f32.const 0) - ) - (drop - (f32.const 5) - ) - (drop - (f32.const 0) - ) - ) - ) - (func $negZero (type $4) (result f64) - (f64.const -0) - ) - (func $abs (type $FUNCSIG$v) - (local $x i32) - (local $y f64) - (local $z f32) - (local $asm2wasm_i32_temp i32) - (block $block0 - (local.set $x - (block $block1 (result i32) - (local.set $asm2wasm_i32_temp - (i32.const 0) - ) - (select - (i32.sub - (i32.const 0) - (local.get $asm2wasm_i32_temp) - ) - (local.get $asm2wasm_i32_temp) - (i32.lt_s - (local.get $asm2wasm_i32_temp) - (i32.const 0) - ) - ) - ) - ) - (local.set $y - (f64.abs - (f64.const 0) - ) - ) - (local.set $z - (f32.abs - (f32.const 0) - ) - ) - ) - ) - (func $neg (type $FUNCSIG$v) - (local $x f32) - (block $block0 - (local.set $x - (f32.neg - (local.get $x) - ) - ) - (call_indirect (type $FUNCSIG$vf) - (local.get $x) - (i32.add - (i32.and - (i32.const 1) - (i32.const 7) - ) - (i32.const 8) - ) - ) - ) - ) - (func $cneg (type $FUNCSIG$vf) (param $x f32) - (call_indirect (type $FUNCSIG$vf) - (local.get $x) - (i32.add - (i32.and - (i32.const 1) - (i32.const 7) - ) - (i32.const 8) - ) - ) - ) - (func $___syscall_ret (type $FUNCSIG$v) - (local $$0 i32) - (drop - (i32.gt_u - (i32.shr_u - (local.get $$0) - (i32.const 0) - ) - (i32.const -4096) - ) - ) - ) - (func $z (type $FUNCSIG$v) - (nop) - ) - (func $w (type $FUNCSIG$v) - (nop) - ) - (func $block_and_after (type $5) (result i32) - (block $waka - (drop - (i32.const 1) - ) - (br $waka) - ) - (i32.const 0) - ) - (func $loop-roundtrip (type $7) (param $0 f64) (result f64) - (loop $loop-in1 (result f64) - (drop - (local.get $0) - ) - (local.get $0) - ) - ) - (func $big-i64 (type $8) (result i64) - (i64.const -9218868437227405313) - ) - (func $i64-store32 (type $9) (param $0 i32) (param $1 i64) - (i64.store32 - (local.get $0) - (local.get $1) - ) - ) - (func $return-unreachable (result i32) - (return (i32.const 1)) - ) - (func $unreachable-block (result i32) - (f64.abs - (block ;; note no type - valid in binaryen IR, in wasm must be i32 - (drop (i32.const 1)) - (return (i32.const 2)) - ) - ) - ) - (func $unreachable-block-toplevel (result i32) - (block ;; note no type - valid in binaryen IR, in wasm must be i32 - (drop (i32.const 1)) - (return (i32.const 2)) - ) - ) - (func $unreachable-block0 (result i32) - (f64.abs - (block ;; note no type - valid in binaryen IR, in wasm must be i32 - (return (i32.const 2)) - ) - ) - ) - (func $unreachable-block0-toplevel (result i32) - (block ;; note no type - valid in binaryen IR, in wasm must be i32 - (return (i32.const 2)) - ) - ) - (func $unreachable-block-with-br (result i32) - (block $block ;; unreachable type due to last element having that type, but the block is exitable - (drop (i32.const 1)) - (br $block) - ) - (i32.const 1) - ) - (func $unreachable-if (result i32) - (f64.abs - (if ;; note no type - valid in binaryen IR, in wasm must be i32 - (i32.const 3) - (return (i32.const 2)) - (return (i32.const 1)) - ) - ) - ) - (func $unreachable-if-toplevel (result i32) - (if ;; note no type - valid in binaryen IR, in wasm must be i32 - (i32.const 3) - (return (i32.const 2)) - (return (i32.const 1)) - ) - ) - (func $unreachable-loop (result i32) - (f64.abs - (loop ;; note no type - valid in binaryen IR, in wasm must be i32 - (nop) - (return (i32.const 1)) - ) - ) - ) - (func $unreachable-loop0 (result i32) - (f64.abs - (loop ;; note no type - valid in binaryen IR, in wasm must be i32 - (return (i32.const 1)) - ) - ) - ) - (func $unreachable-loop-toplevel (result i32) - (loop ;; note no type - valid in binaryen IR, in wasm must be i32 - (nop) - (return (i32.const 1)) - ) - ) - (func $unreachable-loop0-toplevel (result i32) - (loop ;; note no type - valid in binaryen IR, in wasm must be i32 - (return (i32.const 1)) - ) - ) - (func $unreachable-ifs - (if (unreachable) (nop)) - (if (unreachable) (unreachable)) - (if (unreachable) (nop) (nop)) - (if (unreachable) (unreachable) (nop)) - (if (unreachable) (nop) (unreachable)) - (if (unreachable) (unreachable) (unreachable)) - ;; - (if (i32.const 1) (unreachable) (nop)) - (if (i32.const 1) (nop) (unreachable)) - (if (i32.const 1) (unreachable) (unreachable)) - ) - (func $unreachable-if-arm - (if - (i32.const 1) - (block - (nop) - ) - (block - (unreachable) - (drop - (i32.const 1) - ) - ) - ) - ) - (func $local-to-stack (param $x i32) (result i32) - (local $temp i32) - (local.set $temp (call $local-to-stack (i32.const 1))) ;; this set could just be on the stack - (drop (call $local-to-stack (i32.const 2))) - (local.get $temp) - ) - (func $local-to-stack-1 (param $x i32) (result i32) - (local $temp i32) - (local.set $temp (call $local-to-stack (i32.const 1))) - (drop (call $local-to-stack (i32.const 2))) - (i32.eqz - (local.get $temp) - ) - ) - (func $local-to-stack-1b (param $x i32) (result i32) - (local $temp i32) - (local.set $temp (call $local-to-stack (i32.const 1))) - (drop (call $local-to-stack (i32.const 2))) - (i32.add - (local.get $temp) - (i32.const 3) - ) - ) - (func $local-to-stack-1c-no (param $x i32) (result i32) - (local $temp i32) - (local.set $temp (call $local-to-stack (i32.const 1))) - (drop (call $local-to-stack (i32.const 2))) - (i32.add - (i32.const 3) ;; this is in the way - (local.get $temp) - ) - ) - (func $local-to-stack-2-no (param $x i32) (result i32) - (local $temp i32) - (local.set $temp (call $local-to-stack (i32.const 1))) - (drop (call $local-to-stack (i32.const 2))) - (i32.add - (local.get $temp) - (local.get $temp) ;; a second use - so cannot stack it - ) - ) - (func $local-to-stack-3-no (param $x i32) (result i32) - (local $temp i32) - (if (i32.const 1) - (local.set $temp (call $local-to-stack (i32.const 1))) - (local.set $temp (call $local-to-stack (i32.const 2))) ;; two sets for that get - ) - (drop (call $local-to-stack (i32.const 3))) - (local.get $temp) - ) - (func $local-to-stack-multi-4 (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 2))) - (drop (local.get $temp1)) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 3))) ;; same local, used later - (drop (call $local-to-stack-multi-4 (i32.const 4))) - (local.get $temp1) - ) - (func $local-to-stack-multi-5 (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 2))) - (drop (local.get $temp1)) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later - (drop (call $local-to-stack-multi-4 (i32.const 4))) - (local.get $temp2) - ) - (func $local-to-stack-multi-6-justone (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 2))) - (drop (local.get $temp1)) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later - (drop (call $local-to-stack-multi-4 (i32.const 4))) - (i32.add - (local.get $temp2) - (local.get $temp2) - ) - ) - (func $local-to-stack-multi-7-justone (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 2))) - (drop - (i32.add - (local.get $temp1) - (local.get $temp1) - ) - ) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 3))) ;; different local, used later - (drop (call $local-to-stack-multi-4 (i32.const 4))) - (local.get $temp2) - ) - (func $local-to-stack-overlapping-multi-8-no (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 3))) - (i32.add - (local.get $temp2) ;; the timing - (local.get $temp1) ;; it sucks - ) - ) - (func $local-to-stack-overlapping-multi-9-yes (param $x i32) (result i32) - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (call $local-to-stack-multi-4 (i32.const 3))) - (i32.add - (local.get $temp1) ;; the stars align - (local.get $temp2) ;; and a time presents itself - ) - ) - (func $local-to-stack-through-control-flow - (local $temp1 i32) - (local $temp2 i32) - (local.set $temp2 (call $local-to-stack-multi-4 (i32.const 0))) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (if (i32.const 0) (nop)) - (drop (local.get $temp1)) - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 2))) - (block $block (br $block)) - (drop (local.get $temp1)) - (drop (local.get $temp2)) - ) - (func $local-to-stack-in-control-flow - (local $temp1 i32) - (if (i32.const 0) - (block - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 0))) - (drop (local.get $temp1)) - ) - (block - (local.set $temp1 (call $local-to-stack-multi-4 (i32.const 1))) - (drop (local.get $temp1)) - ) - ) - ) - (func $remove-block (param $x i32) (result i32) - (local $temp i32) - (i32.add - (call $remove-block (i32.const 0)) - (i32.eqz - (block (result i32) ;; after we use the stack instead of the local, we can remove this block - (local.set $temp (call $remove-block (i32.const 1))) - (drop (call $remove-block (i32.const 2))) - (local.get $temp) - ) - ) - ) - ) -) diff --git a/test/passes/interesting-pass-mix.passes b/test/passes/interesting-pass-mix.passes deleted file mode 100644 index 86b9bf7e351..00000000000 --- a/test/passes/interesting-pass-mix.passes +++ /dev/null @@ -1 +0,0 @@ -flatten_rereloop_dce_remove-unused-brs_remove-unused-names_coalesce-locals_simplify-locals_reorder-locals_remove-unused-brs_merge-blocks_vacuum diff --git a/test/passes/interesting-pass-mix.txt b/test/passes/interesting-pass-mix.txt deleted file mode 100644 index fc1993dfdcd..00000000000 --- a/test/passes/interesting-pass-mix.txt +++ /dev/null @@ -1,234 +0,0 @@ -(module - (type $i32_=>_none (func (param i32))) - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (func $trivial - (nop) - ) - (func $trivial2 - (call $trivial) - (call $trivial) - ) - (func $return-void - (nop) - ) - (func $return-val (result i32) - (i32.const 1) - ) - (func $ifs (param $0 i32) (result i32) - (select - (select - (i32.const 2) - (i32.const 3) - (local.get $0) - ) - (select - (i32.const 4) - (i32.const 5) - (local.get $0) - ) - (local.get $0) - ) - ) - (func $loops (param $0 i32) - (if - (local.get $0) - (loop $shape$2$continue - (call $trivial) - (br $shape$2$continue) - ) - ) - (loop $shape$4$continue - (call $trivial) - (if - (local.get $0) - (br $shape$4$continue) - ) - ) - (loop $shape$6$continue - (call $trivial) - (if - (local.get $0) - (br $shape$6$continue) - ) - ) - ) - (func $br-out (param $0 i32) - (call $br-out - (i32.const 5) - ) - ) - (func $unreachable (param $0 i32) - (if - (i32.eqz - (local.get $0) - ) - (block - (call $unreachable - (i32.const 5) - ) - (return) - ) - ) - (if - (local.get $0) - (block - (call $unreachable - (i32.const 1) - ) - (unreachable) - ) - (call $unreachable - (i32.const 3) - ) - ) - ) - (func $empty-blocks (param $0 i32) - (nop) - ) - (func $before-and-after (param $0 i32) - (call $before-and-after - (i32.const 1) - ) - (call $before-and-after - (i32.const 2) - ) - (call $before-and-after - (i32.const 3) - ) - (call $before-and-after - (i32.const 4) - ) - (if - (i32.eqz - (local.get $0) - ) - (call $before-and-after - (i32.const 5) - ) - ) - (call $before-and-after - (i32.const 6) - ) - (call $before-and-after - (i32.const 7) - ) - (call $before-and-after - (i32.const 8) - ) - (loop $shape$4$continue - (call $before-and-after - (i32.const 9) - ) - (if - (local.get $0) - (br $shape$4$continue) - ) - ) - (call $before-and-after - (i32.const 10) - ) - (call $before-and-after - (i32.const 11) - ) - (if - (local.get $0) - (call $before-and-after - (i32.const 12) - ) - ) - (call $before-and-after - (i32.const 13) - ) - (if - (local.get $0) - (call $before-and-after - (i32.const 14) - ) - (call $before-and-after - (i32.const 15) - ) - ) - (if - (local.get $0) - (call $before-and-after - (i32.const 16) - ) - ) - (call $before-and-after - (i32.const 17) - ) - (call $before-and-after - (i32.const 18) - ) - (call $before-and-after - (i32.const 19) - ) - (call $before-and-after - (i32.const 20) - ) - (call $before-and-after - (i32.const 21) - ) - (call $before-and-after - (i32.const 22) - ) - (call $before-and-after - (i32.const 23) - ) - (call $before-and-after - (i32.const 24) - ) - (call $before-and-after - (i32.const 25) - ) - ) - (func $switch (param $0 i32) - (call $switch - (i32.const 1) - ) - (block $block$7$break - (block $switch$3$default - (block $switch$3$case$7 - (br_table $switch$3$case$7 $switch$3$case$7 $switch$3$case$7 $switch$3$default - (local.get $0) - ) - ) - (br $block$7$break) - ) - (call $switch - (i32.const 2) - ) - ) - (call $switch - (i32.const 3) - ) - ) - (func $no-return - (nop) - ) - (func $if-br-wat (param $0 i32) - (call $if-br-wat - (i32.const 0) - ) - (block $block$2$break - (if - (local.get $0) - (call $if-br-wat - (i32.const 1) - ) - (if - (local.get $0) - (br $block$2$break) - ) - ) - (call $if-br-wat - (i32.const 2) - ) - ) - (call $if-br-wat - (i32.const 3) - ) - ) -) diff --git a/test/passes/interesting-pass-mix.wast b/test/passes/interesting-pass-mix.wast deleted file mode 100644 index fba9e7c9e2e..00000000000 --- a/test/passes/interesting-pass-mix.wast +++ /dev/null @@ -1,179 +0,0 @@ -(module - (func $trivial - (nop) - ) - (func $trivial2 - (call $trivial) - (call $trivial) - ) - (func $return-void - (return) - ) - (func $return-val (result i32) - (return (i32.const 1)) - ) - (func $ifs (param $x i32) (result i32) - (if - (local.get $x) - (if - (local.get $x) - (return (i32.const 2)) - (return (i32.const 3)) - ) - ) - (if - (local.get $x) - (return (i32.const 4)) - ) - (return (i32.const 5)) - ) - (func $loops (param $x i32) - (if (local.get $x) - (loop $top - (call $trivial) - (br $top) - ) - ) - (loop $top2 - (call $trivial) - (br_if $top2 (local.get $x)) - ) - (loop $top3 - (call $trivial) - (if (local.get $x) (br $top3)) - ) - ) - (func $br-out (param $x i32) - (block $out - (call $br-out (i32.const 5)) - (br $out) - ) - ) - (func $unreachable (param $x i32) - (if (local.get $x) - (if (local.get $x) - (block - (call $unreachable (i32.const 1)) - (unreachable) - (call $unreachable (i32.const 2)) - ) - (block - (call $unreachable (i32.const 3)) - (return) - (call $unreachable (i32.const 4)) - ) - ) - ) - (block $out - (call $unreachable (i32.const 5)) - (br $out) - (call $unreachable (i32.const 6)) - ) - ) - (func $empty-blocks (param $x i32) - (block) - (block) - ) - (func $before-and-after (param $x i32) - (call $before-and-after (i32.const 1)) - (block - (call $before-and-after (i32.const 2)) - ) - (call $before-and-after (i32.const 3)) - (block $out - (call $before-and-after (i32.const 4)) - (br_if $out (local.get $x)) - (call $before-and-after (i32.const 5)) - ) - (call $before-and-after (i32.const 6)) - (loop) - (call $before-and-after (i32.const 7)) - (loop $top) - (call $before-and-after (i32.const 8)) - (loop $top2 - (call $before-and-after (i32.const 9)) - (br_if $top2 (local.get $x)) - (call $before-and-after (i32.const 10)) - ) - (call $before-and-after (i32.const 11)) - (if (local.get $x) - (call $before-and-after (i32.const 12)) - ) - (call $before-and-after (i32.const 13)) - (if (local.get $x) - (call $before-and-after (i32.const 14)) - (call $before-and-after (i32.const 15)) - ) - (if (local.get $x) - (block - (call $before-and-after (i32.const 16)) - ) - ) - (call $before-and-after (i32.const 17)) - (block - (call $before-and-after (i32.const 18)) - (block - (call $before-and-after (i32.const 19)) - ) - (call $before-and-after (i32.const 20)) - ) - (call $before-and-after (i32.const 21)) - (block - (block - (call $before-and-after (i32.const 22)) - ) - ) - (call $before-and-after (i32.const 23)) - (block $no1 - (block $no2 - (call $before-and-after (i32.const 24)) - ) - ) - (call $before-and-after (i32.const 25)) - ) - (func $switch (param $x i32) - (block $out - (block $a - (br_table $a $a (local.get $x)) - ) - (call $switch (i32.const 1)) - (block $b - (block $c - (br_table $b $b $b $c (local.get $x)) - ) - (call $switch (i32.const 2)) - ) - (call $switch (i32.const 3)) - ) - ) - (func $no-return - (if (i32.const 1) - (drop (i32.const 2)) - (drop (i32.const 3)) - ) - ) - (func $if-br-wat (param $x i32) - (call $if-br-wat - (i32.const 0) - ) - (block $label$2 - (if - (local.get $x) - (call $if-br-wat - (i32.const 1) - ) - (if - (local.get $x) - (br $label$2) ;; waka - ) - ) - (call $if-br-wat - (i32.const 2) - ) - ) - (call $if-br-wat - (i32.const 3) - ) - ) -) - diff --git a/test/passes/legalize-js-interface-minimally.txt b/test/passes/legalize-js-interface-minimally.txt deleted file mode 100644 index 2234344b206..00000000000 --- a/test/passes/legalize-js-interface-minimally.txt +++ /dev/null @@ -1,59 +0,0 @@ -(module - (type $none_=>_i64 (func (result i64))) - (type $i32_=>_none (func (param i32))) - (type $none_=>_i32 (func (result i32))) - (type $i64_=>_none (func (param i64))) - (type $i32_i32_=>_none (func (param i32 i32))) - (import "env" "imported" (func $imported (result i64))) - (import "env" "setTempRet0" (func $setTempRet0 (param i32))) - (import "env" "invoke_vj" (func $legalimport$invoke_vj (param i32 i32))) - (export "func" (func $func)) - (export "dynCall_foo" (func $legalstub$dyn)) - (func $func (result i64) - (drop - (call $imported) - ) - (call $legalfunc$invoke_vj - (i64.const 0) - ) - (unreachable) - ) - (func $dyn (result i64) - (drop - (call $imported) - ) - (unreachable) - ) - (func $legalstub$dyn (result i32) - (local $0 i64) - (local.set $0 - (call $dyn) - ) - (call $setTempRet0 - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - ) - (i32.wrap_i64 - (local.get $0) - ) - ) - (func $legalfunc$invoke_vj (param $0 i64) - (call $legalimport$invoke_vj - (i32.wrap_i64 - (local.get $0) - ) - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - ) - ) -) -(module -) diff --git a/test/passes/legalize-js-interface-minimally.wast b/test/passes/legalize-js-interface-minimally.wast deleted file mode 100644 index e820734be26..00000000000 --- a/test/passes/legalize-js-interface-minimally.wast +++ /dev/null @@ -1,17 +0,0 @@ -(module - (import "env" "imported" (func $imported (result i64))) - (import "env" "invoke_vj" (func $invoke_vj (param i64))) - (export "func" (func $func)) - (export "dynCall_foo" (func $dyn)) - (func $func (result i64) - (drop (call $imported)) - (call $invoke_vj (i64.const 0)) - (unreachable) - ) - (func $dyn (result i64) - (drop (call $imported)) - (unreachable) - ) -) -(module) - diff --git a/test/passes/legalize-js-interface_all-features.txt b/test/passes/legalize-js-interface_all-features.txt deleted file mode 100644 index b1c57b0b8cf..00000000000 --- a/test/passes/legalize-js-interface_all-features.txt +++ /dev/null @@ -1,150 +0,0 @@ -(module - (type $none_=>_i32 (func (result i32))) - (type $none_=>_i64 (func (result i64))) - (type $i32_i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32 i32))) - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i64_i64_=>_none (func (param i32 i64 i64))) - (import "env" "setTempRet0" (func $setTempRet0 (param i32))) - (import "env" "getTempRet0" (func $getTempRet0 (result i32))) - (import "env" "imported" (func $legalimport$imported (result i32))) - (import "env" "other" (func $legalimport$other (param i32 i32 i32 i32 i32))) - (import "env" "ref-func-arg" (func $legalimport$ref-func-arg (result i32))) - (elem declare func $legalfunc$ref-func-arg) - (export "func" (func $legalstub$func)) - (export "ref-func-test" (func $ref-func-test)) - (export "imported" (func $legalstub$imported)) - (export "imported_again" (func $legalstub$imported)) - (export "other" (func $legalstub$other)) - (func $func (result i64) - (drop - (call $legalfunc$imported) - ) - (call $legalfunc$other - (i32.const 0) - (i64.const 0) - (i64.const 0) - ) - (unreachable) - ) - (func $ref-func-test - (drop - (call $legalfunc$ref-func-arg) - ) - (drop - (ref.func $legalfunc$ref-func-arg) - ) - ) - (func $legalstub$func (result i32) - (local $0 i64) - (local.set $0 - (call $func) - ) - (call $setTempRet0 - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - ) - (i32.wrap_i64 - (local.get $0) - ) - ) - (func $legalstub$imported (result i32) - (local $0 i64) - (local.set $0 - (call $legalfunc$imported) - ) - (call $setTempRet0 - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - ) - (i32.wrap_i64 - (local.get $0) - ) - ) - (func $legalstub$other (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (param $4 i32) - (call $legalfunc$other - (local.get $0) - (i64.or - (i64.extend_i32_u - (local.get $1) - ) - (i64.shl - (i64.extend_i32_u - (local.get $2) - ) - (i64.const 32) - ) - ) - (i64.or - (i64.extend_i32_u - (local.get $3) - ) - (i64.shl - (i64.extend_i32_u - (local.get $4) - ) - (i64.const 32) - ) - ) - ) - ) - (func $legalfunc$imported (result i64) - (i64.or - (i64.extend_i32_u - (call $legalimport$imported) - ) - (i64.shl - (i64.extend_i32_u - (call $getTempRet0) - ) - (i64.const 32) - ) - ) - ) - (func $legalfunc$other (param $0 i32) (param $1 i64) (param $2 i64) - (call $legalimport$other - (local.get $0) - (i32.wrap_i64 - (local.get $1) - ) - (i32.wrap_i64 - (i64.shr_u - (local.get $1) - (i64.const 32) - ) - ) - (i32.wrap_i64 - (local.get $2) - ) - (i32.wrap_i64 - (i64.shr_u - (local.get $2) - (i64.const 32) - ) - ) - ) - ) - (func $legalfunc$ref-func-arg (result i64) - (i64.or - (i64.extend_i32_u - (call $legalimport$ref-func-arg) - ) - (i64.shl - (i64.extend_i32_u - (call $getTempRet0) - ) - (i64.const 32) - ) - ) - ) -) -(module -) diff --git a/test/passes/legalize-js-interface_all-features.wast b/test/passes/legalize-js-interface_all-features.wast deleted file mode 100644 index 7f4352f2702..00000000000 --- a/test/passes/legalize-js-interface_all-features.wast +++ /dev/null @@ -1,30 +0,0 @@ -(module - (import "env" "imported" (func $imported (result i64))) - (import "env" "other" (func $other (param i32) (param i64) (param i64))) - (import "env" "ref-func-arg" (func $ref-func-arg (result i64))) - (export "func" (func $func)) - (export "ref-func-test" (func $ref-func-test)) - (export "imported" (func $imported)) - (export "imported_again" (func $imported)) - (export "other" (func $other)) - (func $func (result i64) - (drop (call $imported)) - (call $other - (i32.const 0) - (i64.const 0) - (i64.const 0) - ) - (unreachable) - ) - - ;; ref.func must also be updated. - (func $ref-func-test - (drop - (call $ref-func-arg) - ) - (drop - (ref.func $ref-func-arg) - ) - ) -) -(module) diff --git a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt deleted file mode 100644 index 1327a4340a1..00000000000 --- a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.txt +++ /dev/null @@ -1,28 +0,0 @@ -(module - (type $none_=>_i64 (func (result i64))) - (type $i32_=>_none (func (param i32))) - (type $none_=>_i32 (func (result i32))) - (import "env" "setTempRet0" (func $setTempRet0 (param i32))) - (export "func" (func $legalstub$func)) - (export "orig$func" (func $func)) - (func $func (result i64) - (unreachable) - ) - (func $legalstub$func (result i32) - (local $0 i64) - (local.set $0 - (call $func) - ) - (call $setTempRet0 - (i32.wrap_i64 - (i64.shr_u - (local.get $0) - (i64.const 32) - ) - ) - ) - (i32.wrap_i64 - (local.get $0) - ) - ) -) diff --git a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast b/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast deleted file mode 100644 index 4b55fa92057..00000000000 --- a/test/passes/legalize-js-interface_pass-arg=legalize-js-interface-export-originals.wast +++ /dev/null @@ -1,7 +0,0 @@ -(module - (export "func" (func $func)) - (func $func (result i64) - (unreachable) - ) -) - diff --git a/test/passes/licm.txt b/test/passes/licm.txt deleted file mode 100644 index 956f6365e0b..00000000000 --- a/test/passes/licm.txt +++ /dev/null @@ -1,695 +0,0 @@ -(module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $none_=>_i64 (func (result i64))) - (type $i32_=>_none (func (param i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (global $glob (mut i32) (i32.const 1)) - (memory $0 1) - (func $loop1 - (drop - (i32.const 10) - ) - (loop $loop - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop2 - (drop - (i32.const 10) - ) - (drop - (i32.const 20) - ) - (loop $loop - (nop) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop3 - (drop - (i32.const 10) - ) - (drop - (i32.const 20) - ) - (loop $loop - (nop) - (call $loop2) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop4 - (drop - (i32.load - (i32.const 1) - ) - ) - (loop $loop - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop3-4 - (loop $loop - (drop - (i32.load - (i32.const 10) - ) - ) - (call $loop2) - (drop - (i32.load - (i32.const 20) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop3-4-b - (drop - (i32.load - (i32.const 10) - ) - ) - (drop - (i32.load - (i32.const 20) - ) - ) - (loop $loop - (nop) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop5 - (loop $loop - (i32.store - (i32.const 1) - (i32.const 2) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop6 - (loop $loop - (i32.store - (i32.const 1) - (i32.const 2) - ) - (i32.store - (i32.const 2) - (i32.const 3) - ) - ) - ) - (func $loop7 - (loop $loop - (i32.store - (i32.const 1) - (i32.const 2) - ) - (i32.store - (i32.const 2) - (i32.const 3) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop8 - (loop $loop - (i32.store - (i32.const 1) - (i32.const 2) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop9 - (loop $loop - (drop - (i32.load - (i32.const 1) - ) - ) - (i32.store - (i32.const 1) - (i32.const 2) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop10 - (drop - (i32.load - (i32.const 1) - ) - ) - (drop - (i32.load - (i32.const 2) - ) - ) - (loop $loop - (nop) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop11 - (local $x i32) - (local $y i32) - (loop $loop - (drop - (local.get $x) - ) - (br_if $loop - (local.tee $x - (i32.const 2) - ) - ) - ) - ) - (func $loop12 - (local $x i32) - (local $y i32) - (drop - (local.get $x) - ) - (loop $loop - (nop) - (br_if $loop - (local.tee $y - (i32.const 2) - ) - ) - ) - ) - (func $loop13 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (loop $loop - (nop) - (call $loop12) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop14 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (loop $loop - (nop) - (call $loop12) - (br_if $loop - (i32.const 1) - ) - (local.set $y - (local.get $x) - ) - ) - ) - (func $loop14-1 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (call $loop12) - (local.set $y - (local.get $x) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop15 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (loop $loop - (nop) - (call $loop12) - (br_if $loop - (i32.const 1) - ) - (drop - (local.get $y) - ) - ) - ) - (func $loop15-1 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (drop - (local.get $y) - ) - (loop $loop - (nop) - (call $loop12) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop16 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (loop $loop - (nop) - (call $loop12) - (br_if $loop - (i32.const 1) - ) - (drop - (local.get $x) - ) - ) - ) - (func $loop16-1 - (local $x i32) - (local $y i32) - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (drop - (local.get $x) - ) - (loop $loop - (nop) - (call $loop12) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop16-2 - (local $x i32) - (local $y i32) - (local.set $x - (i32.const 2) - ) - (block - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (drop - (local.get $x) - ) - (loop $loop - (nop) - (call $loop12) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - ) - (func $loop16-3 - (local $x i32) - (local $y i32) - (local.set $y - (i32.const 2) - ) - (block - (local.set $x - (i32.eqz - (local.get $y) - ) - ) - (drop - (local.get $x) - ) - (loop $loop - (nop) - (call $loop12) - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - ) - (func $nop - (loop $loop - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $nested-blocks - (loop $loop - (block $block - (nop) - ) - (block $x - (nop) - ) - (block $a - (block $b - (block $c - (nop) - ) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $nested-unhoistable-blocks - (loop $loop - (block $block - (call $nested-unhoistable-blocks) - ) - (block $x - (call $nested-unhoistable-blocks) - ) - (block $a - (block $b - (block $c - (call $nested-unhoistable-blocks) - ) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $conditional - (if - (i32.const 0) - (drop - (i32.const 10) - ) - ) - (loop $loop - (nop) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $conditional1 (result i32) - (loop $loop - (if - (call $conditional1) - (drop - (i32.const 10) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - (unreachable) - ) - (func $conditional2 - (block $out - (loop $loop - (br_if $out - (i32.const 1) - ) - (drop - (i32.const 10) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - ) - (func $conditional3 - (block $out - (block - (drop - (i32.const 10) - ) - (loop $loop - (nop) - (br_if $out - (i32.const 1) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - ) - ) - (func $after - (loop $loop - (nop) - ) - (drop - (i32.const 10) - ) - ) - (func $loops - (drop - (i32.const 10) - ) - (loop $loop2 - (nop) - (loop $loop1 - (nop) - (br_if $loop1 - (i32.const 1) - ) - ) - ) - ) - (func $loops2 - (drop - (i32.const 10) - ) - (loop $loop2 - (nop) - (loop $loop1 - (nop) - (br_if $loop2 - (i32.const 1) - ) - ) - ) - ) - (func $fuzz1 (result i64) - (local $var$1 i64) - (drop - (block (result i32) - (local.set $var$1 - (block $label$5 (result i64) - (local.set $var$1 - (i64.const -29585) - ) - (i64.const -70) - ) - ) - (loop $label$4 (result i32) - (nop) - (i32.const 1) - ) - ) - ) - (loop $label$1 (result i64) - (block $label$2 - (block $label$3 - (nop) - (br $label$2) - ) - (unreachable) - ) - (local.get $var$1) - ) - ) - (func $self (result i32) - (local $x i32) - (loop $loop - (local.set $x - (i32.add - (local.get $x) - (i32.const 1) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - (local.get $x) - ) - (func $nested-set - (local $var$0 i32) - (local $var$1 i64) - (loop $label$1 - (local.set $var$0 - (block $label$3 (result i32) - (local.set $var$1 - (i64.const 0) - ) - (local.get $var$0) - ) - ) - (local.set $var$1 - (i64.const 1) - ) - (br_if $label$1 - (i32.const 0) - ) - ) - ) - (func $load-store (param $x i32) - (loop $loop - (drop - (i32.load - (i32.const 0) - ) - ) - (i32.store - (local.get $x) - (local.get $x) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $set-set (param $x i32) (result i32) - (loop $loop - (local.set $x - (i32.const 1) - ) - (br_if $loop - (i32.const 2) - ) - (local.set $x - (i32.const 3) - ) - (br_if $loop - (i32.const 4) - ) - ) - (local.get $x) - ) - (func $copies-no - (local $x i32) - (local $y i32) - (local $z i32) - (local $a i32) - (local $b i32) - (local $c i32) - (loop $loop - (local.set $x - (local.get $x) - ) - (local.set $y - (local.get $z) - ) - (local.set $a - (local.tee $b - (local.get $c) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $consts-no - (local $x i32) - (local $a i32) - (local $b i32) - (loop $loop - (local.set $x - (i32.const 0) - ) - (local.set $a - (local.tee $b - (i32.const 1) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $global - (local $x i32) - (local.set $x - (global.get $glob) - ) - (drop - (local.get $x) - ) - (loop $loop - (nop) - (nop) - (br_if $loop - (local.get $x) - ) - ) - ) -) diff --git a/test/passes/licm.wast b/test/passes/licm.wast deleted file mode 100644 index 6c5c747bd14..00000000000 --- a/test/passes/licm.wast +++ /dev/null @@ -1,401 +0,0 @@ -(module - (memory 1) - (global $glob (mut i32) (i32.const 1)) - (func $loop1 - (loop $loop - (drop (i32.const 10)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop2 - (loop $loop - (drop (i32.const 10)) - (drop (i32.const 20)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop3 - (loop $loop - (drop (i32.const 10)) - (call $loop2) - (drop (i32.const 20)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop4 - (loop $loop - (drop (i32.load (i32.const 1))) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop3-4 - (loop $loop - (drop (i32.load (i32.const 10))) - (call $loop2) ;; may have global side effects which alter a load! - (drop (i32.load (i32.const 20))) ;; this load must stay put - (br_if $loop (i32.const 1)) - ) - ) - (func $loop3-4-b (; 4 ;) - (loop $loop - (drop - (i32.load - (i32.const 10) - ) - ) - (drop - (i32.load - (i32.const 20) - ) - ) - (br_if $loop - (i32.const 1) - ) - ) - ) - (func $loop5 - (loop $loop - (i32.store (i32.const 1) (i32.const 2)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop6 - (loop $loop - (i32.store (i32.const 1) (i32.const 2)) - (i32.store (i32.const 2) (i32.const 3)) - ) - ) - (func $loop7 - (loop $loop - (i32.store (i32.const 1) (i32.const 2)) - (i32.store (i32.const 2) (i32.const 3)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop8 - (loop $loop - (i32.store (i32.const 1) (i32.const 2)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop9 - (loop $loop - (drop (i32.load (i32.const 1))) - (i32.store (i32.const 1) (i32.const 2)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop10 - (loop $loop - (drop (i32.load (i32.const 1))) - (drop (i32.load (i32.const 2))) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop11 - (local $x i32) - (local $y i32) - (loop $loop - (drop (local.get $x)) - (br_if $loop (local.tee $x (i32.const 2))) - ) - ) - (func $loop12 - (local $x i32) - (local $y i32) - (loop $loop - (drop (local.get $x)) - (br_if $loop (local.tee $y (i32.const 2))) - ) - ) - (func $loop13 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop14 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (br_if $loop (i32.const 1)) - (local.set $y (local.get $x)) ;; not actually in the loop! - ) - ) - (func $loop14-1 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (local.set $y (local.get $x)) ;; in the loop - (br_if $loop (i32.const 1)) - ) - ) - (func $loop15 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (br_if $loop (i32.const 1)) - (drop (local.get $y)) - ) - ) - (func $loop15-1 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (drop (local.get $y)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop16 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (br_if $loop (i32.const 1)) - (drop (local.get $x)) - ) - ) - (func $loop16-1 - (local $x i32) - (local $y i32) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (drop (local.get $x)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop16-2 - (local $x i32) - (local $y i32) - (local.set $x (i32.const 2)) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (drop (local.get $x)) - (br_if $loop (i32.const 1)) - ) - ) - (func $loop16-3 - (local $x i32) - (local $y i32) - (local.set $y (i32.const 2)) - (loop $loop - (local.set $x (i32.eqz (local.get $y))) - (call $loop12) - (drop (local.get $x)) - (br_if $loop (i32.const 1)) - ) - ) - (func $nop - (loop $loop - (nop) - (br_if $loop (i32.const 1)) - ) - ) - (func $nested-blocks - (loop $loop - (block - (nop) - ) - (block $x - (nop) - ) - (block $a - (block $b - (block $c - (nop) - ) - ) - ) - (br_if $loop (i32.const 1)) - ) - ) - (func $nested-unhoistable-blocks - (loop $loop - (block - (call $nested-unhoistable-blocks) - ) - (block $x - (call $nested-unhoistable-blocks) - ) - (block $a - (block $b - (block $c - (call $nested-unhoistable-blocks) - ) - ) - ) - (br_if $loop (i32.const 1)) - ) - ) - (func $conditional - (loop $loop - (if (i32.const 0) - (drop (i32.const 10)) ;; cannot be hoisted - might never be reached - ) - (br_if $loop (i32.const 1)) - ) - ) - (func $conditional1 (result i32) - (loop $loop - (if (call $conditional1) - (drop (i32.const 10)) ;; cannot be hoisted - might never be reached - ;; also anyhow the whole if also cannot, due to the call - ) - (br_if $loop (i32.const 1)) - ) - (unreachable) - ) - (func $conditional2 - (block $out - (loop $loop - (br_if $out (i32.const 1)) - (drop (i32.const 10)) ;; cannot be hoisted - might never be reached - (br_if $loop (i32.const 1)) - ) - ) - ) - (func $conditional3 - (block $out - (loop $loop - (drop (i32.const 10)) ;; *CAN* be hoisted - will definitely be reached - (br_if $out (i32.const 1)) - (br_if $loop (i32.const 1)) - ) - ) - ) - (func $after - (loop $loop) - (drop (i32.const 10)) ;; may be part of the loop's basic block, logically, but is not nested in it - ) - (func $loops - (loop $loop2 - (loop $loop1 - (drop (i32.const 10)) - (br_if $loop1 (i32.const 1)) - ) - ) - ) - (func $loops2 - (loop $loop2 - (loop $loop1 - (drop (i32.const 10)) - (br_if $loop2 (i32.const 1)) - ) - ) - ) - (func $fuzz1 (result i64) - (local $var$1 i64) - (loop $label$1 (result i64) ;; multiple loops here require us to be careful not to Nop out stuff before we finalize things - (block $label$2 - (block $label$3 - (drop - (loop $label$4 (result i32) - (local.set $var$1 - (block $label$5 (result i64) - (local.set $var$1 - (i64.const -29585) - ) - (i64.const -70) - ) - ) - (i32.const 1) - ) - ) - (br $label$2) - ) - (unreachable) - ) - (local.get $var$1) - ) - ) - (func $self (result i32) - (local $x i32) - (loop $loop - (local.set $x (i32.add (local.get $x) (i32.const 1))) - (br_if $loop (i32.const 1)) - ) - (local.get $x) - ) - (func $nested-set - (local $var$0 i32) - (local $var$1 i64) - (loop $label$1 - (local.set $var$0 - (block $label$3 (result i32) - (local.set $var$1 ;; cannot be moved out (in current position - other opts would help), and invalidates moving out the set below - (i64.const 0) - ) - (local.get $var$0) - ) - ) - (local.set $var$1 - (i64.const 1) - ) - (br_if $label$1 - (i32.const 0) - ) - ) - ) - (func $load-store (param $x i32) - (loop $loop - (drop (i32.load (i32.const 0))) ;; can't move this out, the store might affect it for later iterations - (i32.store (local.get $x) (local.get $x)) - (br_if $loop (i32.const 1)) - ) - ) - (func $set-set (param $x i32) (result i32) - (loop $loop - (local.set $x (i32.const 1)) - (br_if $loop (i32.const 2)) - (local.set $x (i32.const 3)) - (br_if $loop (i32.const 4)) - ) - (local.get $x) - ) - (func $copies-no - (local $x i32) - (local $y i32) - (local $z i32) - (local $a i32) - (local $b i32) - (local $c i32) - (loop $loop - (local.set $x (local.get $x)) - (local.set $y (local.get $z)) - (local.set $a (local.tee $b (local.get $c))) - (br_if $loop (i32.const 1)) - ) - ) - (func $consts-no - (local $x i32) - (local $a i32) - (local $b i32) - (loop $loop - (local.set $x (i32.const 0)) - (local.set $a (local.tee $b (i32.const 1))) - (br_if $loop (i32.const 1)) - ) - ) - (func $global - (local $x i32) - (loop $loop - (local.set $x (global.get $glob)) - (drop (local.get $x)) - (br_if $loop (local.get $x)) - ) - ) -) diff --git a/test/passes/log-execution.txt b/test/passes/log-execution.txt deleted file mode 100644 index 29fa9943072..00000000000 --- a/test/passes/log-execution.txt +++ /dev/null @@ -1,98 +0,0 @@ -(module - (type $none_=>_none (func)) - (type $none_=>_i32 (func (result i32))) - (type $i32_=>_none (func (param i32))) - (import "env" "func" (func $import)) - (import "env" "log_execution" (func $log_execution (param i32))) - (func $nopp - (call $log_execution - (i32.const 0) - ) - (nop) - ) - (func $intt (result i32) - (call $log_execution - (i32.const 1) - ) - (i32.const 10) - ) - (func $workk - (call $log_execution - (i32.const 3) - ) - (block - (if - (i32.const 0) - (nop) - ) - (block - (call $log_execution - (i32.const 2) - ) - (drop - (i32.const 1) - ) - ) - ) - ) - (func $loops - (call $log_execution - (i32.const 8) - ) - (block - (loop $x - (call $log_execution - (i32.const 4) - ) - (block - (call $loops) - (br $x) - ) - ) - (if - (call $intt) - (loop $y - (call $log_execution - (i32.const 5) - ) - (call $loops) - ) - ) - (block - (call $log_execution - (i32.const 7) - ) - (loop $loop-in - (call $log_execution - (i32.const 6) - ) - (block - (drop - (i32.const 10) - ) - (drop - (i32.const 20) - ) - (drop - (i32.const 30) - ) - ) - ) - ) - ) - ) - (func $loops-similar - (call $log_execution - (i32.const 10) - ) - (loop $x - (call $log_execution - (i32.const 9) - ) - (block - (call $loops) - (br $x) - ) - ) - ) -) diff --git a/test/passes/log-execution.wast b/test/passes/log-execution.wast deleted file mode 100644 index f7448408aea..00000000000 --- a/test/passes/log-execution.wast +++ /dev/null @@ -1,36 +0,0 @@ -(module - (import "env" "func" (func $import)) - (func $nopp - (nop) - ) - (func $intt (result i32) - (i32.const 10) - ) - (func $workk - (if (i32.const 0) (nop)) - (drop (i32.const 1)) - ) - (func $loops - (loop $x - (call $loops) - (br $x) - ) - (if (call $intt) - (loop $y - (call $loops) - ) - ) - (loop - (drop (i32.const 10)) - (drop (i32.const 20)) - (drop (i32.const 30)) - ) - ) - (func $loops-similar - (loop $x - (call $loops) - (br $x) - ) - ) -) -