1 ; RUN: opt -S -O1 < %s -o %t1.ll
2 ; RUN: opt -S < %t1.ll -o %t2.ll
3 ; RUN: opt -S -passes=simplifycfg < %t1.ll -o %t3.ll
4 ;; Show that there's no difference after running another simplify CFG
5 ; RUN: diff %t2.ll %t3.ll
7 ; Test from LoopSink pass, leaves some single-entry single-exit basic blocks.
8 ; After LoopSink, we get a basic block .exit.loopexit which has one entry and
9 ; one exit, the only instruction is a branch. Make sure it doesn't show up.
10 ; Make sure they disappear at -O1.
12 @g = global i32 0, align 4
14 define i32 @t1(i32, i32) {
15 %3 = icmp eq i32 %1, 0
16 br i1 %3, label %.exit, label %.preheader
19 %invariant = load i32, ptr @g
23 %iv = phi i32 [ %t7, %.b7 ], [ 0, %.preheader ]
24 %c1 = icmp sgt i32 %iv, %0
25 br i1 %c1, label %.b2, label %.b6
28 %c2 = icmp sgt i32 %iv, 1
29 br i1 %c2, label %.b3, label %.b4
32 %t3 = sub nsw i32 %invariant, %iv
36 %t4 = add nsw i32 %invariant, %iv
40 %p5 = phi i32 [ %t3, %.b3 ], [ %t4, %.b4 ]
41 %t5 = mul nsw i32 %p5, 5
45 %t6 = add nsw i32 %iv, 100
49 %p7 = phi i32 [ %t6, %.b6 ], [ %t5, %.b5 ]
50 %t7 = add nuw nsw i32 %iv, 1
51 %c7 = icmp eq i32 %t7, %p7
52 br i1 %c7, label %.b1, label %.exit