summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-08-18 04:28:19 +0000
committerChris Lattner <sabre@nondot.org>2010-08-18 04:28:19 +0000
commita33edcb56cda48684292f890cf40de5c56189815 (patch)
tree2f0ce629b010377ddbbcadccd4eb6193c22457b5
parentbc80329f1f674ee93134d6205b61a692e3a158bf (diff)
downloadbcm5719-llvm-a33edcb56cda48684292f890cf40de5c56189815.tar.gz
bcm5719-llvm-a33edcb56cda48684292f890cf40de5c56189815.zip
fix PR7589: In brief:
gep P, (zext x) != gep P, (sext x) DecomposeGEPExpression was getting this wrong, confusing basicaa. llvm-svn: 111352
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp6
-rw-r--r--llvm/test/Analysis/BasicAA/featuretest.ll21
2 files changed, 24 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index b4c9884a20e..cf20e07040a 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -1018,9 +1018,9 @@ static Value *GetLinearExpression(Value *V, APInt &Scale, APInt &Offset,
}
}
- // Since clients don't care about the high bits of the value, just scales and
- // offsets, we can look through extensions.
- if (isa<SExtInst>(V) || isa<ZExtInst>(V)) {
+ // Since GEP indices are sign extended anyway, we don't care about the high
+ // bits of a sign extended value - just scales and offsets.
+ if (isa<SExtInst>(V)) {
Value *CastOp = cast<CastInst>(V)->getOperand(0);
unsigned OldWidth = Scale.getBitWidth();
unsigned SmallWidth = CastOp->getType()->getPrimitiveSizeInBits();
diff --git a/llvm/test/Analysis/BasicAA/featuretest.ll b/llvm/test/Analysis/BasicAA/featuretest.ll
index ce71e9af955..47d278fab1c 100644
--- a/llvm/test/Analysis/BasicAA/featuretest.ll
+++ b/llvm/test/Analysis/BasicAA/featuretest.ll
@@ -104,3 +104,24 @@ define i32 @constexpr_test() {
; CHECK: @constexpr_test
; CHECK: ret i32 0
}
+
+
+
+; PR7589
+; These two index expressions are different, this cannot be CSE'd.
+define i16 @zext_sext_confusion(i16* %row2col, i5 %j) nounwind{
+entry:
+ %sum5.cast = zext i5 %j to i64 ; <i64> [#uses=1]
+ %P1 = getelementptr i16* %row2col, i64 %sum5.cast
+ %row2col.load.1.2 = load i16* %P1, align 1 ; <i16> [#uses=1]
+
+ %sum13.cast31 = sext i5 %j to i6 ; <i6> [#uses=1]
+ %sum13.cast = zext i6 %sum13.cast31 to i64 ; <i64> [#uses=1]
+ %P2 = getelementptr i16* %row2col, i64 %sum13.cast
+ %row2col.load.1.6 = load i16* %P2, align 1 ; <i16> [#uses=1]
+
+ %.ret = sub i16 %row2col.load.1.6, %row2col.load.1.2 ; <i16> [#uses=1]
+ ret i16 %.ret
+; CHECK: @zext_sext_confusion
+; CHECK: ret i16 %.ret
+}
OpenPOWER on IntegriCloud