[InstCombine][NFC] Change cast of FixedVectorType to dyn_cast.
authorJun Ma <JunMa@linux.alibaba.com>
Mon, 14 Dec 2020 06:42:55 +0000 (14:42 +0800)
committerJun Ma <JunMa@linux.alibaba.com>
Tue, 15 Dec 2020 12:36:57 +0000 (20:36 +0800)
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

index c32f6ac..d6f8d2d 100644 (file)
@@ -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) {