diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -7495,6 +7495,9 @@ // horizontal reduction. // Interrupt the process if the Root instruction itself was vectorized or all // sub-trees not higher that RecursionMaxDepth were analyzed/vectorized. + // Skip the analysis of CmpInsts.Compiler implements postanalysis of the + // CmpInsts so we can skip extra attempts in + // tryToVectorizeHorReductionOrInstOperands and save compile time. SmallVector, 8> Stack(1, {Root, 0}); SmallPtrSet VisitedInstrs; bool Res = false; @@ -7531,7 +7534,8 @@ // Set P to nullptr to avoid re-analysis of phi node in // matchAssociativeReduction function unless this is the root node. P = nullptr; - if (Vectorize(Inst, R)) { + // Do not try to vectorize CmpInst operands, this is done separately. + if (!isa(Inst) && Vectorize(Inst, R)) { Res = true; continue; } @@ -7543,7 +7547,10 @@ for (auto *Op : Inst->operand_values()) if (VisitedInstrs.insert(Op).second) if (auto *I = dyn_cast(Op)) - if (!isa(I) && !R.isDeleted(I) && I->getParent() == BB) + // Do not try to vectorize CmpInst operands, this is done + // separately. + if (!isa(I) && !isa(I) && !R.isDeleted(I) && + I->getParent() == BB) Stack.emplace_back(I, Level); } return Res;