1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv8.1-m.main-none-eabi -mcpu=cortex-m55 -O3 < %s | FileCheck %s
4 define i32 @loop(ptr nocapture readonly %x) {
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: .save {r7, lr}
8 ; CHECK-NEXT: push {r7, lr}
9 ; CHECK-NEXT: mov.w lr, #500
10 ; CHECK-NEXT: mov r1, r0
11 ; CHECK-NEXT: movs r0, #0
12 ; CHECK-NEXT: .p2align 2
13 ; CHECK-NEXT: .LBB0_1: @ %for.body
14 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
15 ; CHECK-NEXT: ldr r2, [r1], #4
16 ; CHECK-NEXT: add r0, r2
17 ; CHECK-NEXT: le lr, .LBB0_1
18 ; CHECK-NEXT: @ %bb.2: @ %for.cond.cleanup
19 ; CHECK-NEXT: pop {r7, pc}
23 for.cond.cleanup: ; preds = %for.body
26 for.body: ; preds = %entry, %for.body
27 %i.07 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
28 %s.06 = phi i32 [ 0, %entry ], [ %add, %for.body ]
29 %arrayidx = getelementptr inbounds i32, ptr %x, i32 %i.07
30 %0 = load i32, ptr %arrayidx, align 4
31 %add = add nsw i32 %0, %s.06
32 %inc = add nuw nsw i32 %i.07, 1
33 %exitcond.not = icmp eq i32 %inc, 500
34 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
37 define i64 @loopif(ptr nocapture readonly %x, i32 %y, i32 %n) {
38 ; CHECK-LABEL: loopif:
39 ; CHECK: @ %bb.0: @ %entry
40 ; CHECK-NEXT: .save {r7, lr}
41 ; CHECK-NEXT: push {r7, lr}
42 ; CHECK-NEXT: cmp r2, #1
43 ; CHECK-NEXT: blt .LBB1_4
44 ; CHECK-NEXT: @ %bb.1: @ %for.body.lr.ph
45 ; CHECK-NEXT: dls lr, r2
46 ; CHECK-NEXT: mov r12, r0
47 ; CHECK-NEXT: movs r0, #0
48 ; CHECK-NEXT: movs r3, #0
49 ; CHECK-NEXT: .p2align 2
50 ; CHECK-NEXT: .LBB1_2: @ %for.body
51 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
52 ; CHECK-NEXT: ldr r2, [r12], #4
53 ; CHECK-NEXT: smlal r0, r3, r2, r1
54 ; CHECK-NEXT: le lr, .LBB1_2
55 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
56 ; CHECK-NEXT: mov r1, r3
57 ; CHECK-NEXT: pop {r7, pc}
58 ; CHECK-NEXT: .p2align 2
59 ; CHECK-NEXT: .LBB1_4:
60 ; CHECK-NEXT: movs r0, #0
61 ; CHECK-NEXT: movs r3, #0
62 ; CHECK-NEXT: mov r1, r3
63 ; CHECK-NEXT: pop {r7, pc}
65 %cmp7 = icmp sgt i32 %n, 0
66 br i1 %cmp7, label %for.body.lr.ph, label %for.cond.cleanup
68 for.body.lr.ph: ; preds = %entry
69 %conv1 = sext i32 %y to i64
72 for.cond.cleanup: ; preds = %for.body, %entry
73 %s.0.lcssa = phi i64 [ 0, %entry ], [ %add, %for.body ]
76 for.body: ; preds = %for.body.lr.ph, %for.body
77 %i.09 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
78 %s.08 = phi i64 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
79 %arrayidx = getelementptr inbounds i32, ptr %x, i32 %i.09
80 %0 = load i32, ptr %arrayidx, align 4
81 %conv = sext i32 %0 to i64
82 %mul = mul nsw i64 %conv, %conv1
83 %add = add nsw i64 %mul, %s.08
84 %inc = add nuw nsw i32 %i.09, 1
85 %exitcond.not = icmp eq i32 %inc, %n
86 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body