aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/InstSimplify/compare.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/InstSimplify/compare.ll')
-rw-r--r--test/Transforms/InstSimplify/compare.ll22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Transforms/InstSimplify/compare.ll b/test/Transforms/InstSimplify/compare.ll
index 0957949..abb3869 100644
--- a/test/Transforms/InstSimplify/compare.ll
+++ b/test/Transforms/InstSimplify/compare.ll
@@ -717,3 +717,25 @@ define i1 @alloca_gep(i64 %a, i64 %b) {
ret i1 %cmp
; CHECK-NEXT: ret i1 false
}
+
+define i1 @non_inbounds_gep_compare(i64* %a) {
+; CHECK-LABEL: @non_inbounds_gep_compare(
+; Equality compares with non-inbounds GEPs can be folded.
+ %x = getelementptr i64* %a, i64 42
+ %y = getelementptr inbounds i64* %x, i64 -42
+ %z = getelementptr i64* %a, i64 -42
+ %w = getelementptr inbounds i64* %z, i64 42
+ %cmp = icmp eq i64* %y, %w
+ ret i1 %cmp
+; CHECK-NEXT: ret i1 true
+}
+
+define i1 @non_inbounds_gep_compare2(i64* %a) {
+; CHECK-LABEL: @non_inbounds_gep_compare2(
+; Equality compares with non-inbounds GEPs can be folded.
+ %x = getelementptr i64* %a, i64 4294967297
+ %y = getelementptr i64* %a, i64 1
+ %cmp = icmp eq i64* %y, %y
+ ret i1 %cmp
+; CHECK-NEXT: ret i1 true
+}