summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-10-02 11:12:50 -0700
committerGitHub <noreply@github.com>2017-10-02 11:12:50 -0700
commit45d88e3ef5f895b2fde77e3588f84d66e67bdd88 (patch)
treebd0a3f43cf79c8d70a03ecf558de756b3019221d /src
parent2ec15bea0c5b7d4112e06fadcc3a531f303d4a4c (diff)
downloadbinaryen-45d88e3ef5f895b2fde77e3588f84d66e67bdd88.tar.gz
binaryen-45d88e3ef5f895b2fde77e3588f84d66e67bdd88.tar.bz2
binaryen-45d88e3ef5f895b2fde77e3588f84d66e67bdd88.zip
fix optimize-instructions handling of shifts by a zero or of a zero when combining added constants (#1206)
Diffstat (limited to 'src')
-rw-r--r--src/passes/OptimizeInstructions.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index ad667f888..cdfa29138 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -862,8 +862,9 @@ private:
return;
}
} else if (curr->op == ShlInt32) {
- // shifting a 0 is a 0, unless the shift has side effects
- if (left && Bits::getEffectiveShifts(left) == 0 && !EffectAnalyzer(passOptions, curr->right).hasSideEffects()) {
+ // shifting a 0 is a 0, or anything by 0 has no effect, all unless the shift has side effects
+ if (((left && left->value.geti32() == 0) || (right && Bits::getEffectiveShifts(right) == 0)) &&
+ !EffectAnalyzer(passOptions, curr->right).hasSideEffects()) {
replaceCurrent(left);
return;
}