[LAA] LLE 3/6: Rename InterestingDependence to Dependences, NFC
authorAdam Nemet <anemet@apple.com>
Tue, 3 Nov 2015 21:39:52 +0000 (21:39 +0000)
committerAdam Nemet <anemet@apple.com>
Tue, 3 Nov 2015 21:39:52 +0000 (21:39 +0000)
Summary:
We now collect all types of dependences including lexically forward
deps not just "interesting" ones.

Reviewers: hfinkel

Subscribers: rengolin, llvm-commits

Differential Revision: http://reviews.llvm.org/D13256

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251985 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopAccessAnalysis.h
lib/Analysis/LoopAccessAnalysis.cpp
lib/Transforms/Scalar/LoopDistribute.cpp
test/Analysis/LoopAccessAnalysis/forward-loop-carried.ll
test/Analysis/LoopAccessAnalysis/forward-loop-independent.ll
test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll
test/Analysis/LoopAccessAnalysis/resort-to-memchecks-only.ll
test/Analysis/LoopAccessAnalysis/safe-no-checks.ll
test/Analysis/LoopAccessAnalysis/stride-access-dependence.ll
test/Analysis/LoopAccessAnalysis/underlying-objects-2.ll
test/Analysis/LoopAccessAnalysis/unsafe-and-rt-checks.ll

index ea080bc7f873c4f9aa5fcfd89ca2d02ad5707480..1df04d6b627f5ef16bf323a43f71863a0c6552d4 100644 (file)
@@ -141,7 +141,7 @@ public:
       // read and write of A[i]), LAA will locally deem the dependence "safe"
       // without querying the MemoryDepChecker.  Therefore we can miss
       // enumerating loop-independent forward dependences in
-      // getInterestingDependences.  Note that as soon as there are different
+      // getDependences.  Note that as soon as there are different
       // indices used to access the same array, the MemoryDepChecker *is*
       // queried and the dependence list is complete.
       Forward,
@@ -173,9 +173,6 @@ public:
     /// \brief Dependence types that don't prevent vectorization.
     static bool isSafeForVectorization(DepType Type);
 
-    /// \brief Dependence types that can be queried from the analysis.
-    static bool isInterestingDependence(DepType Type);
-
     /// \brief Lexically backward dependence types.
     bool isPossiblyBackward() const;
 
@@ -189,7 +186,7 @@ public:
                    SCEVUnionPredicate &Preds)
       : SE(Se), InnermostLoop(L), AccessIdx(0),
         ShouldRetryWithRuntimeCheck(false), SafeForVectorization(true),
-        RecordInterestingDependences(true), Preds(Preds) {}
+        RecordDependences(true), Preds(Preds) {}
 
   /// \brief Register the location (instructions are given increasing numbers)
   /// of a write access.
@@ -227,14 +224,14 @@ public:
   /// vectorize the loop with a dynamic array access check.
   bool shouldRetryWithRuntimeCheck() { return ShouldRetryWithRuntimeCheck; }
 
