summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-10-20 12:09:19 -0700
committerGitHub <noreply@github.com>2016-10-20 12:09:19 -0700
commit245d63551b520078feb76167fa58444821ae0c22 (patch)
treedf5754710392f6ca1db439b5be7434c24ffbb5a1 /src/passes/OptimizeInstructions.cpp
parentd887023271985fcf2caa91067e636a0697849589 (diff)
downloadbinaryen-245d63551b520078feb76167fa58444821ae0c22.tar.gz
binaryen-245d63551b520078feb76167fa58444821ae0c22.tar.bz2
binaryen-245d63551b520078feb76167fa58444821ae0c22.zip
Optimize to i64.store[less] (#792)
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index 0b54f9756..7f1483371 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -314,18 +314,24 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
}
} else if (auto* store = curr->dynCast<Store>()) {
// stores of fewer bits truncates anyhow
- if (auto* value = store->value->dynCast<Binary>()) {
- if (value->op == AndInt32) {
- if (auto* right = value->right->dynCast<Const>()) {
+ if (auto* binary = store->value->dynCast<Binary>()) {
+ if (binary->op == AndInt32) {
+ if (auto* right = binary->right->dynCast<Const>()) {
if (right->type == i32) {
auto mask = right->value.geti32();
if ((store->bytes == 1 && mask == 0xff) ||
(store->bytes == 2 && mask == 0xffff)) {
- store->value = value->left;
+ store->value = binary->left;
}
}
}
}
+ } else if (auto* unary = store->value->dynCast<Unary>()) {
+ if (unary->op == WrapInt64) {
+ // instead of wrapping to 32, just store some of the bits in the i64
+ store->valueType = i64;
+ store->value = unary->value;
+ }
}
}
return nullptr;