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 /src/ast/bits.h | |
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 'src/ast/bits.h')
-rw-r--r-- | src/ast/bits.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/ast/bits.h b/src/ast/bits.h index c7d2ea4f0..11cf7b06d 100644 --- a/src/ast/bits.h +++ b/src/ast/bits.h @@ -42,11 +42,20 @@ struct Bits { // gets the number of effective shifts a shift operation does. In // wasm, only 5 bits matter for 32-bit shifts, and 6 for 64. - static uint32_t getEffectiveShifts(Const* amount) { + static Index getEffectiveShifts(Index amount, WasmType type) { + if (type == i32) { + return amount & 31; + } else if (type == i64) { + return amount & 63; + } + WASM_UNREACHABLE(); + } + + static Index getEffectiveShifts(Const* amount) { if (amount->type == i32) { - return amount->value.geti32() & 31; + return getEffectiveShifts(amount->value.geti32(), i32); } else if (amount->type == i64) { - return amount->value.geti64() & 63; + return getEffectiveShifts(amount->value.geti64(), i64); } WASM_UNREACHABLE(); } |