summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-06-02 17:26:12 +0000
committerWojciech Matyjewicz <wmatyjewicz@fastmail.fm>2008-06-02 17:26:12 +0000
commit416867a81b07816f151ff1cdbf5570db1add3513 (patch)
tree771fed7e1f32225be080752ea67ab971da2bedba /llvm/lib/Analysis
parent0b6b0e7157d35b565d2840c94a816c18c9036d0d (diff)
downloadbcm5719-llvm-416867a81b07816f151ff1cdbf5570db1add3513.tar.gz
bcm5719-llvm-416867a81b07816f151ff1cdbf5570db1add3513.zip
Fixes PR2395. Looking for a constant in a GEP tail (when the first GEP
is longer than the second one) should stop after finding one. Added break instruction guarantees it. It also changes difference between offsets to absolute value of this difference in the condition. llvm-svn: 51875
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 21108c64535..599a6f650fd 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -687,7 +687,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
if (isa<ConstantInt>(GEP1Ops[i]) &&
!cast<ConstantInt>(GEP1Ops[i])->isZero()) {
// Yup, there's a constant in the tail. Set all variables to
- // constants in the GEP instruction to make it suiteable for
+ // constants in the GEP instruction to make it suitable for
// TargetData::getIndexedOffset.
for (i = 0; i != MaxOperands; ++i)
if (!isa<ConstantInt>(GEP1Ops[i]))
@@ -702,9 +702,15 @@ BasicAliasAnalysis::CheckGEPInstructions(
int64_t Offset2 = TD.getIndexedOffset(GEPPointerTy, GEP1Ops,
MinOperands);
+ // Make sure we compare the absolute difference.
+ if (Offset1 > Offset2)
+ std::swap(Offset1, Offset2);
+
// If the tail provided a bit enough offset, return noalias!
if ((uint64_t)(Offset2-Offset1) >= SizeMax)
return NoAlias;
+ // Otherwise break - we don't look for another constant in the tail.
+ break;
}
}
OpenPOWER on IntegriCloud