[llvm] 32bee42 - [NFCI][LoopIdiom] 'left-shift until bittest': assert that BaseX is loop-invariant

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Mon May 24 02:15:41 PDT 2021


Author: Roman Lebedev
Date: 2021-05-24T12:15:06+03:00
New Revision: 32bee42719ad8f0d8e15b55dd5b2a7563a817e34

URL: https://github.com/llvm/llvm-project/commit/32bee42719ad8f0d8e15b55dd5b2a7563a817e34
DIFF: https://github.com/llvm/llvm-project/commit/32bee42719ad8f0d8e15b55dd5b2a7563a817e34.diff

LOG: [NFCI][LoopIdiom] 'left-shift until bittest': assert that BaseX is loop-invariant

Given that BaseX is an incoming value when coming from the preheader,
it *should* be loop-invariant, but let's just document this assumption.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 7d14c668fc43..ae8ef00913c4 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<Instruction>(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");


        


More information about the llvm-commits mailing list