[llvm-commits] CVS: llvm/lib/Analysis/AliasAnalysis.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 9 13:39:01 PST 2003


Changes in directory llvm/lib/Analysis:

AliasAnalysis.cpp updated: 1.9 -> 1.10

---
Log message:

Implement knowledge in BasicAA that &A->field != &A and (P+1) != P


---
Diffs of the changes:

Index: llvm/lib/Analysis/AliasAnalysis.cpp
diff -u llvm/lib/Analysis/AliasAnalysis.cpp:1.9 llvm/lib/Analysis/AliasAnalysis.cpp:1.10
--- llvm/lib/Analysis/AliasAnalysis.cpp:1.9	Sun Feb  9 13:27:21 2003
+++ llvm/lib/Analysis/AliasAnalysis.cpp	Sun Feb  9 13:38:11 2003
@@ -220,5 +220,22 @@
     return NoAlias;                    // Unique values don't alias null
   }
 
+  // Check to see if these two pointers are related by a getelementptr
+  // instruction.  If one pointer is a GEP with a non-zero index of the other
+  // pointer, we know they cannot alias.
+  //
+  if (isa<GetElementPtrInst>(V2))
+    std::swap(V1, V2);
+
+  if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V1))
+    if (GEP->getOperand(0) == V2) {
+      // If there is at least one non-zero constant index, we know they cannot
+      // alias.
+      for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i)
+        if (const Constant *C = dyn_cast<Constant>(GEP->getOperand(i)))
+          if (!C->isNullValue())
+            return NoAlias;
+    }
+
   return MayAlias;
 }





More information about the llvm-commits mailing list