1 ; RUN: opt -S -loop-rotate < %s -verify-loop-info | FileCheck %s 2 ; 3 ; Verify that LoopRotate preserves LoopSimplify form even in very peculiar loop 4 ; structures. We manually validate the CFG with FileCheck because currently we 5 ; can't cause a failure when LoopSimplify fails to be preserved. 6 7 define void @PR18643() { 8 ; CHECK-LABEL: @PR18643( 9 entry: 10 br label %outer.header 11 ; CHECK: br label %outer.header 12 13 outer.header: 14 ; CHECK: outer.header: 15 br i1 undef, label %inner.header, label %outer.body 16 ; CHECK-NEXT: br i1 {{[^,]*}}, label %[[INNER_PREROTATE_PREHEADER:[^,]*]], label %outer.body 17 18 ; CHECK: [[INNER_PREROTATE_PREHEADER]]: 19 ; CHECK-NEXT: br i1 {{[^,]*}}, label %[[INNER_PREROTATE_PREHEADER_SPLIT_RETURN:[^,]*]], label %[[INNER_ROTATED_PREHEADER:[^,]*]] 20 21 ; CHECK: [[INNER_ROTATED_PREHEADER]]: 22 ; CHECK-NEXT: br label %inner.body 23 24 inner.header: 25 ; Now the latch! 26 ; CHECK: inner.header: 27 br i1 undef, label %return, label %inner.body 28 ; CHECK-NEXT: br i1 {{[^,]*}}, label %[[INNER_SPLIT_RETURN:[^,]*]], label %inner.body 29 30 inner.body: 31 ; Now the header! 32 ; CHECK: inner.body: 33 br i1 undef, label %outer.latch, label %inner.latch 34 ; CHECK-NEXT: br i1 {{[^,]*}}, label %[[INNER_SPLIT_OUTER_LATCH:[^,]*]], label %inner.header 35 36 inner.latch: 37 ; Dead! 38 br label %inner.header 39 40 outer.body: 41 ; CHECK: outer.body: 42 br label %outer.latch 43 ; CHECK-NEXT: br label %outer.latch 44 45 ; L2 -> L1 exit edge needs a simplified exit block. 46 ; CHECK: [[INNER_SPLIT_OUTER_LATCH]]: 47 ; CHECK-NEXT: br label %outer.latch 48 49 outer.latch: 50 ; CHECK: outer.latch: 51 br label %outer.header 52 ; CHECK-NEXT: br label %outer.header 53 54 ; L1 -> L0 exit edge need sa simplified exit block. 55 ; CHECK: [[INNER_PREROTATE_PREHEADER_SPLIT_RETURN]]: 56 ; CHECK-NEXT: br label %return 57 58 ; L2 -> L0 exit edge needs a simplified exit block. 59 ; CHECK: [[INNER_SPLIT_RETURN]]: 60 ; CHECK-NEXT: br label %return 61 62 return: 63 ; CHECK: return: 64 unreachable 65 } 66