Michael Zolotukhin | 97567e1 | 2016-04-06 21:47:12 +0000 | [diff] [blame] | 1 | ; RUN: opt -loop-unroll -debug-only=loop-unroll -disable-output < %s |
| 2 | ; REQUIRES: asserts |
| 3 | ; Compile this test with debug flag on to verify domtree right after loop unrolling. |
| 4 | target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" |
| 5 | |
| 6 | ; PR27157 |
| 7 | define void @foo() { |
| 8 | entry: |
| 9 | br label %loop_header |
| 10 | loop_header: |
| 11 | %iv = phi i64 [ 0, %entry ], [ %iv_next, %loop_latch ] |
| 12 | br i1 undef, label %loop_latch, label %loop_exiting_bb1 |
| 13 | loop_exiting_bb1: |
| 14 | br i1 false, label %loop_exiting_bb2, label %exit1.loopexit |
| 15 | loop_exiting_bb2: |
| 16 | br i1 false, label %loop_latch, label %bb |
| 17 | bb: |
| 18 | br label %exit1 |
| 19 | loop_latch: |
| 20 | %iv_next = add nuw nsw i64 %iv, 1 |
| 21 | %cmp = icmp ne i64 %iv_next, 2 |
| 22 | br i1 %cmp, label %loop_header, label %exit2 |
| 23 | exit1.loopexit: |
| 24 | br label %exit1 |
| 25 | exit1: |
| 26 | ret void |
| 27 | exit2: |
| 28 | ret void |
| 29 | } |
| 30 | |
| 31 | define void @foo2() { |
| 32 | entry: |
| 33 | br label %loop.header |
| 34 | loop.header: |
| 35 | %iv = phi i32 [ 0, %entry ], [ %iv.inc, %latch ] |
| 36 | %iv.inc = add i32 %iv, 1 |
| 37 | br i1 undef, label %diamond, label %latch |
| 38 | diamond: |
| 39 | br i1 undef, label %left, label %right |
| 40 | left: |
| 41 | br i1 undef, label %exit, label %merge |
| 42 | right: |
| 43 | br i1 undef, label %exit, label %merge |
| 44 | merge: |
| 45 | br label %latch |
| 46 | latch: |
| 47 | %end.cond = icmp eq i32 %iv, 1 |
| 48 | br i1 %end.cond, label %exit1, label %loop.header |
| 49 | exit: |
| 50 | ret void |
| 51 | exit1: |
| 52 | ret void |
| 53 | } |