summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/passes/OptimizeInstructions.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp
index ef18ea777..561e7882c 100644
--- a/src/passes/OptimizeInstructions.cpp
+++ b/src/passes/OptimizeInstructions.cpp
@@ -468,6 +468,13 @@ struct OptimizeInstructions : public WalkerPass<PostWalker<OptimizeInstructions,
default: {}
}
}
+ // eqz of a sign extension can be of zero-extension
+ if (auto* ext = getSignExt(unary->value)) {
+ // we are comparing a sign extend to a constant, which means we can use a cheaper zext
+ auto bits = getSignExtBits(unary->value);
+ unary->value = makeZeroExt(ext, bits);
+ return unary;
+ }
}
} else if (auto* set = curr->dynCast<SetGlobal>()) {
// optimize out a set of a get