51 lines · plain
1; RUN: llc -O3 -mtriple=hexagon < %s | FileCheck %s2; Test to ensure LSR does not optimize out addrec of the outerloop.3; This will help to generate post-increment instructions, otherwise4; it end up an as extra reg+reg add inside the loop.5; CHECK: loop0(.LBB0_[[LOOP:.]],6; CHECK: .LBB0_[[LOOP]]:7; CHECK: memuh{{.*}}++8; CHECK: endloop9 10 11define dso_local signext i16 @foo(ptr nocapture readonly %filt, ptr nocapture readonly %inp, i32 %c1, i32 %c2) local_unnamed_addr {12entry:13 %cmp28 = icmp sgt i32 %c1, 014 %cmp221 = icmp sgt i32 %c2, 015 %or.cond = and i1 %cmp28, %cmp22116 br i1 %or.cond, label %for.cond1.preheader.us, label %for.cond.cleanup17 18for.cond1.preheader.us: ; preds = %entry, %for.cond1.for.cond.cleanup3_crit_edge.us19 %filt.addr.032.us = phi ptr [ %scevgep, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %filt, %entry ]20 %inp.addr.031.us = phi ptr [ %scevgep35, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %inp, %entry ]21 %l.030.us = phi i32 [ %inc11.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %entry ]22 %sum0.029.us = phi i16 [ %add8.us, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ 0, %entry ]23 %scevgep = getelementptr i16, ptr %filt.addr.032.us, i32 %c224 br label %for.body4.us25 26for.body4.us: ; preds = %for.body4.us, %for.cond1.preheader.us27 %z.025.us = phi i32 [ 0, %for.cond1.preheader.us ], [ %inc.us, %for.body4.us ]28 %filt.addr.124.us = phi ptr [ %filt.addr.032.us, %for.cond1.preheader.us ], [ %incdec.ptr.us, %for.body4.us ]29 %inp.addr.123.us = phi ptr [ %inp.addr.031.us, %for.cond1.preheader.us ], [ %incdec.ptr5.us, %for.body4.us ]30 %sum0.122.us = phi i16 [ %sum0.029.us, %for.cond1.preheader.us ], [ %add8.us, %for.body4.us ]31 %incdec.ptr.us = getelementptr inbounds i16, ptr %filt.addr.124.us, i32 132 %0 = load i16, ptr %filt.addr.124.us, align 233 %incdec.ptr5.us = getelementptr inbounds i16, ptr %inp.addr.123.us, i32 134 %1 = load i16, ptr %inp.addr.123.us, align 235 %add.us = add i16 %0, %sum0.122.us36 %add8.us = add i16 %add.us, %137 %inc.us = add nuw nsw i32 %z.025.us, 138 %exitcond = icmp eq i32 %inc.us, %c239 br i1 %exitcond, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us40 41for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us42 %scevgep35 = getelementptr i16, ptr %inp.addr.031.us, i32 %c243 %inc11.us = add nuw nsw i32 %l.030.us, 144 %exitcond36 = icmp eq i32 %inc11.us, %c145 br i1 %exitcond36, label %for.cond.cleanup, label %for.cond1.preheader.us46 47for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %entry48 %sum0.0.lcssa = phi i16 [ 0, %entry ], [ %add8.us, %for.cond1.for.cond.cleanup3_crit_edge.us ]49 ret i16 %sum0.0.lcssa50}51