2 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt < %s -passes=mergeicmps -verify-dom-info -mtriple=x86_64-unknown-unknown -S | FileCheck %s
5 ; This is a more involved test: clang generates this weird pattern for
6 ; tuple<uint8_t, uint8_t, uint8_t, uint8_t>. Right now we skip the entry block
7 ; (which defines the base pointer for other blocks) and the last one (which
8 ; does not have the expected structure). Only middle blocks (bytes [1,2]) are
11 %"class.std::tuple" = type { %"struct.std::_Tuple_impl" }
12 %"struct.std::_Tuple_impl" = type { %"struct.std::_Tuple_impl.0", %"struct.std::_Head_base.6" }
13 %"struct.std::_Tuple_impl.0" = type { %"struct.std::_Tuple_impl.1", %"struct.std::_Head_base.5" }
14 %"struct.std::_Tuple_impl.1" = type { %"struct.std::_Tuple_impl.2", %"struct.std::_Head_base.4" }
15 %"struct.std::_Tuple_impl.2" = type { %"struct.std::_Head_base" }
16 %"struct.std::_Head_base" = type { i8 }
17 %"struct.std::_Head_base.4" = type { i8 }
18 %"struct.std::_Head_base.5" = type { i8 }
19 %"struct.std::_Head_base.6" = type { i8 }
21 define zeroext i1 @opeq(
24 ; These 2 instructions are split. Then we can merge 3 bytes, instead of 2.
25 ; CHECK: br label [[LAND_ELEM0:%.*]]
27 ; CHECK-NEXT: [[A_ELEM1_ADDR:%.*]] = getelementptr inbounds i8, ptr %a.base, i64 1
28 ; CHECK-NEXT: [[B_ELEM1_ADDR:%.*]] = getelementptr inbounds i8, ptr %b.base, i64 1
29 ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(ptr [[A_ELEM1_ADDR]], ptr [[B_ELEM1_ADDR]], i64 3)
30 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[MEMCMP]], 0
31 ; CHECK-NEXT: br label [[OPEQ_EXIT:%.*]]
33 ; CHECK-NEXT: [[TMP3:%.*]] = load i8, ptr [[A:%.*]], align 1
34 ; CHECK-NEXT: [[TMP4:%.*]] = load i8, ptr [[B:%.*]], align 1
35 ; CHECK-NEXT: [[CMP_ELEM0:%.*]] = icmp eq i8 [[TMP3]], [[TMP4]]
36 ; CHECK-NEXT: br i1 [[CMP_ELEM0]], label [[LAND_ELEM1:%.*]], label [[OPEQ_EXIT]]
38 ; CHECK-NEXT: [[TMP5:%.*]] = phi i1 [ [[CMP_ELEM0]], [[LAND_ELEM0]] ], [ [[TMP2]], [[LAND_ELEM1]] ]
39 ; CHECK-NEXT: ret i1 [[TMP5]]
41 ptr nocapture readonly dereferenceable(4) %a,
42 ptr nocapture readonly dereferenceable(4) %b) local_unnamed_addr #1 {
44 %a.elem3.addr = getelementptr inbounds i8, ptr %a, i64 3
45 %0 = load i8, ptr %a.elem3.addr, align 1
46 %b.elem3.addr = getelementptr inbounds i8, ptr %b, i64 3
47 %1 = load i8, ptr %b.elem3.addr, align 1
48 %cmp.elem3 = icmp eq i8 %0, %1
49 br i1 %cmp.elem3, label %land.elem2, label %opeq.exit
52 %a.elem2.addr = getelementptr inbounds i8, ptr %a, i64 2
53 %2 = load i8, ptr %a.elem2.addr, align 1
54 %b.elem2.addr = getelementptr inbounds i8, ptr %b, i64 2
55 %3 = load i8, ptr %b.elem2.addr, align 1
56 %cmp.elem2 = icmp eq i8 %2, %3
57 br i1 %cmp.elem2, label %land.elem1, label %opeq.exit
60 %a.elem1.addr = getelementptr inbounds i8, ptr %a, i64 1
61 %4 = load i8, ptr %a.elem1.addr, align 1
62 %b.elem1.addr = getelementptr inbounds i8, ptr %b, i64 1
63 %5 = load i8, ptr %b.elem1.addr, align 1
64 %cmp.elem1 = icmp eq i8 %4, %5
65 br i1 %cmp.elem1, label %land.elem0, label %opeq.exit
68 %6 = load i8, ptr %a, align 1
69 %7 = load i8, ptr %b, align 1
70 %cmp.elem0 = icmp eq i8 %6, %7
74 %8 = phi i1 [ false, %entry ], [ false, %land.elem2 ], [ false, %land.elem1 ], [ %cmp.elem0, %land.elem0 ]