1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=loop-fusion < %s | FileCheck %s
3 ; RUN: opt -S -passes=loop-fusion -pass-remarks-output=%t < %s
4 ; RUN: FileCheck --input-file=%t %s --check-prefix REMARKS
7 define dso_local void @pr48060(i1 %cond) {
8 ; CHECK-LABEL: @pr48060(
10 ; CHECK-NEXT: br label [[FOR_1_PH:%.*]]
12 ; CHECK-NEXT: br label [[FOR_1:%.*]]
14 ; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[FOR_1_PH]] ], [ [[I_NEXT:%.*]], [[FOR_1]] ]
15 ; CHECK-NEXT: [[I_NEXT]] = add i32 [[I]], 1
16 ; CHECK-NEXT: [[COND_1:%.*]] = icmp eq i32 [[I_NEXT]], 10
17 ; CHECK-NEXT: br i1 [[COND_1]], label [[FOR_1_EXIT:%.*]], label [[FOR_1]]
19 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[END:%.*]], label [[FOR_2_PH:%.*]]
21 ; CHECK-NEXT: br label [[FOR_2:%.*]]
23 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ 0, [[FOR_2_PH]] ], [ [[J_NEXT:%.*]], [[FOR_2]] ]
24 ; CHECK-NEXT: [[J_NEXT]] = add i32 [[J]], 1
25 ; CHECK-NEXT: [[COND_2:%.*]] = icmp eq i32 [[J_NEXT]], 10
26 ; CHECK-NEXT: br i1 [[COND_2]], label [[FOR_2_EXIT:%.*]], label [[FOR_2]]
28 ; CHECK-NEXT: br label [[END]]
30 ; CHECK-NEXT: ret void
33 ; REMARKS: --- !Missed
34 ; REMARKS-NEXT: Pass: loop-fusion
35 ; REMARKS-NEXT: Name: OnlySecondCandidateIsGuarded
36 ; REMARKS-NEXT: Function: pr48060
38 ; REMARKS: - Cand1: for.1.ph
39 ; REMARKS: - Cand2: for.2.ph
40 ; REMARKS: - String: The second candidate is guarded while the first one is not
44 for.1.ph: ; preds = %entry
47 for.1: ; preds = %for.1, %for.1.ph
48 %i = phi i32 [ 0, %for.1.ph ], [ %i.next, %for.1 ]
49 %i.next = add i32 %i, 1
50 %cond.1 = icmp eq i32 %i.next, 10
51 br i1 %cond.1, label %for.1.exit, label %for.1
53 for.1.exit: ; preds = %for.1
54 br i1 %cond, label %end, label %for.2.ph
56 for.2.ph: ; preds = %for.1.exit
59 for.2: ; preds = %for.2, %for.2.ph
60 %j = phi i32 [ 0, %for.2.ph ], [ %j.next, %for.2 ]
61 %j.next = add i32 %j, 1
62 %cond.2 = icmp eq i32 %j.next, 10
63 br i1 %cond.2, label %for.2.exit, label %for.2
65 for.2.exit: ; preds = %for.2
68 end: ; preds = %for.1.exit, %for.2.exit