From b85e8b51464d0ea1d76d08c2a1b53648e9b7ed9c Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 12 Jul 2017 11:16:04 -0700 Subject: zero shifts are not sign-extends --- src/ast/properties.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ast/properties.h b/src/ast/properties.h index 9121deba5..097f7a8f0 100644 --- a/src/ast/properties.h +++ b/src/ast/properties.h @@ -60,11 +60,13 @@ struct Properties { if (auto* outer = curr->dynCast()) { if (outer->op == ShrSInt32) { if (auto* outerConst = outer->right->dynCast()) { - if (auto* inner = outer->left->dynCast()) { - if (inner->op == ShlInt32) { - if (auto* innerConst = inner->right->dynCast()) { - if (outerConst->value == innerConst->value) { - return inner->left; + if (outerConst->value.geti32() != 0) { + if (auto* inner = outer->left->dynCast()) { + if (inner->op == ShlInt32) { + if (auto* innerConst = inner->right->dynCast()) { + if (outerConst->value == innerConst->value) { + return inner->left; + } } } } @@ -87,11 +89,13 @@ struct Properties { if (auto* outer = curr->dynCast()) { if (outer->op == ShrSInt32) { if (auto* outerConst = outer->right->dynCast()) { - if (auto* inner = outer->left->dynCast()) { - if (inner->op == ShlInt32) { - if (auto* innerConst = inner->right->dynCast()) { - if (outerConst->value.leU(innerConst->value).geti32()) { - return inner->left; + if (outerConst->value.geti32() != 0) { + if (auto* inner = outer->left->dynCast()) { + if (inner->op == ShlInt32) { + if (auto* innerConst = inner->right->dynCast()) { + if (outerConst->value.leU(innerConst->value).geti32()) { + return inner->left; + } } } } -- cgit v1.2.3