Author: Max Graey
Date: 2025-05-13T22:34:42+08:00
New Revision: 8aaac80ddde6a23527d3caa98ec998ebe402e0d9

URL: 
https://github.com/llvm/llvm-project/commit/8aaac80ddde6a23527d3caa98ec998ebe402e0d9
DIFF: 
https://github.com/llvm/llvm-project/commit/8aaac80ddde6a23527d3caa98ec998ebe402e0d9.diff

LOG: [NFC] Use more isa and isa_and_nonnull instead dyn_cast for predicates 
(#137393)

Also fix some typos in comments

---------

Co-authored-by: Mehdi Amini <joker....@gmail.com>

Added: 
    

Modified: 
    clang/lib/Sema/SemaChecking.cpp
    clang/lib/Sema/SemaModule.cpp
    clang/lib/Sema/SemaOpenMP.cpp
    clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
    lld/MachO/SymbolTable.cpp
    llvm/include/llvm/Analysis/LoopInfo.h
    llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    llvm/lib/IR/Verifier.cpp
    llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
    mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
    mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
    mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
    mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp
    mlir/lib/Dialect/Affine/IR/AffineOps.cpp
    mlir/lib/Dialect/Arith/Utils/Utils.cpp
    mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
    mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
    mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
    mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
    mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
    mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
    mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
    mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
    mlir/lib/IR/Diagnostics.cpp
    mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5a0cec3d112db..59eb6d16f482c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10052,9 +10052,10 @@ void CheckFreeArgumentsAddressof(Sema &S, const 
std::string &CalleeName,
                                  const UnaryOperator *UnaryExpr) {
   if (const auto *Lvalue = dyn_cast<DeclRefExpr>(UnaryExpr->getSubExpr())) {
     const Decl *D = Lvalue->getDecl();
-    if (isa<DeclaratorDecl>(D))
-      if (!dyn_cast<DeclaratorDecl>(D)->getType()->isReferenceType())
+    if (auto *DD = dyn_cast<DeclaratorDecl>(D)) {
+      if (!DD->getType()->isReferenceType())
         return CheckFreeArgumentsOnLvalue(S, CalleeName, UnaryExpr, D);
+    }
   }
 
   if (const auto *Lvalue = dyn_cast<MemberExpr>(UnaryExpr->getSubExpr()))

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index bf1b76b52e1fc..6c4df0aa35af5 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -942,7 +942,7 @@ static bool checkExportedDecl(Sema &S, Decl *D, 
SourceLocation BlockStart) {
   // HLSL: export declaration is valid only on functions
   if (S.getLangOpts().HLSL) {
     // Export-within-export was already diagnosed in ActOnStartExportDecl
-    if (!dyn_cast<FunctionDecl>(D) && !dyn_cast<ExportDecl>(D)) {
+    if (!isa<FunctionDecl, ExportDecl>(D)) {
       S.Diag(D->getBeginLoc(), diag::err_hlsl_export_not_on_function);
       D->setInvalidDecl();
       return false;

diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index be6ce97d838f3..fcb556f8f2b9f 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -2307,7 +2307,7 @@ bool SemaOpenMP::isInOpenMPTargetExecutionDirective() 
const {
 
 bool SemaOpenMP::isOpenMPRebuildMemberExpr(ValueDecl *D) {
   // Only rebuild for Field.
-  if (!dyn_cast<FieldDecl>(D))
+  if (!isa<FieldDecl>(D))
     return false;
   DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA(
       D,

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
index a23f3aa356cb0..4fb47703e3984 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
@@ -356,7 +356,7 @@ class RawPtrRefLocalVarsChecker
     SmallString<100> Buf;
     llvm::raw_svector_ostream Os(Buf);
 
-    if (dyn_cast<ParmVarDecl>(V)) {
+    if (isa<ParmVarDecl>(V)) {
       Os << "Assignment to an " << ptrKind() << " parameter ";
       printQuotedQualifiedName(Os, V);
       Os << " is unsafe.";

diff  --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index ad48e909903b5..baddddcb76fbf 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -518,7 +518,7 @@ static const Symbol *getAlternativeSpelling(const Undefined 
&sym,
 
     // If in the symbol table and not undefined.
     if (const Symbol *s = symtab->find(newName))
-      if (dyn_cast<Undefined>(s) == nullptr)
+      if (!isa<Undefined>(s))
         return s;
 
     return nullptr;
@@ -567,8 +567,7 @@ static const Symbol *getAlternativeSpelling(const Undefined 
&sym,
     if (name.equals_insensitive(it.first))
       return it.second;
   for (Symbol *sym : symtab->getSymbols())
-    if (dyn_cast<Undefined>(sym) == nullptr &&
-        name.equals_insensitive(sym->getName()))
+    if (!isa<Undefined>(sym) && name.equals_insensitive(sym->getName()))
       return sym;
 
   // The reference may be a mangled name while the definition is not. Suggest a

diff  --git a/llvm/include/llvm/Analysis/LoopInfo.h 
b/llvm/include/llvm/Analysis/LoopInfo.h
index abc0bb8588fa8..814c61bf4c350 100644
--- a/llvm/include/llvm/Analysis/LoopInfo.h
+++ b/llvm/include/llvm/Analysis/LoopInfo.h
@@ -529,7 +529,7 @@ class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
   }
 
   // Return true if a new use of V added in ExitBB would require an LCSSA PHI
-  // to be inserted at the begining of the block.  Note that V is assumed to
+  // to be inserted at the beginning of the block.  Note that V is assumed to
   // dominate ExitBB, and ExitBB must be the exit block of some loop.  The
   // IR is assumed to be in LCSSA form before the planned insertion.
   bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V,

diff  --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp 
b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index 4879569200549..c724488b45d48 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -558,7 +558,7 @@ class MetadataLoader::MetadataLoaderImpl {
           SetVector<Metadata *> EntitiesToRemove;
           for (Metadata *Op : CU->getImportedEntities()->operands()) {
             auto *IE = cast<DIImportedEntity>(Op);
-            if (dyn_cast_or_null<DILocalScope>(IE->getScope())) {
+            if (isa_and_nonnull<DILocalScope>(IE->getScope())) {
               EntitiesToRemove.insert(IE);
             }
           }

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 2cfd3822ea05d..da6963a8d29e6 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6584,7 +6584,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, 
CallBase &Call) {
       for (BasicBlock *ColorFirstBB : CV)
         if (auto It = ColorFirstBB->getFirstNonPHIIt();
             It != ColorFirstBB->end())
-          if (dyn_cast_or_null<FuncletPadInst>(&*It))
+          if (isa_and_nonnull<FuncletPadInst>(&*It))
             InEHFunclet = true;
 
       // Check for funclet operand bundle

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp 
b/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
index 56fa8f9ce51ae..978e08bb89551 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetTransformInfo.cpp
@@ -294,7 +294,7 @@ bool WebAssemblyTTIImpl::isProfitableToSinkOperands(
 
   Value *V = I->getOperand(1);
   // We dont need to sink constant splat.
-  if (dyn_cast<Constant>(V))
+  if (isa<Constant>(V))
     return false;
 
   if (match(V, m_Shuffle(m_InsertElt(m_Value(), m_Value(), m_ZeroInt()),

diff  --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp 
b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
index ea251e4564ea8..57c8f4402cf4b 100644
--- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
@@ -755,7 +755,7 @@ LLVMTypeConverter::promoteOperands(Location loc, ValueRange 
opOperands,
     if (useBarePtrCallConv) {
       // For the bare-ptr calling convention, we only have to extract the
       // aligned pointer of a memref.
-      if (dyn_cast<MemRefType>(operand.getType())) {
+      if (isa<MemRefType>(operand.getType())) {
         MemRefDescriptor desc(llvmOperand);
         llvmOperand = desc.alignedPtr(builder, loc);
       } else if (isa<UnrankedMemRefType>(operand.getType())) {

diff  --git a/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp 
b/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
index df5396ac628cf..7f4655e53609e 100644
--- a/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
+++ b/mlir/lib/Conversion/MathToFuncs/MathToFuncs.cpp
@@ -586,7 +586,7 @@ static func::FuncOp createElementFPowIFunc(ModuleOp *module,
 LogicalResult
 FPowIOpLowering::matchAndRewrite(math::FPowIOp op,
                                  PatternRewriter &rewriter) const {
-  if (dyn_cast<VectorType>(op.getType()))
+  if (isa<VectorType>(op.getType()))
     return rewriter.notifyMatchFailure(op, "non-scalar operation");
 
   FunctionType funcType = getElementalFuncTypeForOp(op);
@@ -751,7 +751,7 @@ static func::FuncOp createCtlzFunc(ModuleOp *module, Type 
elementType) {
 /// operation.
 LogicalResult CtlzOpLowering::matchAndRewrite(math::CountLeadingZerosOp op,
                                               PatternRewriter &rewriter) const 
{
-  if (dyn_cast<VectorType>(op.getType()))
+  if (isa<VectorType>(op.getType()))
     return rewriter.notifyMatchFailure(op, "non-scalar operation");
 
   Type type = getElementTypeOrSelf(op.getResult().getType());

diff  --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp 
b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
index c8b2c0bdc6c20..158de6dea58c9 100644
--- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
+++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
@@ -890,7 +890,7 @@ struct RankOpLowering : public 
ConvertOpToLLVMPattern<memref::RankOp> {
                   ConversionPatternRewriter &rewriter) const override {
     Location loc = op.getLoc();
     Type operandType = op.getMemref().getType();
-    if (dyn_cast<UnrankedMemRefType>(operandType)) {
+    if (isa<UnrankedMemRefType>(operandType)) {
       UnrankedMemRefDescriptor desc(adaptor.getMemref());
       rewriter.replaceOp(op, {desc.rank(rewriter, loc)});
       return success();

diff  --git a/mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp 
b/mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp
index 4fe22eabcb584..96925dbf9f286 100644
--- a/mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp
+++ b/mlir/lib/Dialect/AMDGPU/Transforms/TransferReadToLoad.cpp
@@ -63,7 +63,7 @@ static LogicalResult transferPreconditions(
     return rewriter.notifyMatchFailure(xferOp, "not a memref source");
 
   Attribute addrSpace = memRefType.getMemorySpace();
-  if (!addrSpace || !dyn_cast<amdgpu::AddressSpaceAttr>(addrSpace))
+  if (!isa_and_nonnull<amdgpu::AddressSpaceAttr>(addrSpace))
     return rewriter.notifyMatchFailure(xferOp, "no address space");
 
   if (dyn_cast<amdgpu::AddressSpaceAttr>(addrSpace).getValue() !=

diff  --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
index eb23403a68813..6f99306b54b45 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -2194,7 +2194,7 @@ static void printBound(AffineMapAttr boundMap,
     // Print bound that consists of a single SSA symbol if the map is over a
     // single symbol.
     if (map.getNumDims() == 0 && map.getNumSymbols() == 1) {
-      if (dyn_cast<AffineSymbolExpr>(expr)) {
+      if (isa<AffineSymbolExpr>(expr)) {
         p.printOperand(*boundOperands.begin());
         return;
       }

diff  --git a/mlir/lib/Dialect/Arith/Utils/Utils.cpp 
b/mlir/lib/Dialect/Arith/Utils/Utils.cpp
index 6b1074e454bd5..bb4807ab39cd6 100644
--- a/mlir/lib/Dialect/Arith/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Arith/Utils/Utils.cpp
@@ -205,7 +205,7 @@ static Value 
convertScalarToComplexDtype(ImplicitLocOpBuilder &b, Value operand,
     }
   }
 
-  if (dyn_cast<FloatType>(operand.getType())) {
+  if (isa<FloatType>(operand.getType())) {
     FloatType toFpTy = cast<FloatType>(targetType.getElementType());
     auto toBitwidth = toFpTy.getIntOrFloatBitWidth();
     Value from = operand;
@@ -220,7 +220,7 @@ static Value 
convertScalarToComplexDtype(ImplicitLocOpBuilder &b, Value operand,
     return b.create<complex::CreateOp>(targetType, from, zero);
   }
 
-  if (dyn_cast<IntegerType>(operand.getType())) {
+  if (isa<IntegerType>(operand.getType())) {
     FloatType toFpTy = cast<FloatType>(targetType.getElementType());
     Value from = operand;
     if (isUnsigned) {

diff  --git a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp 
b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
index 27a51c8cba769..d11cd8444636a 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncRuntimeRefCounting.cpp
@@ -534,15 +534,15 @@ void 
AsyncRuntimePolicyBasedRefCountingPass::initializeDefaultPolicy() {
     bool isValue = isa<ValueType>(type);
 
     // Drop reference after async token or group error check (coro await).
-    if (dyn_cast<RuntimeIsErrorOp>(op))
+    if (isa<RuntimeIsErrorOp>(op))
       return (isToken || isGroup) ? -1 : 0;
 
     // Drop reference after async value load.
-    if (dyn_cast<RuntimeLoadOp>(op))
+    if (isa<RuntimeLoadOp>(op))
       return isValue ? -1 : 0;
 
     // Drop reference after async token added to the group.
-    if (dyn_cast<RuntimeAddToGroupOp>(op))
+    if (isa<RuntimeAddToGroupOp>(op))
       return isToken ? -1 : 0;
 
     return 0;

diff  --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp 
b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
index c16c38ea22a5d..7d1844df42195 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
@@ -1296,7 +1296,7 @@ LogicalResult 
mlir::linalg::detail::verifyStructuredOpInterface(Operation *op) {
                      "unexpected result less than 0 at expression #")
                  << dim << " in " << mapStr;
         }
-        if (dyn_cast<AffineDimExpr>(indexingMap.getResult(dim))) {
+        if (isa<AffineDimExpr>(indexingMap.getResult(dim))) {
           if (inferredDimSize != shape[dim]) {
             return op->emitOpError("inferred input/output operand #")
                    << opOperand.getOperandNumber() << " has shape's dimension 
#"

diff  --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp 
b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
index f6ca109b84f9e..fbe7593420102 100644
--- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
+++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
@@ -1211,7 +1211,7 @@ DiagnosedSilenceableFailure 
transform::LinalgCopyToMemrefOp::applyToOne(
   // linalg.copy supports 
diff erent element types on source/dest whereas
   // memref.copy does not, so we must check that the source and dest types can
   // be handled by memref.copy and otherwise reject the transformation.
-  if (!dyn_cast<ShapedType>(input.getType())) {
+  if (!isa<ShapedType>(input.getType())) {
     DiagnosedSilenceableFailure diag =
         emitSilenceableError()
         << "cannot transform a linalg.copy which input has no shape";
@@ -1220,7 +1220,7 @@ DiagnosedSilenceableFailure 
transform::LinalgCopyToMemrefOp::applyToOne(
   }
 
   // linalg.copy destination must be a shaped type.
-  assert(dyn_cast<ShapedType>(output.getType()));
+  assert(isa<ShapedType>(output.getType()));
 
   if (cast<ShapedType>(input.getType()).getElementType() !=
       cast<ShapedType>(output.getType()).getElementType()) {

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
index 0d62d72abd076..20ab5ecbe3c4a 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Detensorize.cpp
@@ -317,9 +317,8 @@ struct LinalgDetensorize
         //       * Add the argument to blockArgsToDetensor.
         //       * Walk the use-def chain backwards to add each predecessor's
         //       terminator-operands corresponding to currentItem to workList.
-        if (dyn_cast<BlockArgument>(currentItem)) {
-          BlockArgument currentItemBlockArgument =
-              cast<BlockArgument>(currentItem);
+        if (auto currentItemBlockArgument =
+                dyn_cast<BlockArgument>(currentItem)) {
           Block *ownerBlock = currentItemBlockArgument.getOwner();
 
           // Function arguments are not detensored/converted.
@@ -414,7 +413,7 @@ struct LinalgDetensorize
         Block *block = blockArg.getParentBlock();
 
         // For the potentially detensorable block argument, find the
-        // correpsonding operands in predecessor blocks.
+        // corresponding operands in predecessor blocks.
         for (PredecessorIterator pred = block->pred_begin();
              pred != block->pred_end(); ++pred) {
           BranchOpInterface terminator =

diff  --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp 
b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
index 984f3f5a34ab1..5b2ec4a6ff528 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -303,7 +303,7 @@ struct FoldAffineOp : public RewritePattern {
       }
       return failure();
     }
-    if (dyn_cast<AffineDimExpr>(expr) || dyn_cast<AffineSymbolExpr>(expr)) {
+    if (isa<AffineDimExpr, AffineSymbolExpr>(expr)) {
       rewriter.replaceOp(op, op->getOperand(0));
       return success();
     }

diff  --git a/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp 
b/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
index 62c7a7128d63a..b66390819103e 100644
--- a/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
+++ b/mlir/lib/Dialect/Quant/Utils/UniformSupport.cpp
@@ -36,7 +36,7 @@ Type ExpressedToQuantizedConverter::convert(QuantizedType 
elementalType) const {
   assert(expressedType && "convert() on unsupported conversion");
   if (auto tensorType = dyn_cast<RankedTensorType>(inputType))
     return RankedTensorType::get(tensorType.getShape(), elementalType);
-  if (dyn_cast<UnrankedTensorType>(inputType))
+  if (isa<UnrankedTensorType>(inputType))
     return UnrankedTensorType::get(elementalType);
   if (auto vectorType = dyn_cast<VectorType>(inputType))
     return VectorType::get(vectorType.getShape(), elementalType);

diff  --git 
a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp 
b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
index 60db71d96547f..dcb0237070885 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
@@ -1284,7 +1284,7 @@ struct DirectConvertRewriter : public 
OpRewritePattern<ConvertOp> {
 
     bool fromSparseConst = false;
     if (auto constOp = op.getSource().getDefiningOp<arith::ConstantOp>())
-      if (dyn_cast<SparseElementsAttr>(constOp.getValue()))
+      if (isa<SparseElementsAttr>(constOp.getValue()))
         fromSparseConst = true;
 
     const AffineMapAttr foreachOrder =

diff  --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp 
b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
index f92382472b478..0ebdc3a54e61b 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/CodegenUtils.cpp
@@ -211,7 +211,7 @@ Value mlir::sparse_tensor::genIsNonzero(OpBuilder &builder, 
mlir::Location loc,
   if (tp.isIntOrIndex())
     return builder.create<arith::CmpIOp>(loc, arith::CmpIPredicate::ne, v,
                                          zero);
-  if (dyn_cast<ComplexType>(tp))
+  if (isa<ComplexType>(tp))
     return builder.create<complex::NotEqualOp>(loc, v, zero);
   llvm_unreachable("Non-numeric type");
 }

diff  --git a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp 
b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
index 92b620473d2a0..c19d3733769b7 100644
--- a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
+++ b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp
@@ -399,7 +399,7 @@ struct TransposeIsReshape : public 
OpRewritePattern<tosa::TransposeOp> {
 
     Value result = op.getResult();
     for (Operation *subop : result.getUsers()) {
-      if (dyn_cast_or_null<tosa::TransposeOp>(subop))
+      if (isa_and_nonnull<tosa::TransposeOp>(subop))
         return rewriter.notifyMatchFailure(
             op, "Dest is used by transpose, can compose transposes");
     }

diff  --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp
index 59d803035bda0..79697be2b45ea 100644
--- a/mlir/lib/IR/Diagnostics.cpp
+++ b/mlir/lib/IR/Diagnostics.cpp
@@ -392,11 +392,11 @@ struct SourceMgrDiagnosticHandlerImpl {
 
 /// Return a processable CallSiteLoc from the given location.
 static std::optional<CallSiteLoc> getCallSiteLoc(Location loc) {
-  if (dyn_cast<NameLoc>(loc))
+  if (isa<NameLoc>(loc))
     return getCallSiteLoc(cast<NameLoc>(loc).getChildLoc());
   if (auto callLoc = dyn_cast<CallSiteLoc>(loc))
     return callLoc;
-  if (dyn_cast<FusedLoc>(loc)) {
+  if (isa<FusedLoc>(loc)) {
     for (auto subLoc : cast<FusedLoc>(loc).getLocations()) {
       if (auto callLoc = getCallSiteLoc(subLoc)) {
         return callLoc;

diff  --git a/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp 
b/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp
index 7dfe320cff2ab..32b9144233f02 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/NVVM/NVVMToLLVMIRTranslation.cpp
@@ -344,7 +344,7 @@ class NVVMDialectLLVMIRTranslationInterface
     llvm::Function *llvmFunc = 
moduleTranslation.lookupFunction(func.getName());
 
     if (attribute.getName() == NVVM::NVVMDialect::getMaxntidAttrName()) {
-      if (!dyn_cast<DenseI32ArrayAttr>(attribute.getValue()))
+      if (!isa<DenseI32ArrayAttr>(attribute.getValue()))
         return failure();
       auto values = cast<DenseI32ArrayAttr>(attribute.getValue());
       const std::string attr = llvm::formatv(
@@ -352,7 +352,7 @@ class NVVMDialectLLVMIRTranslationInterface
                                        values.asArrayRef().end()));
       llvmFunc->addFnAttr("nvvm.maxntid", attr);
     } else if (attribute.getName() == NVVM::NVVMDialect::getReqntidAttrName()) 
{
-      if (!dyn_cast<DenseI32ArrayAttr>(attribute.getValue()))
+      if (!isa<DenseI32ArrayAttr>(attribute.getValue()))
         return failure();
       auto values = cast<DenseI32ArrayAttr>(attribute.getValue());
       const std::string attr = llvm::formatv(
@@ -361,7 +361,7 @@ class NVVMDialectLLVMIRTranslationInterface
       llvmFunc->addFnAttr("nvvm.reqntid", attr);
     } else if (attribute.getName() ==
                NVVM::NVVMDialect::getClusterDimAttrName()) {
-      if (!dyn_cast<DenseI32ArrayAttr>(attribute.getValue()))
+      if (!isa<DenseI32ArrayAttr>(attribute.getValue()))
         return failure();
       auto values = cast<DenseI32ArrayAttr>(attribute.getValue());
       const std::string attr = llvm::formatv(


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to