1*cee313d2SEric Christophertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" 2*cee313d2SEric Christopher 3*cee313d2SEric Christopher; RUN: opt -mtriple=thumbv7em %s -S -loop-reduce -lsr-complexity-limit=65536 -o - | FileCheck %s 4*cee313d2SEric Christopher; RUN: opt -mtriple=thumbv7em %s -S -loop-reduce -lsr-complexity-limit=2147483647 -o - | FileCheck %s 5*cee313d2SEric Christopher 6*cee313d2SEric Christopher; CHECK-LABEL: for.body12.us.us: 7*cee313d2SEric Christopher; CHECK: [[LSR_IV6:%[^ ]+]] = phi i16* [ [[SCEVGEP7:%[^ ]+]], %for.body12.us.us ], [ [[SCEVGEP5:%[^ ]+]], %for.cond9.preheader.us.us ] 8*cee313d2SEric Christopher; CHECK: phi i32 9*cee313d2SEric Christopher; CHECK: [[LSR_IV:%[^ ]+]] = phi i16* [ [[SCEVGEP1:%[^ ]+]], %for.body12.us.us ], [ [[SCEVGEP:%[^ ]+]], %for.cond9.preheader.us.us ] 10*cee313d2SEric Christopher; CHECK: phi i32 11*cee313d2SEric Christopher; CHECK: [[SCEVGEP1]] = getelementptr i16, i16* [[LSR_IV]], i32 4 12*cee313d2SEric Christopher; CHECK: [[SCEVGEP7]] = getelementptr i16, i16* [[LSR_IV6]], i32 4 13*cee313d2SEric Christopher 14*cee313d2SEric Christopherdefine void @convolve(i16** nocapture readonly %input_image, i16** nocapture readonly %filter, i32 %filter_dim, i32 %out_width, i32 %out_height, i32** nocapture readonly %convolved) { 15*cee313d2SEric Christopherentry: 16*cee313d2SEric Christopher %cmp92 = icmp eq i32 %out_height, 0 17*cee313d2SEric Christopher br i1 %cmp92, label %for.cond.cleanup, label %for.cond1.preheader.lr.ph 18*cee313d2SEric Christopher 19*cee313d2SEric Christopherfor.cond1.preheader.lr.ph: ; preds = %entry 20*cee313d2SEric Christopher %xtraiter = and i32 %filter_dim, 3 21*cee313d2SEric Christopher %unroll_iter = sub i32 %filter_dim, %xtraiter 22*cee313d2SEric Christopher br label %for.cond1.preheader 23*cee313d2SEric Christopher 24*cee313d2SEric Christopherfor.cond1.preheader: ; preds = %for.cond.cleanup3, %for.cond1.preheader.lr.ph 25*cee313d2SEric Christopher %res_y.093 = phi i32 [ 0, %for.cond1.preheader.lr.ph ], [ %add28, %for.cond.cleanup3 ] 26*cee313d2SEric Christopher %arrayidx22 = getelementptr inbounds i32*, i32** %convolved, i32 %res_y.093 27*cee313d2SEric Christopher %tmp3 = load i32*, i32** %arrayidx22, align 4 28*cee313d2SEric Christopher br label %for.cond9.preheader.us.us.preheader 29*cee313d2SEric Christopher 30*cee313d2SEric Christopherfor.cond9.preheader.us.us.preheader: ; preds = %for.cond5.for.cond.cleanup7_crit_edge.us, %for.cond5.preheader.lr.ph 31*cee313d2SEric Christopher %res_x.060.us = phi i32 [ %add25.us, %for.cond5.for.cond.cleanup7_crit_edge.us ], [ 0, %for.cond1.preheader ] 32*cee313d2SEric Christopher br label %for.cond9.preheader.us.us 33*cee313d2SEric Christopher 34*cee313d2SEric Christopherfor.cond9.preheader.us.us: ; preds = %for.cond9.for.cond.cleanup11_crit_edge.us.us, %for.cond9.preheader.us.us.preheader 35*cee313d2SEric Christopher %filter_y.056.us.us = phi i32 [ %inc20.us.us, %for.cond9.for.cond.cleanup11_crit_edge.us.us.unr-lcssa ], [ 0, %for.cond9.preheader.us.us.preheader ] 36*cee313d2SEric Christopher %result_element.055.us.us = phi i32 [ %add18.us.us.3, %for.cond9.for.cond.cleanup11_crit_edge.us.us.unr-lcssa ], [ 0, %for.cond9.preheader.us.us.preheader ] 37*cee313d2SEric Christopher %add.us.us = add i32 %filter_y.056.us.us, %res_y.093 38*cee313d2SEric Christopher %arrayidx.us.us = getelementptr inbounds i16*, i16** %filter, i32 %filter_y.056.us.us 39*cee313d2SEric Christopher %tmp5 = load i16*, i16** %arrayidx.us.us, align 4 40*cee313d2SEric Christopher %arrayidx15.us.us = getelementptr inbounds i16*, i16** %input_image, i32 %add.us.us 41*cee313d2SEric Christopher %tmp6 = load i16*, i16** %arrayidx15.us.us, align 4 42*cee313d2SEric Christopher br label %for.body12.us.us 43*cee313d2SEric Christopher 44*cee313d2SEric Christopherfor.body12.us.us: ; preds = %for.body12.us.us, %for.cond9.preheader.us.us 45*cee313d2SEric Christopher %filter_x.053.us.us = phi i32 [ %inc.us.us.3, %for.body12.us.us ], [ 0, %for.cond9.preheader.us.us ] 46*cee313d2SEric Christopher %result_element.152.us.us = phi i32 [ %add18.us.us.3, %for.body12.us.us ], [ %result_element.055.us.us, %for.cond9.preheader.us.us ] 47*cee313d2SEric Christopher %niter = phi i32 [ %niter.nsub.3, %for.body12.us.us ], [ %unroll_iter, %for.cond9.preheader.us.us ] 48*cee313d2SEric Christopher %add13.us.us = add i32 %filter_x.053.us.us, %res_x.060.us 49*cee313d2SEric Christopher %arrayidx14.us.us = getelementptr inbounds i16, i16* %tmp5, i32 %filter_x.053.us.us 50*cee313d2SEric Christopher %tmp9 = load i16, i16* %arrayidx14.us.us, align 2 51*cee313d2SEric Christopher %conv.us.us = sext i16 %tmp9 to i32 52*cee313d2SEric Christopher %arrayidx16.us.us = getelementptr inbounds i16, i16* %tmp6, i32 %add13.us.us 53*cee313d2SEric Christopher %tmp10 = load i16, i16* %arrayidx16.us.us, align 2 54*cee313d2SEric Christopher %conv17.us.us = sext i16 %tmp10 to i32 55*cee313d2SEric Christopher %mul.us.us = mul nsw i32 %conv17.us.us, %conv.us.us 56*cee313d2SEric Christopher %add18.us.us = add nsw i32 %mul.us.us, %result_element.152.us.us 57*cee313d2SEric Christopher %inc.us.us = or i32 %filter_x.053.us.us, 1 58*cee313d2SEric Christopher %add13.us.us.1 = add i32 %inc.us.us, %res_x.060.us 59*cee313d2SEric Christopher %arrayidx14.us.us.1 = getelementptr inbounds i16, i16* %tmp5, i32 %inc.us.us 60*cee313d2SEric Christopher %tmp11 = load i16, i16* %arrayidx14.us.us.1, align 2 61*cee313d2SEric Christopher %conv.us.us.1 = sext i16 %tmp11 to i32 62*cee313d2SEric Christopher %arrayidx16.us.us.1 = getelementptr inbounds i16, i16* %tmp6, i32 %add13.us.us.1 63*cee313d2SEric Christopher %tmp12 = load i16, i16* %arrayidx16.us.us.1, align 2 64*cee313d2SEric Christopher %conv17.us.us.1 = sext i16 %tmp12 to i32 65*cee313d2SEric Christopher %mul.us.us.1 = mul nsw i32 %conv17.us.us.1, %conv.us.us.1 66*cee313d2SEric Christopher %add18.us.us.1 = add nsw i32 %mul.us.us.1, %add18.us.us 67*cee313d2SEric Christopher %inc.us.us.1 = or i32 %filter_x.053.us.us, 2 68*cee313d2SEric Christopher %add13.us.us.2 = add i32 %inc.us.us.1, %res_x.060.us 69*cee313d2SEric Christopher %arrayidx14.us.us.2 = getelementptr inbounds i16, i16* %tmp5, i32 %inc.us.us.1 70*cee313d2SEric Christopher %tmp13 = load i16, i16* %arrayidx14.us.us.2, align 2 71*cee313d2SEric Christopher %conv.us.us.2 = sext i16 %tmp13 to i32 72*cee313d2SEric Christopher %arrayidx16.us.us.2 = getelementptr inbounds i16, i16* %tmp6, i32 %add13.us.us.2 73*cee313d2SEric Christopher %tmp14 = load i16, i16* %arrayidx16.us.us.2, align 2 74*cee313d2SEric Christopher %conv17.us.us.2 = sext i16 %tmp14 to i32 75*cee313d2SEric Christopher %mul.us.us.2 = mul nsw i32 %conv17.us.us.2, %conv.us.us.2 76*cee313d2SEric Christopher %add18.us.us.2 = add nsw i32 %mul.us.us.2, %add18.us.us.1 77*cee313d2SEric Christopher %inc.us.us.2 = or i32 %filter_x.053.us.us, 3 78*cee313d2SEric Christopher %add13.us.us.3 = add i32 %inc.us.us.2, %res_x.060.us 79*cee313d2SEric Christopher %arrayidx14.us.us.3 = getelementptr inbounds i16, i16* %tmp5, i32 %inc.us.us.2 80*cee313d2SEric Christopher %tmp15 = load i16, i16* %arrayidx14.us.us.3, align 2 81*cee313d2SEric Christopher %conv.us.us.3 = sext i16 %tmp15 to i32 82*cee313d2SEric Christopher %arrayidx16.us.us.3 = getelementptr inbounds i16, i16* %tmp6, i32 %add13.us.us.3 83*cee313d2SEric Christopher %tmp16 = load i16, i16* %arrayidx16.us.us.3, align 2 84*cee313d2SEric Christopher %conv17.us.us.3 = sext i16 %tmp16 to i32 85*cee313d2SEric Christopher %mul.us.us.3 = mul nsw i32 %conv17.us.us.3, %conv.us.us.3 86*cee313d2SEric Christopher %add18.us.us.3 = add nsw i32 %mul.us.us.3, %add18.us.us.2 87*cee313d2SEric Christopher %inc.us.us.3 = add i32 %filter_x.053.us.us, 4 88*cee313d2SEric Christopher %niter.nsub.3 = add i32 %niter, -4 89*cee313d2SEric Christopher %niter.ncmp.3 = icmp eq i32 %niter.nsub.3, 0 90*cee313d2SEric Christopher br i1 %niter.ncmp.3, label %for.cond9.for.cond.cleanup11_crit_edge.us.us.unr-lcssa, label %for.body12.us.us 91*cee313d2SEric Christopher 92*cee313d2SEric Christopherfor.cond9.for.cond.cleanup11_crit_edge.us.us.unr-lcssa: ; preds = %for.body12.us.us, %for.cond9.preheader.us.us 93*cee313d2SEric Christopher %inc20.us.us = add nuw i32 %filter_y.056.us.us, 1 94*cee313d2SEric Christopher %exitcond98 = icmp eq i32 %inc20.us.us, %filter_dim 95*cee313d2SEric Christopher br i1 %exitcond98, label %for.cond5.for.cond.cleanup7_crit_edge.us, label %for.cond9.preheader.us.us 96*cee313d2SEric Christopher 97*cee313d2SEric Christopherfor.cond5.for.cond.cleanup7_crit_edge.us: ; preds = %for.cond9.for.cond.cleanup11_crit_edge.us.us 98*cee313d2SEric Christopher %arrayidx23.us = getelementptr inbounds i32, i32* %tmp3, i32 %res_x.060.us 99*cee313d2SEric Christopher store i32 %add18.us.us.3, i32* %arrayidx23.us, align 4 100*cee313d2SEric Christopher %add25.us = add nuw i32 %res_x.060.us, 1 101*cee313d2SEric Christopher %exitcond99 = icmp eq i32 %add25.us, %out_width 102*cee313d2SEric Christopher br i1 %exitcond99, label %for.cond.cleanup3, label %for.cond9.preheader.us.us.preheader 103*cee313d2SEric Christopher 104*cee313d2SEric Christopherfor.cond.cleanup3: ; preds = %for.cond5.for.cond.cleanup7_crit_edge.us, %for.cond5.preheader.preheader, %for.cond1.preheader 105*cee313d2SEric Christopher %add28 = add nuw i32 %res_y.093, 1 106*cee313d2SEric Christopher %exitcond100 = icmp eq i32 %add28, %out_height 107*cee313d2SEric Christopher br i1 %exitcond100, label %for.cond.cleanup, label %for.cond1.preheader 108*cee313d2SEric Christopher 109*cee313d2SEric Christopherfor.cond.cleanup: ; preds = %for.cond.cleanup3, %entry 110*cee313d2SEric Christopher ret void 111*cee313d2SEric Christopher} 112*cee313d2SEric Christopher 113