[llvm-branch-commits] [llvm] ffe84d9 - [InstCombine][NFC] Change cast of FixedVectorType to dyn_cast.

Jun Ma via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 15 04:52:18 PST 2020


Author: Jun Ma
Date: 2020-12-15T20:36:57+08:00
New Revision: ffe84d90e9a7279fafbdcaf70da03174a522ab62

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

LOG: [InstCombine][NFC] Change cast of FixedVectorType to dyn_cast.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index c32f6ace42db..d6f8d2dcc7ce 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -1985,11 +1985,11 @@ Instruction *InstCombinerImpl::foldSelectExtConst(SelectInst &Sel) {
 static Instruction *canonicalizeSelectToShuffle(SelectInst &SI) {
   Value *CondVal = SI.getCondition();
   Constant *CondC;
-  if (!CondVal->getType()->isVectorTy() || !match(CondVal, m_Constant(CondC)))
+  auto *CondValTy = dyn_cast<FixedVectorType>(CondVal->getType());
+  if (!CondValTy || !match(CondVal, m_Constant(CondC)))
     return nullptr;
 
-  unsigned NumElts =
-      cast<FixedVectorType>(CondVal->getType())->getNumElements();
+  unsigned NumElts = CondValTy->getNumElements();
   SmallVector<int, 16> Mask;
   Mask.reserve(NumElts);
   for (unsigned i = 0; i != NumElts; ++i) {


        


More information about the llvm-branch-commits mailing list