1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -mattr=+neon | FileCheck %s --check-prefix=CHECK
4 declare i1 @llvm.vector.reduce.umax.v1i1(<1 x i1> %a)
5 declare i8 @llvm.vector.reduce.umax.v1i8(<1 x i8> %a)
6 declare i16 @llvm.vector.reduce.umax.v1i16(<1 x i16> %a)
7 declare i24 @llvm.vector.reduce.umax.v1i24(<1 x i24> %a)
8 declare i32 @llvm.vector.reduce.umax.v1i32(<1 x i32> %a)
9 declare i64 @llvm.vector.reduce.umax.v1i64(<1 x i64> %a)
10 declare i128 @llvm.vector.reduce.umax.v1i128(<1 x i128> %a)
12 declare i64 @llvm.vector.reduce.umax.v2i64(<2 x i64> %a)
13 declare i8 @llvm.vector.reduce.umax.v3i8(<3 x i8> %a)
14 declare i8 @llvm.vector.reduce.umax.v9i8(<9 x i8> %a)
15 declare i32 @llvm.vector.reduce.umax.v3i32(<3 x i32> %a)
16 declare i1 @llvm.vector.reduce.umax.v4i1(<4 x i1> %a)
17 declare i24 @llvm.vector.reduce.umax.v4i24(<4 x i24> %a)
18 declare i128 @llvm.vector.reduce.umax.v2i128(<2 x i128> %a)
19 declare i32 @llvm.vector.reduce.umax.v16i32(<16 x i32> %a)
21 define i1 @test_v1i1(<1 x i1> %a) nounwind {
22 ; CHECK-LABEL: test_v1i1:
24 ; CHECK-NEXT: and w0, w0, #0x1
26 %b = call i1 @llvm.vector.reduce.umax.v1i1(<1 x i1> %a)
30 define i8 @test_v1i8(<1 x i8> %a) nounwind {
31 ; CHECK-LABEL: test_v1i8:
33 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
34 ; CHECK-NEXT: umov w0, v0.b[0]
36 %b = call i8 @llvm.vector.reduce.umax.v1i8(<1 x i8> %a)
40 define i16 @test_v1i16(<1 x i16> %a) nounwind {
41 ; CHECK-LABEL: test_v1i16:
43 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
44 ; CHECK-NEXT: umov w0, v0.h[0]
46 %b = call i16 @llvm.vector.reduce.umax.v1i16(<1 x i16> %a)
50 define i24 @test_v1i24(<1 x i24> %a) nounwind {
51 ; CHECK-LABEL: test_v1i24:
54 %b = call i24 @llvm.vector.reduce.umax.v1i24(<1 x i24> %a)
58 define i32 @test_v1i32(<1 x i32> %a) nounwind {
59 ; CHECK-LABEL: test_v1i32:
61 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
62 ; CHECK-NEXT: fmov w0, s0
64 %b = call i32 @llvm.vector.reduce.umax.v1i32(<1 x i32> %a)
68 define i64 @test_v1i64(<1 x i64> %a) nounwind {
69 ; CHECK-LABEL: test_v1i64:
71 ; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
72 ; CHECK-NEXT: fmov x0, d0
74 %b = call i64 @llvm.vector.reduce.umax.v1i64(<1 x i64> %a)
78 define i128 @test_v1i128(<1 x i128> %a) nounwind {
79 ; CHECK-LABEL: test_v1i128:
82 %b = call i128 @llvm.vector.reduce.umax.v1i128(<1 x i128> %a)
86 ; No i64 vector support for UMAX.
87 define i64 @test_v2i64(<2 x i64> %a) nounwind {
88 ; CHECK-LABEL: test_v2i64:
90 ; CHECK-NEXT: ext v1.16b, v0.16b, v0.16b, #8
91 ; CHECK-NEXT: cmhi d2, d0, d1
92 ; CHECK-NEXT: bif v0.8b, v1.8b, v2.8b
93 ; CHECK-NEXT: fmov x0, d0
95 %b = call i64 @llvm.vector.reduce.umax.v2i64(<2 x i64> %a)
99 define i8 @test_v3i8(<3 x i8> %a) nounwind {
100 ; CHECK-LABEL: test_v3i8:
102 ; CHECK-NEXT: movi v0.2d, #0000000000000000
103 ; CHECK-NEXT: mov v0.h[0], w0
104 ; CHECK-NEXT: mov v0.h[1], w1
105 ; CHECK-NEXT: mov v0.h[2], w2
106 ; CHECK-NEXT: bic v0.4h, #255, lsl #8
107 ; CHECK-NEXT: umaxv h0, v0.4h
108 ; CHECK-NEXT: fmov w0, s0
110 %b = call i8 @llvm.vector.reduce.umax.v3i8(<3 x i8> %a)
114 define i8 @test_v9i8(<9 x i8> %a) nounwind {
115 ; CHECK-LABEL: test_v9i8:
117 ; CHECK-NEXT: adrp x8, .LCPI9_0
118 ; CHECK-NEXT: ldr q1, [x8, :lo12:.LCPI9_0]
119 ; CHECK-NEXT: and v0.16b, v0.16b, v1.16b
120 ; CHECK-NEXT: umaxv b0, v0.16b
121 ; CHECK-NEXT: fmov w0, s0
123 %b = call i8 @llvm.vector.reduce.umax.v9i8(<9 x i8> %a)
127 define i32 @test_v3i32(<3 x i32> %a) nounwind {
128 ; CHECK-LABEL: test_v3i32:
130 ; CHECK-NEXT: mov v0.s[3], wzr
131 ; CHECK-NEXT: umaxv s0, v0.4s
132 ; CHECK-NEXT: fmov w0, s0
134 %b = call i32 @llvm.vector.reduce.umax.v3i32(<3 x i32> %a)
138 define i1 @test_v4i1(<4 x i1> %a) nounwind {
139 ; CHECK-LABEL: test_v4i1:
141 ; CHECK-NEXT: shl v0.4h, v0.4h, #15
142 ; CHECK-NEXT: cmlt v0.4h, v0.4h, #0
143 ; CHECK-NEXT: umaxv h0, v0.4h
144 ; CHECK-NEXT: fmov w8, s0
145 ; CHECK-NEXT: and w0, w8, #0x1
147 %b = call i1 @llvm.vector.reduce.umax.v4i1(<4 x i1> %a)
151 define i24 @test_v4i24(<4 x i24> %a) nounwind {
152 ; CHECK-LABEL: test_v4i24:
154 ; CHECK-NEXT: bic v0.4s, #255, lsl #24
155 ; CHECK-NEXT: umaxv s0, v0.4s
156 ; CHECK-NEXT: fmov w0, s0
158 %b = call i24 @llvm.vector.reduce.umax.v4i24(<4 x i24> %a)
162 define i128 @test_v2i128(<2 x i128> %a) nounwind {
163 ; CHECK-LABEL: test_v2i128:
165 ; CHECK-NEXT: cmp x2, x0
166 ; CHECK-NEXT: sbcs xzr, x3, x1
167 ; CHECK-NEXT: csel x0, x0, x2, lo
168 ; CHECK-NEXT: csel x1, x1, x3, lo
170 %b = call i128 @llvm.vector.reduce.umax.v2i128(<2 x i128> %a)
174 define i32 @test_v16i32(<16 x i32> %a) nounwind {
175 ; CHECK-LABEL: test_v16i32:
177 ; CHECK-NEXT: umax v1.4s, v1.4s, v3.4s
178 ; CHECK-NEXT: umax v0.4s, v0.4s, v2.4s
179 ; CHECK-NEXT: umax v0.4s, v0.4s, v1.4s
180 ; CHECK-NEXT: umaxv s0, v0.4s
181 ; CHECK-NEXT: fmov w0, s0
183 %b = call i32 @llvm.vector.reduce.umax.v16i32(<16 x i32> %a)