Skip to content

Commit cf16733

Browse files
committed
opt for #7455
1 parent c528c7e commit cf16733

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/passes/OptimizeInstructions.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,19 @@ 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+
}
2939+
}
29272940
}
29282941
if (auto* ext = Properties::getSignExtValue(binary)) {
29292942
// use a cheaper zero-extent, we just care about the boolean value

0 commit comments

Comments
 (0)