1865d88d4SRoman Lebedev; RUN: opt -passes=loop-unroll-and-jam -allow-unroll-and-jam -unroll-and-jam-count=4 -pass-remarks=loop-unroll-and-jam < %s -S 2>&1 | FileCheck %s 2a95796a3SArthur Eubanks; RUN: opt -passes='loop-unroll-and-jam' -allow-unroll-and-jam -unroll-and-jam-count=4 -pass-remarks=loop-unroll-and-jam < %s -S 2>&1 | FileCheck %s 3cee313d2SEric Christopher 4cee313d2SEric Christophertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 5cee313d2SEric Christopher 6cee313d2SEric Christopher;; Common check for all tests. None should be unroll and jammed 7cee313d2SEric Christopher; CHECK-NOT: remark: {{.*}} unroll and jammed 8cee313d2SEric Christopher 9cee313d2SEric Christopher 10cee313d2SEric Christopher; CHECK-LABEL: disabled1 11cee313d2SEric Christopher; Tests for(i) { sum = A[i]; for(j) sum += B[j]; A[i+1] = sum; } 12cee313d2SEric Christopher; A[i] to A[i+1] dependency should block unrollandjam 13*055fb779SNikita Popovdefine void @disabled1(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 14cee313d2SEric Christopher; CHECK: %i.029 = phi i32 [ %add10, %for.latch ], [ 0, %for.preheader ] 15cee313d2SEric Christopher; CHECK: %j.026 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 16cee313d2SEric Christopherentry: 17cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 18cee313d2SEric Christopher %cmp127 = icmp ne i32 %I, 0 19cee313d2SEric Christopher %or.cond = and i1 %cmp127, %cmp 20cee313d2SEric Christopher br i1 %or.cond, label %for.preheader, label %return 21cee313d2SEric Christopher 22cee313d2SEric Christopherfor.preheader: 23cee313d2SEric Christopher br label %for.outer 24cee313d2SEric Christopher 25cee313d2SEric Christopherfor.outer: 26cee313d2SEric Christopher %i.029 = phi i32 [ %add10, %for.latch ], [ 0, %for.preheader ] 27cee313d2SEric Christopher %b.028 = phi i32 [ %inc8, %for.latch ], [ 1, %for.preheader ] 28*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.029 29*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 30cee313d2SEric Christopher br label %for.inner 31cee313d2SEric Christopher 32cee313d2SEric Christopherfor.inner: 33cee313d2SEric Christopher %j.026 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 34cee313d2SEric Christopher %sum1.025 = phi i32 [ %0, %for.outer ], [ %add, %for.inner ] 35*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %B, i32 %j.026 36*055fb779SNikita Popov %1 = load i32, ptr %arrayidx6, align 4 37cee313d2SEric Christopher %add = add i32 %1, %sum1.025 38cee313d2SEric Christopher %inc = add nuw i32 %j.026, 1 39cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 40cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 41cee313d2SEric Christopher 42cee313d2SEric Christopherfor.latch: 43*055fb779SNikita Popov %arrayidx7 = getelementptr inbounds i32, ptr %A, i32 %b.028 44*055fb779SNikita Popov store i32 %add, ptr %arrayidx7, align 4 45cee313d2SEric Christopher %inc8 = add nuw nsw i32 %b.028, 1 46cee313d2SEric Christopher %add10 = add nuw nsw i32 %i.029, 1 47cee313d2SEric Christopher %exitcond30 = icmp eq i32 %add10, %I 48cee313d2SEric Christopher br i1 %exitcond30, label %return, label %for.outer 49cee313d2SEric Christopher 50cee313d2SEric Christopherreturn: 51cee313d2SEric Christopher ret void 52cee313d2SEric Christopher} 53cee313d2SEric Christopher 54cee313d2SEric Christopher 55cee313d2SEric Christopher; CHECK-LABEL: disabled2 56cee313d2SEric Christopher; Tests an incompatible block layout (for.outer jumps past for.inner) 57cee313d2SEric Christopher; FIXME: Make this work 58*055fb779SNikita Popovdefine void @disabled2(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 59cee313d2SEric Christopher; CHECK: %i.032 = phi i32 [ %add13, %for.latch ], [ 0, %for.preheader ] 60cee313d2SEric Christopher; CHECK: %j.030 = phi i32 [ %inc, %for.inner ], [ 0, %for.inner.preheader ] 61cee313d2SEric Christopherentry: 62cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 63cee313d2SEric Christopher %cmp131 = icmp ne i32 %I, 0 64cee313d2SEric Christopher %or.cond = and i1 %cmp131, %cmp 65cee313d2SEric Christopher br i1 %or.cond, label %for.preheader, label %for.end14 66cee313d2SEric Christopher 67cee313d2SEric Christopherfor.preheader: 68cee313d2SEric Christopher br label %for.outer 69cee313d2SEric Christopher 70cee313d2SEric Christopherfor.outer: 71cee313d2SEric Christopher %i.032 = phi i32 [ %add13, %for.latch ], [ 0, %for.preheader ] 72*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %i.032 73*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 74cee313d2SEric Christopher %tobool = icmp eq i32 %0, 0 75cee313d2SEric Christopher br i1 %tobool, label %for.latch, label %for.inner 76cee313d2SEric Christopher 77cee313d2SEric Christopherfor.inner: 78cee313d2SEric Christopher %j.030 = phi i32 [ %inc, %for.inner ], [ 0, %for.outer ] 79cee313d2SEric Christopher %sum1.029 = phi i32 [ %sum1.1, %for.inner ], [ 0, %for.outer ] 80*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %B, i32 %j.030 81*055fb779SNikita Popov %1 = load i32, ptr %arrayidx6, align 4 82cee313d2SEric Christopher %tobool7 = icmp eq i32 %1, 0 83cee313d2SEric Christopher %sub = add i32 %sum1.029, 10 84cee313d2SEric Christopher %add = sub i32 %sub, %1 85cee313d2SEric Christopher %sum1.1 = select i1 %tobool7, i32 %sum1.029, i32 %add 86cee313d2SEric Christopher %inc = add nuw i32 %j.030, 1 87cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 88cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 89cee313d2SEric Christopher 90cee313d2SEric Christopherfor.latch: 91cee313d2SEric Christopher %sum1.1.lcssa = phi i32 [ 0, %for.outer ], [ %sum1.1, %for.inner ] 92*055fb779SNikita Popov %arrayidx11 = getelementptr inbounds i32, ptr %A, i32 %i.032 93*055fb779SNikita Popov store i32 %sum1.1.lcssa, ptr %arrayidx11, align 4 94cee313d2SEric Christopher %add13 = add nuw i32 %i.032, 1 95cee313d2SEric Christopher %exitcond33 = icmp eq i32 %add13, %I 96cee313d2SEric Christopher br i1 %exitcond33, label %for.end14, label %for.outer 97cee313d2SEric Christopher 98cee313d2SEric Christopherfor.end14: 99cee313d2SEric Christopher ret void 100cee313d2SEric Christopher} 101cee313d2SEric Christopher 102cee313d2SEric Christopher 103cee313d2SEric Christopher; CHECK-LABEL: disabled3 104cee313d2SEric Christopher; Tests loop carry dependencies in an array S 105*055fb779SNikita Popovdefine void @disabled3(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 106cee313d2SEric Christopher; CHECK: %i.029 = phi i32 [ 0, %for.preheader ], [ %add12, %for.latch ] 107cee313d2SEric Christopher; CHECK: %j.027 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 108cee313d2SEric Christopherentry: 109cee313d2SEric Christopher %S = alloca [4 x i32], align 4 110cee313d2SEric Christopher %cmp = icmp eq i32 %J, 0 111cee313d2SEric Christopher br i1 %cmp, label %return, label %if.end 112cee313d2SEric Christopher 113cee313d2SEric Christopherif.end: 114cee313d2SEric Christopher %cmp128 = icmp eq i32 %I, 0 115cee313d2SEric Christopher br i1 %cmp128, label %for.cond.cleanup, label %for.preheader 116cee313d2SEric Christopher 117cee313d2SEric Christopherfor.preheader: 118cee313d2SEric Christopher br label %for.outer 119cee313d2SEric Christopher 120cee313d2SEric Christopherfor.cond.cleanup: 121cee313d2SEric Christopher br label %return 122cee313d2SEric Christopher 123cee313d2SEric Christopherfor.outer: 124cee313d2SEric Christopher %i.029 = phi i32 [ 0, %for.preheader ], [ %add12, %for.latch ] 125cee313d2SEric Christopher br label %for.inner 126cee313d2SEric Christopher 127cee313d2SEric Christopherfor.inner: 128cee313d2SEric Christopher %j.027 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 129*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j.027 130*055fb779SNikita Popov %l2 = load i32, ptr %arrayidx, align 4 131cee313d2SEric Christopher %add = add i32 %j.027, %i.029 132cee313d2SEric Christopher %rem = urem i32 %add, %J 133*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %B, i32 %rem 134*055fb779SNikita Popov %l3 = load i32, ptr %arrayidx6, align 4 135cee313d2SEric Christopher %mul = mul i32 %l3, %l2 136cee313d2SEric Christopher %rem7 = urem i32 %j.027, 3 137*055fb779SNikita Popov %arrayidx8 = getelementptr inbounds [4 x i32], ptr %S, i32 0, i32 %rem7 138*055fb779SNikita Popov store i32 %mul, ptr %arrayidx8, align 4 139cee313d2SEric Christopher %inc = add nuw i32 %j.027, 1 140cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 141cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 142cee313d2SEric Christopher 143cee313d2SEric Christopherfor.latch: 144*055fb779SNikita Popov %l1 = load i32, ptr %S, align 4 145*055fb779SNikita Popov %arrayidx10 = getelementptr inbounds i32, ptr %A, i32 %i.029 146*055fb779SNikita Popov store i32 %l1, ptr %arrayidx10, align 4 147cee313d2SEric Christopher %add12 = add nuw i32 %i.029, 1 148cee313d2SEric Christopher %exitcond31 = icmp eq i32 %add12, %I 149cee313d2SEric Christopher br i1 %exitcond31, label %for.cond.cleanup, label %for.outer 150cee313d2SEric Christopher 151cee313d2SEric Christopherreturn: 152cee313d2SEric Christopher ret void 153cee313d2SEric Christopher} 154cee313d2SEric Christopher 155cee313d2SEric Christopher 156cee313d2SEric Christopher; CHECK-LABEL: disabled4 157cee313d2SEric Christopher; Inner looop induction variable is not consistent 158cee313d2SEric Christopher; ie for(i = 0..n) for (j = 0..i) sum+=B[j] 159*055fb779SNikita Popovdefine void @disabled4(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 160cee313d2SEric Christopher; CHECK: %indvars.iv = phi i32 [ %indvars.iv.next, %for.latch ], [ 1, %for.preheader ] 161cee313d2SEric Christopher; CHECK: %j.021 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 162cee313d2SEric Christopherentry: 163cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 164cee313d2SEric Christopher %cmp122 = icmp ugt i32 %I, 1 165cee313d2SEric Christopher %or.cond = and i1 %cmp122, %cmp 166cee313d2SEric Christopher br i1 %or.cond, label %for.preheader, label %for.end9 167cee313d2SEric Christopher 168cee313d2SEric Christopherfor.preheader: 169cee313d2SEric Christopher br label %for.outer 170cee313d2SEric Christopher 171cee313d2SEric Christopherfor.outer: 172cee313d2SEric Christopher %indvars.iv = phi i32 [ %indvars.iv.next, %for.latch ], [ 1, %for.preheader ] 173cee313d2SEric Christopher br label %for.inner 174cee313d2SEric Christopher 175cee313d2SEric Christopherfor.inner: 176cee313d2SEric Christopher %j.021 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 177cee313d2SEric Christopher %sum1.020 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 178*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j.021 179*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 180cee313d2SEric Christopher %add = add i32 %0, %sum1.020 181cee313d2SEric Christopher %inc = add nuw i32 %j.021, 1 182cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %indvars.iv 183cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 184cee313d2SEric Christopher 185cee313d2SEric Christopherfor.latch: 186*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %indvars.iv 187*055fb779SNikita Popov store i32 %add, ptr %arrayidx6, align 4 188cee313d2SEric Christopher %indvars.iv.next = add nuw i32 %indvars.iv, 1 189cee313d2SEric Christopher %exitcond24 = icmp eq i32 %indvars.iv.next, %I 190cee313d2SEric Christopher br i1 %exitcond24, label %for.end9, label %for.outer 191cee313d2SEric Christopher 192cee313d2SEric Christopherfor.end9: 193cee313d2SEric Christopher ret void 194cee313d2SEric Christopher} 195cee313d2SEric Christopher 196cee313d2SEric Christopher 197cee313d2SEric Christopher; CHECK-LABEL: disabled5 198cee313d2SEric Christopher; Test odd uses of phi nodes where the outer IV cannot be moved into Fore as it hits a PHI 199cee313d2SEric Christopher@f = hidden global i32 0, align 4 200cee313d2SEric Christopherdefine i32 @disabled5() #0 { 201cee313d2SEric Christopher; CHECK: %0 = phi i32 [ %f.promoted10, %entry ], [ 2, %for.latch ] 202cee313d2SEric Christopher; CHECK: %1 = phi i32 [ %0, %for.outer ], [ 2, %for.inner ] 203cee313d2SEric Christopherentry: 204*055fb779SNikita Popov %f.promoted10 = load i32, ptr @f, align 4 205cee313d2SEric Christopher br label %for.outer 206cee313d2SEric Christopher 207cee313d2SEric Christopherfor.outer: 208cee313d2SEric Christopher %0 = phi i32 [ %f.promoted10, %entry ], [ 2, %for.latch ] 209cee313d2SEric Christopher %d.018 = phi i16 [ 0, %entry ], [ %odd.lcssa, %for.latch ] 210cee313d2SEric Christopher %inc5.sink9 = phi i32 [ 2, %entry ], [ %inc5, %for.latch ] 211cee313d2SEric Christopher br label %for.inner 212cee313d2SEric Christopher 213cee313d2SEric Christopherfor.inner: 214cee313d2SEric Christopher %1 = phi i32 [ %0, %for.outer ], [ 2, %for.inner ] 215cee313d2SEric Christopher %inc.sink8 = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 216cee313d2SEric Christopher %inc = add nuw nsw i32 %inc.sink8, 1 217cee313d2SEric Christopher %exitcond = icmp ne i32 %inc, 7 218cee313d2SEric Christopher br i1 %exitcond, label %for.inner, label %for.latch 219cee313d2SEric Christopher 220cee313d2SEric Christopherfor.latch: 221cee313d2SEric Christopher %.lcssa = phi i32 [ %1, %for.inner ] 222cee313d2SEric Christopher %odd.lcssa = phi i16 [ 1, %for.inner ] 223cee313d2SEric Christopher %inc5 = add nuw nsw i32 %inc5.sink9, 1 224cee313d2SEric Christopher %exitcond11 = icmp ne i32 %inc5, 7 225cee313d2SEric Christopher br i1 %exitcond11, label %for.outer, label %for.end 226cee313d2SEric Christopher 227cee313d2SEric Christopherfor.end: 228cee313d2SEric Christopher %.lcssa.lcssa = phi i32 [ %.lcssa, %for.latch ] 229cee313d2SEric Christopher %inc.lcssa.lcssa = phi i32 [ 7, %for.latch ] 230cee313d2SEric Christopher ret i32 0 231cee313d2SEric Christopher} 232cee313d2SEric Christopher 233cee313d2SEric Christopher 234cee313d2SEric Christopher; CHECK-LABEL: disabled6 235cee313d2SEric Christopher; There is a dependency in here, between @d and %0 (=@f) 236cee313d2SEric Christopher@d6 = hidden global i16 5, align 2 237*055fb779SNikita Popov@f6 = hidden global ptr @d6, align 4 238cee313d2SEric Christopherdefine i32 @disabled6() #0 { 239cee313d2SEric Christopher; CHECK: %inc8.sink14.i = phi i16 [ 1, %entry ], [ %inc8.i, %for.cond.cleanup.i ] 240cee313d2SEric Christopher; CHECK: %c.013.i = phi i32 [ 0, %for.body.i ], [ %inc.i, %for.body6.i ] 241cee313d2SEric Christopherentry: 242*055fb779SNikita Popov store i16 1, ptr @d6, align 2 243*055fb779SNikita Popov %0 = load ptr, ptr @f6, align 4 244cee313d2SEric Christopher br label %for.body.i 245cee313d2SEric Christopher 246cee313d2SEric Christopherfor.body.i: 247cee313d2SEric Christopher %inc8.sink14.i = phi i16 [ 1, %entry ], [ %inc8.i, %for.cond.cleanup.i ] 248*055fb779SNikita Popov %1 = load i16, ptr %0, align 2 249cee313d2SEric Christopher br label %for.body6.i 250cee313d2SEric Christopher 251cee313d2SEric Christopherfor.cond.cleanup.i: 252cee313d2SEric Christopher %inc8.i = add nuw nsw i16 %inc8.sink14.i, 1 253*055fb779SNikita Popov store i16 %inc8.i, ptr @d6, align 2 254cee313d2SEric Christopher %cmp.i = icmp ult i16 %inc8.i, 6 255cee313d2SEric Christopher br i1 %cmp.i, label %for.body.i, label %test.exit 256cee313d2SEric Christopher 257cee313d2SEric Christopherfor.body6.i: 258cee313d2SEric Christopher %c.013.i = phi i32 [ 0, %for.body.i ], [ %inc.i, %for.body6.i ] 259cee313d2SEric Christopher %inc.i = add nuw nsw i32 %c.013.i, 1 260cee313d2SEric Christopher %exitcond.i = icmp eq i32 %inc.i, 7 261cee313d2SEric Christopher br i1 %exitcond.i, label %for.cond.cleanup.i, label %for.body6.i 262cee313d2SEric Christopher 263cee313d2SEric Christophertest.exit: 264cee313d2SEric Christopher %conv2.i = sext i16 %1 to i32 265cee313d2SEric Christopher ret i32 0 266cee313d2SEric Christopher} 267cee313d2SEric Christopher 268cee313d2SEric Christopher 269cee313d2SEric Christopher; CHECK-LABEL: disabled7 270cee313d2SEric Christopher; Has negative output dependency 271*055fb779SNikita Popovdefine void @disabled7(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 272cee313d2SEric Christopher; CHECK: %i.028 = phi i32 [ %add11, %for.cond3.for.cond.cleanup5_crit_edge ], [ 0, %for.body.preheader ] 273cee313d2SEric Christopher; CHECK: %j.026 = phi i32 [ 0, %for.body ], [ %add9, %for.body6 ] 274cee313d2SEric Christopherentry: 275cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 276cee313d2SEric Christopher %cmp127 = icmp ne i32 %I, 0 277cee313d2SEric Christopher %or.cond = and i1 %cmp127, %cmp 278cee313d2SEric Christopher br i1 %or.cond, label %for.body.preheader, label %for.end12 279cee313d2SEric Christopher 280cee313d2SEric Christopherfor.body.preheader: 281cee313d2SEric Christopher br label %for.body 282cee313d2SEric Christopher 283cee313d2SEric Christopherfor.body: 284cee313d2SEric Christopher %i.028 = phi i32 [ %add11, %for.cond3.for.cond.cleanup5_crit_edge ], [ 0, %for.body.preheader ] 285*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.028 286*055fb779SNikita Popov store i32 0, ptr %arrayidx, align 4 287cee313d2SEric Christopher %sub = add i32 %i.028, -1 288*055fb779SNikita Popov %arrayidx2 = getelementptr inbounds i32, ptr %A, i32 %sub 289*055fb779SNikita Popov store i32 2, ptr %arrayidx2, align 4 290cee313d2SEric Christopher br label %for.body6 291cee313d2SEric Christopher 292cee313d2SEric Christopherfor.cond3.for.cond.cleanup5_crit_edge: 293*055fb779SNikita Popov store i32 %add, ptr %arrayidx, align 4 294cee313d2SEric Christopher %add11 = add nuw i32 %i.028, 1 295cee313d2SEric Christopher %exitcond29 = icmp eq i32 %add11, %I 296cee313d2SEric Christopher br i1 %exitcond29, label %for.end12, label %for.body 297cee313d2SEric Christopher 298cee313d2SEric Christopherfor.body6: 299cee313d2SEric Christopher %0 = phi i32 [ 0, %for.body ], [ %add, %for.body6 ] 300cee313d2SEric Christopher %j.026 = phi i32 [ 0, %for.body ], [ %add9, %for.body6 ] 301*055fb779SNikita Popov %arrayidx7 = getelementptr inbounds i32, ptr %B, i32 %j.026 302*055fb779SNikita Popov %1 = load i32, ptr %arrayidx7, align 4 303cee313d2SEric Christopher %add = add i32 %1, %0 304cee313d2SEric Christopher %add9 = add nuw i32 %j.026, 1 305cee313d2SEric Christopher %exitcond = icmp eq i32 %add9, %J 306cee313d2SEric Christopher br i1 %exitcond, label %for.cond3.for.cond.cleanup5_crit_edge, label %for.body6 307cee313d2SEric Christopher 308cee313d2SEric Christopherfor.end12: 309cee313d2SEric Christopher ret void 310cee313d2SEric Christopher} 311cee313d2SEric Christopher 312cee313d2SEric Christopher 313cee313d2SEric Christopher; CHECK-LABEL: disabled8 314cee313d2SEric Christopher; Same as above with an extra outer loop nest 315*055fb779SNikita Popovdefine void @disabled8(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 316cee313d2SEric Christopher; CHECK: %i.036 = phi i32 [ %add15, %for.latch ], [ 0, %for.body ] 317cee313d2SEric Christopher; CHECK: %j.034 = phi i32 [ 0, %for.outer ], [ %add13, %for.inner ] 318cee313d2SEric Christopherentry: 319cee313d2SEric Christopher %cmp = icmp eq i32 %J, 0 320cee313d2SEric Christopher %cmp335 = icmp eq i32 %I, 0 321cee313d2SEric Christopher %or.cond = or i1 %cmp, %cmp335 322cee313d2SEric Christopher br i1 %or.cond, label %for.end18, label %for.body.preheader 323cee313d2SEric Christopher 324cee313d2SEric Christopherfor.body.preheader: 325cee313d2SEric Christopher br label %for.body 326cee313d2SEric Christopher 327cee313d2SEric Christopherfor.body: 328cee313d2SEric Christopher %x.037 = phi i32 [ %inc, %for.cond.cleanup4 ], [ 0, %for.body.preheader ] 329cee313d2SEric Christopher br label %for.outer 330cee313d2SEric Christopher 331cee313d2SEric Christopherfor.cond.cleanup4: 332cee313d2SEric Christopher %inc = add nuw nsw i32 %x.037, 1 333cee313d2SEric Christopher %exitcond40 = icmp eq i32 %inc, 5 334cee313d2SEric Christopher br i1 %exitcond40, label %for.end18, label %for.body 335cee313d2SEric Christopher 336cee313d2SEric Christopherfor.outer: 337cee313d2SEric Christopher %i.036 = phi i32 [ %add15, %for.latch ], [ 0, %for.body ] 338*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %A, i32 %i.036 339*055fb779SNikita Popov store i32 0, ptr %arrayidx, align 4 340cee313d2SEric Christopher %sub = add i32 %i.036, -1 341*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %sub 342*055fb779SNikita Popov store i32 2, ptr %arrayidx6, align 4 343cee313d2SEric Christopher br label %for.inner 344cee313d2SEric Christopher 345cee313d2SEric Christopherfor.latch: 346*055fb779SNikita Popov store i32 %add, ptr %arrayidx, align 4 347cee313d2SEric Christopher %add15 = add nuw i32 %i.036, 1 348cee313d2SEric Christopher %exitcond38 = icmp eq i32 %add15, %I 349cee313d2SEric Christopher br i1 %exitcond38, label %for.cond.cleanup4, label %for.outer 350cee313d2SEric Christopher 351cee313d2SEric Christopherfor.inner: 352cee313d2SEric Christopher %0 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 353cee313d2SEric Christopher %j.034 = phi i32 [ 0, %for.outer ], [ %add13, %for.inner ] 354*055fb779SNikita Popov %arrayidx11 = getelementptr inbounds i32, ptr %B, i32 %j.034 355*055fb779SNikita Popov %1 = load i32, ptr %arrayidx11, align 4 356cee313d2SEric Christopher %add = add i32 %1, %0 357cee313d2SEric Christopher %add13 = add nuw i32 %j.034, 1 358cee313d2SEric Christopher %exitcond = icmp eq i32 %add13, %J 359cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 360cee313d2SEric Christopher 361cee313d2SEric Christopherfor.end18: 362cee313d2SEric Christopher ret void 363cee313d2SEric Christopher} 364cee313d2SEric Christopher 365cee313d2SEric Christopher 366cee313d2SEric Christopher; CHECK-LABEL: disabled9 367cee313d2SEric Christopher; Can't prove alias between A and B 368*055fb779SNikita Popovdefine void @disabled9(i32 %I, i32 %J, ptr nocapture %A, ptr nocapture readonly %B) #0 { 369cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 370cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 371cee313d2SEric Christopherentry: 372cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 373cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 374cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 375cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 376cee313d2SEric Christopher 377cee313d2SEric Christopherfor.outer.preheader: 378cee313d2SEric Christopher br label %for.outer 379cee313d2SEric Christopher 380cee313d2SEric Christopherfor.outer: 381cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 382cee313d2SEric Christopher br label %for.inner 383cee313d2SEric Christopher 384cee313d2SEric Christopherfor.inner: 385cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 386cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 387*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 388*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 389cee313d2SEric Christopher %add = add i32 %0, %sum1 390cee313d2SEric Christopher %inc = add nuw i32 %j, 1 391cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 392cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 393cee313d2SEric Christopher 394cee313d2SEric Christopherfor.latch: 395cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 396*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 397*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 398cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 399cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 400cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 401cee313d2SEric Christopher 402cee313d2SEric Christopherfor.end.loopexit: 403cee313d2SEric Christopher br label %for.end 404cee313d2SEric Christopher 405cee313d2SEric Christopherfor.end: 406cee313d2SEric Christopher ret void 407cee313d2SEric Christopher} 408cee313d2SEric Christopher 409cee313d2SEric Christopher 410cee313d2SEric Christopher; CHECK-LABEL: disable10 411cee313d2SEric Christopher; Simple call 412cee313d2SEric Christopherdeclare void @f10(i32, i32) #0 413*055fb779SNikita Popovdefine void @disable10(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 414cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 415cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 416cee313d2SEric Christopherentry: 417cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 418cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 419cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 420cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 421cee313d2SEric Christopher 422cee313d2SEric Christopherfor.outer.preheader: 423cee313d2SEric Christopher br label %for.outer 424cee313d2SEric Christopher 425cee313d2SEric Christopherfor.outer: 426cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 427cee313d2SEric Christopher br label %for.inner 428cee313d2SEric Christopher 429cee313d2SEric Christopherfor.inner: 430cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 431cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 432*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 433*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 434cee313d2SEric Christopher %add = add i32 %0, %sum1 435cee313d2SEric Christopher %inc = add nuw i32 %j, 1 436cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 437cee313d2SEric Christopher tail call void @f10(i32 %i, i32 %j) nounwind 438cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 439cee313d2SEric Christopher 440cee313d2SEric Christopherfor.latch: 441cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 442*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 443*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 444cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 445cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 446cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 447cee313d2SEric Christopher 448cee313d2SEric Christopherfor.end.loopexit: 449cee313d2SEric Christopher br label %for.end 450cee313d2SEric Christopher 451cee313d2SEric Christopherfor.end: 452cee313d2SEric Christopher ret void 453cee313d2SEric Christopher} 454cee313d2SEric Christopher 455cee313d2SEric Christopher 456cee313d2SEric Christopher; CHECK-LABEL: disable11 457cee313d2SEric Christopher; volatile 458*055fb779SNikita Popovdefine void @disable11(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 459cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 460cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 461cee313d2SEric Christopherentry: 462cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 463cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 464cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 465cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 466cee313d2SEric Christopher 467cee313d2SEric Christopherfor.outer.preheader: 468cee313d2SEric Christopher br label %for.outer 469cee313d2SEric Christopher 470cee313d2SEric Christopherfor.outer: 471cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 472cee313d2SEric Christopher br label %for.inner 473cee313d2SEric Christopher 474cee313d2SEric Christopherfor.inner: 475cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 476cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 477*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 478*055fb779SNikita Popov %0 = load volatile i32, ptr %arrayidx, align 4 479cee313d2SEric Christopher %add = add i32 %0, %sum1 480cee313d2SEric Christopher %inc = add nuw i32 %j, 1 481cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 482cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 483cee313d2SEric Christopher 484cee313d2SEric Christopherfor.latch: 485cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 486*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 487*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 488cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 489cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 490cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 491cee313d2SEric Christopher 492cee313d2SEric Christopherfor.end.loopexit: 493cee313d2SEric Christopher br label %for.end 494cee313d2SEric Christopher 495cee313d2SEric Christopherfor.end: 496cee313d2SEric Christopher ret void 497cee313d2SEric Christopher} 498cee313d2SEric Christopher 499cee313d2SEric Christopher 500cee313d2SEric Christopher; CHECK-LABEL: disable12 501cee313d2SEric Christopher; Multiple aft blocks 502*055fb779SNikita Popovdefine void @disable12(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 503cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch3 ], [ 0, %for.outer.preheader ] 504cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 505cee313d2SEric Christopherentry: 506cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 507cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 508cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 509cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 510cee313d2SEric Christopher 511cee313d2SEric Christopherfor.outer.preheader: 512cee313d2SEric Christopher br label %for.outer 513cee313d2SEric Christopher 514cee313d2SEric Christopherfor.outer: 515cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch3 ], [ 0, %for.outer.preheader ] 516cee313d2SEric Christopher br label %for.inner 517cee313d2SEric Christopher 518cee313d2SEric Christopherfor.inner: 519cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 520cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 521*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 522*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 523cee313d2SEric Christopher %add = add i32 %0, %sum1 524cee313d2SEric Christopher %inc = add nuw i32 %j, 1 525cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 526cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 527cee313d2SEric Christopher 528cee313d2SEric Christopherfor.latch: 529cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 530*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 531*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 532cee313d2SEric Christopher %cmpl = icmp eq i32 %add.lcssa, 10 533cee313d2SEric Christopher br i1 %cmpl, label %for.latch2, label %for.latch3 534cee313d2SEric Christopher 535cee313d2SEric Christopherfor.latch2: 536cee313d2SEric Christopher br label %for.latch3 537cee313d2SEric Christopher 538cee313d2SEric Christopherfor.latch3: 539cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 540cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 541cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 542cee313d2SEric Christopher 543cee313d2SEric Christopherfor.end.loopexit: 544cee313d2SEric Christopher br label %for.end 545cee313d2SEric Christopher 546cee313d2SEric Christopherfor.end: 547cee313d2SEric Christopher ret void 548cee313d2SEric Christopher} 549cee313d2SEric Christopher 550cee313d2SEric Christopher 551cee313d2SEric Christopher; CHECK-LABEL: disable13 552cee313d2SEric Christopher; Two subloops 553*055fb779SNikita Popovdefine void @disable13(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 554cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 555cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 556cee313d2SEric Christopher; CHECK: %j2 = phi i32 [ %inc2, %for.inner2 ], [ 0, %for.inner2.preheader ] 557cee313d2SEric Christopherentry: 558cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 559cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 560cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 561cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 562cee313d2SEric Christopher 563cee313d2SEric Christopherfor.outer.preheader: 564cee313d2SEric Christopher br label %for.outer 565cee313d2SEric Christopher 566cee313d2SEric Christopherfor.outer: 567cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 568cee313d2SEric Christopher br label %for.inner 569cee313d2SEric Christopher 570cee313d2SEric Christopherfor.inner: 571cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 572cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 573*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 574*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 575cee313d2SEric Christopher %add = add i32 %0, %sum1 576cee313d2SEric Christopher %inc = add nuw i32 %j, 1 577cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 578cee313d2SEric Christopher br i1 %exitcond, label %for.inner2, label %for.inner 579cee313d2SEric Christopher 580cee313d2SEric Christopherfor.inner2: 581cee313d2SEric Christopher %j2 = phi i32 [ 0, %for.inner ], [ %inc2, %for.inner2 ] 582cee313d2SEric Christopher %sum12 = phi i32 [ 0, %for.inner ], [ %add2, %for.inner2 ] 583*055fb779SNikita Popov %arrayidx2 = getelementptr inbounds i32, ptr %B, i32 %j2 584*055fb779SNikita Popov %l0 = load i32, ptr %arrayidx2, align 4 585cee313d2SEric Christopher %add2 = add i32 %l0, %sum12 586cee313d2SEric Christopher %inc2 = add nuw i32 %j2, 1 587cee313d2SEric Christopher %exitcond2 = icmp eq i32 %inc2, %J 588cee313d2SEric Christopher br i1 %exitcond2, label %for.latch, label %for.inner2 589cee313d2SEric Christopher 590cee313d2SEric Christopherfor.latch: 591cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner2 ] 592*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 593*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 594cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 595cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 596cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 597cee313d2SEric Christopher 598cee313d2SEric Christopherfor.end.loopexit: 599cee313d2SEric Christopher br label %for.end 600cee313d2SEric Christopher 601cee313d2SEric Christopherfor.end: 602cee313d2SEric Christopher ret void 603cee313d2SEric Christopher} 604cee313d2SEric Christopher 605cee313d2SEric Christopher 606cee313d2SEric Christopher; CHECK-LABEL: disable14 607cee313d2SEric Christopher; Multiple exits blocks 608*055fb779SNikita Popovdefine void @disable14(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 609cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 610cee313d2SEric Christopher; CHECK: %j = phi i32 [ %inc, %for.inner ], [ 0, %for.inner.preheader ] 611cee313d2SEric Christopherentry: 612cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 613cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 614cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 615cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 616cee313d2SEric Christopher 617cee313d2SEric Christopherfor.outer.preheader: 618cee313d2SEric Christopher br label %for.outer 619cee313d2SEric Christopher 620cee313d2SEric Christopherfor.outer: 621cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 622cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 623cee313d2SEric Christopher %exitcond23 = icmp eq i32 %add8, %I 624cee313d2SEric Christopher br i1 %exitcond23, label %for.end.loopexit, label %for.inner 625cee313d2SEric Christopher 626cee313d2SEric Christopherfor.inner: 627cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 628cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 629*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 630*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 631cee313d2SEric Christopher %add = add i32 %0, %sum1 632cee313d2SEric Christopher %inc = add nuw i32 %j, 1 633cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 634cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 635cee313d2SEric Christopher 636cee313d2SEric Christopherfor.latch: 637cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 638*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 639*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 640cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 641cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 642cee313d2SEric Christopher 643cee313d2SEric Christopherfor.end.loopexit: 644cee313d2SEric Christopher br label %for.end 645cee313d2SEric Christopher 646cee313d2SEric Christopherfor.end: 647cee313d2SEric Christopher ret void 648cee313d2SEric Christopher} 649cee313d2SEric Christopher 650cee313d2SEric Christopher 651cee313d2SEric Christopher; CHECK-LABEL: disable15 652cee313d2SEric Christopher; Latch != exit 653*055fb779SNikita Popovdefine void @disable15(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 654cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 655cee313d2SEric Christopher; CHECK: %j = phi i32 [ %inc, %for.inner ], [ 0, %for.inner.preheader ] 656cee313d2SEric Christopherentry: 657cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 658cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 659cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 660cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 661cee313d2SEric Christopher 662cee313d2SEric Christopherfor.outer.preheader: 663cee313d2SEric Christopher br label %for.outer 664cee313d2SEric Christopher 665cee313d2SEric Christopherfor.outer: 666cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 667cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 668cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 669cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.inner 670cee313d2SEric Christopher 671cee313d2SEric Christopherfor.inner: 672cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 673cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 674*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 675*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 676cee313d2SEric Christopher %add = add i32 %0, %sum1 677cee313d2SEric Christopher %inc = add nuw i32 %j, 1 678cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 679cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 680cee313d2SEric Christopher 681cee313d2SEric Christopherfor.latch: 682cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 683*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 684*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 685cee313d2SEric Christopher br label %for.outer 686cee313d2SEric Christopher 687cee313d2SEric Christopherfor.end.loopexit: 688cee313d2SEric Christopher br label %for.end 689cee313d2SEric Christopher 690cee313d2SEric Christopherfor.end: 691cee313d2SEric Christopher ret void 692cee313d2SEric Christopher} 693cee313d2SEric Christopher 694cee313d2SEric Christopher 695cee313d2SEric Christopher; CHECK-LABEL: disable16 696cee313d2SEric Christopher; Cannot move other before inner loop 697*055fb779SNikita Popovdefine void @disable16(i32 %I, i32 %J, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 { 698cee313d2SEric Christopher; CHECK: %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 699cee313d2SEric Christopher; CHECK: %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 700cee313d2SEric Christopherentry: 701cee313d2SEric Christopher %cmp = icmp ne i32 %J, 0 702cee313d2SEric Christopher %cmp122 = icmp ne i32 %I, 0 703cee313d2SEric Christopher %or.cond = and i1 %cmp, %cmp122 704cee313d2SEric Christopher br i1 %or.cond, label %for.outer.preheader, label %for.end 705cee313d2SEric Christopher 706cee313d2SEric Christopherfor.outer.preheader: 707cee313d2SEric Christopher br label %for.outer 708cee313d2SEric Christopher 709cee313d2SEric Christopherfor.outer: 710cee313d2SEric Christopher %i = phi i32 [ %add8, %for.latch ], [ 0, %for.outer.preheader ] 711cee313d2SEric Christopher %otherphi = phi i32 [ %other, %for.latch ], [ 0, %for.outer.preheader ] 712cee313d2SEric Christopher br label %for.inner 713cee313d2SEric Christopher 714cee313d2SEric Christopherfor.inner: 715cee313d2SEric Christopher %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ] 716cee313d2SEric Christopher %sum1 = phi i32 [ 0, %for.outer ], [ %add, %for.inner ] 717*055fb779SNikita Popov %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j 718*055fb779SNikita Popov %0 = load i32, ptr %arrayidx, align 4 719cee313d2SEric Christopher %add = add i32 %0, %sum1 720cee313d2SEric Christopher %inc = add nuw i32 %j, 1 721cee313d2SEric Christopher %exitcond = icmp eq i32 %inc, %J 722cee313d2SEric Christopher br i1 %exitcond, label %for.latch, label %for.inner 723cee313d2SEric Christopher 724cee313d2SEric Christopherfor.latch: 725cee313d2SEric Christopher %add.lcssa = phi i32 [ %add, %for.inner ] 726*055fb779SNikita Popov %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i 727*055fb779SNikita Popov store i32 %add.lcssa, ptr %arrayidx6, align 4 728cee313d2SEric Christopher %add8 = add nuw i32 %i, 1 729cee313d2SEric Christopher %exitcond25 = icmp eq i32 %add8, %I 730*055fb779SNikita Popov %loadarr = getelementptr inbounds i32, ptr %A, i32 %i 731*055fb779SNikita Popov %load = load i32, ptr %arrayidx6, align 4 732cee313d2SEric Christopher %other = add i32 %otherphi, %load 733cee313d2SEric Christopher br i1 %exitcond25, label %for.end.loopexit, label %for.outer 734cee313d2SEric Christopher 735cee313d2SEric Christopherfor.end.loopexit: 736cee313d2SEric Christopher br label %for.end 737cee313d2SEric Christopher 738cee313d2SEric Christopherfor.end: 739cee313d2SEric Christopher ret void 740cee313d2SEric Christopher} 741