[llvm] r244845 - [LIR] Move all the helpers to be private and re-order the methods in

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 12 17:10:04 PDT 2015


Author: chandlerc
Date: Wed Aug 12 19:10:03 2015
New Revision: 244845

URL: http://llvm.org/viewvc/llvm-project?rev=244845&view=rev
Log:
[LIR] Move all the helpers to be private and re-order the methods in
a way that groups things logically. No functionality changed.

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

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp?rev=244845&r1=244844&r2=244845&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIdiomRecognize.cpp Wed Aug 12 19:10:03 2015
@@ -129,20 +129,6 @@ public:
   }
 
   bool runOnLoop(Loop *L, LPPassManager &LPM) override;
-  bool runOnLoopBlock(BasicBlock *BB, const SCEV *BECount,
-                      SmallVectorImpl<BasicBlock *> &ExitBlocks);
-
-  bool processLoopStore(StoreInst *SI, const SCEV *BECount);
-  bool processLoopMemSet(MemSetInst *MSI, const SCEV *BECount);
-
-  bool processLoopStridedStore(Value *DestPtr, unsigned StoreSize,
-                               unsigned StoreAlignment, Value *SplatValue,
-                               Instruction *TheStore, const SCEVAddRecExpr *Ev,
-                               const SCEV *BECount);
-  bool processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
-                                  const SCEVAddRecExpr *StoreEv,
-                                  const SCEVAddRecExpr *LoadEv,
-                                  const SCEV *BECount);
 
   /// This transformation requires natural loop information & requires that
   /// loop preheaders be inserted into the CFG.
@@ -189,8 +175,32 @@ public:
   Loop *getLoop() const { return CurLoop; }
 
 private:
-  bool runOnNoncountableLoop();
+  /// \name Countable Loop Idiom Handling
+  /// @{
+
   bool runOnCountableLoop();
+  bool runOnLoopBlock(BasicBlock *BB, const SCEV *BECount,
+                      SmallVectorImpl<BasicBlock *> &ExitBlocks);
+
+  bool processLoopStore(StoreInst *SI, const SCEV *BECount);
+  bool processLoopMemSet(MemSetInst *MSI, const SCEV *BECount);
+
+  bool processLoopStridedStore(Value *DestPtr, unsigned StoreSize,
+                               unsigned StoreAlignment, Value *SplatValue,
+                               Instruction *TheStore, const SCEVAddRecExpr *Ev,
+                               const SCEV *BECount);
+  bool processLoopStoreOfLoopLoad(StoreInst *SI, unsigned StoreSize,
+                                  const SCEVAddRecExpr *StoreEv,
+                                  const SCEVAddRecExpr *LoadEv,
+                                  const SCEV *BECount);
+
+  /// @}
+  /// \name Noncountable Loop Idiom Handling
+  /// @{
+
+  bool runOnNoncountableLoop();
+
+  /// @}
 };
 
 } // End anonymous namespace.
@@ -552,7 +562,6 @@ CallInst *NclPopcountRecognize::createPo
 ///   detected, transform the relevant code to popcount intrinsic function
 ///   call, and return true; otherwise, return false.
 bool NclPopcountRecognize::recognize() {
-
   if (!LIR.getTargetTransformInfo())
     return false;
 
@@ -577,6 +586,28 @@ bool NclPopcountRecognize::recognize() {
 //
 //===----------------------------------------------------------------------===//
 
+bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
+  if (skipOptnoneFunction(L))
+    return false;
+
+  CurLoop = L;
+
+  // If the loop could not be converted to canonical form, it must have an
+  // indirectbr in it, just give up.
+  if (!L->getLoopPreheader())
+    return false;
+
+  // Disable loop idiom recognition if the function's name is a common idiom.
+  StringRef Name = L->getHeader()->getParent()->getName();
+  if (Name == "memset" || Name == "memcpy")
+    return false;
+
+  SE = &getAnalysis<ScalarEvolution>();
+  if (SE->hasLoopInvariantBackedgeTakenCount(L))
+    return runOnCountableLoop();
+  return runOnNoncountableLoop();
+}
+
 bool LoopIdiomRecognize::runOnCountableLoop() {
   const SCEV *BECount = SE->getBackedgeTakenCount(CurLoop);
   assert(!isa<SCEVCouldNotCompute>(BECount) &&
@@ -617,36 +648,6 @@ bool LoopIdiomRecognize::runOnCountableL
   return MadeChange;
 }
 
-bool LoopIdiomRecognize::runOnNoncountableLoop() {
-  NclPopcountRecognize Popcount(*this);
-  if (Popcount.recognize())
-    return true;
-
-  return false;
-}
-
-bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) {
-  if (skipOptnoneFunction(L))
-    return false;
-
-  CurLoop = L;
-
-  // If the loop could not be converted to canonical form, it must have an
-  // indirectbr in it, just give up.
-  if (!L->getLoopPreheader())
-    return false;
-
-  // Disable loop idiom recognition if the function's name is a common idiom.
-  StringRef Name = L->getHeader()->getParent()->getName();
-  if (Name == "memset" || Name == "memcpy")
-    return false;
-
-  SE = &getAnalysis<ScalarEvolution>();
-  if (SE->hasLoopInvariantBackedgeTakenCount(L))
-    return runOnCountableLoop();
-  return runOnNoncountableLoop();
-}
-
 /// runOnLoopBlock - Process the specified block, which lives in a counted loop
 /// with the specified backedge count.  This block is known to be in the current
 /// loop and not in any subloops.
@@ -1062,3 +1063,11 @@ bool LoopIdiomRecognize::processLoopStor
   ++NumMemCpy;
   return true;
 }
+
+bool LoopIdiomRecognize::runOnNoncountableLoop() {
+  NclPopcountRecognize Popcount(*this);
+  if (Popcount.recognize())
+    return true;
+
+  return false;
+}




More information about the llvm-commits mailing list