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 }
6 ; Last block does not produce the non-constant value into the phi.
7 ; We could handle this case, but an easier way would be to allow other transformations such as
8 ; SimplifyCFG to remove %land.rhs.i.2 and turn the terminator of %land.rhs.i into an unconditional
11 define zeroext i1 @opeq1(
12 ; CHECK-LABEL: @opeq1(
14 ; CHECK-NEXT: [[FIRST_I:%.*]] = getelementptr inbounds [[S:%.*]], %S* [[A:%.*]], i64 0, i32 0
15 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, i32* [[FIRST_I]], align 4
16 ; CHECK-NEXT: [[FIRST1_I:%.*]] = getelementptr inbounds [[S]], %S* [[B:%.*]], i64 0, i32 0
17 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[FIRST1_I]], align 4
18 ; CHECK-NEXT: [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
19 ; CHECK-NEXT: br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]]
21 ; CHECK-NEXT: [[SECOND_I:%.*]] = getelementptr inbounds [[S]], %S* [[A]], i64 0, i32 1
22 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[SECOND_I]], align 4
23 ; CHECK-NEXT: [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], %S* [[B]], i64 0, i32 1
24 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, i32* [[SECOND2_I]], align 4
25 ; CHECK-NEXT: [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]]
26 ; CHECK-NEXT: br i1 [[CMP3_I]], label [[LAND_RHS_I_2:%.*]], label [[OPEQ1_EXIT]]
27 ; CHECK: land.rhs.i.2:
28 ; CHECK-NEXT: br label [[OPEQ1_EXIT]]
30 ; CHECK-NEXT: [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ false, [[LAND_RHS_I]] ], [ [[CMP3_I]], [[LAND_RHS_I_2]] ]
31 ; CHECK-NEXT: ret i1 [[TMP4]]
33 %S* nocapture readonly dereferenceable(12) %a,
34 %S* nocapture readonly dereferenceable(12) %b) local_unnamed_addr #0 {
36 %first.i = getelementptr inbounds %S, %S* %a, i64 0, i32 0
37 %0 = load i32, i32* %first.i, align 4
38 %first1.i = getelementptr inbounds %S, %S* %b, i64 0, i32 0
39 %1 = load i32, i32* %first1.i, align 4
40 %cmp.i = icmp eq i32 %0, %1
41 br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
44 %second.i = getelementptr inbounds %S, %S* %a, i64 0, i32 1
45 %2 = load i32, i32* %second.i, align 4
46 %second2.i = getelementptr inbounds %S, %S* %b, i64 0, i32 1
47 %3 = load i32, i32* %second2.i, align 4
48 %cmp3.i = icmp eq i32 %2, %3
49 br i1 %cmp3.i, label %land.rhs.i.2, label %opeq1.exit
55 %4 = phi i1 [ false, %entry ], [ false, %land.rhs.i], [ %cmp3.i, %land.rhs.i.2 ]