Skip to content

Commit b7a8f5f

Browse files
committed
[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
1 parent 4ac891c commit b7a8f5f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9362,6 +9362,12 @@ void BoUpSLP::reorderGatherNode(TreeEntry &TE) {
93629362
DenseMap<std::pair<size_t, Value *>, SmallVector<LoadInst *>> LoadsMap;
93639363
SmallSet<size_t, 2> LoadKeyUsed;
93649364

9365+
// Do not reorder nodes if it small (just 2 elements), all-constant or all
9366+
// instructions have same opcode already.
9367+
if (TE.Scalars.size() == 2 || (TE.getOpcode() && !TE.isAltShuffle()) ||
9368+
all_of(TE.Scalars, isConstant))
9369+
return;
9370+
93659371
if (any_of(seq<unsigned>(TE.Idx), [&](unsigned Idx) {
93669372
return VectorizableTree[Idx]->isSame(TE.Scalars);
93679373
}))

0 commit comments

Comments
 (0)