1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 target 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"
5 target triple = "thumbv7m--linux-gnu"
7 ; NOTE: When optimising for minimum size, an LDM is expected to be generated
8 define void @f(i32 %n, ptr nocapture %a, ptr nocapture readonly %b) optsize minsize {
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
22 %1 = icmp sgt i32 %n, 0
23 br i1 %1, label %.lr.ph, label %._crit_edge
25 .lr.ph: ; preds = %.lr.ph, %0
26 %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
27 %.03 = phi ptr [ %2, %.lr.ph ], [ %b, %0 ]
28 %.012 = phi ptr [ %5, %.lr.ph ], [ %a, %0 ]
29 %2 = getelementptr inbounds i32, ptr %.03, i32 1
30 %3 = load i32, ptr %.03, align 4
31 %4 = add nsw i32 %3, 3
32 %5 = getelementptr inbounds i32, ptr %.012, i32 1
33 store i32 %4, ptr %.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
38 ._crit_edge: ; preds = %.lr.ph, %0
42 ; NOTE: When not optimising for minimum size, an LDM is expected not to be generated
43 define void @f_nominsize(i32 %n, ptr nocapture %a, ptr nocapture readonly %b) optsize {
44 ; CHECK-LABEL: f_nominsize:
46 ; CHECK-NEXT: cmp r0, #1
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
58 %1 = icmp sgt i32 %n, 0
59 br i1 %1, label %.lr.ph, label %._crit_edge
61 .lr.ph: ; preds = %.lr.ph, %0
62 %i.04 = phi i32 [ %6, %.lr.ph ], [ 0, %0 ]
63 %.03 = phi ptr [ %2, %.lr.ph ], [ %b, %0 ]
64 %.012 = phi ptr [ %5, %.lr.ph ], [ %a, %0 ]
65 %2 = getelementptr inbounds i32, ptr %.03, i32 1
66 %3 = load i32, ptr %.03, align 4
67 %4 = add nsw i32 %3, 3
68 %5 = getelementptr inbounds i32, ptr %.012, i32 1
69 store i32 %4, ptr %.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
74 ._crit_edge: ; preds = %.lr.ph, %0