[llvm] r231816 - [LAA-memchecks 1/3] Split out NumComparisons checks. NFC

Adam Nemet anemet at apple.com
Tue Mar 10 11:54:19 PDT 2015


Author: anemet
Date: Tue Mar 10 13:54:19 2015
New Revision: 231816

URL: http://llvm.org/viewvc/llvm-project?rev=231816&view=rev
Log:
[LAA-memchecks 1/3] Split out NumComparisons checks. NFC

The check for the number of memchecks will be moved to the client of
this analysis.  Besides allowing for transform-specific thresholds, this
also lets Loop Distribution post-process the memchecks; Loop
Distribution only needs memchecks between pointers of different
partitions.

The motivation for this first patch is to untangle the CanDoRT check
from the NumComparison check before moving the NumComparison part.
CanDoRT means that we couldn't determine the bounds for the pointer.
Note that NumComparison is set independent of this flag.

Modified:
    llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp?rev=231816&r1=231815&r2=231816&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp Tue Mar 10 13:54:19 2015
@@ -1086,18 +1086,10 @@ void LoopAccessInfo::analyzeLoop(const V
   if (NumComparisons == 0 && NeedRTCheck)
     NeedRTCheck = false;
 
-  // Check that we did not collect too many pointers or found an unsizeable
-  // pointer.
-  if (!CanDoRT || NumComparisons > RuntimeMemoryCheckThreshold) {
-    PtrRtCheck.reset();
-    CanDoRT = false;
-  }
-
-  if (CanDoRT) {
+  // Check that we did not find an unsizeable pointer.
+  if (CanDoRT)
     DEBUG(dbgs() << "LAA: We can perform a memory runtime check if needed.\n");
-  }
-
-  if (NeedRTCheck && !CanDoRT) {
+  else if (NeedRTCheck) {
     emitAnalysis(LoopAccessReport() << "cannot identify array bounds");
     DEBUG(dbgs() << "LAA: We can't vectorize because we can't find " <<
           "the array bounds.\n");
@@ -1106,6 +1098,17 @@ void LoopAccessInfo::analyzeLoop(const V
     return;
   }
 
+  if (NumComparisons > RuntimeMemoryCheckThreshold) {
+    emitAnalysis(LoopAccessReport()
+                 << NumComparisons << " exceeds limit of "
+                 << RuntimeMemoryCheckThreshold
+                 << " dependent memory operations checked at runtime");
+    DEBUG(dbgs() << "LAA: Too many memory checks needed.\n");
+    PtrRtCheck.reset();
+    CanVecMem = false;
+    return;
+  }
+
   PtrRtCheck.Need = NeedRTCheck;
 
   CanVecMem = true;
@@ -1127,17 +1130,22 @@ void LoopAccessInfo::analyzeLoop(const V
 
       CanDoRT = Accesses.canCheckPtrAtRT(PtrRtCheck, NumComparisons, SE,
                                          TheLoop, Strides, true);
-      // Check that we did not collect too many pointers or found an unsizeable
-      // pointer.
-      if (!CanDoRT || NumComparisons > RuntimeMemoryCheckThreshold) {
-        if (!CanDoRT && NumComparisons > 0)
-          emitAnalysis(LoopAccessReport()
-                       << "cannot check memory dependencies at runtime");
-        else
-          emitAnalysis(LoopAccessReport()
-                       << NumComparisons << " exceeds limit of "
-                       << RuntimeMemoryCheckThreshold
-                       << " dependent memory operations checked at runtime");
+      // Check that we didn't find an unsizeable pointer.
+      if (!CanDoRT && NumComparisons > 0) {
+        emitAnalysis(LoopAccessReport()
+                     << "cannot check memory dependencies at runtime");
+        DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n");
+        PtrRtCheck.reset();
+        CanVecMem = false;
+        return;
+      }
+
+      // Check that we did not collect too many pointers.
+      if (NumComparisons > RuntimeMemoryCheckThreshold) {
+        emitAnalysis(LoopAccessReport()
+                     << NumComparisons << " exceeds limit of "
+                     << RuntimeMemoryCheckThreshold
+                     << " dependent memory operations checked at runtime");
         DEBUG(dbgs() << "LAA: Can't vectorize with memory checks\n");
         PtrRtCheck.reset();
         CanVecMem = false;





More information about the llvm-commits mailing list