diff options
author | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-31 14:11:33 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2017-08-01 10:10:36 -0700 |
commit | 04418d5617f6ab7015c5cf7b905b4775a5219f4b (patch) | |
tree | 3b6b75b982702f7cabc777ae7fcc3f1a8dec2392 /src/ast/properties.h | |
parent | 5a07a930ad51003411b2bc827ea9bf08728ecc5a (diff) | |
download | binaryen-04418d5617f6ab7015c5cf7b905b4775a5219f4b.tar.gz binaryen-04418d5617f6ab7015c5cf7b905b4775a5219f4b.tar.bz2 binaryen-04418d5617f6ab7015c5cf7b905b4775a5219f4b.zip |
use effective shifts in more places in optimize-instructions
Diffstat (limited to 'src/ast/properties.h')
-rw-r--r-- | src/ast/properties.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ast/properties.h b/src/ast/properties.h index 097f7a8f0..8c8655c07 100644 --- a/src/ast/properties.h +++ b/src/ast/properties.h @@ -79,7 +79,7 @@ struct Properties { // gets the size of the sign-extended value static Index getSignExtBits(Expression* curr) { - return 32 - curr->cast<Binary>()->right->cast<Const>()->value.geti32(); + return 32 - Bits::getEffectiveShifts(curr->cast<Binary>()->right); } // Check if an expression is almost a sign-extend: perhaps the inner shift @@ -93,7 +93,7 @@ struct Properties { if (auto* inner = outer->left->dynCast<Binary>()) { if (inner->op == ShlInt32) { if (auto* innerConst = inner->right->dynCast<Const>()) { - if (outerConst->value.leU(innerConst->value).geti32()) { + if (Bits::getEffectiveShifts(outerConst) <= Bits::getEffectiveShifts(innerConst)) { return inner->left; } } @@ -109,8 +109,8 @@ struct Properties { // gets the size of the almost sign-extended value, as well as the // extra shifts, if any static Index getAlmostSignExtBits(Expression* curr, Index& extraShifts) { - extraShifts = curr->cast<Binary>()->left->cast<Binary>()->right->cast<Const>()->value.geti32() - - curr->cast<Binary>()->right->cast<Const>()->value.geti32(); + extraShifts = Bits::getEffectiveShifts(curr->cast<Binary>()->left->cast<Binary>()->right) - + Bits::getEffectiveShifts(curr->cast<Binary>()->right); return getSignExtBits(curr); } |