1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes=mergeicmps -verify-dom-info | FileCheck %s
3 target triple = "x86_64"
5 ; First check that we try to from a memcmp.
6 define void @form_memcmp(ptr dereferenceable(16) %a, ptr dereferenceable(16) %b) {
7 ; CHECK-LABEL: @form_memcmp(
9 ; CHECK-NEXT: [[PTR_A1:%.*]] = getelementptr inbounds [2 x i64], ptr [[A:%.*]], i64 0, i64 1
10 ; CHECK-NEXT: [[PTR_B1:%.*]] = getelementptr inbounds [2 x i64], ptr [[B:%.*]], i64 0, i64 1
11 ; CHECK-NEXT: br label %"bb1+bb2"
13 ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(ptr [[A]], ptr [[B]], i64 16)
14 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[MEMCMP]], 0
15 ; CHECK-NEXT: br label [[BB3:%.*]]
17 ; CHECK-NEXT: ret void
20 %ptr_a1 = getelementptr inbounds [2 x i64], ptr %a, i64 0, i64 1
21 %ptr_b1 = getelementptr inbounds [2 x i64], ptr %b, i64 0, i64 1
25 %a0 = load i64, ptr %a
26 %b0 = load i64, ptr %b
27 %cond0 = icmp eq i64 %a0, %b0
28 br i1 %cond0, label %bb2, label %bb3
31 %a1 = load i64, ptr %ptr_a1
32 %b1 = load i64, ptr %ptr_b1
33 %cond1 = icmp eq i64 %a1, %b1
36 bb3: ; preds = %bb2, %bb1
37 %necessary = phi i1 [ %cond1, %bb2 ], [ false, %bb1 ]
41 ; We can't use memcmp between arbitrary addressesspaces
42 define void @no_memcmp(ptr addrspace(11) dereferenceable(16) %a, ptr addrspace(11) dereferenceable(16) %b) {
43 ; CHECK-LABEL: @no_memcmp(
45 ; CHECK-NEXT: [[PTR_A1:%.*]] = getelementptr inbounds [2 x i64], ptr addrspace(11) [[A:%.*]], i64 0, i64 1
46 ; CHECK-NEXT: [[PTR_B1:%.*]] = getelementptr inbounds [2 x i64], ptr addrspace(11) [[B:%.*]], i64 0, i64 1
47 ; CHECK-NEXT: br label [[BB1:%.*]]
49 ; CHECK-NEXT: [[A0:%.*]] = load i64, ptr addrspace(11) [[A]], align 8
50 ; CHECK-NEXT: [[B0:%.*]] = load i64, ptr addrspace(11) [[B]], align 8
51 ; CHECK-NEXT: [[COND0:%.*]] = icmp eq i64 [[A0]], [[B0]]
52 ; CHECK-NEXT: br i1 [[COND0]], label [[BB2:%.*]], label [[BB3:%.*]]
54 ; CHECK-NEXT: [[A1:%.*]] = load i64, ptr addrspace(11) [[PTR_A1]], align 8
55 ; CHECK-NEXT: [[B1:%.*]] = load i64, ptr addrspace(11) [[PTR_B1]], align 8
56 ; CHECK-NEXT: [[COND1:%.*]] = icmp eq i64 [[A1]], [[B1]]
57 ; CHECK-NEXT: br label [[BB3]]
59 ; CHECK-NEXT: [[NECESSARY:%.*]] = phi i1 [ [[COND1]], [[BB2]] ], [ false, [[BB1]] ]
60 ; CHECK-NEXT: ret void
63 %ptr_a1 = getelementptr inbounds [2 x i64], ptr addrspace(11) %a, i64 0, i64 1
64 %ptr_b1 = getelementptr inbounds [2 x i64], ptr addrspace(11) %b, i64 0, i64 1
68 %a0 = load i64, ptr addrspace(11) %a
69 %b0 = load i64, ptr addrspace(11) %b
70 %cond0 = icmp eq i64 %a0, %b0
71 br i1 %cond0, label %bb2, label %bb3
74 %a1 = load i64, ptr addrspace(11) %ptr_a1
75 %b1 = load i64, ptr addrspace(11) %ptr_b1
76 %cond1 = icmp eq i64 %a1, %b1
79 bb3: ; preds = %bb2, %bb1
80 %necessary = phi i1 [ %cond1, %bb2 ], [ false, %bb1 ]