summaryrefslogtreecommitdiff
path: root/src/passes/OptimizeInstructions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/OptimizeInstructions.cpp')
-rw-r--r--src/passes/OptimizeInstructions.cpp13
1 files changed, 11 insertions, 2 deletions
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<Binary>()) {
if (left->op == binary->op) {
if (auto* leftRight = left->right->dynCast<Const>()) {
- 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) {