From db49a78900f5e4b59714565876b5dbb5e2dfe840 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 28 Jan 2022 10:34:16 -0800 Subject: [PATCH] [SLP] Add a clarifying assert in block scheduling [NFC] The fact we could have a block with a valid scheduling window, but nothing to schedule was surprising to me. After digging through the code, this can only happen if we don't find anything to directly vectorize. However, the reduction handling code relies on this mode, so we can't simply consider such trees unvectorizeable. The assert conveys both that this situation can happen, but also that it can *only* happen for an immediate gather. Context: We built the bundle before deciding that vectorization of a bundle is possible. A side effect of bundle construction is manipulating the scheduling window, so a bundle which isn't vectorizable can cause the creation or expansion of a scheduling window. --- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 967e527b16d51..84d00d50e7bc8 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -7668,6 +7668,11 @@ void BoUpSLP::scheduleBlock(BlockScheduling *BS) { } BS->initialFillReadyList(ReadyInsts); + assert((!ReadyInsts.empty() || + (VectorizableTree.size() == 1 && + VectorizableTree[0]->State == TreeEntry::NeedToGather)) && + "why no ready insts from scheduleable tree?"); + Instruction *LastScheduledInst = BS->ScheduleEnd; // Do the "real" scheduling.