1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s | FileCheck %s
3
4target 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"
5target triple = "thumbv7m--linux-gnu"
6
7; NOTE: When optimising for minimum size, an LDM is expected to be generated
8define void @f(i32 %n, i32* nocapture %a, i32* nocapture readonly %b) optsize minsize {
9; CHECK-LABEL: f:
10; CHECK:       @ %bb.0:
11; CHECK-NEXT:    cmp r0, #1
12; CHECK-NEXT:    blt .LBB0_2
13; CHECK-NEXT:  .LBB0_1: @ %.lr.ph
14; CHECK-NEXT:    @ =>This Inner Loop Header: Depth=1
15; CHECK-NEXT:    ldm r2!, {r3}
16; CHECK-NEXT:    adds r3, #3
17; CHECK-NEXT:    stm r1!, {r3}
18; CHECK-NEXT:    subs r0, #1
19; CHECK-NEXT:    bne .LBB0_1
20; CHECK-NEXT:  .LBB0_2: @ %._crit_edge
21; CHECK-NEXT:    bx lr
22  %1 = icmp sgt i32 %n, 0
23  br i1 %1, label %.lr.ph, label %._crit_edge
24
25.lr.ph:                                           ; preds = %.lr.ph, %0
26  %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
27  %.03 = phi i32* [ %2, %.lr.ph ], [ %b, %0 ]
28  %.012 = phi i32* [ %5, %.lr.ph ], [ %a, %0 ]
29  %2 = getelementptr inbounds i32, i32* %.03, i32 1
30  %3 = load i32, i32* %.03, align 4
31  %4 = add nsw i32 %3, 3
32  %5 = getelementptr inbounds i32, i32* %.012, i32 1
33  store i32 %4, i32* %.012, align 4
34  %6 = add nsw i32 %i.04, 1
35  %exitcond = icmp eq i32 %6, %n
36  br i1 %exitcond, label %._crit_edge, label %.lr.ph
37
38._crit_edge:                                      ; preds = %.lr.ph, %0
39  ret void
40}
41
42; NOTE: When not optimising for minimum size, an LDM is expected not to be generated
43define void @f_nominsize(i32 %n, i32* nocapture %a, i32* nocapture readonly %b) optsize {
44; CHECK-LABEL: f_nominsize:
45; CHECK:       @ %bb.0:
46; CHECK-NEXT:    cmp r0, #1
47; CHECK-NEXT:    it lt
48; CHECK-NEXT:    bxlt lr
49; CHECK-NEXT:  .LBB1_1: @ %.lr.ph
50; CHECK-NEXT:    @ =>This Inner Loop Header: Depth=1
51; CHECK-NEXT:    ldr r3, [r2], #4
52; CHECK-NEXT:    subs r0, #1
53; CHECK-NEXT:    add.w r3, r3, #3
54; CHECK-NEXT:    str r3, [r1], #4
55; CHECK-NEXT:    bne .LBB1_1
56; CHECK-NEXT:  @ %bb.2: @ %._crit_edge
57; CHECK-NEXT:    bx lr
58  %1 = icmp sgt i32 %n, 0
59  br i1 %1, label %.lr.ph, label %._crit_edge
60
61.lr.ph:                                           ; preds = %.lr.ph, %0
62  %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
63  %.03 = phi i32* [ %2, %.lr.ph ], [ %b, %0 ]
64  %.012 = phi i32* [ %5, %.lr.ph ], [ %a, %0 ]
65  %2 = getelementptr inbounds i32, i32* %.03, i32 1
66  %3 = load i32, i32* %.03, align 4
67  %4 = add nsw i32 %3, 3
68  %5 = getelementptr inbounds i32, i32* %.012, i32 1
69  store i32 %4, i32* %.012, align 4
70  %6 = add nsw i32 %i.04, 1
71  %exitcond = icmp eq i32 %6, %n
72  br i1 %exitcond, label %._crit_edge, label %.lr.ph
73
74._crit_edge:                                      ; preds = %.lr.ph, %0
75  ret void
76}
77