1; RUN: llc -O3 -march=hexagon < %s | FileCheck %s 2; Test to ensure LSR does not optimize out addrec of the outerloop. 3; This will help to generate post-increment instructions, otherwise 4; 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: endloop 9 10 11define dso_local signext i16 @foo(i16* nocapture readonly %filt, i16* nocapture readonly %inp, i32 %c1, i32 %c2) local_unnamed_addr { 12entry: 13 %cmp28 = icmp sgt i32 %c1, 0 14 %cmp221 = icmp sgt i32 %c2, 0 15 %or.cond = and i1 %cmp28, %cmp221 16 br i1 %or.cond, label %for.cond1.preheader.us, label %for.cond.cleanup 17 18for.cond1.preheader.us: ; preds = %entry, %for.cond1.for.cond.cleanup3_crit_edge.us 19 %filt.addr.032.us = phi i16* [ %scevgep, %for.cond1.for.cond.cleanup3_crit_edge.us ], [ %filt, %entry ] 20 %inp.addr.031.us = phi i16* [ %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, i16* %filt.addr.032.us, i32 %c2 24 br label %for.body4.us 25 26for.body4.us: ; preds = %for.body4.us, %for.cond1.preheader.us 27 %z.025.us = phi i32 [ 0, %for.cond1.preheader.us ], [ %inc.us, %for.body4.us ] 28 %filt.addr.124.us = phi i16* [ %filt.addr.032.us, %for.cond1.preheader.us ], [ %incdec.ptr.us, %for.body4.us ] 29 %inp.addr.123.us = phi i16* [ %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, i16* %filt.addr.124.us, i32 1 32 %0 = load i16, i16* %filt.addr.124.us, align 2 33 %incdec.ptr5.us = getelementptr inbounds i16, i16* %inp.addr.123.us, i32 1 34 %1 = load i16, i16* %inp.addr.123.us, align 2 35 %add.us = add i16 %0, %sum0.122.us 36 %add8.us = add i16 %add.us, %1 37 %inc.us = add nuw nsw i32 %z.025.us, 1 38 %exitcond = icmp eq i32 %inc.us, %c2 39 br i1 %exitcond, label %for.cond1.for.cond.cleanup3_crit_edge.us, label %for.body4.us 40 41for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us 42 %scevgep35 = getelementptr i16, i16* %inp.addr.031.us, i32 %c2 43 %inc11.us = add nuw nsw i32 %l.030.us, 1 44 %exitcond36 = icmp eq i32 %inc11.us, %c1 45 br i1 %exitcond36, label %for.cond.cleanup, label %for.cond1.preheader.us 46 47for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %entry 48 %sum0.0.lcssa = phi i16 [ 0, %entry ], [ %add8.us, %for.cond1.for.cond.cleanup3_crit_edge.us ] 49 ret i16 %sum0.0.lcssa 50} 51