diff options
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 4 | ||||
-rw-r--r-- | test/passes/O1.wast | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 7d4735686..c098d0ed7 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -825,11 +825,11 @@ private: // find added constants in an expression tree, including multiplied/shifted, and combine them // note that we ignore division/shift-right, as rounding makes this nonlinear, so not a valid opt Expression* optimizeAddedConstants(Binary* binary) { - int32_t constant = 0; + uint32_t constant = 0; std::vector<Const*> constants; std::function<void (Expression*, int)> seek = [&](Expression* curr, int mul) { if (auto* c = curr->dynCast<Const>()) { - auto value = c->value.geti32(); + uint32_t value = c->value.geti32(); if (value != 0) { constant += value * mul; constants.push_back(c); diff --git a/test/passes/O1.wast b/test/passes/O1.wast index 87b06b063..6c1f3abda 100644 --- a/test/passes/O1.wast +++ b/test/passes/O1.wast @@ -14,6 +14,12 @@ ) ) ) + (func $signed-overflow (param $0 f32) (result i32) + (i32.sub + (i32.const 268435456) + (i32.const -2147483648) + ) + ) ) |