;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited. ;; NOTE: This test was ported using port_passes_tests_to_lit.py and could be cleaned up. ;; RUN: foreach %s %t wasm-opt -O -S -o - | filecheck %s (module ;; CHECK: (type $0 (func (param i32) (result i32))) ;; CHECK: (type $1 (func (result i32))) ;; CHECK: (type $2 (func (param i64))) ;; CHECK: (export "ret" (func $ret)) ;; CHECK: (export "waka" (func $if-0-unreachable-to-none)) ;; CHECK: (export "many-selects" (func $many-selects)) ;; CHECK: (export "end-if-else" (func $end-if-else)) ;; CHECK: (export "end-if-else-call" (func $end-if-else-call)) ;; CHECK: (func $ret (; has Stack IR ;) (result i32) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (call $ret) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (call $ret) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (return ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.const 999) ;; CHECK-NEXT: ) (func $ret (export "ret") (result i32) (block $out (result i32) (drop (call $ret)) (if (call $ret) (then (return (return (i32.const 1) ) ) ) ) (drop (br_if $out (i32.const 999) (i32.const 1))) (unreachable) ) ) ;; CHECK: (func $if-0-unreachable-to-none (; has Stack IR ;) (param $0 i64) ;; CHECK-NEXT: (unreachable) ;; CHECK-NEXT: ) (func $if-0-unreachable-to-none (export "waka") (param $var$0 i64) (local $var$1 i64) (local $var$2 i64) (block $label$1 (if (i32.const 0) (then (br $label$1) ) (else (unreachable) ) ) ) ) ;; CHECK: (func $many-selects (; has Stack IR ;) (param $0 i32) (result i32) ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.const -1073741824) ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.const 1073741823) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.gt_s ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const 1073741823) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (i32.lt_s ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (i32.const -1073741824) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $many-selects (export "many-selects") (param $0 i32) (result i32) (if (i32.lt_s (local.get $0) (i32.const -1073741824) ) (then (local.set $0 (i32.const -1073741824) ) ) (else (if (i32.gt_s (local.get $0) (i32.const 1073741823) ) (then (local.set $0 (i32.const 1073741823) ) ) ) ) ) (local.get $0) ) ;; CHECK: (func $end-if-else (; has Stack IR ;) (param $0 i32) (result i32) ;; CHECK-NEXT: (select ;; CHECK-NEXT: (i32.const 1) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $end-if-else (export "end-if-else") (param $x i32) (result i32) (if (local.get $x) (then (local.set $x (i32.const 1) ) ) ) (local.get $x) ) ;; CHECK: (func $end-if-else-call (; has Stack IR ;) (param $0 i32) (result i32) ;; CHECK-NEXT: (if (result i32) ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (call $ret) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (else ;; CHECK-NEXT: (local.get $0) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $end-if-else-call (export "end-if-else-call") (param $x i32) (result i32) (if (local.get $x) (then (local.set $x (call $ret) ) ) ) (local.get $x) ) )