[llvm-commits] [llvm] r139277 - /llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp

Eli Friedman eli.friedman at gmail.com
Wed Sep 7 19:37:07 PDT 2011


Author: efriedma
Date: Wed Sep  7 21:37:07 2011
New Revision: 139277

URL: http://llvm.org/viewvc/llvm-project?rev=139277&view=rev
Log:
A couple minor corrections to r139276.


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

Modified: llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp?rev=139277&r1=139276&r2=139277&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/BasicAliasAnalysis.cpp Wed Sep  7 21:37:07 2011
@@ -977,20 +977,20 @@
 
   // Try to distinguish something like &A[i][1] against &A[42][0].
   // Grab the least significant bit set in any of the scales.
-  uint64_t Modulo = 0;
-  for (unsigned i = 0, e = GEP1VariableIndices.size();
-       i != e; ++i)
-    Modulo |= (uint64_t)GEP1VariableIndices[0].Scale;
-  Modulo = Modulo ^ (Modulo & (Modulo - 1));
-
-  // We can compute the difference between the two addresses
-  // mod Modulo. Check whether that difference guarantees that the
-  // two locations do not alias.
-  uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
-  if (V1Size != UnknownSize && V2Size != UnknownSize &&
-      ModOffset >= V2Size && V1Size <= Modulo - ModOffset)
-    return NoAlias;
-
+  if (!GEP1VariableIndices.empty()) {
+    uint64_t Modulo = 0;
+    for (unsigned i = 0, e = GEP1VariableIndices.size(); i != e; ++i)
+      Modulo |= (uint64_t)GEP1VariableIndices[i].Scale;
+    Modulo = Modulo ^ (Modulo & (Modulo - 1));
+
+    // We can compute the difference between the two addresses
+    // mod Modulo. Check whether that difference guarantees that the
+    // two locations do not alias.
+    uint64_t ModOffset = (uint64_t)GEP1BaseOffset & (Modulo - 1);
+    if (V1Size != UnknownSize && V2Size != UnknownSize &&
+        ModOffset >= V2Size && V1Size <= Modulo - ModOffset)
+      return NoAlias;
+  }
 
   // Statically, we can see that the base objects are the same, but the
   // pointers have dynamic offsets which we can't resolve. And none of our





More information about the llvm-commits mailing list