-; RUN: opt < %s -loop-unroll -S | FileCheck %s
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -loop-unroll -verify-loop-lcssa -S | FileCheck %s
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
; This test shows how unrolling an inner loop could break LCSSA for an outer
; phis for definitions in L2 should now be placed there. In particular, we need
; to insert such a definition for %y1.
-; CHECK-LABEL: @foo1
define void @foo1() {
+; CHECK-LABEL: @foo1(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[L1_HEADER:%.*]]
+; CHECK: L1_header:
+; CHECK-NEXT: br label [[L2_HEADER:%.*]]
+; CHECK: L2_header:
+; CHECK-NEXT: [[Y1:%.*]] = phi i64 [ undef, [[L1_HEADER]] ], [ [[X_LCSSA:%.*]], [[L2_LATCH:%.*]] ]
+; CHECK-NEXT: br label [[L3_HEADER:%.*]]
+; CHECK: L3_header:
+; CHECK-NEXT: br i1 true, label [[L2_LATCH]], label [[L3_BODY:%.*]]
+; CHECK: L2_latch:
+; CHECK-NEXT: [[X_LCSSA]] = phi i64 [ undef, [[L3_HEADER]] ]
+; CHECK-NEXT: br label [[L2_HEADER]]
+; CHECK: L3_body:
+; CHECK-NEXT: [[Y1_LCSSA:%.*]] = phi i64 [ [[Y1]], [[L3_HEADER]] ]
+; CHECK-NEXT: store i64 [[Y1_LCSSA]], i64* undef, align 8
+; CHECK-NEXT: br i1 false, label [[L3_LATCH:%.*]], label [[L1_LATCH:%.*]]
+; CHECK: L3_latch:
+; CHECK-NEXT: ret void
+; CHECK: L1_latch:
+; CHECK-NEXT: [[Y_LCSSA:%.*]] = phi i64 [ [[Y1_LCSSA]], [[L3_BODY]] ]
+; CHECK-NEXT: br label [[L1_HEADER]]
+;
entry:
br label %L1_header
%x.lcssa = phi i64 [ %x, %L3_header ]
br label %L2_header
-; CHECK: L3_body:
-; CHECK-NEXT: %y1.lcssa = phi i64 [ %y1, %L3_header ]
L3_body:
store i64 %y1, i64* undef
br i1 false, label %L3_latch, label %L1_latch
}
; Additional tests for some corner cases.
-;
-; CHECK-LABEL: @foo2
define void @foo2() {
+; CHECK-LABEL: @foo2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[L1_HEADER:%.*]]
+; CHECK: L1_header:
+; CHECK-NEXT: br label [[L2_HEADER:%.*]]
+; CHECK: L2_header.loopexit:
+; CHECK-NEXT: [[DEC_US_LCSSA:%.*]] = phi i64 [ undef, [[L3_HEADER:%.*]] ]
+; CHECK-NEXT: br label [[L2_HEADER]]
+; CHECK: L2_header:
+; CHECK-NEXT: [[A:%.*]] = phi i64 [ undef, [[L1_HEADER]] ], [ [[DEC_US_LCSSA]], [[L2_HEADER_LOOPEXIT:%.*]] ]
+; CHECK-NEXT: br label [[L3_HEADER]]
+; CHECK: L3_header:
+; CHECK-NEXT: br i1 true, label [[L2_HEADER_LOOPEXIT]], label [[L3_BREAK_TO_L1:%.*]]
+; CHECK: L3_break_to_L1:
+; CHECK-NEXT: [[A_LCSSA:%.*]] = phi i64 [ [[A]], [[L3_HEADER]] ]
+; CHECK-NEXT: br i1 false, label [[L3_LATCH:%.*]], label [[L1_LATCH:%.*]]
+; CHECK: L1_latch:
+; CHECK-NEXT: [[B_LCSSA:%.*]] = phi i64 [ [[A_LCSSA]], [[L3_BREAK_TO_L1]] ]
+; CHECK-NEXT: br label [[L1_HEADER]]
+; CHECK: L3_latch:
+; CHECK-NEXT: ret void
+;
entry:
br label %L1_header
%dec_us = add i64 undef, -1
br i1 true, label %L2_header, label %L3_break_to_L1
-; CHECK: L3_break_to_L1:
-; CHECK-NEXT: %a.lcssa = phi i64 [ %a, %L3_header ]
L3_break_to_L1:
br i1 false, label %L3_latch, label %L1_latch
ret void
}
-; CHECK-LABEL: @foo3
define void @foo3() {
+; CHECK-LABEL: @foo3(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[L1_HEADER:%.*]]
+; CHECK: L1_header:
+; CHECK-NEXT: [[A:%.*]] = phi i8* [ [[B:%.*]], [[L1_LATCH:%.*]] ], [ null, [[ENTRY:%.*]] ]
+; CHECK-NEXT: br i1 undef, label [[L2_HEADER_PREHEADER:%.*]], label [[L1_LATCH]]
+; CHECK: L2_header.preheader:
+; CHECK-NEXT: br label [[L2_HEADER:%.*]]
+; CHECK: L2_header:
+; CHECK-NEXT: br i1 false, label [[L2_LATCH:%.*]], label [[L1_LATCH_LOOPEXIT:%.*]]
+; CHECK: L2_latch:
+; CHECK-NEXT: [[A_LCSSA:%.*]] = phi i8* [ [[A]], [[L2_HEADER]] ]
+; CHECK-NEXT: br label [[EXIT:%.*]]
+; CHECK: L1_latch.loopexit:
+; CHECK-NEXT: br label [[L1_LATCH]]
+; CHECK: L1_latch:
+; CHECK-NEXT: [[B]] = phi i8* [ undef, [[L1_HEADER]] ], [ null, [[L1_LATCH_LOOPEXIT]] ]
+; CHECK-NEXT: br label [[L1_HEADER]]
+; CHECK: Exit:
+; CHECK-NEXT: [[A_LCSSA2:%.*]] = phi i8* [ [[A_LCSSA]], [[L2_LATCH]] ]
+; CHECK-NEXT: ret void
+;
entry:
br label %L1_header
L2_header:
br i1 undef, label %L2_latch, label %L1_latch
-; CHECK: L2_latch:
-; CHECK-NEXT: %a.lcssa = phi i8* [ %a, %L2_header ]
L2_latch:
br i1 true, label %L2_exit, label %L2_header
}
; PR26688
-; CHECK-LABEL: @foo4
define i8 @foo4() {
+; CHECK-LABEL: @foo4(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[L1_HEADER:%.*]]
+; CHECK: L1_header:
+; CHECK-NEXT: br label [[L2_HEADER:%.*]]
+; CHECK: L2_header.loopexit:
+; CHECK-NEXT: br label [[L2_HEADER]]
+; CHECK: L2_header:
+; CHECK-NEXT: br label [[L3_HEADER:%.*]]
+; CHECK: L3_header:
+; CHECK-NEXT: br i1 true, label [[L2_HEADER_LOOPEXIT:%.*]], label [[L3_EXITING:%.*]]
+; CHECK: L3_exiting:
+; CHECK-NEXT: br i1 true, label [[L3_BODY:%.*]], label [[L1_LATCH:%.*]]
+; CHECK: L3_body:
+; CHECK-NEXT: [[X_LCSSA:%.*]] = phi i1 [ false, [[L3_EXITING]] ]
+; CHECK-NEXT: br i1 [[X_LCSSA]], label [[L3_LATCH:%.*]], label [[L3_LATCH]]
+; CHECK: L3_latch:
+; CHECK-NEXT: ret i8 0
+; CHECK: L1_latch:
+; CHECK-NEXT: unreachable
+;
entry:
br label %L1_header
L3_exiting:
br i1 true, label %L3_body, label %L1_latch
-; CHECK: L3_body:
-; CHECK-NEXT: %x.lcssa = phi i1
L3_body:
br i1 %x, label %L3_latch, label %L3_latch
ret i8 0
}
-; CHECK-LABEL: @foo5
define void @foo5() {
+; CHECK-LABEL: @foo5(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[OUTER:%.*]]
+; CHECK: outer:
+; CHECK-NEXT: br label [[INNER1:%.*]]
+; CHECK: inner1:
+; CHECK-NEXT: br label [[INNER2_INDIRECT_EXIT:%.*]]
+; CHECK: inner2_indirect_exit:
+; CHECK-NEXT: [[A:%.*]] = phi i32 [ [[B:%.*]], [[INNER2_LATCH:%.*]] ], [ undef, [[INNER1]] ]
+; CHECK-NEXT: indirectbr i8* undef, [label [[INNER2_LATCH]], label [[INNER3:%.*]], label %outer_latch]
+; CHECK: inner2_latch:
+; CHECK-NEXT: [[B]] = load i32, i32* undef, align 8
+; CHECK-NEXT: br label [[INNER2_INDIRECT_EXIT]]
+; CHECK: inner3:
+; CHECK-NEXT: [[A_LCSSA:%.*]] = phi i32 [ [[A_LCSSA]], [[INNER3]] ], [ [[A]], [[INNER2_INDIRECT_EXIT]] ]
+; CHECK-NEXT: br i1 true, label [[OUTER_LATCH_LOOPEXIT:%.*]], label [[INNER3]]
+; CHECK: outer_latch.loopexit:
+; CHECK-NEXT: [[A_LCSSA_LCSSA2:%.*]] = phi i32 [ [[A_LCSSA]], [[INNER3]] ]
+; CHECK-NEXT: [[A_LCSSA_LCSSA:%.*]] = phi i32 [ [[A_LCSSA]], [[INNER3]] ]
+; CHECK-NEXT: br label [[OUTER_LATCH:%.*]]
+; CHECK: outer_latch:
+; CHECK-NEXT: br label [[OUTER]]
+;
entry:
br label %outer
outer:
br label %inner1
-; CHECK: inner1:
-; CHECK-NOT: br i1 true
-; CHECK: br label %inner2_indirect_exit
inner1:
br i1 true, label %inner2_indirect_exit.preheader, label %inner1
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -loop-unroll -verify-loop-info | FileCheck %s
; RUN: opt < %s -S -passes='require<opt-remark-emit>,loop-unroll,verify<loops>' | FileCheck %s
;
; Ensure that tail->inner is removed and rely on verify-loopinfo to
; check soundness.
-;
-; CHECK-LABEL: @skiplevelexit(
-; CHECK: tail:
-; CHECK-NOT: br
-; CHECK: ret void
define void @skiplevelexit() nounwind {
+; CHECK-LABEL: @skiplevelexit(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[OUTER:%.*]]
+; CHECK: outer:
+; CHECK-NEXT: br label [[INNER:%.*]]
+; CHECK: inner:
+; CHECK-NEXT: [[TMP0:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 true, label [[OUTER_BACKEDGE:%.*]], label [[TAIL:%.*]]
+; CHECK: tail:
+; CHECK-NEXT: ret void
+; CHECK: outer.backedge:
+; CHECK-NEXT: br label [[OUTER]]
+;
entry:
br label %outer
; Remove the middle loop of a triply nested loop tree.
; Ensure that only the middle loop is removed and rely on verify-loopinfo to
; check soundness.
-;
-; CHECK-LABEL: @unloopNested(
-; Outer loop control.
-; CHECK: while.body:
-; CHECK: br i1 %cmp3, label %if.then, label %if.end
-; Inner loop control.
-; CHECK: while.end14.i:
-; CHECK: br i1 %call15.i, label %if.end.i, label %exit
-; Middle loop control should no longer reach %while.cond.
-; Now it is the outer loop backedge.
-; CHECK: exit:
-; CHECK: br label %while.cond.outer
define void @unloopNested() {
+; CHECK-LABEL: @unloopNested(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER:%.*]]
+; CHECK: while.cond.outer:
+; CHECK-NEXT: br label [[WHILE_COND:%.*]]
+; CHECK: while.cond:
+; CHECK-NEXT: [[CMP:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP]], label [[WHILE_BODY:%.*]], label [[WHILE_END:%.*]]
+; CHECK: while.body:
+; CHECK-NEXT: [[CMP3:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP3]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then:
+; CHECK-NEXT: br label [[RETURN:%.*]]
+; CHECK: if.end:
+; CHECK-NEXT: [[CMP_I48:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP_I48]], label [[IF_THEN_I:%.*]], label [[IF_ELSE20_I:%.*]]
+; CHECK: if.then.i:
+; CHECK-NEXT: [[CMP8_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP8_I]], label [[MERGE:%.*]], label [[IF_ELSE_I:%.*]]
+; CHECK: if.else.i:
+; CHECK-NEXT: br label [[MERGE]]
+; CHECK: if.else20.i:
+; CHECK-NEXT: [[CMP25_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP25_I]], label [[MERGE]], label [[IF_ELSE28_I:%.*]]
+; CHECK: if.else28.i:
+; CHECK-NEXT: br label [[MERGE]]
+; CHECK: merge:
+; CHECK-NEXT: br label [[WHILE_COND2_I:%.*]]
+; CHECK: while.cond2.i:
+; CHECK-NEXT: [[CMP_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP_I]], label [[WHILE_COND2_BACKEDGE_I:%.*]], label [[WHILE_END_I:%.*]]
+; CHECK: while.cond2.backedge.i:
+; CHECK-NEXT: br label [[WHILE_COND2_I]]
+; CHECK: while.end.i:
+; CHECK-NEXT: [[CMP1114_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP1114_I]], label [[WHILE_BODY12_LR_PH_I:%.*]], label [[WHILE_END14_I:%.*]]
+; CHECK: while.body12.lr.ph.i:
+; CHECK-NEXT: br label [[WHILE_END14_I]]
+; CHECK: while.end14.i:
+; CHECK-NEXT: [[CALL15_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CALL15_I]], label [[IF_END_I:%.*]], label [[EXIT:%.*]]
+; CHECK: if.end.i:
+; CHECK-NEXT: br label [[WHILE_COND2_BACKEDGE_I]]
+; CHECK: exit:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER]]
+; CHECK: while.end:
+; CHECK-NEXT: br label [[RETURN]]
+; CHECK: return:
+; CHECK-NEXT: ret void
+;
entry:
br label %while.cond.outer
;
; This test must be disabled until trip count computation can be optimized...
; rdar:14038809 [SCEV]: Optimize trip count computation for multi-exit loops.
-; CHECKFIXME-LABEL: @unloopDeepNested(
-; Inner-inner loop control.
-; CHECKFIXME: while.cond.us.i:
-; CHECKFIXME: br i1 %cmp.us.i, label %next_data.exit, label %while.body.us.i
-; CHECKFIXME: if.then.us.i:
-; CHECKFIXME: br label %while.cond.us.i
-; Inner loop tail.
-; CHECKFIXME: if.else.i:
-; CHECKFIXME: br label %while.cond.outer.i
-; Middle loop control (removed).
-; CHECKFIXME: valid_data.exit:
-; CHECKFIXME-NOT: br
-; CHECKFIXME: %cmp = call zeroext i1 @check()
-; Outer loop control.
-; CHECKFIXME: copy_data.exit:
-; CHECKFIXME: br i1 %cmp38, label %if.then39, label %while.cond.outer
-; Outer-outer loop tail.
-; CHECKFIXME: while.cond.outer.outer.backedge:
-; CHECKFIXME: br label %while.cond.outer.outer
define void @unloopDeepNested() nounwind {
+; CHECK-LABEL: @unloopDeepNested(
+; CHECK-NEXT: for.cond8.preheader.i:
+; CHECK-NEXT: [[CMP113_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP113_I]], label [[MAKE_DATA_EXIT:%.*]], label [[FOR_BODY13_LR_PH_I:%.*]]
+; CHECK: for.body13.lr.ph.i:
+; CHECK-NEXT: br label [[MAKE_DATA_EXIT]]
+; CHECK: make_data.exit:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_OUTER:%.*]]
+; CHECK: while.cond.outer.outer:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER:%.*]]
+; CHECK: while.cond.outer:
+; CHECK-NEXT: br label [[WHILE_COND:%.*]]
+; CHECK: while.cond:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_I:%.*]]
+; CHECK: while.cond.outer.i:
+; CHECK-NEXT: [[TMP192_PH_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[TMP192_PH_I]], label [[WHILE_COND_OUTER_SPLIT_US_I:%.*]], label [[WHILE_BODY_LOOPEXIT:%.*]]
+; CHECK: while.cond.outer.split.us.i:
+; CHECK-NEXT: br label [[WHILE_COND_US_I:%.*]]
+; CHECK: while.cond.us.i:
+; CHECK-NEXT: [[CMP_US_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP_US_I]], label [[NEXT_DATA_EXIT:%.*]], label [[WHILE_BODY_US_I:%.*]]
+; CHECK: while.body.us.i:
+; CHECK-NEXT: [[CMP7_US_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP7_US_I]], label [[IF_THEN_US_I:%.*]], label [[IF_ELSE_I:%.*]]
+; CHECK: if.then.us.i:
+; CHECK-NEXT: br label [[WHILE_COND_US_I]]
+; CHECK: if.else.i:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_I]]
+; CHECK: next_data.exit:
+; CHECK-NEXT: [[TMP192_PH_I_LCSSA28:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[TMP192_PH_I_LCSSA28]], label [[WHILE_END:%.*]], label [[WHILE_BODY:%.*]]
+; CHECK: while.body.loopexit:
+; CHECK-NEXT: br label [[WHILE_BODY]]
+; CHECK: while.body:
+; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
+; CHECK: while.cond.i:
+; CHECK-NEXT: [[CMP_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP_I]], label [[VALID_DATA_EXIT:%.*]], label [[WHILE_BODY_I:%.*]]
+; CHECK: while.body.i:
+; CHECK-NEXT: [[CMP7_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP7_I]], label [[VALID_DATA_EXIT]], label [[IF_END_I:%.*]]
+; CHECK: if.end.i:
+; CHECK-NEXT: br label [[WHILE_COND_I]]
+; CHECK: valid_data.exit:
+; CHECK-NEXT: [[CMP:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN12:%.*]], label [[IF_END:%.*]]
+; CHECK: if.then12:
+; CHECK-NEXT: br label [[IF_END]]
+; CHECK: if.end:
+; CHECK-NEXT: [[TOBOOL3_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[TOBOOL3_I]], label [[COPY_DATA_EXIT:%.*]], label [[WHILE_BODY_LR_PH_I:%.*]]
+; CHECK: while.body.lr.ph.i:
+; CHECK-NEXT: br label [[COPY_DATA_EXIT]]
+; CHECK: copy_data.exit:
+; CHECK-NEXT: [[CMP38:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP38]], label [[IF_THEN39:%.*]], label [[WHILE_COND_OUTER]]
+; CHECK: if.then39:
+; CHECK-NEXT: [[CMP5_I:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP5_I]], label [[WHILE_COND_OUTER_OUTER_BACKEDGE:%.*]], label [[FOR_COND8_PREHEADER_I8_THREAD:%.*]]
+; CHECK: for.cond8.preheader.i8.thread:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_OUTER_BACKEDGE]]
+; CHECK: while.cond.outer.outer.backedge:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_OUTER]]
+; CHECK: while.end:
+; CHECK-NEXT: ret void
+;
for.cond8.preheader.i:
%cmp113.i = call zeroext i1 @check()
br i1 %cmp113.i, label %make_data.exit, label %for.body13.lr.ph.i
; Remove a nested loop with irreducible control flow.
; Ensure that only the middle loop is removed and rely on verify-loopinfo to
; check soundness.
-;
-; CHECK-LABEL: @unloopIrreducible(
-; Irreducible loop.
-; CHECK: for.inc117:
-; CHECK: br label %for.cond103t
-; Nested loop (removed).
-; CHECK: for.inc159:
-; CHECK: br label %for.inc163
define void @unloopIrreducible() nounwind {
-
+; CHECK-LABEL: @unloopIrreducible(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_BODY:%.*]]
+; CHECK: for.body:
+; CHECK-NEXT: [[CMP2113:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP2113]], label [[FOR_BODY22_LR_PH:%.*]], label [[FOR_INC163:%.*]]
+; CHECK: for.body22.lr.ph:
+; CHECK-NEXT: br label [[FOR_BODY22:%.*]]
+; CHECK: for.body22:
+; CHECK-NEXT: br label [[FOR_BODY33:%.*]]
+; CHECK: for.body33:
+; CHECK-NEXT: br label [[FOR_END:%.*]]
+; CHECK: for.end:
+; CHECK-NEXT: [[CMP424:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP424]], label [[FOR_BODY43_LR_PH:%.*]], label [[FOR_END93:%.*]]
+; CHECK: for.body43.lr.ph:
+; CHECK-NEXT: br label [[FOR_END93]]
+; CHECK: for.end93:
+; CHECK-NEXT: [[CMP96:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP96]], label [[IF_THEN97:%.*]], label [[FOR_COND103:%.*]]
+; CHECK: if.then97:
+; CHECK-NEXT: br label [[FOR_COND103T:%.*]]
+; CHECK: for.cond103t:
+; CHECK-NEXT: br label [[FOR_COND103]]
+; CHECK: for.cond103:
+; CHECK-NEXT: [[CMP105:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP105]], label [[FOR_BODY106:%.*]], label [[FOR_END120:%.*]]
+; CHECK: for.body106:
+; CHECK-NEXT: [[CMP108:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP108]], label [[IF_THEN109:%.*]], label [[FOR_INC117:%.*]]
+; CHECK: if.then109:
+; CHECK-NEXT: br label [[FOR_INC117]]
+; CHECK: for.inc117:
+; CHECK-NEXT: br label [[FOR_COND103T]]
+; CHECK: for.end120:
+; CHECK-NEXT: br label [[FOR_INC159:%.*]]
+; CHECK: for.inc159:
+; CHECK-NEXT: br label [[FOR_INC163]]
+; CHECK: for.inc163:
+; CHECK-NEXT: [[CMP12:%.*]] = call zeroext i1 @check()
+; CHECK-NEXT: br i1 [[CMP12]], label [[FOR_BODY]], label [[FOR_END166:%.*]]
+; CHECK: for.end166:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.body
; Remove a loop whose exit branches into a sibling loop.
; Ensure that only the loop is removed and rely on verify-loopinfo to
; check soundness.
-;
-; CHECK-LABEL: @unloopCriticalEdge(
-; CHECK: while.cond.outer.i.loopexit.split:
-; CHECK: br label %while.body
-; CHECK: while.body:
-; CHECK: br label %for.end78
define void @unloopCriticalEdge() nounwind {
+; CHECK-LABEL: @unloopCriticalEdge(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[FOR_COND31:%.*]]
+; CHECK: for.cond31:
+; CHECK-NEXT: br i1 false, label [[FOR_BODY35:%.*]], label [[FOR_END94:%.*]]
+; CHECK: for.body35:
+; CHECK-NEXT: br label [[WHILE_COND_I_PREHEADER:%.*]]
+; CHECK: while.cond.i.preheader:
+; CHECK-NEXT: br i1 undef, label [[WHILE_COND_I_PREHEADER_SPLIT:%.*]], label [[WHILE_COND_OUTER_I_LOOPEXIT_SPLIT:%.*]]
+; CHECK: while.cond.i.preheader.split:
+; CHECK-NEXT: br label [[WHILE_COND_I:%.*]]
+; CHECK: while.cond.i:
+; CHECK-NEXT: br i1 true, label [[WHILE_COND_I]], label [[WHILE_COND_OUTER_I_LOOPEXIT:%.*]]
+; CHECK: while.cond.outer.i.loopexit:
+; CHECK-NEXT: br label [[WHILE_COND_OUTER_I_LOOPEXIT_SPLIT]]
+; CHECK: while.cond.outer.i.loopexit.split:
+; CHECK-NEXT: br label [[WHILE_BODY:%.*]]
+; CHECK: while.body:
+; CHECK-NEXT: br label [[FOR_END78:%.*]]
+; CHECK: for.end78:
+; CHECK-NEXT: br i1 false, label [[PROC2_EXIT:%.*]], label [[FOR_COND_I_PREHEADER:%.*]]
+; CHECK: for.cond.i.preheader:
+; CHECK-NEXT: br label [[FOR_COND_I:%.*]]
+; CHECK: for.cond.i:
+; CHECK-NEXT: br label [[FOR_COND_I]]
+; CHECK: Proc2.exit:
+; CHECK-NEXT: br label [[FOR_COND31]]
+; CHECK: for.end94:
+; CHECK-NEXT: ret void
+;
entry:
br label %for.cond31
;
; Check that the loop backedge is removed from the middle loop 1699,
; but not the inner loop 1676.
-; CHECK: while.body1694:
-; CHECK: unreachable
-; CHECK: while.end1699:
-; CHECK: br label %sw.default1711
define void @removeSubloopBlocks() nounwind {
+; CHECK-LABEL: @removeSubloopBlocks(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: br label [[TRYAGAIN_OUTER:%.*]]
+; CHECK: tryagain.outer:
+; CHECK-NEXT: br label [[TRYAGAIN:%.*]]
+; CHECK: tryagain:
+; CHECK-NEXT: br i1 false, label [[SW_BB1669:%.*]], label [[SW_BB304:%.*]]
+; CHECK: sw.bb304:
+; CHECK-NEXT: ret void
+; CHECK: sw.bb1669:
+; CHECK-NEXT: br i1 true, label [[SW_DEFAULT1711:%.*]], label [[WHILE_COND1676_PREHEADER:%.*]]
+; CHECK: while.cond1676.preheader:
+; CHECK-NEXT: br label [[WHILE_COND1676:%.*]]
+; CHECK: while.cond1676:
+; CHECK-NEXT: br i1 true, label [[WHILE_END1699:%.*]], label [[WHILE_BODY1694:%.*]]
+; CHECK: while.body1694:
+; CHECK-NEXT: unreachable
+; CHECK: while.end1699:
+; CHECK-NEXT: br label [[SW_DEFAULT1711]]
+; CHECK: sw.default1711:
+; CHECK-NEXT: br label [[DEFCHAR:%.*]]
+; CHECK: defchar:
+; CHECK-NEXT: br i1 undef, label [[IF_END2413:%.*]], label [[IF_THEN2368:%.*]]
+; CHECK: if.then2368:
+; CHECK-NEXT: unreachable
+; CHECK: if.end2413:
+; CHECK-NEXT: unreachable
+;
entry:
br label %tryagain.outer
}
; PR11335: the most deeply nested block should be removed from the outer loop.
-; CHECK-LABEL: @removeSubloopBlocks2(
-; CHECK: for.cond3:
-; CHECK-NOT: br
-; CHECK: ret void
define void @removeSubloopBlocks2() nounwind {
+; CHECK-LABEL: @removeSubloopBlocks2(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TOBOOL_I:%.*]] = icmp ne i32 undef, 0
+; CHECK-NEXT: br label [[LBL_616:%.*]]
+; CHECK: lbl_616.loopexit:
+; CHECK-NEXT: br label [[LBL_616]]
+; CHECK: lbl_616:
+; CHECK-NEXT: br label [[FOR_COND:%.*]]
+; CHECK: for.cond:
+; CHECK-NEXT: br i1 false, label [[FOR_COND1_PREHEADER:%.*]], label [[LBL_616_LOOPEXIT:%.*]]
+; CHECK: for.cond1.preheader:
+; CHECK-NEXT: br label [[FOR_COND1:%.*]]
+; CHECK: for.cond1.loopexit:
+; CHECK-NEXT: unreachable
+; CHECK: for.cond1:
+; CHECK-NEXT: br i1 false, label [[FOR_BODY2:%.*]], label [[FOR_COND3:%.*]]
+; CHECK: for.body2:
+; CHECK-NEXT: br label [[FOR_COND_I:%.*]]
+; CHECK: for.cond.i:
+; CHECK-NEXT: br i1 [[TOBOOL_I]], label [[FOR_COND_I]], label [[FOR_COND1_LOOPEXIT:%.*]]
+; CHECK: for.cond3:
+; CHECK-NEXT: ret void
+;
entry:
%tobool.i = icmp ne i32 undef, 0
br label %lbl_616