aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-01-01 22:42:29 +0000
committerChris Lattner <sabre@nondot.org>2010-01-01 22:42:29 +0000
commit85c1c964dc5b73085f2b2dce1cfc171fa9b765e2 (patch)
treec4335ee741506654a5e7d0dcc8148f8d7402930f /test/Transforms
parentf2ebc682d1ee008782d44261f28e92bf982790c2 (diff)
downloadexternal_llvm-85c1c964dc5b73085f2b2dce1cfc171fa9b765e2.zip
external_llvm-85c1c964dc5b73085f2b2dce1cfc171fa9b765e2.tar.gz
external_llvm-85c1c964dc5b73085f2b2dce1cfc171fa9b765e2.tar.bz2
generalize the pointer difference optimization to handle
a constantexpr gep on the 'base' side of the expression. This completes comment #4 in PR3351, which comes from 483.xalancbmk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/sub.ll13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/sub.ll b/test/Transforms/InstCombine/sub.ll
index 85ee64e..f8f7c44 100644
--- a/test/Transforms/InstCombine/sub.ll
+++ b/test/Transforms/InstCombine/sub.ll
@@ -260,3 +260,16 @@ define i64 @test24b(i8* %P, i64 %A){
; CHECK-NEXT: ret i64
}
+
+define i64 @test25(i8* %P, i64 %A){
+ %B = getelementptr inbounds [42 x i16]* @Arr, i64 0, i64 %A
+ %C = ptrtoint i16* %B to i64
+ %G = sub i64 %C, ptrtoint (i16* getelementptr ([42 x i16]* @Arr, i64 1, i64 0) to i64)
+ ret i64 %G
+; CHECK: @test25
+; CHECK-NEXT: shl i64 %A, 1
+; CHECK-NEXT: add i64 {{.*}}, -84
+; CHECK-NEXT: ret i64
+}
+
+