-  /// \brief Returns the interesting dependences.  If null is returned we
-  /// exceeded the MaxInterestingDependence threshold and this information is
-  /// not available.
-  const SmallVectorImpl<Dependence> *getInterestingDependences() const {
-    return RecordInterestingDependences ? &InterestingDependences : nullptr;
+  /// \brief Returns the memory dependences.  If null is returned we exceeded
+  /// the MaxDependences threshold and this information is not
+  /// available.
+  const SmallVectorImpl<Dependence> *getDependences() const {
+    return RecordDependences ? &Dependences : nullptr;
   }
 
-  void clearInterestingDependences() { InterestingDependences.clear(); }
+  void clearDependences() { Dependences.clear(); }
 
   /// \brief The vector of memory access instructions.  The indices are used as
   /// instruction identifiers in the Dependence class.
@@ -270,15 +267,14 @@ private:
   /// vectorization.
   bool SafeForVectorization;
 
-  //// \brief True if InterestingDependences reflects the dependences in the
-  //// loop.  If false we exceeded MaxInterestingDependence and
-  //// InterestingDependences is invalid.
-  bool RecordInterestingDependences;
+  //// \brief True if Dependences reflects the dependences in the
+  //// loop.  If false we exceeded MaxDependences and
+  //// Dependences is invalid.
+  bool RecordDependences;
 
-  /// \brief Interesting memory dependences collected during the analysis as
-  /// defined by isInterestingDependence.  Only valid if
-  /// RecordInterestingDependences is true.
-  SmallVector<Dependence, 8> InterestingDependences;
+  /// \brief Memory dependences collected during the analysis.  Only valid if
+  /// RecordDependences is true.
+  SmallVector<Dependence, 8> Dependences;
 
   /// \brief Check whether there is a plausible dependence between the two
   /// accesses.
index 80d6575a9c249999705fd026218d9c1e3e40aae3..fd85a908ffb45a59373af355eda4fd0e2a34177a 100644 (file)
@@ -58,12 +58,12 @@ static cl::opt<unsigned> MemoryCheckMergeThreshold(
 /// Maximum SIMD width.
 const unsigned VectorizerParams::MaxVectorWidth = 64;
 
-/// \brief We collect interesting dependences up to this threshold.
-static cl::opt<unsigned> MaxInterestingDependence(
-    "max-interesting-dependences", cl::Hidden,
-    cl::desc("Maximum number of interesting dependences collected by "
-             "loop-access analysis (default = 100)"),
-    cl::init(100));
+/// \brief We collect dependences up to this threshold.
+static cl::opt<unsigned>
+    MaxDependences("max-dependences", cl::Hidden,
+                   cl::desc("Maximum number of dependences collected by "
+                            "loop-access analysis (default = 100)"),
+                   cl::init(100));
 
 bool VectorizerParams::isInterleaveForced() {
   return ::VectorizationInterleave.getNumOccurrences() > 0;
@@ -468,7 +468,7 @@ public:
   /// We decided that no dependence analysis would be used.  Reset the state.
   void resetDepChecks(MemoryDepChecker &DepChecker) {
     CheckDeps.clear();
-    DepChecker.clearInterestingDependences();
+    DepChecker.clearDependences();
   }
 
   MemAccessInfoSet &getDependenciesToCheck() { return CheckDeps; }
@@ -910,10 +910,6 @@ bool MemoryDepChecker::Dependence::isSafeForVectorization(DepType Type) {
   llvm_unreachable("unexpected DepType!");
 }
 
-bool MemoryDepChecker::Dependence::isInterestingDependence(DepType Type) {
-  return Type != NoDep;
-}
-
 bool MemoryDepChecker::Dependence::isPossiblyBackward() const {
   switch (Type) {
   case NoDep:
@@ -1229,22 +1225,21 @@ bool MemoryDepChecker::areDepsSafe(DepCandidates &AccessSets,
                 isDependent(*A.first, A.second, *B.first, B.second, Strides);
             SafeForVectorization &= Dependence::isSafeForVectorization(Type);
 
-            // Gather dependences unless we accumulated MaxInterestingDependence
+            // Gather dependences unless we accumulated MaxDependences
             // dependences.  In that case return as soon as we find the first
             // unsafe dependence.  This puts a limit on this quadratic
             // algorithm.
-            if (RecordInterestingDependences) {
-              if (Dependence::isInterestingDependence(Type))
-                InterestingDependences.push_back(
-                    Dependence(A.second, B.second, Type));
-
-              if (InterestingDependences.size() >= MaxInterestingDependence) {
-                RecordInterestingDependences = false;
-                InterestingDependences.clear();
+            if (RecordDependences) {
+              if (Type != Dependence::NoDep)
+                Dependences.push_back(Dependence(A.second, B.second, Type));
+
+              if (Dependences.size() >= MaxDependences) {
+                RecordDependences = false;
+                Dependences.clear();
                 DEBUG(dbgs() << "Too many dependences, stopped recording\n");
               }
             }
-            if (!RecordInterestingDependences && !SafeForVectorization)
+            if (!RecordDependences && !SafeForVectorization)
               return false;
           }
         ++OI;
@@ -1253,8 +1248,7 @@ bool MemoryDepChecker::areDepsSafe(DepCandidates &AccessSets,
     }
   }
 
-  DEBUG(dbgs() << "Total Interesting Dependences: "
-               << InterestingDependences.size() << "\n");
+  DEBUG(dbgs() << "Total Dependences: " << Dependences.size() << "\n");
   return SafeForVectorization;
 }
 
@@ -1749,14 +1743,14 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const {
   if (Report)
     OS.indent(Depth) << "Report: " << Report->str() << "\n";
 
-  if (auto *InterestingDependences = DepChecker.getInterestingDependences()) {
-    OS.indent(Depth) << "Interesting Dependences:\n";
-    for (auto &Dep : *InterestingDependences) {
+  if (auto *Dependences = DepChecker.getDependences()) {
+    OS.indent(Depth) << "Dependences:\n";
+    for (auto &Dep : *Dependences) {
       Dep.print(OS, Depth + 2, DepChecker.getMemoryInstructions());
       OS << "\n";
     }
   } else
-    OS.indent(Depth) << "Too many interesting dependences, not recorded\n";
+    OS.indent(Depth) << "Too many dependences, not recorded\n";
 
   // List the pair of accesses need run-time checks to prove independence.
   PtrRtChecking.print(OS, Depth);
index a7769644203cac5ae297c263cf46344ba7b9c3dc..1584f0fa3ebac4b3d052f485e6383509dbde64d1 100644 (file)
@@ -546,11 +546,11 @@ public:
 
   MemoryInstructionDependences(
       const SmallVectorImpl<Instruction *> &Instructions,
-      const SmallVectorImpl<Dependence> &InterestingDependences) {
+      const SmallVectorImpl<Dependence> &Dependences) {
     Accesses.append(Instructions.begin(), Instructions.end());
 
     DEBUG(dbgs() << "Backward dependences:\n");
-    for (auto &Dep : InterestingDependences)
+    for (auto &Dep : Dependences)
       if (Dep.isPossiblyBackward()) {
         // Note that the designations source and destination follow the program
         // order, i.e. source is always first.  (The direction is given by the
@@ -674,9 +674,8 @@ private:
       DEBUG(dbgs() << "Skipping; memory operations are safe for vectorization");
       return false;
     }
-    auto *InterestingDependences =
-        LAI.getDepChecker().getInterestingDependences();
-    if (!InterestingDependences || InterestingDependences->empty()) {
+    auto *Dependences = LAI.getDepChecker().getDependences();
+    if (!Dependences || Dependences->empty()) {
       DEBUG(dbgs() << "Skipping; No unsafe dependences to isolate");
       return false;
     }
@@ -704,7 +703,7 @@ private:
     // NumUnsafeDependencesActive reaches 0.
     const MemoryDepChecker &DepChecker = LAI.getDepChecker();
     MemoryInstructionDependences MID(DepChecker.getMemoryInstructions(),
-                                     *InterestingDependences);
+                                     *Dependences);
 
     int NumUnsafeDependencesActive = 0;
     for (auto &InstDep : MID) {
index 138762c2a6605079b66e0fc3e8a759ea372acd2a..e18ec2357fdb2ad5173e2bb31d7256844a194349 100644 (file)
@@ -9,7 +9,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 define void @f(i32* %A, i32* %B, i32* %C, i64 %N) {
 
-; CHECK: Interesting Dependences:
+; CHECK: Dependences:
 ; CHECK-NEXT: Forward:
 ; CHECK-NEXT:   store i32 %a_p1, i32* %Aidx_ahead, align 4 ->
 ; CHECK-NEXT:   %a = load i32, i32* %Aidx, align 4
index c5573aee579d3678a105ec6a67cb12d23d0a3f47..e1ba674ce80ad86e51e6df15dfe038071eb70f29 100644 (file)
@@ -22,7 +22,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
 define void @f(i32* noalias %A, i32* noalias %B, i32* noalias %C, i64 %N) {
 
-; CHECK: Interesting Dependences:
+; CHECK: Dependences:
 ; CHECK-NEXT:   Forward:
 ; CHECK-NEXT:       store i32 %b_p1, i32* %Aidx, align 4 ->
 ; CHECK-NEXT:       %a = load i32, i32* %Aidx, align 4
index 5348cfe0542752b32d6874bba105f5773d0e6c75..20b7fb2c633532130a95c4fb78defed786ecaaa9 100644 (file)
@@ -12,7 +12,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 ; CHECK: for.body:
 ; CHECK:     Report: unsafe dependent memory operations in loop
 ; CHECK-NOT: Report: cannot identify array bounds
-; CHECK:     Interesting Dependences:
+; CHECK:     Dependences:
 ; CHECK:       Unknown:
 ; CHECK:           %loadA = load i16, i16* %arrayidxA, align 2 ->
 ; CHECK:           store i16 %mul, i16* %arrayidxA, align 2
index e7305173dd951649210bef3d7c78875c78c8bd63..9412028fc702621f0c8b3ddc57d46c74d4a0d112 100644 (file)
@@ -2,7 +2,7 @@
 
 ; We give up analyzing the dependences in this loop due to non-constant
 ; distance between A[i+offset] and A[i] and add memchecks to prove
-; independence.  Make sure that no interesting dependences are reported in
+; independence.  Make sure that no dependences are reported in
 ; this case.
 ;
 ;   for (i = 0; i < n; i++)
@@ -12,7 +12,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.10.0"
 
 ; CHECK: Memory dependences are safe with run-time checks
-; CHECK-NEXT: Interesting Dependences:
+; CHECK-NEXT: Dependences:
 ; CHECK-NEXT: Run-time memory checks:
 ; CHECK-NEXT: 0:
 ; CHECK-NEXT: Comparing group
index 069135e8525826e35b088e9cd8c9c9f017f32e26..d85258f75aaef39ed922e8933d658e5646941354 100644 (file)
@@ -11,7 +11,7 @@ target triple = "x86_64-apple-macosx10.10.0"
 ; store of A[i];
 
 ; CHECK: Memory dependences are safe{{$}}
-; CHECK-NEXT: Interesting Dependences:
+; CHECK-NEXT: Dependences:
 ; CHECK-NEXT:   Forward:
 ; CHECK-NEXT:     %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2 ->
 ; CHECK-NEXT:     store i16 %mul1, i16* %arrayidxA, align 2
index 73573566295296f502ef41929825e34a9f9eb74e..5fc353e70cf8317d45085a6af8662e124f6bc9d4 100644 (file)
@@ -13,7 +13,7 @@ target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
 ; CHECK: function 'nodep_Read_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:     Run-time memory checks:
 
 define void @nodep_Read_Write(i32* nocapture %A) {
@@ -49,7 +49,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'nodep_Write_Read':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:     Run-time memory checks:
 
 define i32 @nodep_Write_Read(i32* nocapture %A) {
@@ -84,7 +84,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'nodep_Write_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:     Run-time memory checks:
 
 define void @nodep_Write_Write(i32* nocapture %A) {
@@ -118,7 +118,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'unsafe_Read_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:      Backward:
 ; CHECK-NEXT:           %0 = load i32, i32* %arrayidx, align 4 -> 
 ; CHECK-NEXT:           store i32 %add, i32* %arrayidx3, align 4
@@ -157,7 +157,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'unsafe_Write_Read':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:      Backward:
 ; CHECK-NEXT:           store i32 %0, i32* %arrayidx, align 4 ->
 ; CHECK-NEXT:           %1 = load i32, i32* %arrayidx2, align 4
@@ -193,7 +193,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'unsafe_Write_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:      Backward:
 ; CHECK-NEXT:           store i32 %0, i32* %arrayidx, align 4 ->
 ; CHECK-NEXT:           store i32 %2, i32* %arrayidx3, align 4
@@ -230,7 +230,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'vectorizable_Read_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       BackwardVectorizable:
 ; CHECK-NEXT:           %0 = load i32, i32* %arrayidx, align 4 ->
 ; CHECK-NEXT:           store i32 %add, i32* %arrayidx2, align 4
@@ -269,7 +269,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'vectorizable_Write_Read':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       BackwardVectorizable:
 ; CHECK-NEXT:           store i32 %0, i32* %arrayidx, align 4 ->
 ; CHECK-NEXT:           %1 = load i32, i32* %arrayidx2, align 4
@@ -307,7 +307,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'vectorizable_Write_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       BackwardVectorizable:
 ; CHECK-NEXT:           store i32 %0, i32* %arrayidx, align 4 -> 
 ; CHECK-NEXT:           store i32 %2, i32* %arrayidx2, align 4
@@ -346,7 +346,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'vectorizable_unscaled_Read_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       BackwardVectorizableButPreventsForwarding:
 ; CHECK-NEXT:           %2 = load i32, i32* %arrayidx, align 4 ->
 ; CHECK-NEXT:           store i32 %add, i32* %arrayidx2, align 4
@@ -387,7 +387,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: for function 'vectorizable_unscaled_Write_Read':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Memory dependences are safe
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       BackwardVectorizable:
 ; CHECK-NEXT:           store i32 %2, i32* %arrayidx, align 4 -> 
 ; CHECK-NEXT:           %3 = load i32, i32* %arrayidx2, align 4
@@ -425,7 +425,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'unsafe_unscaled_Read_Write':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       Backward:
 ; CHECK-NEXT:           %2 = load i32, i32* %arrayidx, align 4 -> 
 ; CHECK-NEXT:           store i32 %add, i32* %arrayidx2, align 4
@@ -455,7 +455,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'unsafe_unscaled_Read_Write2':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       Backward:
 ; CHECK-NEXT:           %2 = load i32, i32* %arrayidx, align 4 -> 
 ; CHECK-NEXT:           store i32 %add, i32* %arrayidx2, align 4
@@ -505,7 +505,7 @@ for.body:                                         ; preds = %entry, %for.body
 ; CHECK: function 'interleaved_stores':
 ; CHECK-NEXT:   for.body:
 ; CHECK-NEXT:     Report: unsafe dependent memory operations in loop
-; CHECK-NEXT:     Interesting Dependences:
+; CHECK-NEXT:     Dependences:
 ; CHECK-NEXT:       Backward:
 ; CHECK-NEXT:           store i32 %4, i32* %arrayidx5, align 4 -> 
 ; CHECK-NEXT:           store i32 %4, i32* %arrayidx9, align 4
index d0bed68188dbc2bd18d75fb57a6e7c39e6c4331a..d388151365f18a3d4a3d2f6ef070ebf2a2ad020c 100644 (file)
@@ -38,7 +38,7 @@ target triple = "x86_64-apple-macosx10.10.0"
 
 ; CHECK: for_j.body:
 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop
-; CHECK-NEXT: Interesting Dependences:
+; CHECK-NEXT: Dependences:
 ; CHECK-NEXT: Backward:
 ; CHECK-NEXT: %loadB = load i8, i8* %gepB, align 1 ->
 ; CHECK-NEXT: store i8 2, i8* %gepB_plus_one, align 1
index 237cbc8b98739ac7120c776772ab2b5600120add..7157b954c5b6d9580143bd77db19ac821fd870cf 100644 (file)
@@ -8,7 +8,7 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-apple-macosx10.10.0"
 
 ; CHECK: Report: unsafe dependent memory operations in loop
-; CHECK-NEXT: Interesting Dependences:
+; CHECK-NEXT: Dependences:
 ; CHECK-NEXT:   Backward:
 ; CHECK-NEXT:     %loadA = load i16, i16* %arrayidxA, align 2 ->
 ; CHECK-NEXT:     store i16 %mul1, i16* %arrayidxA_plus_2, align 2