1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=gvn -S -verify-loop-info %s | FileCheck %s
4 ; Make sure we do not try to preserve loop-simplify form, if it would mean
5 ; splitting blocks with indirectbr predecessors.
9 define i32 @foo(ptr %p1, ptr %p2, ptr %p3) {
12 ; CHECK-NEXT: br label [[LOOP_HEADER:%.*]]
14 ; CHECK-NEXT: store i32 0, ptr [[P3:%.*]], align 4
15 ; CHECK-NEXT: indirectbr ptr [[P1:%.*]], [label [[LOOP_LATCH1:%.*]], label %loop.latch2]
17 ; CHECK-NEXT: [[C:%.*]] = call i1 @cond()
18 ; CHECK-NEXT: br i1 [[C]], label [[LOOP_HEADER]], label [[LOOP_LATCH1_EXIT_CRIT_EDGE:%.*]]
19 ; CHECK: loop.latch1.exit_crit_edge:
20 ; CHECK-NEXT: [[X_PRE:%.*]] = load i32, ptr [[P3]], align 4
21 ; CHECK-NEXT: br label [[EXIT:%.*]]
23 ; CHECK-NEXT: indirectbr ptr [[P2:%.*]], [label [[LOOP_HEADER]], label %exit]
25 ; CHECK-NEXT: [[X:%.*]] = phi i32 [ [[X_PRE]], [[LOOP_LATCH1_EXIT_CRIT_EDGE]] ], [ 0, [[LOOP_LATCH2:%.*]] ]
26 ; CHECK-NEXT: ret i32 [[X]]
31 loop.header: ; preds = %loop.latch2, %loop.latch1, %bb
32 store i32 0, ptr %p3, align 4
33 indirectbr ptr %p1, [label %loop.latch1, label %loop.latch2]
35 loop.latch1: ; preds = %loop.header
37 br i1 %c, label %loop.header, label %exit
39 loop.latch2: ; preds = %loop.header
40 indirectbr ptr %p2, [label %loop.header, label %exit]
42 exit: ; preds = %loop.latch2, %loop.latch1
43 %x = load i32, ptr %p3, align 4