From 245d63551b520078feb76167fa58444821ae0c22 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 20 Oct 2016 12:09:19 -0700 Subject: Optimize to i64.store[less] (#792) --- src/passes/OptimizeInstructions.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') 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 WalkerPassdynCast()) { // stores of fewer bits truncates anyhow - if (auto* value = store->value->dynCast()) { - if (value->op == AndInt32) { - if (auto* right = value->right->dynCast()) { + if (auto* binary = store->value->dynCast()) { + if (binary->op == AndInt32) { + if (auto* right = binary->right->dynCast()) { 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()) { + 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; -- cgit v1.2.3