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(i32* 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: movs r1, #0
11 ; CHECK-NEXT: .p2align 2
12 ; CHECK-NEXT: .LBB0_1: @ %for.body
13 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
14 ; CHECK-NEXT: ldr r2, [r0], #4
15 ; CHECK-NEXT: add r1, r2
16 ; CHECK-NEXT: le lr, .LBB0_1
17 ; CHECK-NEXT: .p2align 2
18 ; CHECK-NEXT: @ %bb.2: @ %for.cond.cleanup
19 ; CHECK-NEXT: mov r0, r1
20 ; CHECK-NEXT: pop {r7, pc}
24 for.cond.cleanup: ; preds = %for.body
27 for.body: ; preds = %entry, %for.body
28 %i.07 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
29 %s.06 = phi i32 [ 0, %entry ], [ %add, %for.body ]
30 %arrayidx = getelementptr inbounds i32, i32* %x, i32 %i.07
31 %0 = load i32, i32* %arrayidx, align 4
32 %add = add nsw i32 %0, %s.06
33 %inc = add nuw nsw i32 %i.07, 1
34 %exitcond.not = icmp eq i32 %inc, 500
35 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
38 define i64 @loopif(i32* nocapture readonly %x, i32 %y, i32 %n) {
39 ; CHECK-LABEL: loopif:
40 ; CHECK: @ %bb.0: @ %entry
41 ; CHECK-NEXT: .save {r7, lr}
42 ; CHECK-NEXT: push {r7, lr}
43 ; CHECK-NEXT: cmp r2, #1
44 ; CHECK-NEXT: blt .LBB1_4
45 ; CHECK-NEXT: @ %bb.1: @ %for.body.lr.ph
46 ; CHECK-NEXT: mov lr, r2
47 ; CHECK-NEXT: dls lr, r2
48 ; CHECK-NEXT: mov r12, r0
49 ; CHECK-NEXT: movs r0, #0
50 ; CHECK-NEXT: movs r3, #0
51 ; CHECK-NEXT: .p2align 2
52 ; CHECK-NEXT: .LBB1_2: @ %for.body
53 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
54 ; CHECK-NEXT: ldr r2, [r12], #4
55 ; CHECK-NEXT: smlal r0, r3, r2, r1
56 ; CHECK-NEXT: le lr, .LBB1_2
57 ; CHECK-NEXT: .p2align 2
58 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
59 ; CHECK-NEXT: mov r1, r3
60 ; CHECK-NEXT: pop {r7, pc}
61 ; CHECK-NEXT: .p2align 2
62 ; CHECK-NEXT: .LBB1_4:
63 ; CHECK-NEXT: movs r0, #0
64 ; CHECK-NEXT: movs r3, #0
65 ; CHECK-NEXT: mov r1, r3
66 ; CHECK-NEXT: pop {r7, pc}
68 %cmp7 = icmp sgt i32 %n, 0
69 br i1 %cmp7, label %for.body.lr.ph, label %for.cond.cleanup
71 for.body.lr.ph: ; preds = %entry
72 %conv1 = sext i32 %y to i64
75 for.cond.cleanup: ; preds = %for.body, %entry
76 %s.0.lcssa = phi i64 [ 0, %entry ], [ %add, %for.body ]
79 for.body: ; preds = %for.body.lr.ph, %for.body
80 %i.09 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
81 %s.08 = phi i64 [ 0, %for.body.lr.ph ], [ %add, %for.body ]
82 %arrayidx = getelementptr inbounds i32, i32* %x, i32 %i.09
83 %0 = load i32, i32* %arrayidx, align 4
84 %conv = sext i32 %0 to i64
85 %mul = mul nsw i64 %conv, %conv1
86 %add = add nsw i64 %mul, %s.08
87 %inc = add nuw nsw i32 %i.09, 1
88 %exitcond.not = icmp eq i32 %inc, %n
89 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body