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 @@ -353,7 +353,8 @@ // Verify that all of the indices are within the shape dimensions. auto shape = type.getShape(); return llvm::all_of(llvm::seq(0, rank), [&](int i) { - return static_cast(index[i]) < shape[i]; + int64_t dim = static_cast(index[i]); + return 0 <= dim && dim < shape[i]; }); }