[llvm] c17f5af - [X86] getShape - don't dereference dyn_cast<>

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 26 07:08:31 PDT 2021


Author: Simon Pilgrim
Date: 2021-08-26T15:08:13+01:00
New Revision: c17f5afa886a860a30adaa84827c9ec526cdd8f4

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

LOG: [X86] getShape - don't dereference dyn_cast<>

dyn_cast can return nullptr, use cast<> to assert we have the correct type.

Added: 
    

Modified: 
    llvm/lib/Target/X86/X86LowerAMXType.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86LowerAMXType.cpp b/llvm/lib/Target/X86/X86LowerAMXType.cpp
index e150f2dbc354..29f7c90f0935 100644
--- a/llvm/lib/Target/X86/X86LowerAMXType.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXType.cpp
@@ -126,7 +126,7 @@ static std::pair<Value *, Value *> getShape(IntrinsicInst *II, unsigned OpNo) {
     case 5:
       if (isa<ConstantInt>(II->getArgOperand(2)))
         Row = Builder.getInt16(
-            (dyn_cast<ConstantInt>(II->getOperand(2))->getSExtValue()) / 4);
+            (cast<ConstantInt>(II->getOperand(2))->getSExtValue()) / 4);
       else if (isa<Instruction>(II->getArgOperand(2))) {
         // When it is not a const value and it is not a function argument, we
         // create Row after the definition of II->getOperand(2) instead of


        


More information about the llvm-commits mailing list