1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mergeicmps -verify-dom-info -mtriple=x86_64-unknown-unknown -S | FileCheck %s
4 %S = type { i32, i32, i32, i32 }
6 ; The entry block is part of the chain. It however can not be merged. We need to
7 ; make sure that the control flow is still consistent (goes through each of the
10 define zeroext i1 @opeq1(
11 ; CHECK-LABEL: @opeq1(
12 ; CHECK-NEXT: "land.rhs.i+land.rhs.i.2":
13 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0
14 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0
15 ; CHECK-NEXT: [[CSTR:%.*]] = bitcast i32* [[TMP0]] to i8*
16 ; CHECK-NEXT: [[CSTR3:%.*]] = bitcast i32* [[TMP1]] to i8*
17 ; CHECK-NEXT: [[MEMCMP:%.*]] = call i32 @memcmp(i8* [[CSTR]], i8* [[CSTR3]], i64 8)
18 ; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[MEMCMP]], 0
19 ; CHECK-NEXT: br i1 [[TMP2]], label [[ENTRY2:%.*]], label [[OPEQ1_EXIT:%.*]]
21 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 3
22 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 2
23 ; CHECK-NEXT: [[TMP5:%.*]] = load i32, i32* [[TMP3]]
24 ; CHECK-NEXT: [[TMP6:%.*]] = load i32, i32* [[TMP4]]
25 ; CHECK-NEXT: [[TMP7:%.*]] = icmp eq i32 [[TMP5]], [[TMP6]]
26 ; CHECK-NEXT: br i1 [[TMP7]], label [[LAND_RHS_I_31:%.*]], label [[OPEQ1_EXIT]]
27 ; CHECK: land.rhs.i.31:
28 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 3
29 ; CHECK-NEXT: [[TMP9:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 3
30 ; CHECK-NEXT: [[TMP10:%.*]] = load i32, i32* [[TMP8]]
31 ; CHECK-NEXT: [[TMP11:%.*]] = load i32, i32* [[TMP9]]
32 ; CHECK-NEXT: [[TMP12:%.*]] = icmp eq i32 [[TMP10]], [[TMP11]]
33 ; CHECK-NEXT: br label [[OPEQ1_EXIT]]
35 ; CHECK-NEXT: [[TMP13:%.*]] = phi i1 [ [[TMP12]], [[LAND_RHS_I_31]] ], [ false, [[ENTRY2]] ], [ false, %"land.rhs.i+land.rhs.i.2" ]
36 ; CHECK-NEXT: ret i1 [[TMP13]]
38 %S* nocapture readonly dereferenceable(16) %a,
39 %S* nocapture readonly dereferenceable(16) %b) local_unnamed_addr #0 {
41 %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3
42 %0 = load i32, i32* %first.i, align 4
43 %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 2
44 %1 = load i32, i32* %first1.i, align 4
45 %cmp.i = icmp eq i32 %0, %1
46 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
49 %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0
50 %2 = load i32, i32* %second.i, align 4
51 %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0
52 %3 = load i32, i32* %second2.i, align 4
53 %cmp3.i = icmp eq i32 %2, %3
54 br i1 %cmp3.i, label %land.rhs.i.2, label %opeq1.exit
57 %third.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1
58 %4 = load i32, i32* %third.i, align 4
59 %third2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1
60 %5 = load i32, i32* %third2.i, align 4
61 %cmp4.i = icmp eq i32 %4, %5
62 br i1 %cmp4.i, label %land.rhs.i.3, label %opeq1.exit
65 %fourth.i = getelementptr inbounds %S, %S* %a, i64 0, i32 3
66 %6 = load i32, i32* %fourth.i, align 4
67 %fourth2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 3
68 %7 = load i32, i32* %fourth2.i, align 4
69 %cmp5.i = icmp eq i32 %6, %7
73 %8 = phi i1 [ false, %entry ], [ false, %land.rhs.i], [ false, %land.rhs.i.2 ], [ %cmp5.i, %land.rhs.i.3 ]