Skip to content

Commit 6fc95f2

Browse files
committed
Fix asserts in APInt contructor
1 parent 5238d8d commit 6fc95f2

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ LogicalResult static unaryOp(PatternRewriter &rewriter, PDLResultList &results,
6363
? std::pow(2, operandIntAttr.getValue().getZExtValue())
6464
: std::pow(2, operandIntAttr.getValue().getSExtValue());
6565

66-
APInt resultInt(bitWidth, resultVal, integerType.isSigned());
66+
APInt resultInt(bitWidth, resultVal, integerType.isSigned(),
67+
/*implicitTrunc*/ true);
6768

6869
bool isOverflow = integerType.isSigned()
6970
? resultInt.slt(operandIntAttr.getValue())

mlir/lib/Dialect/Tosa/Transforms/TosaFolders.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,11 @@ struct TosaFoldConstantMatMul
15401540

15411541
// Convert int64_t to the correct output type.
15421542
std::vector<APInt> apintValues;
1543-
llvm::transform(values, std::back_inserter(apintValues),
1544-
[&](const int64_t &val) {
1545-
APInt apIntVal(baseType.getIntOrFloatBitWidth(), val);
1543+
llvm::transform(
1544+
values, std::back_inserter(apintValues), [&](const int64_t &val) {
1545+
APInt apIntVal(baseType.getIntOrFloatBitWidth(), val,
1546+
/*isSigned=*/true); // tosa-mlir uses signless
1547+
// instead of signed
15461548
return apIntVal;
15471549
});
15481550
return DenseElementsAttr::get(outputType, apintValues);

0 commit comments

Comments
 (0)