diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -435,8 +435,14 @@ << value.getBitWidth() << ")"; return success(); } - if (type.isa()) + if (type.isa()) { + if (value.getBitWidth() != IndexType::kInternalStorageBitWidth) + return emitError() + << "value bit width (" << value.getBitWidth() + << ") doesn't match index type internal storage bit width (" + << IndexType::kInternalStorageBitWidth << ")"; return success(); + } return emitError() << "expected integer or index type"; }