From 68b57f6c015af1eaf95b039b0bc2bc3b9efbab4e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Tue, 5 Sep 2017 11:33:22 -0700 Subject: when if arms are identical, merging them may change the type of the if, if it has a forced type --- test/passes/optimize-instructions.txt | 34 ++++++++++++++++++++++++++++++++++ test/passes/optimize-instructions.wast | 21 +++++++++++++++++++++ 2 files changed, 55 insertions(+) (limited to 'test') diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index 6a99ee106..aae0724a0 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -1913,6 +1913,40 @@ ) ) ) + (drop + (block (result i32) + (i32.add + (get_local $1) + (unreachable) + ) + ) + ) + (drop + (block (result i32) + (drop + (tee_local $0 + (get_local $1) + ) + ) + (i32.add + (get_local $1) + (unreachable) + ) + ) + ) + (drop + (if (result i32) + (unreachable) + (i32.add + (get_local $1) + (unreachable) + ) + (i32.add + (get_local $1) + (unreachable) + ) + ) + ) ) (func $select-parallel (type $4) (param $0 i32) (param $1 i32) (drop diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index c26aad196..f84be8330 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -2321,6 +2321,27 @@ (i32.add (get_local $1) (i32.const 1)) ) ) + (drop + (if (result i32) + (get_local $0) + (i32.add (get_local $1) (unreachable)) ;; folding them would change the type of the if + (i32.add (get_local $1) (unreachable)) + ) + ) + (drop + (if (result i32) + (tee_local $0 (get_local $1)) ;; side effects! + (i32.add (get_local $1) (unreachable)) ;; folding them would change the type of the if + (i32.add (get_local $1) (unreachable)) + ) + ) + (drop + (if (result i32) + (unreachable) ;; !!! + (i32.add (get_local $1) (unreachable)) ;; folding them would change the type of the if + (i32.add (get_local $1) (unreachable)) + ) + ) ) (func $select-parallel (param $0 i32) (param $1 i32) (drop -- cgit v1.2.3