1; RUN: llc < %s | FileCheck %s
2
3target datalayout = "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32"
4target triple = "thumbv7m--linux-gnu"
5
6; CHECK-LABEL: f:
7; CHECK: ldm	r{{[0-9]}}!, {r[[x:[0-9]]]}
8; CHECK: add.w	r[[x]], r[[x]], #3
9; CHECK: stm	r{{[0-9]}}!, {r[[x]]}
10define void @f(i32 %n, i32* nocapture %a, i32* nocapture readonly %b) optsize minsize {
11  %1 = icmp sgt i32 %n, 0
12  br i1 %1, label %.lr.ph, label %._crit_edge
13
14.lr.ph:                                           ; preds = %.lr.ph, %0
15  %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
16  %.03 = phi i32* [ %2, %.lr.ph ], [ %b, %0 ]
17  %.012 = phi i32* [ %5, %.lr.ph ], [ %a, %0 ]
18  %2 = getelementptr inbounds i32, i32* %.03, i32 1
19  %3 = load i32, i32* %.03, align 4
20  %4 = add nsw i32 %3, 3
21  %5 = getelementptr inbounds i32, i32* %.012, i32 1
22  store i32 %4, i32* %.012, align 4
23  %6 = add nsw i32 %i.04, 1
24  %exitcond = icmp eq i32 %6, %n
25  br i1 %exitcond, label %._crit_edge, label %.lr.ph
26
27._crit_edge:                                      ; preds = %.lr.ph, %0
28  ret void
29}
30
31; CHECK-LABEL: f_nominsize:
32; CHECK-NOT: ldm
33define void @f_nominsize(i32 %n, i32* nocapture %a, i32* nocapture readonly %b) optsize {
34  %1 = icmp sgt i32 %n, 0
35  br i1 %1, label %.lr.ph, label %._crit_edge
36
37.lr.ph:                                           ; preds = %.lr.ph, %0
38  %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
39  %.03 = phi i32* [ %2, %.lr.ph ], [ %b, %0 ]
40  %.012 = phi i32* [ %5, %.lr.ph ], [ %a, %0 ]
41  %2 = getelementptr inbounds i32, i32* %.03, i32 1
42  %3 = load i32, i32* %.03, align 4
43  %4 = add nsw i32 %3, 3
44  %5 = getelementptr inbounds i32, i32* %.012, i32 1
45  store i32 %4, i32* %.012, align 4
46  %6 = add nsw i32 %i.04, 1
47  %exitcond = icmp eq i32 %6, %n
48  br i1 %exitcond, label %._crit_edge, label %.lr.ph
49
50._crit_edge:                                      ; preds = %.lr.ph, %0
51  ret void
52}
53