diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions.txt | 96 | ||||
-rw-r--r-- | test/passes/optimize-instructions.wast | 124 |
2 files changed, 217 insertions, 3 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index 41d45d57f..03edc6e4c 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -541,7 +541,16 @@ (get_local $0) (i32.const 255) ) - (i32.const 255) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $0) + (i32.const 255) + ) + (i32.const 107) ) ) (drop @@ -1103,7 +1112,25 @@ (get_local $0) (i32.const 255) ) - (i32.const 232) + (i32.const -2147483648) + ) + ) + (drop + (i32.ne + (i32.and + (get_local $0) + (i32.const 255) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.ne + (i32.and + (get_local $0) + (i32.const 255) + ) + (i32.const 107) ) ) (drop @@ -1790,4 +1817,69 @@ ) ) ) + (func $fuzz-comp-impossible (type $5) (param $x i32) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 65535) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const 127) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const -2147483648) + ) + ) + (drop + (i32.eq + (i32.and + (get_local $x) + (i32.const 255) + ) + (i32.const 252) + ) + ) + ) ) diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index 8ef6f67a5..eccbf1268 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -491,7 +491,19 @@ ) (i32.const 24) ) - (i32.const 32767) ;; non-zero and bigger than the mask + (i32.const 32767) ;; non-zero and bigger than the mask, with sign bit + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const -149) ;; non-zero and bigger than the mask, without sign bit ) ) ;; eq of two sign-ext, can both be a zext @@ -1370,6 +1382,30 @@ ) (i32.const 24) ) + (i32.const 64872) ;; no sign bit + ) + ) + (drop + (i32.ne + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const -149) ;; no sign bit, not all ones + ) + ) + (drop + (i32.ne + (i32.shr_s + (i32.shl + (get_local $0) + (i32.const 24) + ) + (i32.const 24) + ) (i32.const 111) ) ) @@ -2181,4 +2217,90 @@ ) ) ) + (func $fuzz-comp-impossible (param $x i32) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 16) + ) + (i32.const 16) + ) + (i32.const 65535) ;; impossible to be equal, the effective sign bit is set, but not the higher bits, which the sign-ext will set on the non-const value + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const 255) + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const 127) ;; safe + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const 128) ;; unsafe again + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const 4223) ;; more big bits, so sign bit though + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const 4224) ;; more big bits + ) + ) + (drop + (i32.eq + (i32.shr_s + (i32.shl + (get_local $x) + (i32.const 24) + ) + (i32.const 24) + ) + (i32.const -4) ;; safe even with more big bits, as they are all 1s + ) + ) + ) ) |