[llvm] a78e86e - [SLP]Avoid multiple attempts to vectorize CmpInsts.
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 7 06:16:58 PDT 2021
Author: Alexey Bataev
Date: 2021-04-07T06:15:42-07:00
New Revision: a78e86e6beb2d62196fa42be9f4a2994823f71f3
URL: https://github.com/llvm/llvm-project/commit/a78e86e6beb2d62196fa42be9f4a2994823f71f3
DIFF: https://github.com/llvm/llvm-project/commit/a78e86e6beb2d62196fa42be9f4a2994823f71f3.diff
LOG: [SLP]Avoid multiple attempts to vectorize CmpInsts.
No need to lookup through and/or try to vectorize operands of the
CmpInst instructions during attempts to find/vectorize min/max
reductions. Compiler implements postanalysis of the CmpInsts so we can
skip extra attempts in tryToVectorizeHorReductionOrInstOperands and save
compile time.
Differential Revision: https://reviews.llvm.org/D99950
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 86c2569ae898..76bfdcc97e63 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7495,6 +7495,9 @@ static bool tryToVectorizeHorReductionOrInstOperands(
// 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<std::pair<Instruction *, unsigned>, 8> Stack(1, {Root, 0});
SmallPtrSet<Value *, 8> VisitedInstrs;
bool Res = false;
@@ -7531,7 +7534,8 @@ static bool tryToVectorizeHorReductionOrInstOperands(
// 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<CmpInst>(Inst) && Vectorize(Inst, R)) {
Res = true;
continue;
}
@@ -7543,7 +7547,10 @@ static bool tryToVectorizeHorReductionOrInstOperands(
for (auto *Op : Inst->operand_values())
if (VisitedInstrs.insert(Op).second)
if (auto *I = dyn_cast<Instruction>(Op))
- if (!isa<PHINode>(I) && !R.isDeleted(I) && I->getParent() == BB)
+ // Do not try to vectorize CmpInst operands, this is done
+ // separately.
+ if (!isa<PHINode>(I) && !isa<CmpInst>(I) && !R.isDeleted(I) &&
+ I->getParent() == BB)
Stack.emplace_back(I, Level);
}
return Res;
More information about the llvm-commits
mailing list