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]]:
11 define dso_local signext i16 @foo(ptr nocapture readonly %filt, ptr nocapture readonly %inp, i32 %c1, i32 %c2) local_unnamed_addr {
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
18 for.cond1.preheader.us: ; preds = %entry, %for.cond1.for.cond.cleanup3_crit_edge.us
19 %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 %c2
24 br label %for.body4.us
26 for.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 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 1
32 %0 = load i16, ptr %filt.addr.124.us, align 2
33 %incdec.ptr5.us = getelementptr inbounds i16, ptr %inp.addr.123.us, i32 1
34 %1 = load i16, ptr %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
41 for.cond1.for.cond.cleanup3_crit_edge.us: ; preds = %for.body4.us
42 %scevgep35 = getelementptr i16, ptr %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
47 for.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 ]