1 ; RUN: llc < %s -mtriple=arm64-eabi -aarch64-neon-syntax=apple -asm-verbose=false | FileCheck %s
2 ; RUN: llc < %s -global-isel=1 -mtriple=arm64-eabi -aarch64-neon-syntax=apple -asm-verbose=false | FileCheck %s
4 define i32 @vmax_u8x8(<8 x i8> %a) nounwind ssp {
5 ; CHECK-LABEL: vmax_u8x8:
6 ; CHECK: umaxv.8b b[[REG:[0-9]+]], v0
7 ; CHECK: fmov [[REG2:w[0-9]+]], s[[REG]]
11 %vmaxv.i = tail call i32 @llvm.aarch64.neon.umaxv.i32.v8i8(<8 x i8> %a) nounwind
12 %tmp = trunc i32 %vmaxv.i to i8
13 %tobool = icmp eq i8 %tmp, 0
14 br i1 %tobool, label %return, label %if.then
17 %call1 = tail call i32 @bar() nounwind
21 %retval.0 = phi i32 [ %call1, %if.then ], [ 0, %entry ]
27 define i32 @vmax_u4x16(<4 x i16> %a) nounwind ssp {
28 ; CHECK-LABEL: vmax_u4x16:
29 ; CHECK: umaxv.4h h[[REG:[0-9]+]], v0
30 ; CHECK: fmov [[REG2:w[0-9]+]], s[[REG]]
32 ; CHECK: cbz [[REG2]],
34 %vmaxv.i = tail call i32 @llvm.aarch64.neon.umaxv.i32.v4i16(<4 x i16> %a) nounwind
35 %tmp = trunc i32 %vmaxv.i to i16
36 %tobool = icmp eq i16 %tmp, 0
37 br i1 %tobool, label %return, label %if.then
40 %call1 = tail call i32 @bar() nounwind
44 %retval.0 = phi i32 [ %call1, %if.then ], [ 0, %entry ]
48 define i32 @vmax_u8x16(<8 x i16> %a) nounwind ssp {
49 ; CHECK-LABEL: vmax_u8x16:
50 ; CHECK: umaxv.8h h[[REG:[0-9]+]], v0
51 ; CHECK: fmov [[REG2:w[0-9]+]], s[[REG]]
53 ; CHECK: cbz [[REG2]],
55 %vmaxv.i = tail call i32 @llvm.aarch64.neon.umaxv.i32.v8i16(<8 x i16> %a) nounwind
56 %tmp = trunc i32 %vmaxv.i to i16
57 %tobool = icmp eq i16 %tmp, 0
58 br i1 %tobool, label %return, label %if.then
61 %call1 = tail call i32 @bar() nounwind
65 %retval.0 = phi i32 [ %call1, %if.then ], [ 0, %entry ]
69 define i32 @vmax_u16x8(<16 x i8> %a) nounwind ssp {
70 ; CHECK-LABEL: vmax_u16x8:
71 ; CHECK: umaxv.16b b[[REG:[0-9]+]], v0
72 ; CHECK: fmov [[REG2:w[0-9]+]], s[[REG]]
74 ; CHECK: cbz [[REG2]],
76 %vmaxv.i = tail call i32 @llvm.aarch64.neon.umaxv.i32.v16i8(<16 x i8> %a) nounwind
77 %tmp = trunc i32 %vmaxv.i to i8
78 %tobool = icmp eq i8 %tmp, 0
79 br i1 %tobool, label %return, label %if.then
82 %call1 = tail call i32 @bar() nounwind
86 %retval.0 = phi i32 [ %call1, %if.then ], [ 0, %entry ]
90 define <8 x i8> @test_vmaxv_u8_used_by_laneop(<8 x i8> %a1, <8 x i8> %a2) {
91 ; CHECK-LABEL: test_vmaxv_u8_used_by_laneop:
92 ; CHECK: umaxv.8b b[[REGNUM:[0-9]+]], v1
93 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
96 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v8i8(<8 x i8> %a2)
97 %1 = trunc i32 %0 to i8
98 %2 = insertelement <8 x i8> %a1, i8 %1, i32 3
102 define <4 x i16> @test_vmaxv_u16_used_by_laneop(<4 x i16> %a1, <4 x i16> %a2) {
103 ; CHECK-LABEL: test_vmaxv_u16_used_by_laneop:
104 ; CHECK: umaxv.4h h[[REGNUM:[0-9]+]], v1
105 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
108 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v4i16(<4 x i16> %a2)
109 %1 = trunc i32 %0 to i16
110 %2 = insertelement <4 x i16> %a1, i16 %1, i32 3
114 define <2 x i32> @test_vmaxv_u32_used_by_laneop(<2 x i32> %a1, <2 x i32> %a2) {
115 ; CHECK-LABEL: test_vmaxv_u32_used_by_laneop:
116 ; CHECK: umaxp.2s v[[REGNUM:[0-9]+]], v1, v1
117 ; CHECK-NEXT: mov.s v0[1], v[[REGNUM]][0]
120 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v2i32(<2 x i32> %a2)
121 %1 = insertelement <2 x i32> %a1, i32 %0, i32 1
125 define <16 x i8> @test_vmaxvq_u8_used_by_laneop(<16 x i8> %a1, <16 x i8> %a2) {
126 ; CHECK-LABEL: test_vmaxvq_u8_used_by_laneop:
127 ; CHECK: umaxv.16b b[[REGNUM:[0-9]+]], v1
128 ; CHECK-NEXT: mov.b v0[3], v[[REGNUM]][0]
131 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v16i8(<16 x i8> %a2)
132 %1 = trunc i32 %0 to i8
133 %2 = insertelement <16 x i8> %a1, i8 %1, i32 3
137 define <8 x i16> @test_vmaxvq_u16_used_by_laneop(<8 x i16> %a1, <8 x i16> %a2) {
138 ; CHECK-LABEL: test_vmaxvq_u16_used_by_laneop:
139 ; CHECK: umaxv.8h h[[REGNUM:[0-9]+]], v1
140 ; CHECK-NEXT: mov.h v0[3], v[[REGNUM]][0]
143 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v8i16(<8 x i16> %a2)
144 %1 = trunc i32 %0 to i16
145 %2 = insertelement <8 x i16> %a1, i16 %1, i32 3
149 define <4 x i32> @test_vmaxvq_u32_used_by_laneop(<4 x i32> %a1, <4 x i32> %a2) {
150 ; CHECK-LABEL: test_vmaxvq_u32_used_by_laneop:
151 ; CHECK: umaxv.4s s[[REGNUM:[0-9]+]], v1
152 ; CHECK-NEXT: mov.s v0[3], v[[REGNUM]][0]
155 %0 = tail call i32 @llvm.aarch64.neon.umaxv.i32.v4i32(<4 x i32> %a2)
156 %1 = insertelement <4 x i32> %a1, i32 %0, i32 3
160 declare i32 @llvm.aarch64.neon.umaxv.i32.v16i8(<16 x i8>) nounwind readnone
161 declare i32 @llvm.aarch64.neon.umaxv.i32.v8i16(<8 x i16>) nounwind readnone
162 declare i32 @llvm.aarch64.neon.umaxv.i32.v4i16(<4 x i16>) nounwind readnone
163 declare i32 @llvm.aarch64.neon.umaxv.i32.v8i8(<8 x i8>) nounwind readnone
164 declare i32 @llvm.aarch64.neon.umaxv.i32.v2i32(<2 x i32>) nounwind readnone
165 declare i32 @llvm.aarch64.neon.umaxv.i32.v4i32(<4 x i32>) nounwind readnone