Skip to content

Commit eb7e236

Browse files
committed
generalize existing rule
1 parent cf16733 commit eb7e236

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

src/passes/OptimizeInstructions.cpp

+11-12
Original file line numberDiff line numberDiff line change
@@ -2924,18 +2924,17 @@ struct OptimizeInstructions
29242924
return binary;
29252925
}
29262926
}
2927-
} else if (binary->op == LtUInt32) {
2928-
auto value = Properties::getFallthrough(
2929-
binary->right, getPassOptions(), *getModule());
2930-
if (Properties::isConstantExpression(value)) {
2931-
if (Properties::getLiteral(value).isZero()) {
2932-
// Hoist potential zero to be good for constant propagation
2933-
// in case of being blocked by side effect.
2934-
// (unsigned)x < 0 ==> i32(0)
2935-
Builder builder(*getModule());
2936-
return getDroppedChildrenAndAppend(
2937-
binary, LiteralUtils::makeZero(Type::i32, *getModule()));
2938-
}
2927+
}
2928+
if (auto* block = binary->right->dynCast<Block>()) {
2929+
auto fallthrough =
2930+
Properties::getFallthrough(block, getPassOptions(), *getModule());
2931+
if (auto* c = fallthrough->dynCast<Const>()) {
2932+
Builder builder(*getModule());
2933+
auto ret = getDroppedChildrenAndAppend(
2934+
binary,
2935+
LiteralUtils::makeFromInt32(
2936+
c->value.geti32(), Type::i32, *getModule()));
2937+
return ret;
29392938
}
29402939
}
29412940
if (auto* ext = Properties::getSignExtValue(binary)) {

0 commit comments

Comments
 (0)