xref: /llvm-project/llvm/test/Transforms/LoopUnroll/ARM/lob-unroll.ll (revision f8d270474c14c6705c77971494505dbe4b6d55ae)
1; RUN: opt -mcpu=cortex-m7 -mtriple=thumbv8.1m.main -passes=loop-unroll -S  %s -o - | FileCheck %s --check-prefix=NLOB
2; RUN: opt -mcpu=cortex-m55 -mtriple=thumbv8.1m.main -passes=loop-unroll -S  %s -o - | FileCheck %s --check-prefix=LOB
3
4; This test checks behaviour of loop unrolling on processors with low overhead branching available
5
6; NLOB-LABEL: for.body{{.*}}.prol:
7; NLOB-COUNT-1:     fmul fast float
8; NLOB-LABEL: for.body{{.*}}.prol.1:
9; NLOB-COUNT-1:     fmul fast float
10; NLOB-LABEL: for.body{{.*}}.prol.2:
11; NLOB-COUNT-1:     fmul fast float
12; NLOB-LABEL: for.body{{.*}}:
13; NLOB-COUNT-4:     fmul fast float
14; NLOB-NOT:     fmul fast float
15
16; LOB-LABEL: for.body{{.*}}:
17; LOB:     fmul fast float
18; LOB-NOT:     fmul fast float
19
20
21; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite)
22define dso_local void @test(i32 noundef %n, ptr nocapture noundef %pA) local_unnamed_addr #0 {
23entry:
24  %cmp46 = icmp sgt i32 %n, 0
25  br i1 %cmp46, label %for.body, label %for.cond.cleanup
26
27for.cond.loopexit:                                ; preds = %for.cond6.for.cond.cleanup8_crit_edge.us, %for.body
28  %exitcond49.not = icmp eq i32 %add, %n
29  br i1 %exitcond49.not, label %for.cond.cleanup, label %for.body, !llvm.loop !0
30
31for.cond.cleanup:                                 ; preds = %for.cond.loopexit, %entry
32  ret void
33
34for.body:                                         ; preds = %entry, %for.cond.loopexit
35  %k.047 = phi i32 [ %add, %for.cond.loopexit ], [ 0, %entry ]
36  %add = add nuw nsw i32 %k.047, 1
37  %cmp244 = icmp slt i32 %add, %n
38  br i1 %cmp244, label %for.cond6.preheader.lr.ph, label %for.cond.loopexit
39
40for.cond6.preheader.lr.ph:                        ; preds = %for.body
41  %invariant.gep = getelementptr float, ptr %pA, i32 %k.047
42  br label %for.cond6.preheader.us
43
44for.cond6.preheader.us:                           ; preds = %for.cond6.for.cond.cleanup8_crit_edge.us, %for.cond6.preheader.lr.ph
45  %w.045.us = phi i32 [ %add, %for.cond6.preheader.lr.ph ], [ %inc19.us, %for.cond6.for.cond.cleanup8_crit_edge.us ]
46  %mul.us = mul nuw nsw i32 %w.045.us, %n
47  %0 = getelementptr float, ptr %pA, i32 %mul.us
48  %arrayidx.us = getelementptr float, ptr %0, i32 %k.047
49  br label %for.body9.us
50
51for.body9.us:                                     ; preds = %for.cond6.preheader.us, %for.body9.us
52  %x.043.us = phi i32 [ %add, %for.cond6.preheader.us ], [ %inc.us, %for.body9.us ]
53  %1 = load float, ptr %arrayidx.us, align 4
54  %mul11.us = mul nuw nsw i32 %x.043.us, %n
55  %gep.us = getelementptr float, ptr %invariant.gep, i32 %mul11.us
56  %2 = load float, ptr %gep.us, align 4
57  %mul14.us = fmul fast float %2, %1
58  %arrayidx17.us = getelementptr float, ptr %0, i32 %x.043.us
59  store float %mul14.us, ptr %arrayidx17.us, align 4
60  %inc.us = add nuw nsw i32 %x.043.us, 1
61  %exitcond.not = icmp eq i32 %inc.us, %n
62  br i1 %exitcond.not, label %for.cond6.for.cond.cleanup8_crit_edge.us, label %for.body9.us
63
64for.cond6.for.cond.cleanup8_crit_edge.us:         ; preds = %for.body9.us
65  %inc19.us = add nuw nsw i32 %w.045.us, 1
66  %exitcond48.not = icmp eq i32 %inc19.us, %n
67  br i1 %exitcond48.not, label %for.cond.loopexit, label %for.cond6.preheader.us
68}
69
70!0 = distinct !{!0, !1, !2}
71!1 = !{!"llvm.loop.mustprogress"}
72!2 = !{!"llvm.loop.unroll.disable"}
73