1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
5 define void @abs_v16i8(ptr %x) {
6 ; CHECK-LABEL: abs_v16i8:
8 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
9 ; CHECK-NEXT: vle8.v v8, (a0)
10 ; CHECK-NEXT: vrsub.vi v9, v8, 0
11 ; CHECK-NEXT: vmax.vv v8, v8, v9
12 ; CHECK-NEXT: vse8.v v8, (a0)
14 %a = load <16 x i8>, ptr %x
15 %b = call <16 x i8> @llvm.abs.v16i8(<16 x i8> %a, i1 false)
16 store <16 x i8> %b, ptr %x
19 declare <16 x i8> @llvm.abs.v16i8(<16 x i8>, i1)
21 define void @abs_v8i16(ptr %x) {
22 ; CHECK-LABEL: abs_v8i16:
24 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
25 ; CHECK-NEXT: vle16.v v8, (a0)
26 ; CHECK-NEXT: vrsub.vi v9, v8, 0
27 ; CHECK-NEXT: vmax.vv v8, v8, v9
28 ; CHECK-NEXT: vse16.v v8, (a0)
30 %a = load <8 x i16>, ptr %x
31 %b = call <8 x i16> @llvm.abs.v8i16(<8 x i16> %a, i1 false)
32 store <8 x i16> %b, ptr %x
35 declare <8 x i16> @llvm.abs.v8i16(<8 x i16>, i1)
37 define void @abs_v6i16(ptr %x) {
38 ; CHECK-LABEL: abs_v6i16:
40 ; CHECK-NEXT: vsetivli zero, 6, e16, m1, ta, ma
41 ; CHECK-NEXT: vle16.v v8, (a0)
42 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
43 ; CHECK-NEXT: vrsub.vi v9, v8, 0
44 ; CHECK-NEXT: vmax.vv v8, v8, v9
45 ; CHECK-NEXT: vsetivli zero, 6, e16, m1, ta, ma
46 ; CHECK-NEXT: vse16.v v8, (a0)
48 %a = load <6 x i16>, ptr %x
49 %b = call <6 x i16> @llvm.abs.v6i16(<6 x i16> %a, i1 false)
50 store <6 x i16> %b, ptr %x
53 declare <6 x i16> @llvm.abs.v6i16(<6 x i16>, i1)
55 define void @abs_v4i32(ptr %x) {
56 ; CHECK-LABEL: abs_v4i32:
58 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
59 ; CHECK-NEXT: vle32.v v8, (a0)
60 ; CHECK-NEXT: vrsub.vi v9, v8, 0
61 ; CHECK-NEXT: vmax.vv v8, v8, v9
62 ; CHECK-NEXT: vse32.v v8, (a0)
64 %a = load <4 x i32>, ptr %x
65 %b = call <4 x i32> @llvm.abs.v4i32(<4 x i32> %a, i1 false)
66 store <4 x i32> %b, ptr %x
69 declare <4 x i32> @llvm.abs.v4i32(<4 x i32>, i1)
71 define void @abs_v2i64(ptr %x) {
72 ; CHECK-LABEL: abs_v2i64:
74 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
75 ; CHECK-NEXT: vle64.v v8, (a0)
76 ; CHECK-NEXT: vrsub.vi v9, v8, 0
77 ; CHECK-NEXT: vmax.vv v8, v8, v9
78 ; CHECK-NEXT: vse64.v v8, (a0)
80 %a = load <2 x i64>, ptr %x
81 %b = call <2 x i64> @llvm.abs.v2i64(<2 x i64> %a, i1 false)
82 store <2 x i64> %b, ptr %x
85 declare <2 x i64> @llvm.abs.v2i64(<2 x i64>, i1)
87 define void @abs_v32i8(ptr %x) {
88 ; CHECK-LABEL: abs_v32i8:
90 ; CHECK-NEXT: li a1, 32
91 ; CHECK-NEXT: vsetvli zero, a1, e8, m2, ta, ma
92 ; CHECK-NEXT: vle8.v v8, (a0)
93 ; CHECK-NEXT: vrsub.vi v10, v8, 0
94 ; CHECK-NEXT: vmax.vv v8, v8, v10
95 ; CHECK-NEXT: vse8.v v8, (a0)
97 %a = load <32 x i8>, ptr %x
98 %b = call <32 x i8> @llvm.abs.v32i8(<32 x i8> %a, i1 false)
99 store <32 x i8> %b, ptr %x
102 declare <32 x i8> @llvm.abs.v32i8(<32 x i8>, i1)
104 define void @abs_v16i16(ptr %x) {
105 ; CHECK-LABEL: abs_v16i16:
107 ; CHECK-NEXT: vsetivli zero, 16, e16, m2, ta, ma
108 ; CHECK-NEXT: vle16.v v8, (a0)
109 ; CHECK-NEXT: vrsub.vi v10, v8, 0
110 ; CHECK-NEXT: vmax.vv v8, v8, v10
111 ; CHECK-NEXT: vse16.v v8, (a0)
113 %a = load <16 x i16>, ptr %x
114 %b = call <16 x i16> @llvm.abs.v16i16(<16 x i16> %a, i1 false)
115 store <16 x i16> %b, ptr %x
118 declare <16 x i16> @llvm.abs.v16i16(<16 x i16>, i1)
120 define void @abs_v8i32(ptr %x) {
121 ; CHECK-LABEL: abs_v8i32:
123 ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
124 ; CHECK-NEXT: vle32.v v8, (a0)
125 ; CHECK-NEXT: vrsub.vi v10, v8, 0
126 ; CHECK-NEXT: vmax.vv v8, v8, v10
127 ; CHECK-NEXT: vse32.v v8, (a0)
129 %a = load <8 x i32>, ptr %x
130 %b = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %a, i1 false)
131 store <8 x i32> %b, ptr %x
134 declare <8 x i32> @llvm.abs.v8i32(<8 x i32>, i1)
136 define void @abs_v4i64(ptr %x) {
137 ; CHECK-LABEL: abs_v4i64:
139 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
140 ; CHECK-NEXT: vle64.v v8, (a0)
141 ; CHECK-NEXT: vrsub.vi v10, v8, 0
142 ; CHECK-NEXT: vmax.vv v8, v8, v10
143 ; CHECK-NEXT: vse64.v v8, (a0)
145 %a = load <4 x i64>, ptr %x
146 %b = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a, i1 false)
147 store <4 x i64> %b, ptr %x
150 declare <4 x i64> @llvm.abs.v4i64(<4 x i64>, i1)
152 define void @abs_v4i64_of_sext_v4i8(ptr %x) {
153 ; CHECK-LABEL: abs_v4i64_of_sext_v4i8:
155 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
156 ; CHECK-NEXT: vle8.v v8, (a0)
157 ; CHECK-NEXT: vrsub.vi v9, v8, 0
158 ; CHECK-NEXT: vmax.vv v8, v8, v9
159 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
160 ; CHECK-NEXT: vzext.vf8 v10, v8
161 ; CHECK-NEXT: vse64.v v10, (a0)
163 %a = load <4 x i8>, ptr %x
164 %a.ext = sext <4 x i8> %a to <4 x i64>
165 %b = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a.ext, i1 false)
166 store <4 x i64> %b, ptr %x
170 define void @abs_v4i64_of_sext_v4i16(ptr %x) {
171 ; CHECK-LABEL: abs_v4i64_of_sext_v4i16:
173 ; CHECK-NEXT: vsetivli zero, 4, e16, mf2, ta, ma
174 ; CHECK-NEXT: vle16.v v8, (a0)
175 ; CHECK-NEXT: vrsub.vi v9, v8, 0
176 ; CHECK-NEXT: vmax.vv v8, v8, v9
177 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
178 ; CHECK-NEXT: vzext.vf4 v10, v8
179 ; CHECK-NEXT: vse64.v v10, (a0)
181 %a = load <4 x i16>, ptr %x
182 %a.ext = sext <4 x i16> %a to <4 x i64>
183 %b = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a.ext, i1 false)
184 store <4 x i64> %b, ptr %x
188 define void @abs_v4i64_of_sext_v4i32(ptr %x) {
189 ; CHECK-LABEL: abs_v4i64_of_sext_v4i32:
191 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
192 ; CHECK-NEXT: vle32.v v8, (a0)
193 ; CHECK-NEXT: vrsub.vi v9, v8, 0
194 ; CHECK-NEXT: vmax.vv v8, v8, v9
195 ; CHECK-NEXT: vsetvli zero, zero, e64, m2, ta, ma
196 ; CHECK-NEXT: vzext.vf2 v10, v8
197 ; CHECK-NEXT: vse64.v v10, (a0)
199 %a = load <4 x i32>, ptr %x
200 %a.ext = sext <4 x i32> %a to <4 x i64>
201 %b = call <4 x i64> @llvm.abs.v4i64(<4 x i64> %a.ext, i1 false)
202 store <4 x i64> %b, ptr %x