Skip to content

Commit 6c949aa

Browse files
committed
fix: don't assert when calculating log2 of non-power-of-two number, fail instead.
1 parent 17f7259 commit 6c949aa

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mlir/lib/Dialect/PDL/IR/Builtins.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ LogicalResult static unaryOp(PatternRewriter &rewriter, PDLResultList &results,
8787
} else if constexpr (T == UnaryOpKind::log2) {
8888
auto getIntegerAsAttr = [&](const APSInt &value) {
8989
int32_t log2Value = value.exactLogBase2();
90-
assert(log2Value >= 0 &&
91-
"log2 of an integer is expected to return an exact integer.");
90+
if (log2Value < 0)
91+
return failure();
9292
return rewriter.getIntegerAttr(
9393
integerType,
9494
APSInt(APInt(bitWidth, log2Value), integerType.isUnsigned()));

0 commit comments

Comments
 (0)