[llvm] f989db5 - [NFC] Use cast instead of dyn_cast for Src and Dst vec types in VecCombine folding (#134432)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 10 07:21:40 PDT 2025


Author: calebwat
Date: 2025-04-10T15:21:37+01:00
New Revision: f989db5745b88cd72f2af7f67ff96071f5059922

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

LOG: [NFC] Use cast instead of dyn_cast for Src and Dst vec types in VecCombine folding (#134432)

SrcVecTy and DstVecTy are used without a null check, and originate from
a dyn_cast. This patch adjusts this to use a fixed cast, since it is not
checked for null before use otherwise, but is semantically guaranteed
from previous checks.

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index ffb82bd5baf4e..bd225bcc0635e 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -2051,8 +2051,8 @@ bool VectorCombine::foldShuffleOfSelects(Instruction &I) {
        (SI0FOp->getFastMathFlags() != SI1FOp->getFastMathFlags())))
     return false;
 
-  auto *SrcVecTy = dyn_cast<FixedVectorType>(T1->getType());
-  auto *DstVecTy = dyn_cast<FixedVectorType>(I.getType());
+  auto *SrcVecTy = cast<FixedVectorType>(T1->getType());
+  auto *DstVecTy = cast<FixedVectorType>(I.getType());
   auto SK = TargetTransformInfo::SK_PermuteTwoSrc;
   auto SelOp = Instruction::Select;
   InstructionCost OldCost = TTI.getCmpSelInstrCost(


        


More information about the llvm-commits mailing list