diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -1205,9 +1205,15 @@ return op.emitOpError() << "requires attribute's type (" << value.getType() << ") to match op's return type (" << type << ")"; - if (type.isa() || value.isa()) + if (value.isa()) return success(); + if (type.isa()) { + if (!value.isa()) + return op.emitOpError("requires 'value' to be an integer constant"); + return success(); + } + if (auto intAttr = value.dyn_cast()) { IntegerType intType = type.cast(); if (!intType.isSignless())