xref: /llvm-project/llvm/test/Transforms/MergeICmps/pair-int32-int32.ll (revision 9a3e39996320793ec5fe5c6bb4873f82cbc1bbf3)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=mergeicmps -S | FileCheck %s --check-prefix=NOEXPANSION
3
4%"struct.std::pair" = type { i32, i32 }
5
6define zeroext i1 @opeq1(
7; NOEXPANSION-LABEL: @opeq1(
8; NOEXPANSION-NEXT:  entry:
9; NOEXPANSION-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A:%.*]], align 4
10; NOEXPANSION-NEXT:    [[TMP1:%.*]] = load i32, ptr [[B:%.*]], align 4
11; NOEXPANSION-NEXT:    [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
12; NOEXPANSION-NEXT:    br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]]
13; NOEXPANSION:       land.rhs.i:
14; NOEXPANSION-NEXT:    [[SECOND_I:%.*]] = getelementptr inbounds %"struct.std::pair", ptr [[A]], i64 0, i32 1
15; NOEXPANSION-NEXT:    [[TMP2:%.*]] = load i32, ptr [[SECOND_I]], align 4
16; NOEXPANSION-NEXT:    [[SECOND2_I:%.*]] = getelementptr inbounds %"struct.std::pair", ptr [[B]], i64 0, i32 1
17; NOEXPANSION-NEXT:    [[TMP3:%.*]] = load i32, ptr [[SECOND2_I]], align 4
18; NOEXPANSION-NEXT:    [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]]
19; NOEXPANSION-NEXT:    br label [[OPEQ1_EXIT]]
20; NOEXPANSION:       opeq1.exit:
21; NOEXPANSION-NEXT:    [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ]
22; NOEXPANSION-NEXT:    ret i1 [[TMP4]]
23;
24  ptr nocapture readonly dereferenceable(8) %a,
25  ptr nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 {
26entry:
27  %0 = load i32, ptr %a, align 4
28  %1 = load i32, ptr %b, align 4
29  %cmp.i = icmp eq i32 %0, %1
30  br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
31
32land.rhs.i:
33  %second.i = getelementptr inbounds %"struct.std::pair", ptr %a, i64 0, i32 1
34  %2 = load i32, ptr %second.i, align 4
35  %second2.i = getelementptr inbounds %"struct.std::pair", ptr %b, i64 0, i32 1
36  %3 = load i32, ptr %second2.i, align 4
37  %cmp3.i = icmp eq i32 %2, %3
38  br label %opeq1.exit
39
40opeq1.exit:
41  %4 = phi i1 [ false, %entry ], [ %cmp3.i, %land.rhs.i ]
42  ret i1 %4
43}
44
45; Same as above, but the two blocks are in inverse order.
46define zeroext i1 @opeq1_inverse(
47; NOEXPANSION-LABEL: @opeq1_inverse(
48; NOEXPANSION-NEXT:  entry:
49; NOEXPANSION-NEXT:    [[FIRST_I:%.*]] = getelementptr inbounds %"struct.std::pair", ptr [[A:%.*]], i64 0, i32 1
50; NOEXPANSION-NEXT:    [[TMP0:%.*]] = load i32, ptr [[FIRST_I]], align 4
51; NOEXPANSION-NEXT:    [[FIRST1_I:%.*]] = getelementptr inbounds %"struct.std::pair", ptr [[B:%.*]], i64 0, i32 1
52; NOEXPANSION-NEXT:    [[TMP1:%.*]] = load i32, ptr [[FIRST1_I]], align 4
53; NOEXPANSION-NEXT:    [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
54; NOEXPANSION-NEXT:    br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]]
55; NOEXPANSION:       land.rhs.i:
56; NOEXPANSION-NEXT:    [[TMP2:%.*]] = load i32, ptr [[A]], align 4
57; NOEXPANSION-NEXT:    [[TMP3:%.*]] = load i32, ptr [[B]], align 4
58; NOEXPANSION-NEXT:    [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]]
59; NOEXPANSION-NEXT:    br label [[OPEQ1_EXIT]]
60; NOEXPANSION:       opeq1.exit:
61; NOEXPANSION-NEXT:    [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[CMP3_I]], [[LAND_RHS_I]] ]
62; NOEXPANSION-NEXT:    ret i1 [[TMP4]]
63;
64  ptr nocapture readonly dereferenceable(8) %a,
65  ptr nocapture readonly dereferenceable(8) %b) local_unnamed_addr #0 {
66entry:
67  %first.i = getelementptr inbounds %"struct.std::pair", ptr %a, i64 0, i32 1
68  %0 = load i32, ptr %first.i, align 4
69  %first1.i = getelementptr inbounds %"struct.std::pair", ptr %b, i64 0, i32 1
70  %1 = load i32, ptr %first1.i, align 4
71  %cmp.i = icmp eq i32 %0, %1
72  br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
73
74land.rhs.i:
75  %2 = load i32, ptr %a, align 4
76  %3 = load i32, ptr %b, align 4
77  %cmp3.i = icmp eq i32 %2, %3
78  br label %opeq1.exit
79
80opeq1.exit:
81  %4 = phi i1 [ false, %entry ], [ %cmp3.i, %land.rhs.i ]
82  ret i1 %4
83}
84
85
86
87