aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2011-07-31 04:43:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2011-07-31 04:43:41 +0000
commit592ad6a82facd7d7ee58c599767a1b0c85eda0c5 (patch)
tree8057dc0ca5d04025cf692adfaa7651053a423780 /test/Transforms
parentc47690264abd6ec6bdeab86ce057e99bb5d39fe4 (diff)
downloadexternal_llvm-592ad6a82facd7d7ee58c599767a1b0c85eda0c5.zip
external_llvm-592ad6a82facd7d7ee58c599767a1b0c85eda0c5.tar.gz
external_llvm-592ad6a82facd7d7ee58c599767a1b0c85eda0c5.tar.bz2
Add a small gep optimization I noticed was missing while reading some IL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136585 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/InstCombine/getelementptr.ll20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/getelementptr.ll b/test/Transforms/InstCombine/getelementptr.ll
index 26c0e47..1c120ec 100644
--- a/test/Transforms/InstCombine/getelementptr.ll
+++ b/test/Transforms/InstCombine/getelementptr.ll
@@ -472,3 +472,23 @@ entry:
; CHECK: @pr10322_f1
; CHECK: %tmp2 = getelementptr inbounds %pr10322_t* %arrayidx8, i64 0, i32 0
}
+
+; Test that we combine the last two geps in this sequence, before we
+; would wait for gep1 and gep2 to be combined and never combine 2 and 3.
+%three_gep_t = type {i32}
+%three_gep_t2 = type {%three_gep_t}
+
+define void @three_gep_f(%three_gep_t2* %x) {
+ %gep1 = getelementptr %three_gep_t2* %x, i64 2
+ call void @three_gep_h(%three_gep_t2* %gep1)
+ %gep2 = getelementptr %three_gep_t2* %gep1, i64 0, i32 0
+ %gep3 = getelementptr %three_gep_t* %gep2, i64 0, i32 0
+ call void @three_gep_g(i32* %gep3)
+
+; CHECK: @three_gep_f
+; CHECK: %gep3 = getelementptr %three_gep_t2* %gep1, i64 0, i32 0, i32 0
+ ret void
+}
+
+declare void @three_gep_g(i32*)
+declare void @three_gep_h(%three_gep_t2*)