diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 24ee0c45b6672..37c591f90f0a3 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -43694,14 +43694,14 @@ static SDValue combineBitcast(SDNode *N, SelectionDAG &DAG, return combinevXi1ConstantToInteger(N0, DAG); } - if (Subtarget.hasAVX512() && SrcVT.isScalarInteger() && - VT.isVector() && VT.getVectorElementType() == MVT::i1 && - isa(N0)) { - auto *C = cast(N0); - if (C->isAllOnes()) - return DAG.getConstant(1, SDLoc(N0), VT); - if (C->isZero()) - return DAG.getConstant(0, SDLoc(N0), VT); + if (Subtarget.hasAVX512() && SrcVT.isScalarInteger() && VT.isVector() && + VT.getVectorElementType() == MVT::i1) { + if (auto *C = dyn_cast(N0)) { + if (C->isAllOnes()) + return DAG.getConstant(1, SDLoc(N0), VT); + if (C->isZero()) + return DAG.getConstant(0, SDLoc(N0), VT); + } } // Look for MOVMSK that is maybe truncated and then bitcasted to vXi1.