From 6f255d3bea628bd8d2ae2e43d29faeac6dbd7daf Mon Sep 17 00:00:00 2001 From: Max Graey Date: Wed, 14 Oct 2020 20:14:57 +0300 Subject: Improve partial evaluation (#3236) --- src/passes/OptimizeInstructions.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/passes/OptimizeInstructions.cpp') diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 85ab2a168..1790623eb 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -515,12 +515,21 @@ struct OptimizeInstructions if (auto* left = binary->left->dynCast()) { if (left->op == binary->op) { if (auto* leftRight = left->right->dynCast()) { - if (left->op == AndInt32) { + if (left->op == AndInt32 || left->op == AndInt64) { leftRight->value = leftRight->value.and_(right->value); return left; - } else if (left->op == OrInt32) { + } else if (left->op == OrInt32 || left->op == OrInt64) { leftRight->value = leftRight->value.or_(right->value); return left; + } else if (left->op == XorInt32 || left->op == XorInt64) { + leftRight->value = leftRight->value.xor_(right->value); + return left; + } else if (left->op == MulInt32 || left->op == MulInt64) { + leftRight->value = leftRight->value.mul(right->value); + return left; + + // TODO: + // handle signed / unsigned divisions. They are more complex } else if (left->op == ShlInt32 || left->op == ShrUInt32 || left->op == ShrSInt32 || left->op == ShlInt64 || left->op == ShrUInt64 || left->op == ShrSInt64) { -- cgit v1.2.3