diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp index aa5eb95a3d22ed..641b7d7e2d13be 100644 --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -1739,6 +1739,8 @@ OpFoldResult arith::BitcastOp::fold(FoldAdaptor adaptor) { APInt bits = llvm::isa(operand) ? llvm::cast(operand).getValue().bitcastToAPInt() : llvm::cast(operand).getValue(); + assert(resType.getIntOrFloatBitWidth() == bits.getBitWidth() && + "trying to fold on broken IR: operands have incompatible types"); if (auto resFloatType = llvm::dyn_cast(resType)) return FloatAttr::get(resType,