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.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index cbd8c9323..2e59775c0 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -982,6 +982,14 @@ private:
}
}
} else if (auto* binary = boolean->dynCast<Binary>()) {
+ if (binary->op == SubInt32) {
+ if (auto* num = binary->left->dynCast<Const>()) {
+ if (num->value.geti32() == 0) {
+ // bool(0 - x) ==> bool(x)
+ return binary->right;
+ }
+ }
+ }
if (binary->op == OrInt32) {
// an or flowing into a boolean context can consider each input as
// boolean