1 ; RUN: opt -passes=mergefunc -S < %s | FileCheck %s
2 define i1 @cmp_with_range(ptr, ptr) {
3 %v1 = load i8, ptr %0, !range !0
4 %v2 = load i8, ptr %1, !range !0
5 %out = icmp eq i8 %v1, %v2
9 define i1 @cmp_no_range(ptr, ptr) {
10 ; CHECK-LABEL: @cmp_no_range
11 ; CHECK-NEXT: %v1 = load i8, ptr %0
12 ; CHECK-NEXT: %v2 = load i8, ptr %1
13 ; CHECK-NEXT: %out = icmp eq i8 %v1, %v2
14 ; CHECK-NEXT: ret i1 %out
17 %out = icmp eq i8 %v1, %v2
21 define i1 @cmp_different_range(ptr, ptr) {
22 ; CHECK-LABEL: @cmp_different_range
23 ; CHECK-NEXT: %v1 = load i8, ptr %0, align 1, !range !1
24 ; CHECK-NEXT: %v2 = load i8, ptr %1, align 1, !range !1
25 ; CHECK-NEXT: %out = icmp eq i8 %v1, %v2
26 ; CHECK-NEXT: ret i1 %out
27 %v1 = load i8, ptr %0, !range !1
28 %v2 = load i8, ptr %1, !range !1
29 %out = icmp eq i8 %v1, %v2
33 define i1 @cmp_with_same_range(ptr, ptr) {
34 ; CHECK-LABEL: @cmp_with_same_range
35 ; CHECK: tail call i1 @cmp_with_range
36 %v1 = load i8, ptr %0, !range !0
37 %v2 = load i8, ptr %1, !range !0
38 %out = icmp eq i8 %v1, %v2
42 ; The comparison must check every element of the range, not just the first pair.
43 !0 = !{i8 0, i8 2, i8 21, i8 30}
44 !1 = !{i8 0, i8 2, i8 21, i8 25}