1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop-mssa(loop-instsimplify,loop-simplifycfg,simple-loop-unswitch)' -S %s | FileCheck %s
4 ; Test case from PR54023. After SimpleLoopUnswitch, one of the loops processed
5 ; by LoopSimplifyCFG will have exit blocks with predecessors outside the loop
6 ; (i.e. it is not in loop-simplify/canonical form).
7 define i32 @test(i32 %v, i1 %c.1, i1 %c.2) {
10 ; CHECK-NEXT: br label [[OUTER_HEADER:%.*]]
11 ; CHECK: outer.header:
12 ; CHECK-NEXT: br i1 [[C_1:%.*]], label [[OUTER_LATCH:%.*]], label [[INNER_HEADER_PREHEADER:%.*]]
13 ; CHECK: inner.header.preheader:
14 ; CHECK-NEXT: br label [[INNER_HEADER:%.*]]
15 ; CHECK: inner.header:
16 ; CHECK-NEXT: [[CMP_2:%.*]] = icmp ne i32 [[V:%.*]], 0
17 ; CHECK-NEXT: br i1 [[CMP_2]], label [[EXIT:%.*]], label [[INNER_LATCH:%.*]]
19 ; CHECK-NEXT: br i1 [[C_2:%.*]], label [[OUTER_LATCH_LOOPEXIT:%.*]], label [[INNER_HEADER]]
20 ; CHECK: outer.latch.loopexit:
21 ; CHECK-NEXT: br label [[OUTER_LATCH]]
23 ; CHECK-NEXT: br label [[OUTER_HEADER]]
25 ; CHECK-NEXT: [[RES:%.*]] = phi i32 [ [[V]], [[INNER_HEADER]] ]
26 ; CHECK-NEXT: br label [[EXIT_SPLIT:%.*]]
28 ; CHECK-NEXT: [[RES_SPLIT:%.*]] = phi i32 [ [[RES]], [[EXIT]] ]
29 ; CHECK-NEXT: ret i32 [[RES_SPLIT]]
32 br label %outer.header
35 %g.0 = phi i32 [ 10, %outer.latch ], [ 1, %entry ]
36 %cmp.1 = icmp eq i32 %g.0, 0
37 br i1 %c.1, label %outer.latch, label %inner.header
40 %cmp.2 = icmp ne i32 %v, 0
41 %or.cond = or i1 %cmp.1, %cmp.2
42 br i1 %or.cond, label %exit, label %inner.latch
45 br i1 %c.2, label %outer.latch, label %inner.header
48 br label %outer.header
51 %res = phi i32 [ %v, %inner.header ]