summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/lit/passes/optimize-stack-ir.wast1401
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.txt1585
-rw-r--r--test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.wast712
3 files changed, 1401 insertions, 2297 deletions
diff --git a/test/lit/passes/optimize-stack-ir.wast b/test/lit/passes/optimize-stack-ir.wast
new file mode 100644
index 000000000..12981df9a
--- /dev/null
+++ b/test/lit/passes/optimize-stack-ir.wast
@@ -0,0 +1,1401 @@
+;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.
+
+;; RUN: wasm-opt %s -all --optimize-level=3 --generate-stack-ir --optimize-stack-ir --print-stack-ir | filecheck %s
+
+(module
+ ;; CHECK: (type $FUNCSIG$v (func))
+ (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)))
+ ;; 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 (type $FUNCSIG$v)))
+ (import "env" "_emscripten_asm_const_vi" (func $_emscripten_asm_const_vi))
+
+ ;; CHECK: (import "asm2wasm" "f64-to-int" (func $f64-to-int (type $FUNCSIG$id) (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 (type $FUNCSIG$ddd) (param f64 f64) (result f64)))
+ (import "asm2wasm" "f64-rem" (func $f64-rem (param f64 f64) (result f64)))
+
+ ;; CHECK: (memory $mem 4096 4096)
+
+ ;; CHECK: (data $data (i32.const 1026) "\14\00")
+
+ ;; CHECK: (table $table 10 funcref)
+ (table $table 10 funcref)
+
+ ;; CHECK: (elem $elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+ (elem $elem (i32.const 0) $z $big_negative $z $z $w $w $importedDoubles $w $z $cneg)
+
+ (memory $mem 4096 4096)
+
+ (data $data (i32.const 1026) "\14\00")
+
+ ;; CHECK: (export "big_negative" (func $big_negative))
+ (export "big_negative" (func $big_negative))
+
+ ;; CHECK: (func $big_negative (type $FUNCSIG$v)
+ ;; 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 (type $4) (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 (type $FUNCSIG$ddd) (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 (type $5) (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 (type $FUNCSIG$v)
+ ;; 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 (type $FUNCSIG$v)
+ ;; 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 (type $FUNCSIG$v)
+ ;; 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 (type $6) (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: 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: 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: 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 (type $FUNCSIG$v)
+ ;; 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 (type $4) (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 (type $5) (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 (type $FUNCSIG$vf) (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 (type $4) (result f64)
+ ;; CHECK-NEXT: f64.const -0
+ ;; CHECK-NEXT: )
+ (func $negZero (type $4) (result f64)
+ (f64.const -0)
+ )
+
+ ;; CHECK: (func $abs (type $FUNCSIG$v)
+ ;; 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 (type $FUNCSIG$v)
+ ;; 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 $table (type $FUNCSIG$vf)
+ ;; 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 (type $FUNCSIG$vf) (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 $table (type $FUNCSIG$vf)
+ ;; 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 (type $FUNCSIG$v)
+ ;; 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 (type $FUNCSIG$v)
+ ;; CHECK-NEXT: )
+ (func $z (type $FUNCSIG$v)
+ (nop)
+ )
+
+ ;; CHECK: (func $w (type $FUNCSIG$v)
+ ;; CHECK-NEXT: )
+ (func $w (type $FUNCSIG$v)
+ (nop)
+ )
+
+ ;; CHECK: (func $block_and_after (type $5) (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 (type $7) (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 (type $8) (result i64)
+ ;; CHECK-NEXT: i64.const -9218868437227405313
+ ;; CHECK-NEXT: )
+ (func $big-i64 (type $8) (result i64)
+ (i64.const -9218868437227405313)
+ )
+
+ ;; CHECK: (func $i64-store32 (type $9) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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 (type $5) (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-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 (type $5) (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 (type $5) (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-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 (type $5) (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 (type $FUNCSIG$v)
+ ;; 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 (type $FUNCSIG$v)
+ ;; CHECK-NEXT: i32.const 1
+ ;; CHECK-NEXT: if
+ ;; 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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $6) (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 (type $FUNCSIG$v)
+ ;; 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: 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 (type $FUNCSIG$v)
+ ;; 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 (type $6) (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/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 3c9e27d6c..000000000
--- a/test/passes/generate-stack-ir_optimize-stack-ir_print-stack-ir_optimize-level=3.txt
+++ /dev/null
@@ -1,1585 +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 $0 (i32.const 1026) "\14\00")
- (table $0 10 funcref)
- (elem $0 (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
- 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
- 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
- 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 (type $FUNCSIG$vf)
- )
- (func $cneg (param $x f32)
- local.get $x
- i32.const 1
- i32.const 7
- i32.and
- i32.const 8
- i32.add
- call_indirect (type $FUNCSIG$vf)
- )
- (func $___syscall_ret
- (local $$0 i32)
- local.get $$0
- i32.const 0
- i32.shr_u
- i32.const -4096
- i32.gt_u
- drop
- )
- (func $z
- )
- (func $w
- )
- (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
- 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
- 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
- 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
- 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 $0 (i32.const 1026) "\14\00")
- (table $0 10 funcref)
- (elem $0 (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
- (drop
- (i32.const 1)
- )
- (return
- (i32.const 2)
- )
- )
- )
- )
- (func $unreachable-block-toplevel (; has Stack IR ;) (result i32)
- (drop
- (i32.const 1)
- )
- (return
- (i32.const 2)
- )
- )
- (func $unreachable-block0 (; has Stack IR ;) (result i32)
- (f64.abs
- (block
- (return
- (i32.const 2)
- )
- )
- )
- )
- (func $unreachable-block0-toplevel (; has Stack IR ;) (result i32)
- (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)
- (nop)
- (block
- (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
- (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 (; has Stack IR ;) (param $x i32) (result i32)
- (local $temp i32)
- (i32.add
- (call $remove-block
- (i32.const 0)
- )
- (i32.eqz
- (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 3fa184124..000000000
--- 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)
- )
- )
- )
- )
-)