From 45d88e3ef5f895b2fde77e3588f84d66e67bdd88 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 2 Oct 2017 11:12:50 -0700 Subject: fix optimize-instructions handling of shifts by a zero or of a zero when combining added constants (#1206) --- src/passes/OptimizeInstructions.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3