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(ptr nocapture readonly %x, ptr nocapture readonly %y, i32 %n) {
6 ; CHECK: @ %bb.0: @ %entry
7 ; CHECK-NEXT: cmp r2, #1
9 ; CHECK-NEXT: movlt r0, #0
11 ; CHECK-NEXT: .LBB0_1: @ %for.body.preheader
12 ; CHECK-NEXT: .save {r7, lr}
13 ; CHECK-NEXT: push {r7, lr}
14 ; CHECK-NEXT: mov lr, r0
15 ; CHECK-NEXT: movs r0, #0
16 ; CHECK-NEXT: .LBB0_2: @ %for.body
17 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
18 ; CHECK-NEXT: ldrh r3, [r1], #2
19 ; CHECK-NEXT: subs r2, #1
20 ; CHECK-NEXT: ldrh r12, [lr], #2
22 ; CHECK-NEXT: add r3, r12
24 ; CHECK-NEXT: add r0, r3
25 ; CHECK-NEXT: bne .LBB0_2
26 ; CHECK-NEXT: @ %bb.3:
27 ; CHECK-NEXT: pop {r7, pc}
29 %cmp9 = icmp sgt i32 %n, 0
30 br i1 %cmp9, label %for.body, label %for.cond.cleanup
32 for.cond.cleanup: ; preds = %for.body, %entry
33 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
36 for.body: ; preds = %entry, %for.body
37 %s.011 = phi i32 [ %add, %for.body ], [ 0, %entry ]
38 %i.010 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
39 %arrayidx = getelementptr inbounds i16, ptr %x, i32 %i.010
40 %0 = load i16, ptr %arrayidx, align 2
41 %arrayidx1 = getelementptr inbounds i16, ptr %y, i32 %i.010
42 %1 = load i16, ptr %arrayidx1, align 2
43 %2 = tail call i32 asm "add $0, $1, $2", "=r,r,r"(i16 %0, i16 %1) #1
44 %add = add nsw i32 %2, %s.011
45 %inc = add nuw nsw i32 %i.010, 1
46 %exitcond.not = icmp eq i32 %inc, %n
47 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
50 define i32 @testlr(ptr nocapture readonly %x, ptr nocapture readonly %y, i32 %n) {
51 ; CHECK-LABEL: testlr:
52 ; CHECK: @ %bb.0: @ %entry
53 ; CHECK-NEXT: cmp r2, #1
55 ; CHECK-NEXT: movlt r0, #0
57 ; CHECK-NEXT: .LBB1_1: @ %for.body.preheader
58 ; CHECK-NEXT: .save {r4, lr}
59 ; CHECK-NEXT: push {r4, lr}
60 ; CHECK-NEXT: mov r3, r0
61 ; CHECK-NEXT: movs r0, #0
62 ; CHECK-NEXT: .LBB1_2: @ %for.body
63 ; CHECK-NEXT: @ =>This Inner Loop Header: Depth=1
64 ; CHECK-NEXT: ldrh r4, [r1], #2
65 ; CHECK-NEXT: subs r2, #1
66 ; CHECK-NEXT: ldrh r12, [r3], #2
68 ; CHECK-NEXT: add r4, r12
70 ; CHECK-NEXT: add r0, r4
71 ; CHECK-NEXT: bne .LBB1_2
72 ; CHECK-NEXT: @ %bb.3:
73 ; CHECK-NEXT: pop {r4, pc}
75 %cmp9 = icmp sgt i32 %n, 0
76 br i1 %cmp9, label %for.body, label %for.cond.cleanup
78 for.cond.cleanup: ; preds = %for.body, %entry
79 %s.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.body ]
82 for.body: ; preds = %entry, %for.body
83 %s.011 = phi i32 [ %add, %for.body ], [ 0, %entry ]
84 %i.010 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
85 %arrayidx = getelementptr inbounds i16, ptr %x, i32 %i.010
86 %0 = load i16, ptr %arrayidx, align 2
87 %arrayidx1 = getelementptr inbounds i16, ptr %y, i32 %i.010
88 %1 = load i16, ptr %arrayidx1, align 2
89 %2 = tail call i32 asm "add $0, $1, $2", "=r,r,r,~{lr}"(i16 %0, i16 %1) #1
90 %add = add nsw i32 %2, %s.011
91 %inc = add nuw nsw i32 %i.010, 1
92 %exitcond.not = icmp eq i32 %inc, %n
93 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body