diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-30 11:07:51 -0700 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-30 11:07:51 -0700 |
commit | 6cdffee098cb891c7309eb372aea63c0baa7a2c5 (patch) | |
tree | dbab872c51cfec5bd482030199bccdf1f2c2dde9 /test/passes/optimize-instructions.wast | |
parent | 56e49752b4258b89660825f2970a7e55067d7122 (diff) | |
download | binaryen-6cdffee098cb891c7309eb372aea63c0baa7a2c5.tar.gz binaryen-6cdffee098cb891c7309eb372aea63c0baa7a2c5.tar.bz2 binaryen-6cdffee098cb891c7309eb372aea63c0baa7a2c5.zip |
fix optimizing two shifts into one; if the number of effective shifts overflows, it is not vali to just add them
Diffstat (limited to 'test/passes/optimize-instructions.wast')
-rw-r--r-- | test/passes/optimize-instructions.wast | 36 |
1 files changed, 36 insertions, 0 deletions
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 + ) + ) ) |