xref: /llvm-project/llvm/test/Transforms/MergeICmps/X86/last-block-produce-no-value.ll (revision 9a3e39996320793ec5fe5c6bb4873f82cbc1bbf3)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -passes=mergeicmps -verify-dom-info -mtriple=x86_64-unknown-unknown -S | FileCheck %s
3
4%S = type { i32, i32, i32 }
5
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
9; branch.
10
11define zeroext i1 @opeq1(
12; CHECK-LABEL: @opeq1(
13; CHECK-NEXT:  entry:
14; CHECK-NEXT:    [[TMP0:%.*]] = load i32, ptr [[A:%.*]], align 4
15; CHECK-NEXT:    [[TMP1:%.*]] = load i32, ptr [[B:%.*]], align 4
16; CHECK-NEXT:    [[CMP_I:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
17; CHECK-NEXT:    br i1 [[CMP_I]], label [[LAND_RHS_I:%.*]], label [[OPEQ1_EXIT:%.*]]
18; CHECK:       land.rhs.i:
19; CHECK-NEXT:    [[SECOND_I:%.*]] = getelementptr inbounds [[S:%.*]], ptr [[A]], i64 0, i32 1
20; CHECK-NEXT:    [[TMP2:%.*]] = load i32, ptr [[SECOND_I]], align 4
21; CHECK-NEXT:    [[SECOND2_I:%.*]] = getelementptr inbounds [[S]], ptr [[B]], i64 0, i32 1
22; CHECK-NEXT:    [[TMP3:%.*]] = load i32, ptr [[SECOND2_I]], align 4
23; CHECK-NEXT:    [[CMP3_I:%.*]] = icmp eq i32 [[TMP2]], [[TMP3]]
24; CHECK-NEXT:    br i1 [[CMP3_I]], label [[LAND_RHS_I_2:%.*]], label [[OPEQ1_EXIT]]
25; CHECK:       land.rhs.i.2:
26; CHECK-NEXT:    br label [[OPEQ1_EXIT]]
27; CHECK:       opeq1.exit:
28; CHECK-NEXT:    [[TMP4:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ false, [[LAND_RHS_I]] ], [ [[CMP3_I]], [[LAND_RHS_I_2]] ]
29; CHECK-NEXT:    ret i1 [[TMP4]]
30;
31  ptr nocapture readonly dereferenceable(12) %a,
32  ptr nocapture readonly dereferenceable(12) %b) local_unnamed_addr #0 {
33entry:
34  %0 = load i32, ptr %a, align 4
35  %1 = load i32, ptr %b, align 4
36  %cmp.i = icmp eq i32 %0, %1
37  br i1 %cmp.i, label %land.rhs.i, label %opeq1.exit
38
39land.rhs.i:
40  %second.i = getelementptr inbounds %S, ptr %a, i64 0, i32 1
41  %2 = load i32, ptr %second.i, align 4
42  %second2.i = getelementptr inbounds %S, ptr %b, i64 0, i32 1
43  %3 = load i32, ptr %second2.i, align 4
44  %cmp3.i = icmp eq i32 %2, %3
45  br i1 %cmp3.i, label %land.rhs.i.2, label %opeq1.exit
46
47land.rhs.i.2:
48  br label %opeq1.exit
49
50opeq1.exit:
51  %4 = phi i1 [ false, %entry ], [ false,  %land.rhs.i], [ %cmp3.i, %land.rhs.i.2 ]
52  ret i1 %4
53}
54