Skip to content

Commit 7900daa

Browse files
committed
[MLIR] Fix parseInteger(uint64_t) for large values
This is a regression from e692af8
1 parent ab902ee commit 7900daa

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mlir/include/mlir/IR/OpImplementation.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ class AsmParser {
749749
// zero for non-negated integers.
750750
result =
751751
(IntT)uintResult.sextOrTrunc(sizeof(IntT) * CHAR_BIT).getLimitedValue();
752-
if (APInt(uintResult.getBitWidth(), result, /*isSigned=*/true,
752+
if (APInt(uintResult.getBitWidth(), result,
753+
/*isSigned=*/std::is_signed_v<IntT>,
753754
/*implicitTrunc=*/true) != uintResult)
754755
return emitError(loc, "integer value too large");
755756
return success();

mlir/test/mlir-tblgen/attr-or-type-format-roundtrip.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ attributes {
2323
attr7 = #test.custom_anchor<5>,
2424
// CHECK: #test.custom_anchor<5, true>
2525
attr8 = #test.custom_anchor<5, true>,
26-
// CHECK: #test.attr_with_optional_signed<-12>
27-
attr9 = #test.attr_with_optional_signed<-12>,
28-
// CHECK: #test.attr_with_optional_unsigned<22>
29-
attr_10 = #test.attr_with_optional_unsigned<22>
26+
// CHECK: #test.attr_with_optional_signed<-9223372036854775808>
27+
attr9 = #test.attr_with_optional_signed<-9223372036854775808>,
28+
// CHECK: #test.attr_with_optional_unsigned<18446744073709551615>
29+
attr_10 = #test.attr_with_optional_unsigned<18446744073709551615>
3030
}
3131

3232
// CHECK-LABEL: @test_roundtrip_default_parsers_struct

0 commit comments

Comments
 (0)