1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -passes=simplifycfg < %s | FileCheck %s
4 ; This used to infinitely thread between loop and loop.latch without reaching a
9 define i32 @main(i1 %c1, i1 %c2, i32 %y) {
11 ; CHECK-NEXT: br i1 [[C1:%.*]], label [[EXIT:%.*]], label [[LOOP_PRE_PREHEADER:%.*]]
12 ; CHECK: loop.pre.preheader:
13 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[Y:%.*]], -1
14 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP_PREHEADER:%.*]], label [[EXIT]]
15 ; CHECK: loop.preheader:
16 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[Y]], 0
17 ; CHECK-NEXT: br label [[LOOP:%.*]]
19 ; CHECK-NEXT: br i1 [[C1]], label [[LOOP2:%.*]], label [[LOOP_LATCH:%.*]]
21 ; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[EXIT]]
23 ; CHECK-NEXT: br i1 [[CMP2]], label [[JOIN:%.*]], label [[IF:%.*]]
25 ; CHECK-NEXT: call void @dummy()
26 ; CHECK-NEXT: br label [[JOIN]]
28 ; CHECK-NEXT: br i1 [[C2:%.*]], label [[LOOP2]], label [[LOOP_LATCH]]
30 ; CHECK-NEXT: ret i32 0
32 br i1 %c1, label %exit, label %loop.pre.preheader
35 %cmp = icmp sgt i32 %y, -1
36 br i1 %cmp, label %loop.preheader, label %exit
39 %cmp2 = icmp eq i32 %y, 0
43 br i1 %c1, label %loop2, label %loop.latch
46 br i1 %cmp, label %loop, label %exit
49 br i1 %cmp2, label %join, label %if
56 br i1 %c2, label %loop2, label %loop.latch
61 ; uselistorder directives
62 uselistorder label %loop2, { 1, 0 }