1 ; RUN: opt -mtriple=thumbv8.1m.main -mattr=+mve.fp -loop-unroll -S < %s -o - | FileCheck %s
5 ; CHECK: br i1 %7, label %middle.block, label %vector.body, !llvm.loop !0
7 ; CHECK: br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader13
9 ; CHECK: br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !llvm.loop !2
11 define void @loopfn(float* %s1, float* %s2, float* %d, i32 %n) {
13 %cmp10 = icmp sgt i32 %n, 0
14 br i1 %cmp10, label %for.body.preheader, label %for.cond.cleanup
16 for.body.preheader: ; preds = %entry
17 %min.iters.check = icmp ult i32 %n, 4
18 br i1 %min.iters.check, label %for.body.preheader13, label %vector.ph
20 for.body.preheader13: ; preds = %middle.block, %for.body.preheader
21 %i.011.ph = phi i32 [ 0, %for.body.preheader ], [ %n.vec, %middle.block ]
24 vector.ph: ; preds = %for.body.preheader
25 %n.vec = and i32 %n, -4
28 vector.body: ; preds = %vector.body, %vector.ph
29 %index = phi i32 [ 0, %vector.ph ], [ %index.next, %vector.body ]
30 %0 = getelementptr inbounds float, float* %s1, i32 %index
31 %1 = bitcast float* %0 to <4 x float>*
32 %wide.load = load <4 x float>, <4 x float>* %1, align 4
33 %2 = getelementptr inbounds float, float* %s2, i32 %index
34 %3 = bitcast float* %2 to <4 x float>*
35 %wide.load12 = load <4 x float>, <4 x float>* %3, align 4
36 %4 = fadd fast <4 x float> %wide.load12, %wide.load
37 %5 = getelementptr inbounds float, float* %d, i32 %index
38 %6 = bitcast float* %5 to <4 x float>*
39 store <4 x float> %4, <4 x float>* %6, align 4
40 %index.next = add i32 %index, 4
41 %7 = icmp eq i32 %index.next, %n.vec
42 br i1 %7, label %middle.block, label %vector.body, !llvm.loop !0
44 middle.block: ; preds = %vector.body
45 %cmp.n = icmp eq i32 %n.vec, %n
46 br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader13
48 for.cond.cleanup.loopexit: ; preds = %for.body
49 br label %for.cond.cleanup
51 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %middle.block, %entry
54 for.body: ; preds = %for.body.preheader13, %for.body
55 %i.011 = phi i32 [ %add3, %for.body ], [ %i.011.ph, %for.body.preheader13 ]
56 %arrayidx = getelementptr inbounds float, float* %s1, i32 %i.011
57 %8 = load float, float* %arrayidx, align 4
58 %arrayidx1 = getelementptr inbounds float, float* %s2, i32 %i.011
59 %9 = load float, float* %arrayidx1, align 4
60 %add = fadd fast float %9, %8
61 %arrayidx2 = getelementptr inbounds float, float* %d, i32 %i.011
62 store float %add, float* %arrayidx2, align 4
63 %add3 = add nuw nsw i32 %i.011, 1
64 %exitcond = icmp eq i32 %add3, %n
65 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !llvm.loop !2
70 ; CHECK-LABEL: @nested
72 ; CHECK: br label %vector.body
74 ; CHECK: br i1 %8, label %for.latch, label %vector.body, !llvm.loop !0
76 ; CHECK: br i1 %exitcond34, label %for.cond.cleanup.loopexit, label %for.outer
78 define void @nested(float* %s1, float* %s2, float* %d, i32 %n) {
80 %cmp31 = icmp eq i32 %n, 0
81 br i1 %cmp31, label %for.cond.cleanup, label %for.outer.preheader
83 for.outer.preheader: ; preds = %entry
84 %min.iters.check = icmp ult i32 %n, 4
85 %n.vec = and i32 %n, -4
86 %cmp.n = icmp eq i32 %n.vec, %n
89 for.outer: ; preds = %for.outer.preheader, %for.cond1.for.cond.cleanup3_crit_edge.us
90 %j.032.us = phi i32 [ %inc.us, %for.latch ], [ 0, %for.outer.preheader ]
91 %mul.us = mul i32 %j.032.us, %n
94 vector.body: ; preds = %for.outer, %vector.body
95 %index = phi i32 [ %index.next, %vector.body ], [ 0, %for.outer ]
96 %0 = add i32 %index, %mul.us
97 %1 = getelementptr inbounds float, float* %s1, i32 %0
98 %2 = bitcast float* %1 to <4 x float>*
99 %wide.load = load <4 x float>, <4 x float>* %2, align 4
100 %3 = getelementptr inbounds float, float* %s2, i32 %0
101 %4 = bitcast float* %3 to <4 x float>*
102 %wide.load35 = load <4 x float>, <4 x float>* %4, align 4
103 %5 = fadd fast <4 x float> %wide.load35, %wide.load
104 %6 = getelementptr inbounds float, float* %d, i32 %0
105 %7 = bitcast float* %6 to <4 x float>*
106 store <4 x float> %5, <4 x float>* %7, align 4
107 %index.next = add i32 %index, 4
108 %8 = icmp eq i32 %index.next, %n.vec
109 br i1 %8, label %for.latch, label %vector.body, !llvm.loop !0
111 for.latch: ; preds = %vector.body, %for.outer
112 %i.030.us.ph = phi i32 [ %n.vec, %vector.body ]
113 %inc.us = add nuw i32 %j.032.us, 1
114 %exitcond34 = icmp eq i32 %inc.us, %n
115 br i1 %exitcond34, label %for.cond.cleanup.loopexit, label %for.outer
117 for.cond.cleanup.loopexit:
118 br label %for.cond.cleanup
120 for.cond.cleanup: ; preds = %for.cond1.for.cond.cleanup3_crit_edge.us, %entry
124 !0 = distinct !{!0, !1}
125 !1 = !{!"llvm.loop.isvectorized", i32 1}
126 !2 = distinct !{!2, !3, !1}
127 !3 = !{!"llvm.loop.unroll.runtime.disable"}