diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/optimize-instructions.txt | 39 | ||||
-rw-r--r-- | test/passes/optimize-instructions.wast | 36 |
2 files changed, 71 insertions, 4 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index f7948860c..e376d97d9 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -6,6 +6,7 @@ (type $4 (func (param i32 i32))) (type $5 (func (param i32))) (type $6 (func (param i32 i32) (result i32))) + (type $7 (func (param i64) (result i64))) (memory $0 0) (export "load-off-2" (func $load-off-2)) (func $f (type $0) (param $i1 i32) (param $i2 i64) @@ -734,7 +735,7 @@ (i32.shr_s (i32.shl (i32.const 32) - (i32.const 59) + (i32.const 27) ) (i32.const 24) ) @@ -1083,19 +1084,19 @@ (drop (i32.shl (get_local $0) - (i32.const 211) + (i32.const 19) ) ) (drop (i32.shr_s (get_local $0) - (i32.const 211) + (i32.const 19) ) ) (drop (i32.shr_u (get_local $0) - (i32.const 211) + (i32.const 19) ) ) (drop @@ -2024,4 +2025,34 @@ (i32.const 255) ) ) + (func $shifts-square-overflow (type $3) (param $x i32) (result i32) + (i32.shr_u + (i32.shr_u + (get_local $x) + (i32.const 65535) + ) + (i32.const 32767) + ) + ) + (func $shifts-square-no-overflow-small (type $3) (param $x i32) (result i32) + (i32.shr_u + (get_local $x) + (i32.const 9) + ) + ) + (func $shifts-square-overflow-64 (type $7) (param $x i64) (result i64) + (i64.shr_u + (i64.shr_u + (get_local $x) + (i64.const 65535) + ) + (i64.const 64767) + ) + ) + (func $shifts-square-no-overflow-small-64 (type $7) (param $x i64) (result i64) + (i64.shr_u + (get_local $x) + (i64.const 9) + ) + ) ) diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index 107451b87..7e07e8aee 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -2451,4 +2451,40 @@ (i32.const 255) ) ) + (func $shifts-square-overflow (param $x i32) (result i32) + (i32.shr_u + (i32.shr_u + (get_local $x) + (i32.const 65535) ;; 31 bits effectively + ) + (i32.const 32767) ;; also 31 bits, so two shifts that force the value into nothing for sure + ) + ) + (func $shifts-square-no-overflow-small (param $x i32) (result i32) + (i32.shr_u + (i32.shr_u + (get_local $x) + (i32.const 1031) ;; 7 bits effectively + ) + (i32.const 4098) ;; 2 bits effectively + ) + ) + (func $shifts-square-overflow-64 (param $x i64) (result i64) + (i64.shr_u + (i64.shr_u + (get_local $x) + (i64.const 65535) ;; 63 bits effectively + ) + (i64.const 64767) ;; also 63 bits, so two shifts that force the value into nothing for sure + ) + ) + (func $shifts-square-no-overflow-small-64 (param $x i64) (result i64) + (i64.shr_u + (i64.shr_u + (get_local $x) + (i64.const 1031) ;; 7 bits effectively + ) + (i64.const 4098) ;; 2 bits effectively + ) + ) ) |