1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve -verify-machineinstrs -o - %s | FileCheck %s
4 define i32 @test(i16* nocapture readonly %x, i16* nocapture readonly %y, i32 %n) {
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: .save {r7, lr}
8 ; CHECK-NEXT: push {r7, lr}
9 ; CHECK-NEXT: cmp r2, #1
10 ; CHECK-NEXT: blt .LBB0_4
11 ; CHECK-NEXT: @ %bb.1: @ %for.body.preheader
12 ; CHECK-NEXT: mov lr, r0
13 ; CHECK-NEXT: movs r0, #0
14 ; CHECK-NEXT: .LBB0_2: @ %for.body
15 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
16 ; CHECK-NEXT: ldrh r3, [r1], #2
17 ; CHECK-NEXT: subs r2, #1
18 ; CHECK-NEXT: ldrh r12, [lr], #2
20 ; CHECK-NEXT: add r3, r12
22 ; CHECK-NEXT: add r0, r3
23 ; CHECK-NEXT: bne .LBB0_2
24 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
25 ; CHECK-NEXT: pop {r7, pc}
26 ; CHECK-NEXT: .LBB0_4:
27 ; CHECK-NEXT: movs r0, #0
28 ; CHECK-NEXT: pop {r7, pc}
30 %cmp9 = icmp sgt i32 %n, 0
31 br i1 %cmp9, label %for.body, label %for.cond.cleanup
33 for.cond.cleanup: ; preds = %for.body, %entry
34 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
37 for.body: ; preds = %entry, %for.body
38 %s.011 = phi i32 [ %add, %for.body ], [ 0, %entry ]
39 %i.010 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
40 %arrayidx = getelementptr inbounds i16, i16* %x, i32 %i.010
41 %0 = load i16, i16* %arrayidx, align 2
42 %arrayidx1 = getelementptr inbounds i16, i16* %y, i32 %i.010
43 %1 = load i16, i16* %arrayidx1, align 2
44 %2 = tail call i32 asm "add $0, $1, $2", "=r,r,r"(i16 %0, i16 %1) #1
45 %add = add nsw i32 %2, %s.011
46 %inc = add nuw nsw i32 %i.010, 1
47 %exitcond.not = icmp eq i32 %inc, %n
48 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
51 define i32 @testlr(i16* nocapture readonly %x, i16* nocapture readonly %y, i32 %n) {
52 ; CHECK-LABEL: testlr:
53 ; CHECK: @ %bb.0: @ %entry
54 ; CHECK-NEXT: .save {r4, lr}
55 ; CHECK-NEXT: push {r4, lr}
56 ; CHECK-NEXT: cmp r2, #1
57 ; CHECK-NEXT: blt .LBB1_4
58 ; CHECK-NEXT: @ %bb.1: @ %for.body.preheader
59 ; CHECK-NEXT: mov r3, r0
60 ; CHECK-NEXT: movs r0, #0
61 ; CHECK-NEXT: .LBB1_2: @ %for.body
62 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
63 ; CHECK-NEXT: ldrh r4, [r1], #2
64 ; CHECK-NEXT: subs r2, #1
65 ; CHECK-NEXT: ldrh r12, [r3], #2
67 ; CHECK-NEXT: add r4, r12
69 ; CHECK-NEXT: add r0, r4
70 ; CHECK-NEXT: bne .LBB1_2
71 ; CHECK-NEXT: @ %bb.3: @ %for.cond.cleanup
72 ; CHECK-NEXT: pop {r4, pc}
73 ; CHECK-NEXT: .LBB1_4:
74 ; CHECK-NEXT: movs r0, #0
75 ; CHECK-NEXT: pop {r4, pc}
77 %cmp9 = icmp sgt i32 %n, 0
78 br i1 %cmp9, label %for.body, label %for.cond.cleanup
80 for.cond.cleanup: ; preds = %for.body, %entry
81 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
84 for.body: ; preds = %entry, %for.body
85 %s.011 = phi i32 [ %add, %for.body ], [ 0, %entry ]
86 %i.010 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
87 %arrayidx = getelementptr inbounds i16, i16* %x, i32 %i.010
88 %0 = load i16, i16* %arrayidx, align 2
89 %arrayidx1 = getelementptr inbounds i16, i16* %y, i32 %i.010
90 %1 = load i16, i16* %arrayidx1, align 2
91 %2 = tail call i32 asm "add $0, $1, $2", "=r,r,r,~{lr}"(i16 %0, i16 %1) #1
92 %add = add nsw i32 %2, %s.011
93 %inc = add nuw nsw i32 %i.010, 1
94 %exitcond.not = icmp eq i32 %inc, %n
95 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body