[llvm] 1375543 - [PowerPC] return early if there is no preparing candidate in the loop; NFC

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 21 23:10:16 PDT 2021


Author: Chen Zheng
Date: 2021-10-22T05:39:51Z
New Revision: 13755436bb3d7853470a10ddb86fe23dabdeaea2

URL: https://github.com/llvm/llvm-project/commit/13755436bb3d7853470a10ddb86fe23dabdeaea2
DIFF: https://github.com/llvm/llvm-project/commit/13755436bb3d7853470a10ddb86fe23dabdeaea2.diff

LOG: [PowerPC] return early if there is no preparing candidate in the loop; NFC

This is to improve compiling time.

Differential Revision: https://reviews.llvm.org/D112196

Reviewed By: jsji

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
index db9177932720c..39afe58da9687 100644
--- a/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
+++ b/llvm/lib/Target/PowerPC/PPCLoopInstrFormPrep.cpp
@@ -174,6 +174,7 @@ namespace {
     LoopInfo *LI;
     ScalarEvolution *SE;
     bool PreserveLCSSA;
+    bool HasCandidateForPrepare;
 
     /// Successful preparation number for Update/DS/DQ form in all inner most
     /// loops. One successful preparation will put one common base out of loop,
@@ -570,6 +571,9 @@ SmallVector<Bucket, 16> PPCLoopInstrFormPrep::collectCandidates(
       if (!LARSCEV || LARSCEV->getLoop() != L)
         continue;
 
+      // Mark that we have candidates for preparing.
+      HasCandidateForPrepare = true;
+
       if (isValidCandidate(&J, PtrValue, PointerElementType))
         addOneCandidate(&J, LSCEV, Buckets, MaxCandidateNum);
     }
@@ -1046,6 +1050,8 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
     return ST && ST->hasP9Vector() && (PointerElementType->isVectorTy());
   };
 
+  HasCandidateForPrepare = false;
+
   // Collect buckets of comparable addresses used by loads and stores for update
   // form.
   SmallVector<Bucket, 16> UpdateFormBuckets =
@@ -1054,6 +1060,9 @@ bool PPCLoopInstrFormPrep::runOnLoop(Loop *L) {
   // Prepare for update form.
   if (!UpdateFormBuckets.empty())
     MadeChange |= updateFormPrep(L, UpdateFormBuckets);
+  else if (!HasCandidateForPrepare)
+    // If no candidate for preparing, return early.
+    return MadeChange;
 
   // Collect buckets of comparable addresses used by loads and stores for DS
   // form.


        


More information about the llvm-commits mailing list