Relax LDA memory instruction checks.
authorAndreas Bolka <a@bolka.at>
Mon, 29 Jun 2009 18:51:11 +0000 (18:51 +0000)
committerAndreas Bolka <a@bolka.at>
Mon, 29 Jun 2009 18:51:11 +0000 (18:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74439 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/LoopDependenceAnalysis.cpp

index 779508dce41d79f15755fd59ad2bd0423cba35c4..020a8c77ccc221802b24d5ecc2a0623df1c2a462 100644 (file)
@@ -36,8 +36,9 @@ char LoopDependenceAnalysis::ID = 0;
 //                             Utility Functions
 //===----------------------------------------------------------------------===//
 
-static inline bool IsMemRefInstr(const Value *I) {
-  return isa<LoadInst>(I) || isa<StoreInst>(I);
+static inline bool IsMemRefInstr(const Value *V) {
+  const Instruction *I = dyn_cast<const Instruction>(V);
+  return I && (I->mayReadFromMemory() || I->mayWriteToMemory());
 }
 
 static void GetMemRefInstrs(
@@ -56,8 +57,10 @@ static void GetMemRefInstrs(
 
 bool LoopDependenceAnalysis::isDependencePair(const Value *x,
                                               const Value *y) const {
-  return IsMemRefInstr(x) && IsMemRefInstr(y)
-      && (isa<StoreInst>(x) || isa<StoreInst>(y));
+  return IsMemRefInstr(x) &&
+         IsMemRefInstr(y) &&
+         (cast<const Instruction>(x)->mayWriteToMemory() ||
+          cast<const Instruction>(y)->mayWriteToMemory());
 }
 
 bool LoopDependenceAnalysis::depends(Value *src, Value *dst) {