1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-eabi -aarch64-neon-syntax=generic | FileCheck %s
4 ; Function Attrs: nounwind readnone
5 declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>)
6 declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>)
7 declare i16 @llvm.vector.reduce.add.v8i16(<8 x i16>)
8 declare i16 @llvm.vector.reduce.add.v4i16(<4 x i16>)
9 declare i8 @llvm.vector.reduce.add.v8i8(<8 x i8>)
10 declare i8 @llvm.vector.reduce.add.v16i8(<16 x i8>)
12 define i8 @add_B(<16 x i8>* %arr) {
15 ; CHECK-NEXT: ldr q0, [x0]
16 ; CHECK-NEXT: addv b0, v0.16b
17 ; CHECK-NEXT: fmov w0, s0
19 %bin.rdx = load <16 x i8>, <16 x i8>* %arr
20 %r = call i8 @llvm.vector.reduce.add.v16i8(<16 x i8> %bin.rdx)
24 define i16 @add_H(<8 x i16>* %arr) {
27 ; CHECK-NEXT: ldr q0, [x0]
28 ; CHECK-NEXT: addv h0, v0.8h
29 ; CHECK-NEXT: fmov w0, s0
31 %bin.rdx = load <8 x i16>, <8 x i16>* %arr
32 %r = call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %bin.rdx)
36 define i32 @add_S( <4 x i32>* %arr) {
39 ; CHECK-NEXT: ldr q0, [x0]
40 ; CHECK-NEXT: addv s0, v0.4s
41 ; CHECK-NEXT: fmov w0, s0
43 %bin.rdx = load <4 x i32>, <4 x i32>* %arr
44 %r = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
48 define i64 @add_D(<2 x i64>* %arr) {
51 ; CHECK-NEXT: ldr q0, [x0]
52 ; CHECK-NEXT: addp d0, v0.2d
53 ; CHECK-NEXT: fmov x0, d0
55 %bin.rdx = load <2 x i64>, <2 x i64>* %arr
56 %r = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %bin.rdx)
60 declare i32 @llvm.vector.reduce.add.v8i32(<8 x i32>)
62 define i32 @oversized_ADDV_256(i8* noalias nocapture readonly %arg1, i8* noalias nocapture readonly %arg2) {
63 ; CHECK-LABEL: oversized_ADDV_256:
64 ; CHECK: // %bb.0: // %entry
65 ; CHECK-NEXT: ldr d0, [x0]
66 ; CHECK-NEXT: ldr d1, [x1]
67 ; CHECK-NEXT: uabdl v0.8h, v0.8b, v1.8b
68 ; CHECK-NEXT: ushll v1.4s, v0.4h, #0
69 ; CHECK-NEXT: uaddw2 v0.4s, v1.4s, v0.8h
70 ; CHECK-NEXT: addv s0, v0.4s
71 ; CHECK-NEXT: fmov w0, s0
74 %0 = bitcast i8* %arg1 to <8 x i8>*
75 %1 = load <8 x i8>, <8 x i8>* %0, align 1
76 %2 = zext <8 x i8> %1 to <8 x i32>
77 %3 = bitcast i8* %arg2 to <8 x i8>*
78 %4 = load <8 x i8>, <8 x i8>* %3, align 1
79 %5 = zext <8 x i8> %4 to <8 x i32>
80 %6 = sub nsw <8 x i32> %2, %5
81 %7 = icmp slt <8 x i32> %6, zeroinitializer
82 %8 = sub nsw <8 x i32> zeroinitializer, %6
83 %9 = select <8 x i1> %7, <8 x i32> %8, <8 x i32> %6
84 %r = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> %9)
88 declare i32 @llvm.vector.reduce.add.v16i32(<16 x i32>)
90 define i32 @oversized_ADDV_512(<16 x i32>* %arr) {
91 ; CHECK-LABEL: oversized_ADDV_512:
93 ; CHECK-NEXT: ldp q0, q1, [x0, #32]
94 ; CHECK-NEXT: ldp q3, q2, [x0]
95 ; CHECK-NEXT: add v1.4s, v2.4s, v1.4s
96 ; CHECK-NEXT: add v0.4s, v3.4s, v0.4s
97 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
98 ; CHECK-NEXT: addv s0, v0.4s
99 ; CHECK-NEXT: fmov w0, s0
101 %bin.rdx = load <16 x i32>, <16 x i32>* %arr
102 %r = call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> %bin.rdx)
106 define i8 @addv_combine_i8(<8 x i8> %a1, <8 x i8> %a2) {
107 ; CHECK-LABEL: addv_combine_i8:
108 ; CHECK: // %bb.0: // %entry
109 ; CHECK-NEXT: addv b0, v0.8b
110 ; CHECK-NEXT: addv b1, v1.8b
111 ; CHECK-NEXT: fmov w8, s0
112 ; CHECK-NEXT: fmov w9, s1
113 ; CHECK-NEXT: add w0, w8, w9
116 %rdx.1 = call i8 @llvm.vector.reduce.add.v8i8(<8 x i8> %a1)
117 %rdx.2 = call i8 @llvm.vector.reduce.add.v8i8(<8 x i8> %a2)
118 %r = add i8 %rdx.1, %rdx.2
122 define i16 @addv_combine_i16(<4 x i16> %a1, <4 x i16> %a2) {
123 ; CHECK-LABEL: addv_combine_i16:
124 ; CHECK: // %bb.0: // %entry
125 ; CHECK-NEXT: addv h0, v0.4h
126 ; CHECK-NEXT: addv h1, v1.4h
127 ; CHECK-NEXT: fmov w8, s0
128 ; CHECK-NEXT: fmov w9, s1
129 ; CHECK-NEXT: add w0, w8, w9
132 %rdx.1 = call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> %a1)
133 %rdx.2 = call i16 @llvm.vector.reduce.add.v4i16(<4 x i16> %a2)
134 %r = add i16 %rdx.1, %rdx.2
138 define i32 @addv_combine_i32(<4 x i32> %a1, <4 x i32> %a2) {
139 ; CHECK-LABEL: addv_combine_i32:
140 ; CHECK: // %bb.0: // %entry
141 ; CHECK-NEXT: add v0.4s, v0.4s, v1.4s
142 ; CHECK-NEXT: addv s0, v0.4s
143 ; CHECK-NEXT: fmov w0, s0
146 %rdx.1 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %a1)
147 %rdx.2 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %a2)
148 %r = add i32 %rdx.1, %rdx.2
152 define i64 @addv_combine_i64(<2 x i64> %a1, <2 x i64> %a2) {
153 ; CHECK-LABEL: addv_combine_i64:
154 ; CHECK: // %bb.0: // %entry
155 ; CHECK-NEXT: add v0.2d, v0.2d, v1.2d
156 ; CHECK-NEXT: addp d0, v0.2d
157 ; CHECK-NEXT: fmov x0, d0
160 %rdx.1 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %a1)
161 %rdx.2 = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %a2)
162 %r = add i64 %rdx.1, %rdx.2