Chandler Carruth | a5a29f9 | 2012-07-02 12:47:22 +0000 | [diff] [blame] | 1 | ; RUN: opt -S < %s -indvars | opt -analyze -iv-users | grep "%cmp = icmp slt i32" | grep "= {%\.ph,+,1}<%for.cond>" |
Dan Gohman | 487e250 | 2010-09-04 02:42:48 +0000 | [diff] [blame] | 2 | ; PR8079 |
| 3 | |
Mehdi Amini | 46a4355 | 2015-03-04 18:43:29 +0000 | [diff] [blame^] | 4 | ; Provide legal integer types. |
| 5 | target datalayout = "n8:16:32:64" |
| 6 | |
Dan Gohman | 487e250 | 2010-09-04 02:42:48 +0000 | [diff] [blame] | 7 | ; LoopSimplify should invalidate indvars when splitting out the |
| 8 | ; inner loop. |
| 9 | |
| 10 | @maxStat = external global i32 |
| 11 | |
| 12 | define i32 @test() nounwind { |
| 13 | entry: |
| 14 | br label %for.cond |
| 15 | |
| 16 | for.cond: ; preds = %if.then5, %if.end, %entry |
| 17 | %cuts.1 = phi i32 [ 0, %entry ], [ %inc, %if.then5 ], [ %cuts.1, %if.end ] |
| 18 | %0 = phi i32 [ 0, %entry ], [ %add, %if.end ], [ %add, %if.then5 ] |
| 19 | %add = add i32 %0, 1 |
| 20 | %cmp = icmp slt i32 %0, 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 21 | %tmp1 = load i32, i32* @maxStat, align 4 |
Dan Gohman | 487e250 | 2010-09-04 02:42:48 +0000 | [diff] [blame] | 22 | br i1 %cmp, label %for.body, label %for.cond14.preheader |
| 23 | |
| 24 | for.cond14.preheader: ; preds = %for.cond |
| 25 | %cmp1726 = icmp sgt i32 %tmp1, 0 |
| 26 | br i1 %cmp1726, label %for.body18, label %return |
| 27 | |
| 28 | for.body: ; preds = %for.cond |
| 29 | %cmp2 = icmp sgt i32 %tmp1, 100 |
| 30 | br i1 %cmp2, label %return, label %if.end |
| 31 | |
| 32 | if.end: ; preds = %for.body |
| 33 | %cmp4 = icmp sgt i32 %tmp1, -1 |
| 34 | br i1 %cmp4, label %if.then5, label %for.cond |
| 35 | |
| 36 | if.then5: ; preds = %if.end |
| 37 | call void @foo() nounwind |
| 38 | %inc = add i32 %cuts.1, 1 |
| 39 | br label %for.cond |
| 40 | |
| 41 | for.body18: ; preds = %for.body18, %for.cond14.preheader |
| 42 | %i13.027 = phi i32 [ %1, %for.body18 ], [ 0, %for.cond14.preheader ] |
| 43 | call void @foo() nounwind |
| 44 | %1 = add nsw i32 %i13.027, 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 45 | %tmp16 = load i32, i32* @maxStat, align 4 |
Dan Gohman | 487e250 | 2010-09-04 02:42:48 +0000 | [diff] [blame] | 46 | %cmp17 = icmp slt i32 %1, %tmp16 |
| 47 | br i1 %cmp17, label %for.body18, label %return |
| 48 | |
| 49 | return: ; preds = %for.body18, %for.body, %for.cond14.preheader |
| 50 | ret i32 0 |
| 51 | } |
| 52 | |
| 53 | declare void @foo() nounwind |
Andrew Trick | bf69d03 | 2011-08-03 18:32:11 +0000 | [diff] [blame] | 54 | |
| 55 | ; Notify SCEV when removing an ExitingBlock. |
Stephen Lin | c1c7a13 | 2013-07-14 01:42:54 +0000 | [diff] [blame] | 56 | ; CHECK-LABEL: @mergeExit( |
Andrew Trick | bf69d03 | 2011-08-03 18:32:11 +0000 | [diff] [blame] | 57 | ; CHECK: while.cond191: |
| 58 | ; CHECK: br i1 %or.cond, label %while.body197 |
| 59 | ; CHECK-NOT: land.rhs: |
| 60 | ; CHECK: ret |
| 61 | define void @mergeExit(i32 %MapAttrCount) nounwind uwtable ssp { |
| 62 | entry: |
| 63 | br i1 undef, label %if.then124, label %if.end126 |
| 64 | |
| 65 | if.then124: ; preds = %entry |
| 66 | unreachable |
| 67 | |
| 68 | if.end126: ; preds = %entry |
| 69 | br i1 undef, label %while.body.lr.ph, label %if.end591 |
| 70 | |
| 71 | while.body.lr.ph: ; preds = %if.end126 |
| 72 | br i1 undef, label %if.end140, label %if.then137 |
| 73 | |
| 74 | if.then137: ; preds = %while.body.lr.ph |
| 75 | unreachable |
| 76 | |
| 77 | if.end140: ; preds = %while.body.lr.ph |
| 78 | br i1 undef, label %while.cond191.outer, label %if.then148 |
| 79 | |
| 80 | if.then148: ; preds = %if.end140 |
| 81 | unreachable |
| 82 | |
| 83 | while.cond191.outer: ; preds = %if.then205, %if.end140 |
| 84 | br label %while.cond191 |
| 85 | |
| 86 | while.cond191: ; preds = %while.body197, %while.cond191.outer |
| 87 | %CppIndex.0 = phi i32 [ %inc, %while.body197 ], [ undef, %while.cond191.outer ] |
| 88 | br i1 undef, label %land.rhs, label %if.then216 |
| 89 | |
| 90 | land.rhs: ; preds = %while.cond191 |
| 91 | %inc = add i32 %CppIndex.0, 1 |
| 92 | %cmp196 = icmp ult i32 %inc, %MapAttrCount |
| 93 | br i1 %cmp196, label %while.body197, label %if.then216 |
| 94 | |
| 95 | while.body197: ; preds = %land.rhs |
| 96 | br i1 undef, label %if.then205, label %while.cond191 |
| 97 | |
| 98 | if.then205: ; preds = %while.body197 |
| 99 | br label %while.cond191.outer |
| 100 | |
| 101 | if.then216: ; preds = %land.rhs, %while.cond191 |
| 102 | br i1 undef, label %if.else, label %if.then221 |
| 103 | |
| 104 | if.then221: ; preds = %if.then216 |
| 105 | unreachable |
| 106 | |
| 107 | if.else: ; preds = %if.then216 |
| 108 | br i1 undef, label %if.then266, label %if.end340 |
| 109 | |
| 110 | if.then266: ; preds = %if.else |
| 111 | switch i32 undef, label %if.else329 [ |
| 112 | i32 17, label %if.then285 |
| 113 | i32 19, label %if.then285 |
| 114 | i32 18, label %if.then285 |
| 115 | i32 15, label %if.then285 |
| 116 | ] |
| 117 | |
| 118 | if.then285: ; preds = %if.then266, %if.then266, %if.then266, %if.then266 |
| 119 | br i1 undef, label %if.then317, label %if.else324 |
| 120 | |
| 121 | if.then317: ; preds = %if.then285 |
| 122 | br label %if.end340 |
| 123 | |
| 124 | if.else324: ; preds = %if.then285 |
| 125 | unreachable |
| 126 | |
| 127 | if.else329: ; preds = %if.then266 |
| 128 | unreachable |
| 129 | |
| 130 | if.end340: ; preds = %if.then317, %if.else |
| 131 | unreachable |
| 132 | |
| 133 | if.end591: ; preds = %if.end126 |
| 134 | br i1 undef, label %cond.end, label %cond.false |
| 135 | |
| 136 | cond.false: ; preds = %if.end591 |
| 137 | unreachable |
| 138 | |
| 139 | cond.end: ; preds = %if.end591 |
| 140 | ret void |
| 141 | } |