diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 7d14c668fc435..ae8ef00913c4c 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -2166,6 +2166,9 @@ static bool detectShiftUntilBitTestIdiom(Loop *CurLoop, Value *&BaseX, NextX = dyn_cast(CurrXPN->getIncomingValueForBlock(LoopHeaderBB)); + assert(CurLoop->isLoopInvariant(BaseX) && + "Expected BaseX to be avaliable in the preheader!"); + if (!NextX || !match(NextX, m_Shl(m_Specific(CurrX), m_One()))) { // FIXME: support right-shift? LLVM_DEBUG(dbgs() << DEBUG_TYPE " Bad recurrence.\n");