diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h index 606a56c7fd55b5..a7222794f320b2 100644 --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -749,7 +749,8 @@ class AsmParser { // zero for non-negated integers. result = (IntT)uintResult.sextOrTrunc(sizeof(IntT) * CHAR_BIT).getLimitedValue(); - if (APInt(uintResult.getBitWidth(), result, /*isSigned=*/true, + if (APInt(uintResult.getBitWidth(), result, + /*isSigned=*/std::is_signed_v, /*implicitTrunc=*/true) != uintResult) return emitError(loc, "integer value too large"); return success(); diff --git a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir index 160c388cedf756..f0d1571d583877 100644 --- a/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir +++ b/mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir @@ -23,10 +23,10 @@ attributes { attr7 = #test.custom_anchor<5>, // CHECK: #test.custom_anchor<5, true> attr8 = #test.custom_anchor<5, true>, - // CHECK: #test.attr_with_optional_signed<-12> - attr9 = #test.attr_with_optional_signed<-12>, - // CHECK: #test.attr_with_optional_unsigned<22> - attr_10 = #test.attr_with_optional_unsigned<22> + // CHECK: #test.attr_with_optional_signed<-9223372036854775808> + attr9 = #test.attr_with_optional_signed<-9223372036854775808>, + // CHECK: #test.attr_with_optional_unsigned<18446744073709551615> + attr_10 = #test.attr_with_optional_unsigned<18446744073709551615> } // CHECK-LABEL: @test_roundtrip_default_parsers_struct