[llvm] b7a8f5f - [SLP][NFC]Exit early from attempt-to-reorder, if it is useless
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 11:08:00 PST 2024
Author: Alexey Bataev
Date: 2024-11-07T11:07:49-08:00
New Revision: b7a8f5f4c978856852bc39dc3d29265756e37cfe
URL: https://github.com/llvm/llvm-project/commit/b7a8f5f4c978856852bc39dc3d29265756e37cfe
DIFF: https://github.com/llvm/llvm-project/commit/b7a8f5f4c978856852bc39dc3d29265756e37cfe.diff
LOG: [SLP][NFC]Exit early from attempt-to-reorder, if it is useless
Adds early exits, which just save compile time. It can exit earl, if the
total number of scalars is 2, or all scalars are constant, or the opcode
is the same and not alternate. In this case reordering will not happen
and compiler can exit early to save compile time
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 184413b420089a..be7ddeb89e789f 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -9362,6 +9362,12 @@ void BoUpSLP::reorderGatherNode(TreeEntry &TE) {
DenseMap<std::pair<size_t, Value *>, SmallVector<LoadInst *>> LoadsMap;
SmallSet<size_t, 2> LoadKeyUsed;
+ // Do not reorder nodes if it small (just 2 elements), all-constant or all
+ // instructions have same opcode already.
+ if (TE.Scalars.size() == 2 || (TE.getOpcode() && !TE.isAltShuffle()) ||
+ all_of(TE.Scalars, isConstant))
+ return;
+
if (any_of(seq<unsigned>(TE.Idx), [&](unsigned Idx) {
return VectorizableTree[Idx]->isSame(TE.Scalars);
}))
More information about the llvm-commits
mailing list