Debian Codegraph @

gcc/config/riscv/vector.md

raw
1 ;; Machine description for RISC-V 'V' Extension for GNU compiler.
2 ;; Copyright (C) 2022-2025 Free Software Foundation, Inc.
3 ;; Contributed by Juzhe Zhong ([email protected]), RiVAI Technologies Ltd.
4
5 ;; This file is part of GCC.
6
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 3, or (at your option)
10 ;; any later version.
11
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
16
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
20
21 ;; This file describes the RISC-V 'V' Extension, Version 1.0.
22 ;;
23 ;; This file include :
24 ;;
25 ;; - Intrinsics (https://github.com/riscv/rvv-intrinsic-doc)
26 ;; - Auto-vectorization (autovec.md)
27 ;; - Optimization (autovec-opt.md)
28
29 (include "vector-iterators.md")
30
31 (define_constants [
32 (INVALID_ATTRIBUTE 255)
33 (X0_REGNUM 0)
34 ])
35
36 ;; True if the type is RVV instructions that include VTYPE
37 ;; global status register in the use op list.
38 ;; We known VTYPE has 4 fields: SEW, LMUL, TA, MA.
39 ;; The instruction need any of VTYPE field is set as true
40 ;; in this attribute.
41 (define_attr "has_vtype_op" "false,true"
42 (cond [(eq_attr "type" "vlde,vste,vldm,vstm,vlds,vsts,\
43 vldux,vldox,vstux,vstox,vldff,\
44 vialu,viwalu,vext,vicalu,vshift,vnshift,vicmp,viminmax,\
45 vimul,vidiv,viwmul,vimuladd,viwmuladd,vimerge,
46 vmov,vimov,\
47 vsalu,vaalu,vsmul,vsshift,vnclip,\
48 vfalu,vfwalu,vfmul,vfdiv,vfwmul,vfmuladd,vfwmuladd,vfsqrt,vfrecp,\
49 vfcmp,vfminmax,vfsgnj,vfclass,vfmerge,vfmov,\
50 vfcvtitof,vfcvtftoi,vfwcvtitof,vfwcvtftoi,\
51 vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,\
52 vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\
53 vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovvx,vimovxv,vfmovvf,vfmovfv,\
54 vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\
55 vgather,vcompress,vlsegde,vssegte,vlsegds,vssegts,vlsegdux,vlsegdox,\
56 vssegtux,vssegtox,vlsegdff,vandn,vbrev,vbrev8,vrev8,vcpop,vclz,vctz,vrol,\
57 vror,vwsll,vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\
58 vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,\
59 vfncvtbf16,vfwcvtbf16,vfwmaccbf16,\
60 sf_vqmacc,sf_vfnrclip")
61 (const_string "true")]
62 (const_string "false")))
63
64 ;; True if the type is RVV instructions that include VL
65 ;; global status register in the use op list.
66 ;; The instruction need vector length to be specified is set
67 ;; in this attribute.
68 (define_attr "has_vl_op" "false,true"
69 (cond [(eq_attr "type" "vlde,vste,vldm,vstm,vlds,vsts,\
70 vldux,vldox,vstux,vstox,vldff,\
71 vialu,viwalu,vext,vicalu,vshift,vnshift,vicmp,viminmax,\
72 vimul,vidiv,viwmul,vimuladd,viwmuladd,vimerge,vimov,\
73 vsalu,vaalu,vsmul,vsshift,vnclip,\
74 vfalu,vfwalu,vfmul,vfdiv,vfwmul,vfmuladd,vfwmuladd,vfsqrt,vfrecp,\
75 vfcmp,vfminmax,vfsgnj,vfclass,vfmerge,vfmov,\
76 vfcvtitof,vfcvtftoi,vfwcvtitof,vfwcvtftoi,\
77 vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,\
78 vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\
79 vmalu,vmpop,vmffs,vmsfs,vmiota,vmidx,vimovxv,vfmovfv,\
80 vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\
81 vgather,vcompress,vlsegde,vssegte,vlsegds,vssegts,vlsegdux,vlsegdox,\
82 vssegtux,vssegtox,vlsegdff,vandn,vbrev,vbrev8,vrev8,vcpop,vclz,vctz,vrol,\
83 vror,vwsll,vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\
84 vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c,\
85 vfncvtbf16,vfwcvtbf16,vfwmaccbf16")
86 (const_string "true")]
87 (const_string "false")))
88
89 ;; The default SEW of RVV instruction. This attribute doesn't mean the instruction
90 ;; is necessary to require SEW check for example vlm.v which require ratio to
91 ;; check. However, we need default value of SEW for vsetvl instruction since there
92 ;; is no field for ratio in the vsetvl instruction encoding.
93 (define_attr "sew" ""
94 (cond [(eq_attr "mode" "RVVMF8BI,RVVMF4BI,RVVMF2BI,RVVM1BI,\
95 RVVM8QI,RVVM4QI,RVVM2QI,RVVM1QI,RVVMF2QI,RVVMF4QI,RVVMF8QI,\
96 RVVM1x8QI,RVVMF2x8QI,RVVMF4x8QI,RVVMF8x8QI,\
97 RVVM1x7QI,RVVMF2x7QI,RVVMF4x7QI,RVVMF8x7QI,\
98 RVVM1x6QI,RVVMF2x6QI,RVVMF4x6QI,RVVMF8x6QI,\
99 RVVM1x5QI,RVVMF2x5QI,RVVMF4x5QI,RVVMF8x5QI,\
100 RVVM2x4QI,RVVM1x4QI,RVVMF2x4QI,RVVMF4x4QI,RVVMF8x4QI,\
101 RVVM2x3QI,RVVM1x3QI,RVVMF2x3QI,RVVMF4x3QI,RVVMF8x3QI,\
102 RVVM4x2QI,RVVM2x2QI,RVVM1x2QI,RVVMF2x2QI,RVVMF4x2QI,RVVMF8x2QI,\
103 V1QI,V2QI,V4QI,V8QI,V16QI,V32QI,V64QI,V128QI,V256QI,V512QI,V1024QI,V2048QI,V4096QI,\
104 V1BI,V2BI,V4BI,V8BI,V16BI,V32BI,V64BI,V128BI,V256BI,V512BI,V1024BI,V2048BI,V4096BI")
105 (const_int 8)
106 (eq_attr "mode" "RVVMF16BI")
107 (if_then_else (match_test "TARGET_XTHEADVECTOR")
108 (const_int 16)
109 (const_int 8))
110 (eq_attr "mode" "RVVMF32BI")
111 (if_then_else (match_test "TARGET_XTHEADVECTOR")
112 (const_int 32)
113 (const_int 8))
114 (eq_attr "mode" "RVVMF64BI")
115 (if_then_else (match_test "TARGET_XTHEADVECTOR")
116 (const_int 64)
117 (const_int 8))
118 (eq_attr "mode" "RVVM8HI,RVVM4HI,RVVM2HI,RVVM1HI,RVVMF2HI,RVVMF4HI,\
119 RVVM1x8HI,RVVMF2x8HI,RVVMF4x8HI,\
120 RVVM1x7HI,RVVMF2x7HI,RVVMF4x7HI,\
121 RVVM1x6HI,RVVMF2x6HI,RVVMF4x6HI,\
122 RVVM1x5HI,RVVMF2x5HI,RVVMF4x5HI,\
123 RVVM2x4HI,RVVM1x4HI,RVVMF2x4HI,RVVMF4x4HI,\
124 RVVM2x3HI,RVVM1x3HI,RVVMF2x3HI,RVVMF4x3HI,\
125 RVVM4x2HI,RVVM2x2HI,RVVM1x2HI,RVVMF2x2HI,RVVMF4x2HI,\
126 RVVM8BF,RVVM4BF,RVVM2BF,RVVM1BF,RVVMF2BF,RVVMF4BF,\
127 RVVM1x8BF,RVVMF2x8BF,RVVMF4x8BF,\
128 RVVM1x7BF,RVVMF2x7BF,RVVMF4x7BF,\
129 RVVM1x6BF,RVVMF2x6BF,RVVMF4x6BF,\
130 RVVM1x5BF,RVVMF2x5BF,RVVMF4x5BF,\
131 RVVM2x4BF,RVVM1x4BF,RVVMF2x4BF,RVVMF4x4BF,\
132 RVVM2x3BF,RVVM1x3BF,RVVMF2x3BF,RVVMF4x3BF,\
133 RVVM4x2BF,RVVM2x2BF,RVVM1x2BF,RVVMF2x2BF,RVVMF4x2BF,\
134 RVVM8HF,RVVM4HF,RVVM2HF,RVVM1HF,RVVMF2HF,RVVMF4HF,\
135 RVVM1x8HF,RVVMF2x8HF,RVVMF4x8HF,\
136 RVVM1x7HF,RVVMF2x7HF,RVVMF4x7HF,\
137 RVVM1x6HF,RVVMF2x6HF,RVVMF4x6HF,\
138 RVVM1x5HF,RVVMF2x5HF,RVVMF4x5HF,\
139 RVVM2x4HF,RVVM1x4HF,RVVMF2x4HF,RVVMF4x4HF,\
140 RVVM2x3HF,RVVM1x3HF,RVVMF2x3HF,RVVMF4x3HF,\
141 RVVM4x2HF,RVVM2x2HF,RVVM1x2HF,RVVMF2x2HF,RVVMF4x2HF,\
142 V1HI,V2HI,V4HI,V8HI,V16HI,V32HI,V64HI,V128HI,V256HI,V512HI,V1024HI,V2048HI,\
143 V1HF,V2HF,V4HF,V8HF,V16HF,V32HF,V64HF,V128HF,V256HF,V512HF,V1024HF,V2048HF")
144 (const_int 16)
145 (eq_attr "mode" "RVVM8SI,RVVM4SI,RVVM2SI,RVVM1SI,RVVMF2SI,\
146 RVVM8SF,RVVM4SF,RVVM2SF,RVVM1SF,RVVMF2SF,\
147 RVVM1x8SI,RVVMF2x8SI,\
148 RVVM1x7SI,RVVMF2x7SI,\
149 RVVM1x6SI,RVVMF2x6SI,\
150 RVVM1x5SI,RVVMF2x5SI,\
151 RVVMF2x4SI,RVVMF2x3SI,\
152 RVVM2x4SI,RVVM1x4SI,\
153 RVVM2x3SI,RVVM1x3SI,\
154 RVVM4x2SI,RVVM2x2SI,RVVM1x2SI,RVVMF2x2SI,\
155 RVVM1x8SF,RVVMF2x8SF,\
156 RVVM1x7SF,RVVMF2x7SF,\
157 RVVM1x6SF,RVVMF2x6SF,\
158 RVVM1x5SF,RVVMF2x5SF,\
159 RVVM2x4SF,RVVM1x4SF,RVVMF2x4SF,\
160 RVVM2x3SF,RVVM1x3SF,RVVMF2x3SF,\
161 RVVM4x2SF,RVVM2x2SF,RVVM1x2SF,RVVMF2x2SF,\
162 V1SI,V2SI,V4SI,V8SI,V16SI,V32SI,V64SI,V128SI,V256SI,V512SI,V1024SI,\
163 V1SF,V2SF,V4SF,V8SF,V16SF,V32SF,V64SF,V128SF,V256SF,V512SF,V1024SF")
164 (const_int 32)
165 (eq_attr "mode" "RVVM8DI,RVVM4DI,RVVM2DI,RVVM1DI,\
166 RVVM8DF,RVVM4DF,RVVM2DF,RVVM1DF,\
167 RVVM1x8DI,RVVM1x7DI,RVVM1x6DI,RVVM1x5DI,\
168 RVVM2x4DI,RVVM1x4DI,\
169 RVVM2x3DI,RVVM1x3DI,\
170 RVVM4x2DI,RVVM2x2DI,RVVM1x2DI,\
171 RVVM1x8DF,RVVM1x7DF,RVVM1x6DF,RVVM1x5DF,\
172 RVVM2x4DF,RVVM1x4DF,\
173 RVVM2x3DF,RVVM1x3DF,\
174 RVVM4x2DF,RVVM2x2DF,RVVM1x2DF,\
175 V1DI,V2DI,V4DI,V8DI,V16DI,V32DI,V64DI,V128DI,V256DI,V512DI,\
176 V1DF,V2DF,V4DF,V8DF,V16DF,V32DF,V64DF,V128DF,V256DF,V512DF")
177 (const_int 64)]
178 (const_int INVALID_ATTRIBUTE)))
179
180 ;; Ditto to LMUL.
181 (define_attr "vlmul" ""
182 (cond [(eq_attr "mode" "RVVM8QI,RVVM1BI") (symbol_ref "riscv_vector::LMUL_8")
183 (eq_attr "mode" "RVVM4QI,RVVMF2BI") (symbol_ref "riscv_vector::LMUL_4")
184 (eq_attr "mode" "RVVM2QI,RVVMF4BI") (symbol_ref "riscv_vector::LMUL_2")
185 (eq_attr "mode" "RVVM1QI,RVVMF8BI") (symbol_ref "riscv_vector::LMUL_1")
186 (eq_attr "mode" "RVVMF2QI,RVVMF16BI") (symbol_ref "TARGET_XTHEADVECTOR ? riscv_vector::LMUL_1 : riscv_vector::LMUL_F2")
187 (eq_attr "mode" "RVVMF4QI,RVVMF32BI") (symbol_ref "TARGET_XTHEADVECTOR ? riscv_vector::LMUL_1 : riscv_vector::LMUL_F4")
188 (eq_attr "mode" "RVVMF8QI,RVVMF64BI") (symbol_ref "TARGET_XTHEADVECTOR ? riscv_vector::LMUL_1 : riscv_vector::LMUL_F8")
189 (eq_attr "mode" "RVVM8HI") (symbol_ref "riscv_vector::LMUL_8")
190 (eq_attr "mode" "RVVM4HI") (symbol_ref "riscv_vector::LMUL_4")
191 (eq_attr "mode" "RVVM2HI") (symbol_ref "riscv_vector::LMUL_2")
192 (eq_attr "mode" "RVVM1HI") (symbol_ref "riscv_vector::LMUL_1")
193 (eq_attr "mode" "RVVMF2HI") (symbol_ref "riscv_vector::LMUL_F2")
194 (eq_attr "mode" "RVVMF4HI") (symbol_ref "riscv_vector::LMUL_F4")
195 (eq_attr "mode" "RVVM8BF") (symbol_ref "riscv_vector::LMUL_8")
196 (eq_attr "mode" "RVVM4BF") (symbol_ref "riscv_vector::LMUL_4")
197 (eq_attr "mode" "RVVM2BF") (symbol_ref "riscv_vector::LMUL_2")
198 (eq_attr "mode" "RVVM1BF") (symbol_ref "riscv_vector::LMUL_1")
199 (eq_attr "mode" "RVVMF2BF") (symbol_ref "riscv_vector::LMUL_F2")
200 (eq_attr "mode" "RVVMF4BF") (symbol_ref "riscv_vector::LMUL_F4")
201 (eq_attr "mode" "RVVM8HF") (symbol_ref "riscv_vector::LMUL_8")
202 (eq_attr "mode" "RVVM4HF") (symbol_ref "riscv_vector::LMUL_4")
203 (eq_attr "mode" "RVVM2HF") (symbol_ref "riscv_vector::LMUL_2")
204 (eq_attr "mode" "RVVM1HF") (symbol_ref "riscv_vector::LMUL_1")
205 (eq_attr "mode" "RVVMF2HF") (symbol_ref "riscv_vector::LMUL_F2")
206 (eq_attr "mode" "RVVMF4HF") (symbol_ref "riscv_vector::LMUL_F4")
207 (eq_attr "mode" "RVVM8SI") (symbol_ref "riscv_vector::LMUL_8")
208 (eq_attr "mode" "RVVM4SI") (symbol_ref "riscv_vector::LMUL_4")
209 (eq_attr "mode" "RVVM2SI") (symbol_ref "riscv_vector::LMUL_2")
210 (eq_attr "mode" "RVVM1SI") (symbol_ref "riscv_vector::LMUL_1")
211 (eq_attr "mode" "RVVMF2SI") (symbol_ref "riscv_vector::LMUL_F2")
212 (eq_attr "mode" "RVVM8SF") (symbol_ref "riscv_vector::LMUL_8")
213 (eq_attr "mode" "RVVM4SF") (symbol_ref "riscv_vector::LMUL_4")
214 (eq_attr "mode" "RVVM2SF") (symbol_ref "riscv_vector::LMUL_2")
215 (eq_attr "mode" "RVVM1SF") (symbol_ref "riscv_vector::LMUL_1")
216 (eq_attr "mode" "RVVMF2SF") (symbol_ref "riscv_vector::LMUL_F2")
217 (eq_attr "mode" "RVVM8DI") (symbol_ref "riscv_vector::LMUL_8")
218 (eq_attr "mode" "RVVM4DI") (symbol_ref "riscv_vector::LMUL_4")
219 (eq_attr "mode" "RVVM2DI") (symbol_ref "riscv_vector::LMUL_2")
220 (eq_attr "mode" "RVVM1DI") (symbol_ref "riscv_vector::LMUL_1")
221 (eq_attr "mode" "RVVM8DF") (symbol_ref "riscv_vector::LMUL_8")
222 (eq_attr "mode" "RVVM4DF") (symbol_ref "riscv_vector::LMUL_4")
223 (eq_attr "mode" "RVVM2DF") (symbol_ref "riscv_vector::LMUL_2")
224 (eq_attr "mode" "RVVM1DF") (symbol_ref "riscv_vector::LMUL_1")
225 (eq_attr "mode" "RVVM1x8QI") (symbol_ref "riscv_vector::LMUL_1")
226 (eq_attr "mode" "RVVMF2x8QI") (symbol_ref "riscv_vector::LMUL_F2")
227 (eq_attr "mode" "RVVMF4x8QI") (symbol_ref "riscv_vector::LMUL_F4")
228 (eq_attr "mode" "RVVMF8x8QI") (symbol_ref "riscv_vector::LMUL_F8")
229 (eq_attr "mode" "RVVM1x7QI") (symbol_ref "riscv_vector::LMUL_1")
230 (eq_attr "mode" "RVVMF2x7QI") (symbol_ref "riscv_vector::LMUL_F2")
231 (eq_attr "mode" "RVVMF4x7QI") (symbol_ref "riscv_vector::LMUL_F4")
232 (eq_attr "mode" "RVVMF8x7QI") (symbol_ref "riscv_vector::LMUL_F8")
233 (eq_attr "mode" "RVVM1x6QI") (symbol_ref "riscv_vector::LMUL_1")
234 (eq_attr "mode" "RVVMF2x6QI") (symbol_ref "riscv_vector::LMUL_F2")
235 (eq_attr "mode" "RVVMF4x6QI") (symbol_ref "riscv_vector::LMUL_F4")
236 (eq_attr "mode" "RVVMF8x6QI") (symbol_ref "riscv_vector::LMUL_F8")
237 (eq_attr "mode" "RVVM1x5QI") (symbol_ref "riscv_vector::LMUL_1")
238 (eq_attr "mode" "RVVMF2x5QI") (symbol_ref "riscv_vector::LMUL_F2")
239 (eq_attr "mode" "RVVMF4x5QI") (symbol_ref "riscv_vector::LMUL_F4")
240 (eq_attr "mode" "RVVMF8x5QI") (symbol_ref "riscv_vector::LMUL_F8")
241 (eq_attr "mode" "RVVM2x4QI") (symbol_ref "riscv_vector::LMUL_2")
242 (eq_attr "mode" "RVVM1x4QI") (symbol_ref "riscv_vector::LMUL_1")
243 (eq_attr "mode" "RVVMF2x4QI") (symbol_ref "riscv_vector::LMUL_F2")
244 (eq_attr "mode" "RVVMF4x4QI") (symbol_ref "riscv_vector::LMUL_F4")
245 (eq_attr "mode" "RVVMF8x4QI") (symbol_ref "riscv_vector::LMUL_F8")
246 (eq_attr "mode" "RVVM2x3QI") (symbol_ref "riscv_vector::LMUL_2")
247 (eq_attr "mode" "RVVM1x3QI") (symbol_ref "riscv_vector::LMUL_1")
248 (eq_attr "mode" "RVVMF2x3QI") (symbol_ref "riscv_vector::LMUL_F2")
249 (eq_attr "mode" "RVVMF4x3QI") (symbol_ref "riscv_vector::LMUL_F4")
250 (eq_attr "mode" "RVVMF8x3QI") (symbol_ref "riscv_vector::LMUL_F8")
251 (eq_attr "mode" "RVVM4x2QI") (symbol_ref "riscv_vector::LMUL_4")
252 (eq_attr "mode" "RVVM2x2QI") (symbol_ref "riscv_vector::LMUL_2")
253 (eq_attr "mode" "RVVM1x2QI") (symbol_ref "riscv_vector::LMUL_1")
254 (eq_attr "mode" "RVVMF2x2QI") (symbol_ref "riscv_vector::LMUL_F2")
255 (eq_attr "mode" "RVVMF4x2QI") (symbol_ref "riscv_vector::LMUL_F4")
256 (eq_attr "mode" "RVVMF8x2QI") (symbol_ref "riscv_vector::LMUL_F8")
257 (eq_attr "mode" "RVVM1x8HI") (symbol_ref "riscv_vector::LMUL_1")
258 (eq_attr "mode" "RVVMF2x8HI") (symbol_ref "riscv_vector::LMUL_F2")
259 (eq_attr "mode" "RVVMF4x8HI") (symbol_ref "riscv_vector::LMUL_F4")
260 (eq_attr "mode" "RVVM1x7HI") (symbol_ref "riscv_vector::LMUL_1")
261 (eq_attr "mode" "RVVMF2x7HI") (symbol_ref "riscv_vector::LMUL_F2")
262 (eq_attr "mode" "RVVMF4x7HI") (symbol_ref "riscv_vector::LMUL_F4")
263 (eq_attr "mode" "RVVM1x6HI") (symbol_ref "riscv_vector::LMUL_1")
264 (eq_attr "mode" "RVVMF2x6HI") (symbol_ref "riscv_vector::LMUL_F2")
265 (eq_attr "mode" "RVVMF4x6HI") (symbol_ref "riscv_vector::LMUL_F4")
266 (eq_attr "mode" "RVVM1x5HI") (symbol_ref "riscv_vector::LMUL_1")
267 (eq_attr "mode" "RVVMF2x5HI") (symbol_ref "riscv_vector::LMUL_F2")
268 (eq_attr "mode" "RVVMF4x5HI") (symbol_ref "riscv_vector::LMUL_F4")
269 (eq_attr "mode" "RVVM2x4HI") (symbol_ref "riscv_vector::LMUL_2")
270 (eq_attr "mode" "RVVM1x4HI") (symbol_ref "riscv_vector::LMUL_1")
271 (eq_attr "mode" "RVVMF2x4HI") (symbol_ref "riscv_vector::LMUL_F2")
272 (eq_attr "mode" "RVVMF4x4HI") (symbol_ref "riscv_vector::LMUL_F4")
273 (eq_attr "mode" "RVVM2x3HI") (symbol_ref "riscv_vector::LMUL_2")
274 (eq_attr "mode" "RVVM1x3HI") (symbol_ref "riscv_vector::LMUL_1")
275 (eq_attr "mode" "RVVMF2x3HI") (symbol_ref "riscv_vector::LMUL_F2")
276 (eq_attr "mode" "RVVMF4x3HI") (symbol_ref "riscv_vector::LMUL_F4")
277 (eq_attr "mode" "RVVM4x2HI") (symbol_ref "riscv_vector::LMUL_4")
278 (eq_attr "mode" "RVVM2x2HI") (symbol_ref "riscv_vector::LMUL_2")
279 (eq_attr "mode" "RVVM1x2HI") (symbol_ref "riscv_vector::LMUL_1")
280 (eq_attr "mode" "RVVMF2x2HI") (symbol_ref "riscv_vector::LMUL_F2")
281 (eq_attr "mode" "RVVMF4x2HI") (symbol_ref "riscv_vector::LMUL_F4")
282 (eq_attr "mode" "RVVM1x8BF") (symbol_ref "riscv_vector::LMUL_1")
283 (eq_attr "mode" "RVVMF2x8BF") (symbol_ref "riscv_vector::LMUL_F2")
284 (eq_attr "mode" "RVVMF4x8BF") (symbol_ref "riscv_vector::LMUL_F4")
285 (eq_attr "mode" "RVVM1x7BF") (symbol_ref "riscv_vector::LMUL_1")
286 (eq_attr "mode" "RVVMF2x7BF") (symbol_ref "riscv_vector::LMUL_F2")
287 (eq_attr "mode" "RVVMF4x7BF") (symbol_ref "riscv_vector::LMUL_F4")
288 (eq_attr "mode" "RVVM1x6BF") (symbol_ref "riscv_vector::LMUL_1")
289 (eq_attr "mode" "RVVMF2x6BF") (symbol_ref "riscv_vector::LMUL_F2")
290 (eq_attr "mode" "RVVMF4x6BF") (symbol_ref "riscv_vector::LMUL_F4")
291 (eq_attr "mode" "RVVM1x5BF") (symbol_ref "riscv_vector::LMUL_1")
292 (eq_attr "mode" "RVVMF2x5BF") (symbol_ref "riscv_vector::LMUL_F2")
293 (eq_attr "mode" "RVVMF4x5BF") (symbol_ref "riscv_vector::LMUL_F4")
294 (eq_attr "mode" "RVVM2x4BF") (symbol_ref "riscv_vector::LMUL_2")
295 (eq_attr "mode" "RVVM1x4BF") (symbol_ref "riscv_vector::LMUL_1")
296 (eq_attr "mode" "RVVMF2x4BF") (symbol_ref "riscv_vector::LMUL_F2")
297 (eq_attr "mode" "RVVMF4x4BF") (symbol_ref "riscv_vector::LMUL_F4")
298 (eq_attr "mode" "RVVM2x3BF") (symbol_ref "riscv_vector::LMUL_2")
299 (eq_attr "mode" "RVVM1x3BF") (symbol_ref "riscv_vector::LMUL_1")
300 (eq_attr "mode" "RVVMF2x3BF") (symbol_ref "riscv_vector::LMUL_F2")
301 (eq_attr "mode" "RVVMF4x3BF") (symbol_ref "riscv_vector::LMUL_F4")
302 (eq_attr "mode" "RVVM4x2BF") (symbol_ref "riscv_vector::LMUL_4")
303 (eq_attr "mode" "RVVM2x2BF") (symbol_ref "riscv_vector::LMUL_2")
304 (eq_attr "mode" "RVVM1x2BF") (symbol_ref "riscv_vector::LMUL_1")
305 (eq_attr "mode" "RVVMF2x2BF") (symbol_ref "riscv_vector::LMUL_F2")
306 (eq_attr "mode" "RVVMF4x2BF") (symbol_ref "riscv_vector::LMUL_F4")
307 (eq_attr "mode" "RVVM1x8HF") (symbol_ref "riscv_vector::LMUL_1")
308 (eq_attr "mode" "RVVMF2x8HF") (symbol_ref "riscv_vector::LMUL_F2")
309 (eq_attr "mode" "RVVMF4x8HF") (symbol_ref "riscv_vector::LMUL_F4")
310 (eq_attr "mode" "RVVM1x7HF") (symbol_ref "riscv_vector::LMUL_1")
311 (eq_attr "mode" "RVVMF2x7HF") (symbol_ref "riscv_vector::LMUL_F2")
312 (eq_attr "mode" "RVVMF4x7HF") (symbol_ref "riscv_vector::LMUL_F4")
313 (eq_attr "mode" "RVVM1x6HF") (symbol_ref "riscv_vector::LMUL_1")
314 (eq_attr "mode" "RVVMF2x6HF") (symbol_ref "riscv_vector::LMUL_F2")
315 (eq_attr "mode" "RVVMF4x6HF") (symbol_ref "riscv_vector::LMUL_F4")
316 (eq_attr "mode" "RVVM1x5HF") (symbol_ref "riscv_vector::LMUL_1")
317 (eq_attr "mode" "RVVMF2x5HF") (symbol_ref "riscv_vector::LMUL_F2")
318 (eq_attr "mode" "RVVMF4x5HF") (symbol_ref "riscv_vector::LMUL_F4")
319 (eq_attr "mode" "RVVM2x4HF") (symbol_ref "riscv_vector::LMUL_2")
320 (eq_attr "mode" "RVVM1x4HF") (symbol_ref "riscv_vector::LMUL_1")
321 (eq_attr "mode" "RVVMF2x4HF") (symbol_ref "riscv_vector::LMUL_F2")
322 (eq_attr "mode" "RVVMF4x4HF") (symbol_ref "riscv_vector::LMUL_F4")
323 (eq_attr "mode" "RVVM2x3HF") (symbol_ref "riscv_vector::LMUL_2")
324 (eq_attr "mode" "RVVM1x3HF") (symbol_ref "riscv_vector::LMUL_1")
325 (eq_attr "mode" "RVVMF2x3HF") (symbol_ref "riscv_vector::LMUL_F2")
326 (eq_attr "mode" "RVVMF4x3HF") (symbol_ref "riscv_vector::LMUL_F4")
327 (eq_attr "mode" "RVVM4x2HF") (symbol_ref "riscv_vector::LMUL_4")
328 (eq_attr "mode" "RVVM2x2HF") (symbol_ref "riscv_vector::LMUL_2")
329 (eq_attr "mode" "RVVM1x2HF") (symbol_ref "riscv_vector::LMUL_1")
330 (eq_attr "mode" "RVVMF2x2HF") (symbol_ref "riscv_vector::LMUL_F2")
331 (eq_attr "mode" "RVVMF4x2HF") (symbol_ref "riscv_vector::LMUL_F4")
332 (eq_attr "mode" "RVVM1x8SI") (symbol_ref "riscv_vector::LMUL_1")
333 (eq_attr "mode" "RVVMF2x8SI") (symbol_ref "riscv_vector::LMUL_F2")
334 (eq_attr "mode" "RVVM1x7SI") (symbol_ref "riscv_vector::LMUL_1")
335 (eq_attr "mode" "RVVMF2x7SI") (symbol_ref "riscv_vector::LMUL_F2")
336 (eq_attr "mode" "RVVM1x6SI") (symbol_ref "riscv_vector::LMUL_1")
337 (eq_attr "mode" "RVVMF2x6SI") (symbol_ref "riscv_vector::LMUL_F2")
338 (eq_attr "mode" "RVVM1x5SI") (symbol_ref "riscv_vector::LMUL_1")
339 (eq_attr "mode" "RVVMF2x5SI") (symbol_ref "riscv_vector::LMUL_F2")
340 (eq_attr "mode" "RVVM2x4SI") (symbol_ref "riscv_vector::LMUL_2")
341 (eq_attr "mode" "RVVM1x4SI") (symbol_ref "riscv_vector::LMUL_1")
342 (eq_attr "mode" "RVVMF2x4SI") (symbol_ref "riscv_vector::LMUL_F2")
343 (eq_attr "mode" "RVVM2x3SI") (symbol_ref "riscv_vector::LMUL_2")
344 (eq_attr "mode" "RVVM1x3SI") (symbol_ref "riscv_vector::LMUL_1")
345 (eq_attr "mode" "RVVMF2x3SI") (symbol_ref "riscv_vector::LMUL_F2")
346 (eq_attr "mode" "RVVM4x2SI") (symbol_ref "riscv_vector::LMUL_4")
347 (eq_attr "mode" "RVVM2x2SI") (symbol_ref "riscv_vector::LMUL_2")
348 (eq_attr "mode" "RVVM1x2SI") (symbol_ref "riscv_vector::LMUL_1")
349 (eq_attr "mode" "RVVMF2x2SI") (symbol_ref "riscv_vector::LMUL_F2")
350 (eq_attr "mode" "RVVM1x8SF") (symbol_ref "riscv_vector::LMUL_1")
351 (eq_attr "mode" "RVVMF2x8SF") (symbol_ref "riscv_vector::LMUL_F2")
352 (eq_attr "mode" "RVVM1x7SF") (symbol_ref "riscv_vector::LMUL_1")
353 (eq_attr "mode" "RVVMF2x7SF") (symbol_ref "riscv_vector::LMUL_F2")
354 (eq_attr "mode" "RVVM1x6SF") (symbol_ref "riscv_vector::LMUL_1")
355 (eq_attr "mode" "RVVMF2x6SF") (symbol_ref "riscv_vector::LMUL_F2")
356 (eq_attr "mode" "RVVM1x5SF") (symbol_ref "riscv_vector::LMUL_1")
357 (eq_attr "mode" "RVVMF2x5SF") (symbol_ref "riscv_vector::LMUL_F2")
358 (eq_attr "mode" "RVVM2x4SF") (symbol_ref "riscv_vector::LMUL_2")
359 (eq_attr "mode" "RVVM1x4SF") (symbol_ref "riscv_vector::LMUL_1")
360 (eq_attr "mode" "RVVMF2x4SF") (symbol_ref "riscv_vector::LMUL_F2")
361 (eq_attr "mode" "RVVM2x3SF") (symbol_ref "riscv_vector::LMUL_2")
362 (eq_attr "mode" "RVVM1x3SF") (symbol_ref "riscv_vector::LMUL_1")
363 (eq_attr "mode" "RVVMF2x3SF") (symbol_ref "riscv_vector::LMUL_F2")
364 (eq_attr "mode" "RVVM4x2SF") (symbol_ref "riscv_vector::LMUL_4")
365 (eq_attr "mode" "RVVM2x2SF") (symbol_ref "riscv_vector::LMUL_2")
366 (eq_attr "mode" "RVVM1x2SF") (symbol_ref "riscv_vector::LMUL_1")
367 (eq_attr "mode" "RVVMF2x2SF") (symbol_ref "riscv_vector::LMUL_F2")
368 (eq_attr "mode" "RVVM1x8DI") (symbol_ref "riscv_vector::LMUL_1")
369 (eq_attr "mode" "RVVM1x7DI") (symbol_ref "riscv_vector::LMUL_1")
370 (eq_attr "mode" "RVVM1x6DI") (symbol_ref "riscv_vector::LMUL_1")
371 (eq_attr "mode" "RVVM1x5DI") (symbol_ref "riscv_vector::LMUL_1")
372 (eq_attr "mode" "RVVM2x4DI") (symbol_ref "riscv_vector::LMUL_2")
373 (eq_attr "mode" "RVVM1x4DI") (symbol_ref "riscv_vector::LMUL_1")
374 (eq_attr "mode" "RVVM2x3DI") (symbol_ref "riscv_vector::LMUL_2")
375 (eq_attr "mode" "RVVM1x3DI") (symbol_ref "riscv_vector::LMUL_1")
376 (eq_attr "mode" "RVVM4x2DI") (symbol_ref "riscv_vector::LMUL_4")
377 (eq_attr "mode" "RVVM2x2DI") (symbol_ref "riscv_vector::LMUL_2")
378 (eq_attr "mode" "RVVM1x2DI") (symbol_ref "riscv_vector::LMUL_1")
379 (eq_attr "mode" "RVVM1x8DF") (symbol_ref "riscv_vector::LMUL_1")
380 (eq_attr "mode" "RVVM1x7DF") (symbol_ref "riscv_vector::LMUL_1")
381 (eq_attr "mode" "RVVM1x6DF") (symbol_ref "riscv_vector::LMUL_1")
382 (eq_attr "mode" "RVVM1x5DF") (symbol_ref "riscv_vector::LMUL_1")
383 (eq_attr "mode" "RVVM2x4DF") (symbol_ref "riscv_vector::LMUL_2")
384 (eq_attr "mode" "RVVM1x4DF") (symbol_ref "riscv_vector::LMUL_1")
385 (eq_attr "mode" "RVVM2x3DF") (symbol_ref "riscv_vector::LMUL_2")
386 (eq_attr "mode" "RVVM1x3DF") (symbol_ref "riscv_vector::LMUL_1")
387 (eq_attr "mode" "RVVM4x2DF") (symbol_ref "riscv_vector::LMUL_4")
388 (eq_attr "mode" "RVVM2x2DF") (symbol_ref "riscv_vector::LMUL_2")
389 (eq_attr "mode" "RVVM1x2DF") (symbol_ref "riscv_vector::LMUL_1")
390
391 ;; VLS modes.
392 (eq_attr "mode" "V1QI,V1BI") (symbol_ref "riscv_vector::get_vlmul(E_V1QImode)")
393 (eq_attr "mode" "V2QI,V2BI") (symbol_ref "riscv_vector::get_vlmul(E_V2QImode)")
394 (eq_attr "mode" "V4QI,V4BI") (symbol_ref "riscv_vector::get_vlmul(E_V4QImode)")
395 (eq_attr "mode" "V8QI,V8BI") (symbol_ref "riscv_vector::get_vlmul(E_V8QImode)")
396 (eq_attr "mode" "V16QI,V16BI") (symbol_ref "riscv_vector::get_vlmul(E_V16QImode)")
397 (eq_attr "mode" "V32QI,V32BI") (symbol_ref "riscv_vector::get_vlmul(E_V32QImode)")
398 (eq_attr "mode" "V64QI,V64BI") (symbol_ref "riscv_vector::get_vlmul(E_V64QImode)")
399 (eq_attr "mode" "V128QI,V128BI") (symbol_ref "riscv_vector::get_vlmul(E_V128QImode)")
400 (eq_attr "mode" "V256QI,V256BI") (symbol_ref "riscv_vector::get_vlmul(E_V256QImode)")
401 (eq_attr "mode" "V512QI,V512BI") (symbol_ref "riscv_vector::get_vlmul(E_V512QImode)")
402 (eq_attr "mode" "V1024QI,V1024BI") (symbol_ref "riscv_vector::get_vlmul(E_V1024QImode)")
403 (eq_attr "mode" "V2048QI,V2048BI") (symbol_ref "riscv_vector::get_vlmul(E_V2048QImode)")
404 (eq_attr "mode" "V4096QI,V4096BI") (symbol_ref "riscv_vector::get_vlmul(E_V4096QImode)")
405 (eq_attr "mode" "V1HI") (symbol_ref "riscv_vector::get_vlmul(E_V1HImode)")
406 (eq_attr "mode" "V2HI") (symbol_ref "riscv_vector::get_vlmul(E_V2HImode)")
407 (eq_attr "mode" "V4HI") (symbol_ref "riscv_vector::get_vlmul(E_V4HImode)")
408 (eq_attr "mode" "V8HI") (symbol_ref "riscv_vector::get_vlmul(E_V8HImode)")
409 (eq_attr "mode" "V16HI") (symbol_ref "riscv_vector::get_vlmul(E_V16HImode)")
410 (eq_attr "mode" "V32HI") (symbol_ref "riscv_vector::get_vlmul(E_V32HImode)")
411 (eq_attr "mode" "V64HI") (symbol_ref "riscv_vector::get_vlmul(E_V64HImode)")
412 (eq_attr "mode" "V128HI") (symbol_ref "riscv_vector::get_vlmul(E_V128HImode)")
413 (eq_attr "mode" "V256HI") (symbol_ref "riscv_vector::get_vlmul(E_V256HImode)")
414 (eq_attr "mode" "V512HI") (symbol_ref "riscv_vector::get_vlmul(E_V512HImode)")
415 (eq_attr "mode" "V1024HI") (symbol_ref "riscv_vector::get_vlmul(E_V1024HImode)")
416 (eq_attr "mode" "V2048HI") (symbol_ref "riscv_vector::get_vlmul(E_V2048HImode)")
417 (eq_attr "mode" "V1SI") (symbol_ref "riscv_vector::get_vlmul(E_V1SImode)")
418 (eq_attr "mode" "V2SI") (symbol_ref "riscv_vector::get_vlmul(E_V2SImode)")
419 (eq_attr "mode" "V4SI") (symbol_ref "riscv_vector::get_vlmul(E_V4SImode)")
420 (eq_attr "mode" "V8SI") (symbol_ref "riscv_vector::get_vlmul(E_V8SImode)")
421 (eq_attr "mode" "V16SI") (symbol_ref "riscv_vector::get_vlmul(E_V16SImode)")
422 (eq_attr "mode" "V32SI") (symbol_ref "riscv_vector::get_vlmul(E_V32SImode)")
423 (eq_attr "mode" "V64SI") (symbol_ref "riscv_vector::get_vlmul(E_V64SImode)")
424 (eq_attr "mode" "V128SI") (symbol_ref "riscv_vector::get_vlmul(E_V128SImode)")
425 (eq_attr "mode" "V256SI") (symbol_ref "riscv_vector::get_vlmul(E_V256SImode)")
426 (eq_attr "mode" "V512SI") (symbol_ref "riscv_vector::get_vlmul(E_V512SImode)")
427 (eq_attr "mode" "V1024SI") (symbol_ref "riscv_vector::get_vlmul(E_V1024SImode)")
428 (eq_attr "mode" "V1DI") (symbol_ref "riscv_vector::get_vlmul(E_V1DImode)")
429 (eq_attr "mode" "V2DI") (symbol_ref "riscv_vector::get_vlmul(E_V2DImode)")
430 (eq_attr "mode" "V4DI") (symbol_ref "riscv_vector::get_vlmul(E_V4DImode)")
431 (eq_attr "mode" "V8DI") (symbol_ref "riscv_vector::get_vlmul(E_V8DImode)")
432 (eq_attr "mode" "V16DI") (symbol_ref "riscv_vector::get_vlmul(E_V16DImode)")
433 (eq_attr "mode" "V32DI") (symbol_ref "riscv_vector::get_vlmul(E_V32DImode)")
434 (eq_attr "mode" "V64DI") (symbol_ref "riscv_vector::get_vlmul(E_V64DImode)")
435 (eq_attr "mode" "V128DI") (symbol_ref "riscv_vector::get_vlmul(E_V128DImode)")
436 (eq_attr "mode" "V256DI") (symbol_ref "riscv_vector::get_vlmul(E_V256DImode)")
437 (eq_attr "mode" "V512DI") (symbol_ref "riscv_vector::get_vlmul(E_V512DImode)")
438 (eq_attr "mode" "V1HF") (symbol_ref "riscv_vector::get_vlmul(E_V1HFmode)")
439 (eq_attr "mode" "V2HF") (symbol_ref "riscv_vector::get_vlmul(E_V2HFmode)")
440 (eq_attr "mode" "V4HF") (symbol_ref "riscv_vector::get_vlmul(E_V4HFmode)")
441 (eq_attr "mode" "V8HF") (symbol_ref "riscv_vector::get_vlmul(E_V8HFmode)")
442 (eq_attr "mode" "V16HF") (symbol_ref "riscv_vector::get_vlmul(E_V16HFmode)")
443 (eq_attr "mode" "V32HF") (symbol_ref "riscv_vector::get_vlmul(E_V32HFmode)")
444 (eq_attr "mode" "V64HF") (symbol_ref "riscv_vector::get_vlmul(E_V64HFmode)")
445 (eq_attr "mode" "V128HF") (symbol_ref "riscv_vector::get_vlmul(E_V128HFmode)")
446 (eq_attr "mode" "V256HF") (symbol_ref "riscv_vector::get_vlmul(E_V256HFmode)")
447 (eq_attr "mode" "V512HF") (symbol_ref "riscv_vector::get_vlmul(E_V512HFmode)")
448 (eq_attr "mode" "V1024HF") (symbol_ref "riscv_vector::get_vlmul(E_V1024HFmode)")
449 (eq_attr "mode" "V2048HF") (symbol_ref "riscv_vector::get_vlmul(E_V2048HFmode)")
450 (eq_attr "mode" "V1SF") (symbol_ref "riscv_vector::get_vlmul(E_V1SFmode)")
451 (eq_attr "mode" "V2SF") (symbol_ref "riscv_vector::get_vlmul(E_V2SFmode)")
452 (eq_attr "mode" "V4SF") (symbol_ref "riscv_vector::get_vlmul(E_V4SFmode)")
453 (eq_attr "mode" "V8SF") (symbol_ref "riscv_vector::get_vlmul(E_V8SFmode)")
454 (eq_attr "mode" "V16SF") (symbol_ref "riscv_vector::get_vlmul(E_V16SFmode)")
455 (eq_attr "mode" "V32SF") (symbol_ref "riscv_vector::get_vlmul(E_V32SFmode)")
456 (eq_attr "mode" "V64SF") (symbol_ref "riscv_vector::get_vlmul(E_V64SFmode)")
457 (eq_attr "mode" "V128SF") (symbol_ref "riscv_vector::get_vlmul(E_V128SFmode)")
458 (eq_attr "mode" "V256SF") (symbol_ref "riscv_vector::get_vlmul(E_V256SFmode)")
459 (eq_attr "mode" "V512SF") (symbol_ref "riscv_vector::get_vlmul(E_V512SFmode)")
460 (eq_attr "mode" "V1024SF") (symbol_ref "riscv_vector::get_vlmul(E_V1024SFmode)")
461 (eq_attr "mode" "V1DF") (symbol_ref "riscv_vector::get_vlmul(E_V1DFmode)")
462 (eq_attr "mode" "V2DF") (symbol_ref "riscv_vector::get_vlmul(E_V2DFmode)")
463 (eq_attr "mode" "V4DF") (symbol_ref "riscv_vector::get_vlmul(E_V4DFmode)")
464 (eq_attr "mode" "V8DF") (symbol_ref "riscv_vector::get_vlmul(E_V8DFmode)")
465 (eq_attr "mode" "V16DF") (symbol_ref "riscv_vector::get_vlmul(E_V16DFmode)")
466 (eq_attr "mode" "V32DF") (symbol_ref "riscv_vector::get_vlmul(E_V32DFmode)")
467 (eq_attr "mode" "V64DF") (symbol_ref "riscv_vector::get_vlmul(E_V64DFmode)")
468 (eq_attr "mode" "V128DF") (symbol_ref "riscv_vector::get_vlmul(E_V128DFmode)")
469 (eq_attr "mode" "V256DF") (symbol_ref "riscv_vector::get_vlmul(E_V256DFmode)")
470 (eq_attr "mode" "V512DF") (symbol_ref "riscv_vector::get_vlmul(E_V512DFmode)")]
471 (const_int INVALID_ATTRIBUTE)))
472
473 ;; It is valid for instruction that require sew/lmul ratio.
474 (define_attr "ratio" ""
475 (cond [(eq_attr "type" "vimov,vfmov,vldux,vldox,vstux,vstox,\
476 vialu,vshift,vicmp,vimul,vidiv,vsalu,\
477 vext,viwalu,viwmul,vicalu,vnshift,\
478 vimuladd,vimerge,vaalu,vsmul,vsshift,\
479 vnclip,viminmax,viwmuladd,\
480 vmiota,vmidx,vfalu,vfmul,vfminmax,vfdiv,\
481 vfwalu,vfwmul,vfsqrt,vfrecp,vfsgnj,vfcmp,\
482 vfmerge,vfcvtitof,vfcvtftoi,vfwcvtitof,\
483 vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,\
484 vfncvtftof,vfmuladd,vfwmuladd,vfclass,vired,\
485 viwred,vfredu,vfredo,vfwredu,vfwredo,vimovvx,\
486 vimovxv,vfmovvf,vfmovfv,vslideup,vslidedown,\
487 vislide1up,vislide1down,vfslide1up,vfslide1down,\
488 vgather,vcompress,vlsegdux,vlsegdox,vssegtux,vssegtox,\
489 vandn,vbrev,vbrev8,vrev8,vcpop,vclz,vctz,vrol,vror,vwsll,\
490 vclmul,vclmulh,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\
491 vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,\
492 vsm3me,vsm3c,vfncvtbf16,vfwcvtbf16,vfwmaccbf16")
493 (const_int INVALID_ATTRIBUTE)
494 (and (eq_attr "type" "vlde,vste,vlds,vsts,vlsegde,vssegte,vlsegds,\
495 vssegts,vlsegdff,vssegtux,vlsegdox,vlsegdux")
496 (match_test "TARGET_XTHEADVECTOR"))
497 (const_int INVALID_ATTRIBUTE)
498 (eq_attr "mode" "RVVM8QI,RVVM1BI") (const_int 1)
499 (eq_attr "mode" "RVVM4QI,RVVMF2BI") (const_int 2)
500 (eq_attr "mode" "RVVM2QI,RVVMF4BI") (const_int 4)
501 (eq_attr "mode" "RVVM1QI,RVVMF8BI") (const_int 8)
502 (eq_attr "mode" "RVVMF2QI,RVVMF16BI") (const_int 16)
503 (eq_attr "mode" "RVVMF4QI,RVVMF32BI") (const_int 32)
504 (eq_attr "mode" "RVVMF8QI,RVVMF64BI") (const_int 64)
505 (eq_attr "mode" "RVVM8HI") (const_int 2)
506 (eq_attr "mode" "RVVM4HI") (const_int 4)
507 (eq_attr "mode" "RVVM2HI") (const_int 8)
508 (eq_attr "mode" "RVVM1HI") (const_int 16)
509 (eq_attr "mode" "RVVMF2HI") (const_int 32)
510 (eq_attr "mode" "RVVMF4HI") (const_int 64)
511 (eq_attr "mode" "RVVM8BF") (const_int 2)
512 (eq_attr "mode" "RVVM4BF") (const_int 4)
513 (eq_attr "mode" "RVVM2BF") (const_int 8)
514 (eq_attr "mode" "RVVM1BF") (const_int 16)
515 (eq_attr "mode" "RVVMF2BF") (const_int 32)
516 (eq_attr "mode" "RVVMF4BF") (const_int 64)
517 (eq_attr "mode" "RVVM8HF") (const_int 2)
518 (eq_attr "mode" "RVVM4HF") (const_int 4)
519 (eq_attr "mode" "RVVM2HF") (const_int 8)
520 (eq_attr "mode" "RVVM1HF") (const_int 16)
521 (eq_attr "mode" "RVVMF2HF") (const_int 32)
522 (eq_attr "mode" "RVVMF4HF") (const_int 64)
523 (eq_attr "mode" "RVVM8SI") (const_int 4)
524 (eq_attr "mode" "RVVM4SI") (const_int 8)
525 (eq_attr "mode" "RVVM2SI") (const_int 16)
526 (eq_attr "mode" "RVVM1SI") (const_int 32)
527 (eq_attr "mode" "RVVMF2SI") (const_int 64)
528 (eq_attr "mode" "RVVM8SF") (const_int 4)
529 (eq_attr "mode" "RVVM4SF") (const_int 8)
530 (eq_attr "mode" "RVVM2SF") (const_int 16)
531 (eq_attr "mode" "RVVM1SF") (const_int 32)
532 (eq_attr "mode" "RVVMF2SF") (const_int 64)
533 (eq_attr "mode" "RVVM8DI") (const_int 8)
534 (eq_attr "mode" "RVVM4DI") (const_int 16)
535 (eq_attr "mode" "RVVM2DI") (const_int 32)
536 (eq_attr "mode" "RVVM1DI") (const_int 64)
537 (eq_attr "mode" "RVVM8DF") (const_int 8)
538 (eq_attr "mode" "RVVM4DF") (const_int 16)
539 (eq_attr "mode" "RVVM2DF") (const_int 32)
540 (eq_attr "mode" "RVVM1DF") (const_int 64)
541 (eq_attr "mode" "RVVM1x8QI") (const_int 8)
542 (eq_attr "mode" "RVVMF2x8QI") (const_int 16)
543 (eq_attr "mode" "RVVMF4x8QI") (const_int 32)
544 (eq_attr "mode" "RVVMF8x8QI") (const_int 64)
545 (eq_attr "mode" "RVVM1x7QI") (const_int 8)
546 (eq_attr "mode" "RVVMF2x7QI") (const_int 16)
547 (eq_attr "mode" "RVVMF4x7QI") (const_int 32)
548 (eq_attr "mode" "RVVMF8x7QI") (const_int 64)
549 (eq_attr "mode" "RVVM1x6QI") (const_int 8)
550 (eq_attr "mode" "RVVMF2x6QI") (const_int 16)
551 (eq_attr "mode" "RVVMF4x6QI") (const_int 32)
552 (eq_attr "mode" "RVVMF8x6QI") (const_int 64)
553 (eq_attr "mode" "RVVM1x5QI") (const_int 8)
554 (eq_attr "mode" "RVVMF2x5QI") (const_int 16)
555 (eq_attr "mode" "RVVMF4x5QI") (const_int 32)
556 (eq_attr "mode" "RVVMF8x5QI") (const_int 64)
557 (eq_attr "mode" "RVVM2x4QI") (const_int 4)
558 (eq_attr "mode" "RVVM1x4QI") (const_int 8)
559 (eq_attr "mode" "RVVMF2x4QI") (const_int 16)
560 (eq_attr "mode" "RVVMF4x4QI") (const_int 32)
561 (eq_attr "mode" "RVVMF8x4QI") (const_int 64)
562 (eq_attr "mode" "RVVM2x3QI") (const_int 4)
563 (eq_attr "mode" "RVVM1x3QI") (const_int 8)
564 (eq_attr "mode" "RVVMF2x3QI") (const_int 16)
565 (eq_attr "mode" "RVVMF4x3QI") (const_int 32)
566 (eq_attr "mode" "RVVMF8x3QI") (const_int 64)
567 (eq_attr "mode" "RVVM4x2QI") (const_int 2)
568 (eq_attr "mode" "RVVM2x2QI") (const_int 4)
569 (eq_attr "mode" "RVVM1x2QI") (const_int 8)
570 (eq_attr "mode" "RVVMF2x2QI") (const_int 16)
571 (eq_attr "mode" "RVVMF4x2QI") (const_int 32)
572 (eq_attr "mode" "RVVMF8x2QI") (const_int 64)
573 (eq_attr "mode" "RVVM1x8HI") (const_int 16)
574 (eq_attr "mode" "RVVMF2x8HI") (const_int 32)
575 (eq_attr "mode" "RVVMF4x8HI") (const_int 64)
576 (eq_attr "mode" "RVVM1x7HI") (const_int 16)
577 (eq_attr "mode" "RVVMF2x7HI") (const_int 32)
578 (eq_attr "mode" "RVVMF4x7HI") (const_int 64)
579 (eq_attr "mode" "RVVM1x6HI") (const_int 16)
580 (eq_attr "mode" "RVVMF2x6HI") (const_int 32)
581 (eq_attr "mode" "RVVMF4x6HI") (const_int 64)
582 (eq_attr "mode" "RVVM1x5HI") (const_int 16)
583 (eq_attr "mode" "RVVMF2x5HI") (const_int 32)
584 (eq_attr "mode" "RVVMF4x5HI") (const_int 64)
585 (eq_attr "mode" "RVVM2x4HI") (const_int 8)
586 (eq_attr "mode" "RVVM1x4HI") (const_int 16)
587 (eq_attr "mode" "RVVMF2x4HI") (const_int 32)
588 (eq_attr "mode" "RVVMF4x4HI") (const_int 64)
589 (eq_attr "mode" "RVVM2x3HI") (const_int 8)
590 (eq_attr "mode" "RVVM1x3HI") (const_int 16)
591 (eq_attr "mode" "RVVMF2x3HI") (const_int 32)
592 (eq_attr "mode" "RVVMF4x3HI") (const_int 64)
593 (eq_attr "mode" "RVVM4x2HI") (const_int 4)
594 (eq_attr "mode" "RVVM2x2HI") (const_int 8)
595 (eq_attr "mode" "RVVM1x2HI") (const_int 16)
596 (eq_attr "mode" "RVVMF2x2HI") (const_int 32)
597 (eq_attr "mode" "RVVMF4x2HI") (const_int 64)
598 (eq_attr "mode" "RVVM1x8BF") (const_int 16)
599 (eq_attr "mode" "RVVMF2x8BF") (const_int 32)
600 (eq_attr "mode" "RVVMF4x8BF") (const_int 64)
601 (eq_attr "mode" "RVVM1x7BF") (const_int 16)
602 (eq_attr "mode" "RVVMF2x7BF") (const_int 32)
603 (eq_attr "mode" "RVVMF4x7BF") (const_int 64)
604 (eq_attr "mode" "RVVM1x6BF") (const_int 16)
605 (eq_attr "mode" "RVVMF2x6BF") (const_int 32)
606 (eq_attr "mode" "RVVMF4x6BF") (const_int 64)
607 (eq_attr "mode" "RVVM1x5BF") (const_int 16)
608 (eq_attr "mode" "RVVMF2x5BF") (const_int 32)
609 (eq_attr "mode" "RVVMF4x5BF") (const_int 64)
610 (eq_attr "mode" "RVVM2x4BF") (const_int 8)
611 (eq_attr "mode" "RVVM1x4BF") (const_int 16)
612 (eq_attr "mode" "RVVMF2x4BF") (const_int 32)
613 (eq_attr "mode" "RVVMF4x4BF") (const_int 64)
614 (eq_attr "mode" "RVVM2x3BF") (const_int 8)
615 (eq_attr "mode" "RVVM1x3BF") (const_int 16)
616 (eq_attr "mode" "RVVMF2x3BF") (const_int 32)
617 (eq_attr "mode" "RVVMF4x3BF") (const_int 64)
618 (eq_attr "mode" "RVVM4x2BF") (const_int 4)
619 (eq_attr "mode" "RVVM2x2BF") (const_int 8)
620 (eq_attr "mode" "RVVM1x2BF") (const_int 16)
621 (eq_attr "mode" "RVVMF2x2BF") (const_int 32)
622 (eq_attr "mode" "RVVMF4x2BF") (const_int 64)
623 (eq_attr "mode" "RVVM1x8HF") (const_int 16)
624 (eq_attr "mode" "RVVMF2x8HF") (const_int 32)
625 (eq_attr "mode" "RVVMF4x8HF") (const_int 64)
626 (eq_attr "mode" "RVVM1x7HF") (const_int 16)
627 (eq_attr "mode" "RVVMF2x7HF") (const_int 32)
628 (eq_attr "mode" "RVVMF4x7HF") (const_int 64)
629 (eq_attr "mode" "RVVM1x6HF") (const_int 16)
630 (eq_attr "mode" "RVVMF2x6HF") (const_int 32)
631 (eq_attr "mode" "RVVMF4x6HF") (const_int 64)
632 (eq_attr "mode" "RVVM1x5HF") (const_int 16)
633 (eq_attr "mode" "RVVMF2x5HF") (const_int 32)
634 (eq_attr "mode" "RVVMF4x5HF") (const_int 64)
635 (eq_attr "mode" "RVVM2x4HF") (const_int 8)
636 (eq_attr "mode" "RVVM1x4HF") (const_int 16)
637 (eq_attr "mode" "RVVMF2x4HF") (const_int 32)
638 (eq_attr "mode" "RVVMF4x4HF") (const_int 64)
639 (eq_attr "mode" "RVVM2x3HF") (const_int 8)
640 (eq_attr "mode" "RVVM1x3HF") (const_int 16)
641 (eq_attr "mode" "RVVMF2x3HF") (const_int 32)
642 (eq_attr "mode" "RVVMF4x3HF") (const_int 64)
643 (eq_attr "mode" "RVVM4x2HF") (const_int 4)
644 (eq_attr "mode" "RVVM2x2HF") (const_int 8)
645 (eq_attr "mode" "RVVM1x2HF") (const_int 16)
646 (eq_attr "mode" "RVVMF2x2HF") (const_int 32)
647 (eq_attr "mode" "RVVMF4x2HF") (const_int 64)
648 (eq_attr "mode" "RVVM1x8SI") (const_int 32)
649 (eq_attr "mode" "RVVMF2x8SI") (const_int 64)
650 (eq_attr "mode" "RVVM1x7SI") (const_int 32)
651 (eq_attr "mode" "RVVMF2x7SI") (const_int 64)
652 (eq_attr "mode" "RVVM1x6SI") (const_int 32)
653 (eq_attr "mode" "RVVMF2x6SI") (const_int 64)
654 (eq_attr "mode" "RVVM1x5SI") (const_int 32)
655 (eq_attr "mode" "RVVMF2x5SI") (const_int 64)
656 (eq_attr "mode" "RVVM2x4SI") (const_int 16)
657 (eq_attr "mode" "RVVM1x4SI") (const_int 32)
658 (eq_attr "mode" "RVVMF2x4SI") (const_int 64)
659 (eq_attr "mode" "RVVM2x3SI") (const_int 16)
660 (eq_attr "mode" "RVVM1x3SI") (const_int 32)
661 (eq_attr "mode" "RVVMF2x3SI") (const_int 64)
662 (eq_attr "mode" "RVVM4x2SI") (const_int 8)
663 (eq_attr "mode" "RVVM2x2SI") (const_int 16)
664 (eq_attr "mode" "RVVM1x2SI") (const_int 32)
665 (eq_attr "mode" "RVVMF2x2SI") (const_int 64)
666 (eq_attr "mode" "RVVM1x8SF") (const_int 32)
667 (eq_attr "mode" "RVVMF2x8SF") (const_int 64)
668 (eq_attr "mode" "RVVM1x7SF") (const_int 32)
669 (eq_attr "mode" "RVVMF2x7SF") (const_int 64)
670 (eq_attr "mode" "RVVM1x6SF") (const_int 32)
671 (eq_attr "mode" "RVVMF2x6SF") (const_int 64)
672 (eq_attr "mode" "RVVM1x5SF") (const_int 32)
673 (eq_attr "mode" "RVVMF2x5SF") (const_int 64)
674 (eq_attr "mode" "RVVM2x4SF") (const_int 16)
675 (eq_attr "mode" "RVVM1x4SF") (const_int 32)
676 (eq_attr "mode" "RVVMF2x4SF") (const_int 64)
677 (eq_attr "mode" "RVVM2x3SF") (const_int 16)
678 (eq_attr "mode" "RVVM1x3SF") (const_int 32)
679 (eq_attr "mode" "RVVMF2x3SF") (const_int 64)
680 (eq_attr "mode" "RVVM4x2SF") (const_int 8)
681 (eq_attr "mode" "RVVM2x2SF") (const_int 16)
682 (eq_attr "mode" "RVVM1x2SF") (const_int 32)
683 (eq_attr "mode" "RVVMF2x2SF") (const_int 64)
684 (eq_attr "mode" "RVVM1x8DI") (const_int 64)
685 (eq_attr "mode" "RVVM1x7DI") (const_int 64)
686 (eq_attr "mode" "RVVM1x6DI") (const_int 64)
687 (eq_attr "mode" "RVVM1x5DI") (const_int 64)
688 (eq_attr "mode" "RVVM2x4DI") (const_int 32)
689 (eq_attr "mode" "RVVM1x4DI") (const_int 64)
690 (eq_attr "mode" "RVVM2x3DI") (const_int 32)
691 (eq_attr "mode" "RVVM1x3DI") (const_int 64)
692 (eq_attr "mode" "RVVM4x2DI") (const_int 16)
693 (eq_attr "mode" "RVVM2x2DI") (const_int 32)
694 (eq_attr "mode" "RVVM1x2DI") (const_int 64)
695 (eq_attr "mode" "RVVM1x8DF") (const_int 64)
696 (eq_attr "mode" "RVVM1x7DF") (const_int 64)
697 (eq_attr "mode" "RVVM1x6DF") (const_int 64)
698 (eq_attr "mode" "RVVM1x5DF") (const_int 64)
699 (eq_attr "mode" "RVVM2x4DF") (const_int 32)
700 (eq_attr "mode" "RVVM1x4DF") (const_int 64)
701 (eq_attr "mode" "RVVM2x3DF") (const_int 32)
702 (eq_attr "mode" "RVVM1x3DF") (const_int 64)
703 (eq_attr "mode" "RVVM4x2DF") (const_int 16)
704 (eq_attr "mode" "RVVM2x2DF") (const_int 32)
705 (eq_attr "mode" "RVVM1x2DF") (const_int 64)
706
707 ;; VLS modes.
708 (eq_attr "mode" "V1QI,V1BI") (symbol_ref "riscv_vector::get_ratio(E_V1QImode)")
709 (eq_attr "mode" "V2QI,V2BI") (symbol_ref "riscv_vector::get_ratio(E_V2QImode)")
710 (eq_attr "mode" "V4QI,V4BI") (symbol_ref "riscv_vector::get_ratio(E_V4QImode)")
711 (eq_attr "mode" "V8QI,V8BI") (symbol_ref "riscv_vector::get_ratio(E_V8QImode)")
712 (eq_attr "mode" "V16QI,V16BI") (symbol_ref "riscv_vector::get_ratio(E_V16QImode)")
713 (eq_attr "mode" "V32QI,V32BI") (symbol_ref "riscv_vector::get_ratio(E_V32QImode)")
714 (eq_attr "mode" "V64QI,V64BI") (symbol_ref "riscv_vector::get_ratio(E_V64QImode)")
715 (eq_attr "mode" "V128QI,V128BI") (symbol_ref "riscv_vector::get_ratio(E_V128QImode)")
716 (eq_attr "mode" "V256QI,V256BI") (symbol_ref "riscv_vector::get_ratio(E_V256QImode)")
717 (eq_attr "mode" "V512QI,V512BI") (symbol_ref "riscv_vector::get_ratio(E_V512QImode)")
718 (eq_attr "mode" "V1024QI,V1024BI") (symbol_ref "riscv_vector::get_ratio(E_V1024QImode)")
719 (eq_attr "mode" "V2048QI,V2048BI") (symbol_ref "riscv_vector::get_ratio(E_V2048QImode)")
720 (eq_attr "mode" "V4096QI,V4096BI") (symbol_ref "riscv_vector::get_ratio(E_V4096QImode)")
721 (eq_attr "mode" "V1HI") (symbol_ref "riscv_vector::get_ratio(E_V1HImode)")
722 (eq_attr "mode" "V2HI") (symbol_ref "riscv_vector::get_ratio(E_V2HImode)")
723 (eq_attr "mode" "V4HI") (symbol_ref "riscv_vector::get_ratio(E_V4HImode)")
724 (eq_attr "mode" "V8HI") (symbol_ref "riscv_vector::get_ratio(E_V8HImode)")
725 (eq_attr "mode" "V16HI") (symbol_ref "riscv_vector::get_ratio(E_V16HImode)")
726 (eq_attr "mode" "V32HI") (symbol_ref "riscv_vector::get_ratio(E_V32HImode)")
727 (eq_attr "mode" "V64HI") (symbol_ref "riscv_vector::get_ratio(E_V64HImode)")
728 (eq_attr "mode" "V128HI") (symbol_ref "riscv_vector::get_ratio(E_V128HImode)")
729 (eq_attr "mode" "V256HI") (symbol_ref "riscv_vector::get_ratio(E_V256HImode)")
730 (eq_attr "mode" "V512HI") (symbol_ref "riscv_vector::get_ratio(E_V512HImode)")
731 (eq_attr "mode" "V1024HI") (symbol_ref "riscv_vector::get_ratio(E_V1024HImode)")
732 (eq_attr "mode" "V2048HI") (symbol_ref "riscv_vector::get_ratio(E_V2048HImode)")
733 (eq_attr "mode" "V1SI") (symbol_ref "riscv_vector::get_ratio(E_V1SImode)")
734 (eq_attr "mode" "V2SI") (symbol_ref "riscv_vector::get_ratio(E_V2SImode)")
735 (eq_attr "mode" "V4SI") (symbol_ref "riscv_vector::get_ratio(E_V4SImode)")
736 (eq_attr "mode" "V8SI") (symbol_ref "riscv_vector::get_ratio(E_V8SImode)")
737 (eq_attr "mode" "V16SI") (symbol_ref "riscv_vector::get_ratio(E_V16SImode)")
738 (eq_attr "mode" "V32SI") (symbol_ref "riscv_vector::get_ratio(E_V32SImode)")
739 (eq_attr "mode" "V64SI") (symbol_ref "riscv_vector::get_ratio(E_V64SImode)")
740 (eq_attr "mode" "V128SI") (symbol_ref "riscv_vector::get_ratio(E_V128SImode)")
741 (eq_attr "mode" "V256SI") (symbol_ref "riscv_vector::get_ratio(E_V256SImode)")
742 (eq_attr "mode" "V512SI") (symbol_ref "riscv_vector::get_ratio(E_V512SImode)")
743 (eq_attr "mode" "V1024SI") (symbol_ref "riscv_vector::get_ratio(E_V1024SImode)")
744 (eq_attr "mode" "V1DI") (symbol_ref "riscv_vector::get_ratio(E_V1DImode)")
745 (eq_attr "mode" "V2DI") (symbol_ref "riscv_vector::get_ratio(E_V2DImode)")
746 (eq_attr "mode" "V4DI") (symbol_ref "riscv_vector::get_ratio(E_V4DImode)")
747 (eq_attr "mode" "V8DI") (symbol_ref "riscv_vector::get_ratio(E_V8DImode)")
748 (eq_attr "mode" "V16DI") (symbol_ref "riscv_vector::get_ratio(E_V16DImode)")
749 (eq_attr "mode" "V32DI") (symbol_ref "riscv_vector::get_ratio(E_V32DImode)")
750 (eq_attr "mode" "V64DI") (symbol_ref "riscv_vector::get_ratio(E_V64DImode)")
751 (eq_attr "mode" "V128DI") (symbol_ref "riscv_vector::get_ratio(E_V128DImode)")
752 (eq_attr "mode" "V256DI") (symbol_ref "riscv_vector::get_ratio(E_V256DImode)")
753 (eq_attr "mode" "V512DI") (symbol_ref "riscv_vector::get_ratio(E_V512DImode)")
754 (eq_attr "mode" "V1HF") (symbol_ref "riscv_vector::get_ratio(E_V1HFmode)")
755 (eq_attr "mode" "V2HF") (symbol_ref "riscv_vector::get_ratio(E_V2HFmode)")
756 (eq_attr "mode" "V4HF") (symbol_ref "riscv_vector::get_ratio(E_V4HFmode)")
757 (eq_attr "mode" "V8HF") (symbol_ref "riscv_vector::get_ratio(E_V8HFmode)")
758 (eq_attr "mode" "V16HF") (symbol_ref "riscv_vector::get_ratio(E_V16HFmode)")
759 (eq_attr "mode" "V32HF") (symbol_ref "riscv_vector::get_ratio(E_V32HFmode)")
760 (eq_attr "mode" "V64HF") (symbol_ref "riscv_vector::get_ratio(E_V64HFmode)")
761 (eq_attr "mode" "V128HF") (symbol_ref "riscv_vector::get_ratio(E_V128HFmode)")
762 (eq_attr "mode" "V256HF") (symbol_ref "riscv_vector::get_ratio(E_V256HFmode)")
763 (eq_attr "mode" "V512HF") (symbol_ref "riscv_vector::get_ratio(E_V512HFmode)")
764 (eq_attr "mode" "V1024HF") (symbol_ref "riscv_vector::get_ratio(E_V1024HFmode)")
765 (eq_attr "mode" "V2048HF") (symbol_ref "riscv_vector::get_ratio(E_V2048HFmode)")
766 (eq_attr "mode" "V1SF") (symbol_ref "riscv_vector::get_ratio(E_V1SFmode)")
767 (eq_attr "mode" "V2SF") (symbol_ref "riscv_vector::get_ratio(E_V2SFmode)")
768 (eq_attr "mode" "V4SF") (symbol_ref "riscv_vector::get_ratio(E_V4SFmode)")
769 (eq_attr "mode" "V8SF") (symbol_ref "riscv_vector::get_ratio(E_V8SFmode)")
770 (eq_attr "mode" "V16SF") (symbol_ref "riscv_vector::get_ratio(E_V16SFmode)")
771 (eq_attr "mode" "V32SF") (symbol_ref "riscv_vector::get_ratio(E_V32SFmode)")
772 (eq_attr "mode" "V64SF") (symbol_ref "riscv_vector::get_ratio(E_V64SFmode)")
773 (eq_attr "mode" "V128SF") (symbol_ref "riscv_vector::get_ratio(E_V128SFmode)")
774 (eq_attr "mode" "V256SF") (symbol_ref "riscv_vector::get_ratio(E_V256SFmode)")
775 (eq_attr "mode" "V512SF") (symbol_ref "riscv_vector::get_ratio(E_V512SFmode)")
776 (eq_attr "mode" "V1024SF") (symbol_ref "riscv_vector::get_ratio(E_V1024SFmode)")
777 (eq_attr "mode" "V1DF") (symbol_ref "riscv_vector::get_ratio(E_V1DFmode)")
778 (eq_attr "mode" "V2DF") (symbol_ref "riscv_vector::get_ratio(E_V2DFmode)")
779 (eq_attr "mode" "V4DF") (symbol_ref "riscv_vector::get_ratio(E_V4DFmode)")
780 (eq_attr "mode" "V8DF") (symbol_ref "riscv_vector::get_ratio(E_V8DFmode)")
781 (eq_attr "mode" "V16DF") (symbol_ref "riscv_vector::get_ratio(E_V16DFmode)")
782 (eq_attr "mode" "V32DF") (symbol_ref "riscv_vector::get_ratio(E_V32DFmode)")
783 (eq_attr "mode" "V64DF") (symbol_ref "riscv_vector::get_ratio(E_V64DFmode)")
784 (eq_attr "mode" "V128DF") (symbol_ref "riscv_vector::get_ratio(E_V128DFmode)")
785 (eq_attr "mode" "V256DF") (symbol_ref "riscv_vector::get_ratio(E_V256DFmode)")
786 (eq_attr "mode" "V512DF") (symbol_ref "riscv_vector::get_ratio(E_V512DFmode)")]
787 (const_int INVALID_ATTRIBUTE)))
788
789 ;; The index of operand[] to get the merge op.
790 (define_attr "merge_op_idx" ""
791 (cond [(eq_attr "type" "vlde,vimov,vfmov,vldm,vlds,vmalu,vldux,vldox,vicmp,\
792 vialu,vshift,viminmax,vimul,vidiv,vsalu,vext,viwalu,\
793 viwmul,vnshift,vaalu,vsmul,vsshift,vnclip,vmsfs,\
794 vmiota,vmidx,vfalu,vfmul,vfminmax,vfdiv,vfwalu,vfwmul,\
795 vfsqrt,vfrecp,vfsgnj,vfcmp,vfcvtitof,vfcvtftoi,vfwcvtitof,\
796 vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,vfclass,\
797 vired,viwred,vfredu,vfredo,vfwredu,vfwredo,vimovxv,vfmovfv,\
798 vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\
799 vgather,vldff,viwmuladd,vfwmuladd,vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,\
800 vandn,vbrev,vbrev8,vrev8,vrol,vror,vwsll,vclmul,vclmulh,\
801 vfncvtbf16,vfwcvtbf16,vfwmaccbf16")
802 (const_int 2)
803
804 (eq_attr "type" "vimerge,vfmerge,vcompress,vghsh,vgmul,vaesef,vaesem,vaesdf,vaesdm,\
805 vaeskf1,vaeskf2,vaesz,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm4r,vsm3me,vsm3c")
806 (const_int 1)
807
808 (eq_attr "type" "vimuladd,vfmuladd")
809 (const_int 2)]
810 (const_int INVALID_ATTRIBUTE)))
811
812 ;; The index of operand[] represents the machine mode of the instruction.
813 (define_attr "mode_idx" ""
814 (cond [(eq_attr "type" "vlde,vste,vldm,vstm,vlds,vsts,vldux,vldox,vldff,vldr,vstr,\
815 vlsegde,vlsegds,vlsegdux,vlsegdox,vlsegdff,vialu,vext,vicalu,\
816 vshift,vicmp,viminmax,vimul,vidiv,vimuladd,vimerge,vimov,\
817 vsalu,vaalu,vsmul,vsshift,vfalu,vfmul,vfdiv,vfmuladd,vfsqrt,vfrecp,\
818 vfcmp,vfminmax,vfsgnj,vfclass,vfmerge,vfmov,\
819 vfcvtitof,vfncvtitof,vfncvtftoi,vfncvtftof,vmalu,vmiota,vmidx,\
820 vimovxv,vfmovfv,vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\
821 vgather,vcompress,vmov,vnclip,vnshift,vandn,vcpop,vclz,vctz,vrol,vror")
822 (const_int 0)
823
824 (eq_attr "type" "vimovvx,vfmovvf")
825 (const_int 1)
826
827 (eq_attr "type" "vssegte,vmpop,vmffs")
828 (const_int 2)
829
830 (eq_attr "type" "vstux,vstox,vssegts,vssegtux,vssegtox,vfcvtftoi,vfwcvtitof,vfwcvtftoi,
831 vfwcvtftof,vmsfs,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,vwsll,viwalu,vfwalu,viwmul,vfwmul")
832 (const_int 3)
833
834 (eq_attr "type" "viwmuladd,vfwmuladd")
835 (const_int 4)]
836 (const_int INVALID_ATTRIBUTE)))
837
838 ;; The index of operand[] to get the avl op.
839 (define_attr "vl_op_idx" ""
840 (cond [(eq_attr "type" "vlde,vste,vimov,vfmov,vldm,vstm,vmalu,vsts,vstux,\
841 vstox,vext,vmsfs,vmiota,vfsqrt,vfrecp,vfcvtitof,vldff,\
842 vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,\
843 vfncvtftoi,vfncvtftof,vfclass,vimovxv,vfmovfv,vcompress,\
844 vlsegde,vssegts,vssegtux,vssegtox,vlsegdff,vbrev,vbrev8,vrev8,\
845 vghsh,vaeskf1,vaeskf2,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm3me,vsm3c,\
846 vfncvtbf16,vfwcvtbf16")
847 (const_int 4)
848
849 ;; If operands[3] of "vlds" is not vector mode, it is pred_broadcast.
850 ;; whereas it is pred_strided_load if operands[3] is vector mode.
851 (eq_attr "type" "vlds")
852 (if_then_else (match_test "VECTOR_MODE_P (GET_MODE (operands[3]))")
853 (const_int 5)
854 (const_int 4))
855
856 (eq_attr "type" "vldux,vldox,vialu,vshift,viminmax,vimul,vidiv,vsalu,\
857 viwalu,viwmul,vnshift,vimerge,vaalu,vsmul,\
858 vsshift,vnclip,vfalu,vfmul,vfminmax,vfdiv,vfwalu,vfwmul,\
859 vfsgnj,vfmerge,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\
860 vslideup,vslidedown,vislide1up,vislide1down,vfslide1up,vfslide1down,\
861 vgather,viwmuladd,vfwmuladd,vlsegds,vlsegdux,vlsegdox,vandn,vrol,\
862 vror,vwsll,vclmul,vclmulh,vfwmaccbf16")
863 (const_int 5)
864
865 (eq_attr "type" "vicmp,vimuladd,vfcmp,vfmuladd")
866 (const_int 6)
867
868 (eq_attr "type" "vmpop,vmffs,vmidx,vssegte,vcpop,vclz,vctz,vgmul,vaesef,vaesem,vaesdf,\
869 vaesdm,vaesz,vsm4r")
870 (const_int 3)]
871 (const_int INVALID_ATTRIBUTE)))
872
873 ;; The tail policy op value.
874 (define_attr "ta" ""
875 (cond [(eq_attr "type" "vlde,vimov,vfmov,vext,vmiota,vfsqrt,vfrecp,\
876 vfcvtitof,vfcvtftoi,vfwcvtitof,vfwcvtftoi,vfwcvtftof,\
877 vfncvtitof,vfncvtftoi,vfncvtftof,vfclass,vimovxv,vfmovfv,\
878 vcompress,vldff,vlsegde,vlsegdff,vbrev,vbrev8,vrev8,vghsh,\
879 vaeskf1,vaeskf2,vsha2ms,vsha2ch,vsha2cl,vsm4k,vsm3me,vsm3c,\
880 vfncvtbf16,vfwcvtbf16")
881 (symbol_ref "riscv_vector::get_ta(operands[5])")
882
883 ;; If operands[3] of "vlds" is not vector mode, it is pred_broadcast.
884 ;; whereas it is pred_strided_load if operands[3] is vector mode.
885 (eq_attr "type" "vlds")
886 (if_then_else (match_test "VECTOR_MODE_P (GET_MODE (operands[3]))")
887 (symbol_ref "riscv_vector::get_ta(operands[6])")
888 (symbol_ref "riscv_vector::get_ta(operands[5])"))
889
890 (eq_attr "type" "vldux,vldox,vialu,vshift,viminmax,vimul,vidiv,vsalu,\
891 viwalu,viwmul,vnshift,vimerge,vaalu,vsmul,\
892 vsshift,vnclip,vfalu,vfmul,vfminmax,vfdiv,\
893 vfwalu,vfwmul,vfsgnj,vfmerge,vired,viwred,vfredu,\
894 vfredo,vfwredu,vfwredo,vslideup,vslidedown,vislide1up,\
895 vislide1down,vfslide1up,vfslide1down,vgather,viwmuladd,vfwmuladd,\
896 vlsegds,vlsegdux,vlsegdox,vandn,vrol,vror,vwsll,vclmul,vclmulh,\
897 vfwmaccbf16,sf_vqmacc,sf_vfnrclip")
898 (symbol_ref "riscv_vector::get_ta(operands[6])")
899
900 (eq_attr "type" "vimuladd,vfmuladd")
901 (symbol_ref "riscv_vector::get_ta(operands[7])")
902
903 (eq_attr "type" "vmidx,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaesz,vsm4r")
904 (symbol_ref "riscv_vector::get_ta(operands[4])")]
905 (const_int INVALID_ATTRIBUTE)))
906
907 ;; The mask policy op value.
908 (define_attr "ma" ""
909 (cond [(eq_attr "type" "vlde,vext,vmiota,vfsqrt,vfrecp,vfcvtitof,vfcvtftoi,\
910 vfwcvtitof,vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,\
911 vfncvtftof,vfclass,vldff,vlsegde,vlsegdff,vbrev,vbrev8,vrev8,\
912 vfncvtbf16,vfwcvtbf16")
913 (symbol_ref "riscv_vector::get_ma(operands[6])")
914
915 ;; If operands[3] of "vlds" is not vector mode, it is pred_broadcast.
916 ;; whereas it is pred_strided_load if operands[3] is vector mode.
917 (eq_attr "type" "vlds")
918 (if_then_else (match_test "VECTOR_MODE_P (GET_MODE (operands[3]))")
919 (symbol_ref "riscv_vector::get_ma(operands[7])")
920 (symbol_ref "riscv_vector::get_ma(operands[6])"))
921
922 (eq_attr "type" "vldux,vldox,vialu,vshift,viminmax,vimul,vidiv,vsalu,\
923 viwalu,viwmul,vnshift,vaalu,vsmul,vsshift,\
924 vnclip,vicmp,vfalu,vfmul,vfminmax,vfdiv,\
925 vfwalu,vfwmul,vfsgnj,vfcmp,vslideup,vslidedown,\
926 vislide1up,vislide1down,vfslide1up,vfslide1down,vgather,\
927 viwmuladd,vfwmuladd,vlsegds,vlsegdux,vlsegdox,vandn,vrol,\
928 vror,vwsll,vclmul,vclmulh,vfwmaccbf16,sf_vqmacc,sf_vfnrclip")
929 (symbol_ref "riscv_vector::get_ma(operands[7])")
930
931 (eq_attr "type" "vimuladd,vfmuladd")
932 (symbol_ref "riscv_vector::get_ma(operands[8])")
933
934 (eq_attr "type" "vmsfs,vmidx")
935 (symbol_ref "riscv_vector::get_ma(operands[5])")]
936 (const_int INVALID_ATTRIBUTE)))
937
938 ;; The avl type value.
939 (define_attr "avl_type_idx" ""
940 (cond [(eq_attr "type" "vlde,vldff,vste,vimov,vfmov,vext,vimerge,\
941 vfsqrt,vfrecp,vfmerge,vfcvtitof,vfcvtftoi,vfwcvtitof,\
942 vfwcvtftoi,vfwcvtftof,vfncvtitof,vfncvtftoi,vfncvtftof,\
943 vfclass,vired,viwred,vfredu,vfredo,vfwredu,vfwredo,\
944 vimovxv,vfmovfv,vlsegde,vlsegdff,vmiota,vbrev,vbrev8,vrev8,\
945 vfncvtbf16,vfwcvtbf16")
946 (const_int 7)
947 (eq_attr "type" "vldm,vstm,vmalu,vmalu,vgmul,vaesef,vaesem,vaesdf,vaesdm,vaesz,\
948 vsm4r")
949 (const_int 5)
950
951 ;; If operands[3] of "vlds" is not vector mode, it is pred_broadcast.
952 ;; whereas it is pred_strided_load if operands[3] is vector mode.
953 (eq_attr "type" "vlds")
954 (if_then_else (match_test "VECTOR_MODE_P (GET_MODE (operands[3]))")
955 (const_int 8)
956 (const_int 7))
957
958 (eq_attr "type" "vldux,vldox,vialu,vshift,viminmax,vimul,vidiv,vsalu,\
959 viwalu,viwmul,vnshift,vaalu,vsmul,vsshift,\
960 vnclip,vicmp,vfalu,vfmul,vfminmax,vfdiv,vfwalu,vfwmul,\
961 vfsgnj,vfcmp,vslideup,vslidedown,vislide1up,\
962 vislide1down,vfslide1up,vfslide1down,vgather,viwmuladd,vfwmuladd,\
963 vlsegds,vlsegdux,vlsegdox,vandn,vrol,vror,vclmul,vclmulh,vwsll,\
964 vfwmaccbf16")
965 (const_int 8)
966 (eq_attr "type" "vstux,vstox,vssegts,vssegtux,vssegtox")
967 (const_int 5)
968
969 (eq_attr "type" "vimuladd,vfmuladd")
970 (const_int 9)
971
972 (eq_attr "type" "vmsfs,vmidx,vcompress,vghsh,vaeskf1,vaeskf2,vsha2ms,vsha2ch,vsha2cl,\
973 vsm4k,vsm3me,vsm3c")
974 (const_int 6)
975
976 (eq_attr "type" "vmpop,vmffs,vssegte,vcpop,vclz,vctz")
977 (const_int 4)]
978 (const_int INVALID_ATTRIBUTE)))
979
980 ;; Defines rounding mode of an fixed-point operation.
981
982 (define_attr "vxrm_mode" "rnu,rne,rdn,rod,none"
983 (cond [(eq_attr "type" "vaalu,vsmul,vsshift,vnclip")
984 (cond
985 [(match_test "INTVAL (operands[9]) == riscv_vector::VXRM_RNU")
986 (const_string "rnu")
987
988 (match_test "INTVAL (operands[9]) == riscv_vector::VXRM_RNE")
989 (const_string "rne")
990
991 (match_test "INTVAL (operands[9]) == riscv_vector::VXRM_RDN")
992 (const_string "rdn")
993
994 (match_test "INTVAL (operands[9]) == riscv_vector::VXRM_ROD")
995 (const_string "rod")]
996 (const_string "none"))]
997 (const_string "none")))
998
999 ;; Defines rounding mode of an floating-point operation.
1000 (define_attr "frm_mode" ""
1001 (cond [(eq_attr "type" "vfalu,vfwalu,vfmul,vfdiv,vfwmul")
1002 (symbol_ref "riscv_vector::FRM_DYN")]
1003 (symbol_ref "riscv_vector::FRM_NONE")))
1004
1005 (include "thead-vector.md")
1006
1007 ;; -----------------------------------------------------------------
1008 ;; ---- Miscellaneous Operations
1009 ;; -----------------------------------------------------------------
1010
1011 (define_insn "@vundefined<mode>"
1012 [(set (match_operand:V 0 "register_operand" "=vr")
1013 (unspec:V [(reg:SI X0_REGNUM)] UNSPEC_VUNDEF))]
1014 "TARGET_VECTOR"
1015 ""
1016 [(set_attr "type" "vector")])
1017
1018 (define_insn "@vundefined<mode>"
1019 [(set (match_operand:VB 0 "register_operand" "=vr")
1020 (unspec:VB [(reg:SI X0_REGNUM)] UNSPEC_VUNDEF))]
1021 "TARGET_VECTOR"
1022 ""
1023 [(set_attr "type" "vector")])
1024
1025 (define_insn "@vundefined<mode>"
1026 [(set (match_operand:VT 0 "register_operand" "=vr")
1027 (unspec:VT [(reg:SI X0_REGNUM)] UNSPEC_VUNDEF))]
1028 "TARGET_VECTOR"
1029 ""
1030 [(set_attr "type" "vector")])
1031
1032 (define_expand "@vreinterpret<mode>"
1033 [(set (match_operand:V 0 "register_operand")
1034 (match_operand 1 "vector_any_register_operand"))]
1035 "TARGET_VECTOR"
1036 {
1037 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, operands[1]));
1038 DONE;
1039 }
1040 )
1041
1042 (define_expand "@vreinterpret<mode>"
1043 [(set (match_operand:VB 0 "register_operand")
1044 (match_operand 1 "vector_any_register_operand"))]
1045 "TARGET_VECTOR"
1046 {
1047 emit_move_insn (operands[0], gen_lowpart (<MODE>mode, operands[1]));
1048 DONE;
1049 }
1050 )
1051
1052 ;; This pattern is used to hold the AVL operand for
1053 ;; RVV instructions that implicitly use VLMAX AVL.
1054 ;; RVV instruction implicitly use GPR that is ultimately
1055 ;; defined by this pattern is safe for VSETVL pass emit
1056 ;; a vsetvl instruction modify this register after RA.
1057 ;; Case 1:
1058 ;; vlmax_avl a5
1059 ;; ... (across many blocks)
1060 ;; vadd (implicit use a5) ====> emit: vsetvl a5,zero
1061 ;; Case 2:
1062 ;; vlmax_avl a5
1063 ;; ... (across many blocks)
1064 ;; mv a6,a5
1065 ;; ... (across many blocks)
1066 ;; vadd (implicit use a6) ====> emit: vsetvl a6,zero
1067 ;; Case 3:
1068 ;; vlmax_avl a5
1069 ;; ... (across many blocks)
1070 ;; store mem,a5 (spill)
1071 ;; ... (across many blocks)
1072 ;; load a7,mem (spill)
1073 ;; ... (across many blocks)
1074 ;; vadd (implicit use a7) ====> emit: vsetvl a7,zero
1075 ;; Such cases are all safe for VSETVL PASS to emit a vsetvl
1076 ;; instruction that modifies the AVL operand.
1077 (define_insn "@vlmax_avl<mode>"
1078 [(set (match_operand:P 0 "register_operand" "=r")
1079 (unspec:P [(match_operand:P 1 "const_int_operand" "i")] UNSPEC_VLMAX))]
1080 "TARGET_VECTOR"
1081 ""
1082 [(set_attr "type" "vsetvl_pre")]
1083 )
1084
1085 ;; Set VXRM
1086 (define_insn "vxrmsi"
1087 [(set (reg:SI VXRM_REGNUM)
1088 (match_operand:SI 0 "const_int_operand" "i"))]
1089 "TARGET_VECTOR"
1090 "csrwi\tvxrm,%0"
1091 [(set_attr "type" "wrvxrm")
1092 (set_attr "mode" "SI")])
1093
1094 ;; Set FRM
1095 (define_insn "fsrmsi_backup"
1096 [(set (match_operand:SI 0 "register_operand" "=r,r")
1097 (reg:SI FRM_REGNUM))
1098 (set (reg:SI FRM_REGNUM)
1099 (match_operand:SI 1 "reg_or_int_operand" "r,i"))]
1100 "TARGET_VECTOR"
1101 "@
1102 fsrm\t%0,%1
1103 fsrmi\t%0,%1"
1104 [(set_attr "type" "wrfrm,wrfrm")
1105 (set_attr "mode" "SI")]
1106 )
1107
1108 (define_insn "fsrmsi_restore"
1109 [(set (reg:SI FRM_REGNUM)
1110 (match_operand:SI 0 "reg_or_int_operand" "r,i"))]
1111 "TARGET_VECTOR"
1112 "@
1113 fsrm\t%0
1114 fsrmi\t%0"
1115 [(set_attr "type" "wrfrm,wrfrm")
1116 (set_attr "mode" "SI")]
1117 )
1118
1119 ;; The volatile fsrmsi restore is used for the exit point for the
1120 ;; dynamic mode switching. It will generate one volatile fsrm a5
1121 ;; which won't be eliminated.
1122 (define_insn "fsrmsi_restore_volatile"
1123 [(set (reg:SI FRM_REGNUM)
1124 (unspec_volatile:SI [(match_operand:SI 0 "register_operand" "r")]
1125 UNSPECV_FRM_RESTORE_EXIT))]
1126 "TARGET_VECTOR"
1127 "fsrm\t%0"
1128 [(set_attr "type" "wrfrm")
1129 (set_attr "mode" "SI")]
1130 )
1131
1132 ;; Read FRM
1133 (define_insn "frrmsi"
1134 [(set (match_operand:SI 0 "register_operand" "=r")
1135 (reg:SI FRM_REGNUM))]
1136 "TARGET_VECTOR"
1137 "frrm\t%0"
1138 [(set_attr "type" "fmove")
1139 (set_attr "mode" "SI")]
1140 )
1141
1142 ;; -----------------------------------------------------------------
1143 ;; ---- Moves Operations
1144 ;; -----------------------------------------------------------------
1145
1146 (define_expand "mov<mode>"
1147 [(set (match_operand:V 0 "reg_or_mem_operand")
1148 (match_operand:V 1 "general_operand"))]
1149 "TARGET_VECTOR"
1150 {
1151 /* For whole register move, we transform the pattern into the format
1152 that excludes the clobber of scratch register.
1153
1154 We include clobber of a scalar scratch register which is going to be
1155 used for emit of vsetvl instruction after reload_completed since we
1156 need vsetvl instruction to set VL/VTYPE global status for fractional
1157 vector load/store.
1158
1159 For example:
1160 [(set (match_operand:RVVMF8QI v24)
1161 (match_operand:RVVMF8QI (mem: a4)))
1162 (clobber (scratch:SI a5))]
1163 ====>> vsetvl a5,zero,e8,mf8
1164 ====>> vle8.v v24,(a4)
1165
1166 Philosophy:
1167
1168 - Clobber a scalar scratch register for each mov<mode>.
1169
1170 - Classify the machine_mode mode = <MODE>mode into 2 class:
1171 Whole register move and fractional register move.
1172
1173 - Transform and remove scratch clobber register for whole
1174 register move so that we can avoid occupying the scalar
1175 registers.
1176
1177 - We can not leave it to TARGET_SECONDARY_RELOAD since it happens
1178 before spilling. The clobber scratch is used by spilling fractional
1179 registers in IRA/LRA so it's too early. */
1180 if (TARGET_XTHEADVECTOR && reg_or_mem_operand (operands[1], <MODE>mode))
1181 {
1182 emit_insn (gen_pred_th_whole_mov (<MODE>mode, operands[0], operands[1],
1183 RVV_VLMAX, GEN_INT(riscv_vector::VLMAX)));
1184 DONE;
1185 }
1186
1187 if (riscv_vector::legitimize_move (operands[0], &operands[1]))
1188 DONE;
1189 })
1190
1191 ;; This pattern is used for code-gen for whole register load/stores.
1192 ;; Also applicable for all register moves.
1193 ;; Fractional vector modes load/store are not allowed to match this pattern.
1194 ;; Mask modes load/store are not allowed to match this pattern.
1195 ;; We separate "*mov<mode>" into "*mov<mode>_whole" and "*mov<mode>_fract" because
1196 ;; we don't want to include fractional load/store in "*mov<mode>" which will
1197 ;; create unexpected patterns in LRA.
1198 ;; For example:
1199 ;; ira rtl:
1200 ;; (insn 20 19 9 2 (set (reg/v:RVVMF4QI 97 v1 [ v1 ])
1201 ;; (reg:RVVMF4QI 134 [ _1 ])) "rvv.c":9:22 571 {*movvnx2qi_fract}
1202 ;; (nil))
1203 ;; When the value of pseudo register 134 of the insn above is discovered already
1204 ;; spilled in the memory during LRA.
1205 ;; LRA will reload this pattern into a memory load instruction pattern.
1206 ;; Because RVVMF4QI is a fractional vector, we want LRA reload this pattern into
1207 ;; (insn 20 19 9 2 (parallel [
1208 ;; (set (reg:RVVMF4QI 98 v2 [orig:134 _1 ] [134])
1209 ;; (mem/c:RVVMF4QI (reg:SI 13 a3 [155]) [1 %sfp+[-2, -2] S[2, 2] A8]))
1210 ;; (clobber (reg:SI 14 a4 [149]))])
1211 ;; So that we could be able to emit vsetvl instruction using clobber scratch a4.
1212 ;; To let LRA generate the expected pattern, we should exclude fractional vector
1213 ;; load/store in "*mov<mode>_whole". Otherwise, it will reload this pattern into:
1214 ;; (insn 20 19 9 2 (set (reg:RVVMF4QI 98 v2 [orig:134 _1 ] [134])
1215 ;; (mem/c:RVVMF4QI (reg:SI 13 a3 [155]) [1 %sfp+[-2, -2] S[2, 2] A8])))
1216 ;; which is not the pattern we want.
1217 ;; According the facts above, we make "*mov<mode>_whole" includes load/store/move for whole
1218 ;; vector modes according to '-march' and "*mov<mode>_fract" only include fractional vector modes.
1219 (define_insn_and_split "*mov<mode>_whole"
1220 [(set (match_operand:V_WHOLE 0 "reg_or_mem_operand" "=vr, m,vr")
1221 (match_operand:V_WHOLE 1 "reg_or_mem_operand" " m,vr,vr"))]
1222 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
1223 "@
1224 vl%m1re<sew>.v\t%0,%1
1225 vs%m1r.v\t%1,%0
1226 #"
1227 "&& !memory_operand (operands[0], <MODE>mode)
1228 && !memory_operand (operands[1], <MODE>mode)"
1229 [(parallel [(set (match_dup 0) (match_dup 1))
1230 (use (reg:SI VTYPE_REGNUM))])]
1231 ""
1232 [(set_attr "type" "vldr,vstr,vmov")
1233 (set_attr "mode" "<MODE>")])
1234
1235 ;; Full-register moves like vmv1r.v require a valid vtype.
1236 ;; The ABI does not guarantee that the vtype is valid after a function
1237 ;; call so we need to make it dependent on the vtype and have
1238 ;; the vsetvl pass insert a vsetvl if necessary.
1239 ;; To facilitate optimization we keep the reg-reg move patterns "regular"
1240 ;; until split time and only then switch to a pattern like below that
1241 ;; uses the vtype register.
1242 ;; As the use of these patterns is limited (in the general context)
1243 ;; there is no need for helper functions and we can just create the RTX
1244 ;; directly.
1245 (define_insn "*mov<mode>_reg_whole_vtype"
1246 [(set (match_operand:V_WHOLE 0 "reg_or_mem_operand" "=vr")
1247 (match_operand:V_WHOLE 1 "reg_or_mem_operand" " vr"))
1248 (use (reg:SI VTYPE_REGNUM))]
1249 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
1250 "vmv%m1r.v\t%0,%1"
1251 [(set_attr "type" "vmov")
1252 (set_attr "mode" "<MODE>")])
1253
1254 (define_insn_and_split "*mov<mode>_fract"
1255 [(set (match_operand:V_FRACT 0 "register_operand" "=vr")
1256 (match_operand:V_FRACT 1 "register_operand" " vr"))]
1257 "TARGET_VECTOR"
1258 "#"
1259 "&& 1"
1260 [(parallel [(set (match_dup 0) (match_dup 1))
1261 (use (reg:SI VTYPE_REGNUM))])]
1262 ""
1263 [(set_attr "type" "vmov")
1264 (set_attr "mode" "<MODE>")])
1265
1266 (define_insn "*mov<mode>_fract_vtype"
1267 [(set (match_operand:V_FRACT 0 "register_operand" "=vr")
1268 (match_operand:V_FRACT 1 "register_operand" " vr"))
1269 (use (reg:SI VTYPE_REGNUM))]
1270 "TARGET_VECTOR"
1271 "vmv1r.v\t%0,%1"
1272 [(set_attr "type" "vmov")
1273 (set_attr "mode" "<MODE>")])
1274
1275 (define_expand "mov<mode>"
1276 [(set (match_operand:VB 0 "reg_or_mem_operand")
1277 (match_operand:VB 1 "general_operand"))]
1278 "TARGET_VECTOR"
1279 {
1280 if (TARGET_XTHEADVECTOR && reg_or_mem_operand (operands[1], <MODE>mode))
1281 {
1282 emit_insn (gen_pred_th_whole_mov (<MODE>mode, operands[0], operands[1],
1283 RVV_VLMAX, GEN_INT(riscv_vector::VLMAX)));
1284 DONE;
1285 }
1286
1287 if (riscv_vector::legitimize_move (operands[0], &operands[1]))
1288 DONE;
1289 })
1290
1291 (define_insn_and_split "*mov<mode>"
1292 [(set (match_operand:VB 0 "register_operand" "=vr")
1293 (match_operand:VB 1 "register_operand" " vr"))]
1294 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
1295 "#"
1296 "&& 1"
1297 [(parallel [(set (match_dup 0) (match_dup 1))
1298 (use (reg:SI VTYPE_REGNUM))])]
1299 ""
1300 [(set_attr "type" "vmov")
1301 (set_attr "mode" "<MODE>")])
1302
1303 (define_insn "*mov<mode>_vtype"
1304 [(set (match_operand:VB 0 "register_operand" "=vr")
1305 (match_operand:VB 1 "register_operand" " vr"))
1306 (use (reg:SI VTYPE_REGNUM))]
1307 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
1308 "vmv1r.v\t%0,%1"
1309 [(set_attr "type" "vmov")
1310 (set_attr "mode" "<MODE>")])
1311
1312 (define_expand "@mov<V_FRACT:mode><P:mode>_lra"
1313 [(parallel
1314 [(set (match_operand:V_FRACT 0 "reg_or_mem_operand")
1315 (match_operand:V_FRACT 1 "reg_or_mem_operand"))
1316 (clobber (match_scratch:P 2))])]
1317 "TARGET_VECTOR && (lra_in_progress || reload_completed)"
1318 {})
1319
1320 (define_expand "@mov<VB:mode><P:mode>_lra"
1321 [(parallel
1322 [(set (match_operand:VB 0 "reg_or_mem_operand")
1323 (match_operand:VB 1 "reg_or_mem_operand"))
1324 (clobber (match_scratch:P 2))])]
1325 "TARGET_VECTOR && (lra_in_progress || reload_completed)"
1326 {})
1327
1328 (define_insn_and_split "*mov<V_FRACT:mode><P:mode>_lra"
1329 [(set (match_operand:V_FRACT 0 "reg_or_mem_operand" "=vr, m,vr")
1330 (match_operand:V_FRACT 1 "reg_or_mem_operand" " m,vr,vr"))
1331 (clobber (match_scratch:P 2 "=&r,&r,X"))]
1332 "TARGET_VECTOR && (lra_in_progress || reload_completed)"
1333 "#"
1334 "&& reload_completed"
1335 [(const_int 0)]
1336 {
1337 if (REG_P (operands[0]) && REG_P (operands[1]))
1338 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1339 else
1340 {
1341 riscv_vector::emit_vlmax_vsetvl (<V_FRACT:MODE>mode, operands[2]);
1342 riscv_vector::emit_vlmax_insn_lra (code_for_pred_mov (<V_FRACT:MODE>mode),
1343 riscv_vector::UNARY_OP, operands, operands[2]);
1344 }
1345 DONE;
1346 }
1347 [(set_attr "type" "vector")]
1348 )
1349
1350 (define_insn_and_split "*mov<VB:mode><P:mode>_lra"
1351 [(set (match_operand:VB 0 "reg_or_mem_operand" "=vr, m,vr")
1352 (match_operand:VB 1 "reg_or_mem_operand" " m,vr,vr"))
1353 (clobber (match_scratch:P 2 "=&r,&r,X"))]
1354 "TARGET_VECTOR && (lra_in_progress || reload_completed)"
1355 "#"
1356 "&& reload_completed"
1357 [(const_int 0)]
1358 {
1359 if (REG_P (operands[0]) && REG_P (operands[1]))
1360 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1361 else
1362 {
1363 riscv_vector::emit_vlmax_vsetvl (<VB:MODE>mode, operands[2]);
1364 riscv_vector::emit_vlmax_insn_lra (code_for_pred_mov (<VB:MODE>mode),
1365 riscv_vector::UNARY_MASK_OP, operands, operands[2]);
1366 }
1367 DONE;
1368 }
1369 [(set_attr "type" "vector")]
1370 )
1371
1372 ;; Define tuple modes data movement.
1373 ;; operands[2] is used to save the offset of each subpart.
1374 ;; operands[3] is used to calculate the address for each subpart.
1375 ;; operands[4] is VL of vsetvli instruction.
1376 (define_expand "mov<mode>"
1377 [(parallel [(set (match_operand:VT 0 "reg_or_mem_operand")
1378 (match_operand:VT 1 "general_operand"))
1379 (clobber (match_dup 2))
1380 (clobber (match_dup 3))
1381 (clobber (match_dup 4))])]
1382 "TARGET_VECTOR"
1383 {
1384 /* Need to force register if mem <- !reg. */
1385 if (MEM_P (operands[0]) && !REG_P (operands[1]))
1386 operands[1] = force_reg (<MODE>mode, operands[1]);
1387
1388 if (GET_CODE (operands[1]) == CONST_VECTOR)
1389 {
1390 riscv_vector::expand_tuple_move (operands);
1391 DONE;
1392 }
1393
1394 operands[2] = gen_rtx_SCRATCH (Pmode);
1395 operands[3] = gen_rtx_SCRATCH (Pmode);
1396 operands[4] = gen_rtx_SCRATCH (Pmode);
1397 })
1398
1399 (define_insn_and_split "*mov<VT:mode>_<P:mode>"
1400 [(set (match_operand:VT 0 "reg_or_mem_operand" "=vr,vr, m")
1401 (match_operand:VT 1 "reg_or_mem_operand" " vr, m,vr"))
1402 (clobber (match_scratch:P 2 "=X,&r,&r"))
1403 (clobber (match_scratch:P 3 "=X,&r,&r"))
1404 (clobber (match_scratch:P 4 "=X,&r,&r"))]
1405 "TARGET_VECTOR"
1406 "#"
1407 "&& reload_completed"
1408 [(const_int 0)]
1409 {
1410 riscv_vector::expand_tuple_move (operands);
1411 DONE;
1412 }
1413 [(set_attr "type" "vmov,vlde,vste")
1414 (set_attr "mode" "<VT:MODE>")
1415 (set (attr "merge_op_idx") (const_int INVALID_ATTRIBUTE))
1416 (set (attr "avl_type_idx") (const_int INVALID_ATTRIBUTE))
1417 (set (attr "mode_idx") (const_int INVALID_ATTRIBUTE))])
1418
1419 ;; -----------------------------------------------------------------
1420 ;; ---- VLS Moves Operations
1421 ;; -----------------------------------------------------------------
1422
1423 (define_expand "mov<mode>"
1424 [(set (match_operand:VLS_AVL_IMM 0 "reg_or_mem_operand")
1425 (match_operand:VLS_AVL_IMM 1 "general_operand"))]
1426 "TARGET_VECTOR"
1427 {
1428 if (riscv_vector::legitimize_move (operands[0], &operands[1]))
1429 DONE;
1430 })
1431
1432 (define_insn_and_split "*mov<mode>"
1433 [(set (match_operand:VLS_AVL_IMM 0 "reg_or_mem_operand" "=vr, m, vr")
1434 (match_operand:VLS_AVL_IMM 1 "reg_or_mem_operand" " m,vr, vr"))]
1435 "TARGET_VECTOR
1436 && (register_operand (operands[0], <MODE>mode)
1437 || register_operand (operands[1], <MODE>mode))"
1438 "@
1439 #
1440 #
1441 vmv%m1r.v\t%0,%1"
1442 "&& reload_completed
1443 && (!register_operand (operands[0], <MODE>mode)
1444 || !register_operand (operands[1], <MODE>mode))"
1445 [(const_int 0)]
1446 {
1447 bool ok_p = riscv_vector::legitimize_move (operands[0], &operands[1]);
1448 gcc_assert (ok_p);
1449 DONE;
1450 }
1451 [(set_attr "type" "vlde,vste,vmov")
1452 (set_attr "mode" "<MODE>")
1453 (set (attr "merge_op_idx") (const_int INVALID_ATTRIBUTE))
1454 (set (attr "avl_type_idx") (const_int INVALID_ATTRIBUTE))
1455 (set (attr "mode_idx") (const_int INVALID_ATTRIBUTE))]
1456 )
1457
1458 (define_expand "mov<mode>"
1459 [(set (match_operand:VLS_AVL_REG 0 "reg_or_mem_operand")
1460 (match_operand:VLS_AVL_REG 1 "general_operand"))]
1461 "TARGET_VECTOR"
1462 {
1463 bool ok_p = riscv_vector::legitimize_move (operands[0], &operands[1]);
1464 gcc_assert (ok_p);
1465 DONE;
1466 })
1467
1468 (define_expand "@mov<VLS_AVL_REG:mode><P:mode>_lra"
1469 [(parallel
1470 [(set (match_operand:VLS_AVL_REG 0 "reg_or_mem_operand")
1471 (match_operand:VLS_AVL_REG 1 "reg_or_mem_operand"))
1472 (clobber (match_scratch:P 2))])]
1473 "TARGET_VECTOR && (lra_in_progress || reload_completed)"
1474 {})
1475
1476 (define_insn_and_split "*mov<VLS_AVL_REG:mode><P:mode>_lra"
1477 [(set (match_operand:VLS_AVL_REG 0 "reg_or_mem_operand" "=vr, m,vr")
1478 (match_operand:VLS_AVL_REG 1 "reg_or_mem_operand" " m,vr,vr"))
1479 (clobber (match_scratch:P 2 "=&r,&r,X"))]
1480 "TARGET_VECTOR && (lra_in_progress || reload_completed)
1481 && (register_operand (operands[0], <VLS_AVL_REG:MODE>mode)
1482 || register_operand (operands[1], <VLS_AVL_REG:MODE>mode))"
1483 "#"
1484 "&& reload_completed"
1485 [(const_int 0)]
1486 {
1487 if (REG_P (operands[0]) && REG_P (operands[1]))
1488 emit_insn (gen_rtx_SET (operands[0], operands[1]));
1489 else
1490 {
1491 emit_move_insn (operands[2], gen_int_mode (GET_MODE_NUNITS (<VLS_AVL_REG:MODE>mode),
1492 Pmode));
1493 unsigned insn_flags
1494 = GET_MODE_CLASS (<VLS_AVL_REG:MODE>mode) == MODE_VECTOR_BOOL
1495 ? riscv_vector::UNARY_MASK_OP
1496 : riscv_vector::UNARY_OP;
1497 riscv_vector::emit_nonvlmax_insn (code_for_pred_mov (<VLS_AVL_REG:MODE>mode),
1498 insn_flags, operands, operands[2]);
1499 }
1500 DONE;
1501 }
1502 [(set_attr "type" "vlde,vste,vmov")
1503 (set_attr "mode" "<VLS_AVL_REG:MODE>")
1504 (set (attr "merge_op_idx") (const_int INVALID_ATTRIBUTE))
1505 (set (attr "avl_type_idx") (const_int INVALID_ATTRIBUTE))
1506 (set (attr "mode_idx") (const_int INVALID_ATTRIBUTE))]
1507 )
1508
1509 (define_insn_and_split "*mov<mode>_vls"
1510 [(set (match_operand:VLS 0 "register_operand" "=vr")
1511 (match_operand:VLS 1 "register_operand" " vr"))]
1512 "TARGET_VECTOR"
1513 "#"
1514 "&& 1"
1515 [(parallel [(set (match_dup 0) (match_dup 1))
1516 (use (reg:SI VTYPE_REGNUM))])]
1517 ""
1518 [(set_attr "type" "vmov")
1519 (set_attr "mode" "<MODE>")])
1520
1521 (define_insn "*mov<mode>_vls_vtype"
1522 [(set (match_operand:VLS 0 "register_operand" "=vr")
1523 (match_operand:VLS 1 "register_operand" " vr"))
1524 (use (reg:SI VTYPE_REGNUM))]
1525 "TARGET_VECTOR"
1526 "vmv%m1r.v\t%0,%1"
1527 [(set_attr "type" "vmov")
1528 (set_attr "mode" "<MODE>")])
1529
1530 (define_insn_and_split "*mov<mode>_vls"
1531 [(set (match_operand:VLSB 0 "register_operand" "=vr")
1532 (match_operand:VLSB 1 "register_operand" " vr"))]
1533 "TARGET_VECTOR"
1534 "#"
1535 "&& 1"
1536 [(parallel [(set (match_dup 0) (match_dup 1))
1537 (use (reg:SI VTYPE_REGNUM))])]
1538 ""
1539 [(set_attr "type" "vmov")
1540 (set_attr "mode" "<MODE>")])
1541
1542 (define_insn "*mov<mode>_vls_vtype"
1543 [(set (match_operand:VLSB 0 "register_operand" "=vr")
1544 (match_operand:VLSB 1 "register_operand" " vr"))
1545 (use (reg:SI VTYPE_REGNUM))]
1546 "TARGET_VECTOR"
1547 "vmv1r.v\t%0,%1"
1548 [(set_attr "type" "vmov")
1549 (set_attr "mode" "<MODE>")])
1550
1551 ;; According to RVV ISA:
1552 ;; If an element accessed by a vector memory instruction is not naturally aligned to the size of the element,
1553 ;; either the element is transferred successfully or an address misaligned exception is raised on that element.
1554 (define_expand "movmisalign<mode>"
1555 [(set (match_operand:V_VLS 0 "nonimmediate_operand")
1556 (match_operand:V_VLS 1 "general_operand"))]
1557 "TARGET_VECTOR && TARGET_VECTOR_MISALIGN_SUPPORTED"
1558 {
1559 emit_move_insn (operands[0], operands[1]);
1560 DONE;
1561 }
1562 )
1563
1564 ;; -----------------------------------------------------------------
1565 ;; ---- Duplicate Operations
1566 ;; -----------------------------------------------------------------
1567
1568 (define_expand "vec_duplicate<mode>"
1569 [(set (match_operand:V_VLS 0 "register_operand")
1570 (vec_duplicate:V_VLS
1571 (match_operand:<VEL> 1 "direct_broadcast_operand")))]
1572 "TARGET_VECTOR"
1573 {
1574 /* Early expand DImode broadcast in RV32 system to avoid RA reload
1575 generate (set (reg) (vec_duplicate:DI)). */
1576 bool gt_p = maybe_gt (GET_MODE_SIZE (<VEL>mode), GET_MODE_SIZE (Pmode));
1577 if (!FLOAT_MODE_P (<VEL>mode) && gt_p)
1578 {
1579 riscv_vector::emit_vlmax_insn (code_for_pred_broadcast (<MODE>mode),
1580 riscv_vector::UNARY_OP, operands);
1581 DONE;
1582 }
1583 /* Otherwise, allow it fall into general vec_duplicate pattern
1584 which allow us to have vv->vx combine optimization in later pass. */
1585 })
1586
1587 ;; According to GCC internal:
1588 ;; This pattern only handles duplicates of non-constant inputs.
1589 ;; Constant vectors go through the movm pattern instead.
1590 ;; So "direct_broadcast_operand" can only be mem or reg, no CONSTANT.
1591 (define_insn_and_split "*vec_duplicate<mode>"
1592 [(set (match_operand:V_VLS 0 "register_operand")
1593 (vec_duplicate:V_VLS
1594 (match_operand:<VEL> 1 "direct_broadcast_operand")))]
1595 "TARGET_VECTOR && can_create_pseudo_p ()"
1596 "#"
1597 "&& 1"
1598 [(const_int 0)]
1599 {
1600 riscv_vector::emit_vlmax_insn (code_for_pred_broadcast (<MODE>mode),
1601 riscv_vector::UNARY_OP, operands);
1602 DONE;
1603 }
1604 [(set_attr "type" "vector")]
1605 )
1606
1607 ;; -----------------------------------------------------------------
1608 ;; ---- 6. Configuration-Setting Instructions
1609 ;; -----------------------------------------------------------------
1610 ;; Includes:
1611 ;; - 6.1 vsetvli/vsetivli/vsetvl instructions
1612 ;; -----------------------------------------------------------------
1613
1614 ;; we don't define vsetvli as unspec_volatile which has side effects.
1615 ;; This instruction can be scheduled by the instruction scheduler.
1616 ;; This means these instructions will be deleted when
1617 ;; there is no instructions using vl or vtype in the following.
1618 ;; rd | rs1 | AVL value | Effect on vl
1619 ;; - | !x0 | x[rs1] | Normal stripmining
1620 ;; !x0 | x0 | ~0 | Set vl to VLMAX
1621 ;; operands[0]: VL.
1622 ;; operands[1]: AVL.
1623 ;; operands[2]: SEW
1624 ;; operands[3]: LMUL
1625 ;; operands[4]: Tail policy 0 or 1 (undisturbed/agnostic)
1626 ;; operands[5]: Mask policy 0 or 1 (undisturbed/agnostic)
1627
1628 ;; We define 2 types of "vsetvl*" instruction patterns:
1629
1630 ;; - "@vsetvl<mode>" is a parallel format which has side effects.
1631
1632 ;; - "@vsetvl<mode>_no_side_effects" has no side effects.
1633
1634 ;; - "@vsetvl<mode>" is used by "vsetvl" intrinsics and "insert-vsetvl" PASS.
1635
1636 ;; - "@vsetvl<mode>_no_side_effects" is used by GCC standard patterns.
1637
1638 ;; - "@vsetvl<mode>" includes VL/VTYPE global registers status (define set)
1639 ;; and each RVV instruction includes VL/VTYPE global registers status (use)
1640 ;; so that we can guarantee each RVV instruction can execute with correct
1641 ;; VL/VTYPE global registers status after "insert-vsetvl" PASS.
1642
1643 ;; - "@vsetvl<mode>_no_side_effects" has no side effects and excludes VL/VTYPE
1644 ;; global registers status (define set). It's only used by GCC standard pattern
1645 ;; expansion. For example: "mov<mode>" pattern for fractional vector modes which
1646 ;; need to set VL/VTYPE. Then we could manually call this pattern to gain benefits
1647 ;; from the optimization of each GCC internal PASS.
1648
1649 ;; 1. void foo (float *in, float *out)
1650 ;; {
1651 ;; vfloat32mf2_t v = *(vfloat32mf2_t*)in;
1652 ;; *(vfloat32mf2_t*)out = v;
1653 ;; }
1654 ;; We could eliminate the second "vsetvl" by calling "@vsetvl<mode>_no_side_effects".
1655 ;;
1656 ;; "@vsetvl<mode>": ;; "@vsetvl<mode>_no_side_effects":
1657 ;; vsetvli a4,zero,e32,mf2,ta,ma ;; vsetvli a4,zero,e32,mf2,ta,ma
1658 ;; vle32.v v24,(a0) ;; vle32.v v24,(a0)
1659 ;; vsetvli a4,zero,e32,mf2,ta,ma ;; --
1660 ;; vse32.v v24,(a1) ;; vse32.v v24,(a1)
1661 ;; ret ;; ret
1662
1663 ;; 2. void foo (int8_t *in, int8_t *out, int M)
1664 ;; {
1665 ;; for (int i = 0; i < M; i++){
1666 ;; vint8mf2_t v = *(vint8mf2_t*)(in + i);
1667 ;; *(vint8mf2_t*)(out + i) = v;
1668 ;; }
1669 ;; }
1670 ;;
1671 ;; Hoist "vsetvl" instruction in LICM:
1672 ;; "@vsetvl<mode>": ;; "@vsetvl<mode>_no_side_effects":
1673 ;; - ;; vsetvli a4,zero,e32,mf2,ta,ma
1674 ;; LOOP: ;; LOOP:
1675 ;; vsetvli a4,zero,e32,mf2,ta,ma ;; -
1676 ;; vle32.v v24,(a0) ;; vle32.v v24,(a0)
1677 ;; vsetvli a4,zero,e32,mf2,ta,ma ;; -
1678 ;; vse32.v v24,(a1) ;; vse32.v v24,(a1)
1679
1680 ;; However, it may produce wrong codegen if we exclude VL/VTYPE in "vsetvl<mode>".
1681 ;; 3. void foo (int8_t *in, int8_t *out, int32_t *in2, int32_t *out2, int M)
1682 ;; {
1683 ;; for (int i = 0; i < M; i++){
1684 ;; vint8mf2_t v = *(vint8mf2_t*)(in + i);
1685 ;; vint32mf2_t v2 = *(vint32mf2_t*)(in + i + i);
1686 ;; *(vint8mf2_t*)(out + i) = v;
1687 ;; *(vint32mf2_t*)(out + i + i) = v2;
1688 ;; }
1689 ;; }
1690 ;;
1691 ;; vsetvli a6,zero,e8,mf2,ta,ma
1692 ;; vsetvli a2,zero,e32,mf2,ta,ma
1693 ;; LOOP:
1694 ;; vle8.v v25,(a0)
1695 ;; vle32.v v24,(a5)
1696 ;; addi a0,a0,1
1697 ;; vse8.v v25,(a1)
1698 ;; vse32.v v24,(a3)
1699 ;;
1700 ;; Both vle8.v and vle32.v are using the wrong VL/VTYPE status.
1701 ;; We leave it to "insert-vsetvl" PASS to correct this situation.
1702
1703 ;; The "insert-vsetvl" PASS mechanism:
1704 ;; 1. Before "insert-vsetvl" PASS, only RVV instructions are generated
1705 ;; by GCC standard pattern expansion has the corresponding "vsetvl".
1706 ;; We exploit each GCC internal optimization pass to optimize the "vsetvl".
1707 ;; 2. Correct the VL/VTYPE status for each GCC standard pattern RVV instructions.
1708 ;; Insert vsetvl for each RVV instructions that has no VL/VTYPE status if necessary.
1709 ;; For example: RVV intrinsics.
1710 ;; 3. Optimize "vsetvl" instructions.
1711
1712 (define_insn "@vsetvl<mode>"
1713 [(set (match_operand:P 0 "register_operand" "=r")
1714 (unspec:P [(match_operand:P 1 "vector_length_operand" "rvl")
1715 (match_operand 2 "const_int_operand" "i")
1716 (match_operand 3 "const_int_operand" "i")
1717 (match_operand 4 "const_int_operand" "i")
1718 (match_operand 5 "const_int_operand" "i")] UNSPEC_VSETVL))
1719 (set (reg:SI VL_REGNUM)
1720 (unspec:SI [(match_dup 1)
1721 (match_dup 2)
1722 (match_dup 3)] UNSPEC_VSETVL))
1723 (set (reg:SI VTYPE_REGNUM)
1724 (unspec:SI [(match_dup 2)
1725 (match_dup 3)
1726 (match_dup 4)
1727 (match_dup 5)] UNSPEC_VSETVL))]
1728 "TARGET_VECTOR"
1729 "vset%i1vli\t%0,%1,e%2,%m3,t%p4,m%p5"
1730 [(set_attr "type" "vsetvl")
1731 (set_attr "mode" "<MODE>")
1732 (set (attr "sew") (symbol_ref "INTVAL (operands[2])"))
1733 (set (attr "vlmul") (symbol_ref "INTVAL (operands[3])"))
1734 (set (attr "ta") (symbol_ref "INTVAL (operands[4])"))
1735 (set (attr "ma") (symbol_ref "INTVAL (operands[5])"))])
1736
1737 ;; vsetvl zero,zero,vtype instruction.
1738 ;; This pattern has no side effects and does not set X0 register.
1739 (define_insn "vsetvl_vtype_change_only"
1740 [(set (reg:SI VTYPE_REGNUM)
1741 (unspec:SI
1742 [(match_operand 0 "const_int_operand" "i")
1743 (match_operand 1 "const_int_operand" "i")
1744 (match_operand 2 "const_int_operand" "i")
1745 (match_operand 3 "const_int_operand" "i")] UNSPEC_VSETVL))]
1746 "TARGET_VECTOR"
1747 "vsetvli\tzero,zero,e%0,%m1,t%p2,m%p3"
1748 [(set_attr "type" "vsetvl")
1749 (set_attr "mode" "SI")
1750 (set (attr "sew") (symbol_ref "INTVAL (operands[0])"))
1751 (set (attr "vlmul") (symbol_ref "INTVAL (operands[1])"))
1752 (set (attr "ta") (symbol_ref "INTVAL (operands[2])"))
1753 (set (attr "ma") (symbol_ref "INTVAL (operands[3])"))])
1754
1755 ;; vsetvl zero,rs1,vtype instruction.
1756 ;; The reason we need this pattern since we should avoid setting X0 register
1757 ;; in vsetvl instruction pattern.
1758 (define_insn "@vsetvl_discard_result<mode>"
1759 [(set (reg:SI VL_REGNUM)
1760 (unspec:SI [(match_operand:P 0 "vector_length_operand" "rvl")
1761 (match_operand 1 "const_int_operand" "i")
1762 (match_operand 2 "const_int_operand" "i")] UNSPEC_VSETVL))
1763 (set (reg:SI VTYPE_REGNUM)
1764 (unspec:SI [(match_dup 1)
1765 (match_dup 2)
1766 (match_operand 3 "const_int_operand" "i")
1767 (match_operand 4 "const_int_operand" "i")] UNSPEC_VSETVL))]
1768 "TARGET_VECTOR"
1769 "vset%i0vli\tzero,%0,e%1,%m2,t%p3,m%p4"
1770 [(set_attr "type" "vsetvl")
1771 (set_attr "mode" "<MODE>")
1772 (set (attr "sew") (symbol_ref "INTVAL (operands[1])"))
1773 (set (attr "vlmul") (symbol_ref "INTVAL (operands[2])"))
1774 (set (attr "ta") (symbol_ref "INTVAL (operands[3])"))
1775 (set (attr "ma") (symbol_ref "INTVAL (operands[4])"))])
1776
1777 ;; It's emit by vsetvl/vsetvlmax intrinsics with no side effects.
1778 ;; Since we have many optimization passes from "expand" to "reload_completed",
1779 ;; such pattern can allow us gain benefits of these optimizations.
1780 (define_insn_and_split "@vsetvl<mode>_no_side_effects"
1781 [(set (match_operand:P 0 "register_operand" "=r")
1782 (unspec:P [(match_operand:P 1 "vector_length_operand" "rvl")
1783 (match_operand 2 "const_int_operand" "i")
1784 (match_operand 3 "const_int_operand" "i")
1785 (match_operand 4 "const_int_operand" "i")
1786 (match_operand 5 "const_int_operand" "i")] UNSPEC_VSETVL))]
1787 "TARGET_VECTOR"
1788 "#"
1789 "&& epilogue_completed"
1790 [(parallel
1791 [(set (match_dup 0)
1792 (unspec:P [(match_dup 1) (match_dup 2) (match_dup 3)
1793 (match_dup 4) (match_dup 5)] UNSPEC_VSETVL))
1794 (set (reg:SI VL_REGNUM)
1795 (unspec:SI [(match_dup 1) (match_dup 2) (match_dup 3)] UNSPEC_VSETVL))
1796 (set (reg:SI VTYPE_REGNUM)
1797 (unspec:SI [(match_dup 2) (match_dup 3) (match_dup 4)
1798 (match_dup 5)] UNSPEC_VSETVL))])]
1799 ""
1800 [(set_attr "type" "vsetvl")
1801 (set_attr "mode" "SI")])
1802
1803 ;; This pattern use to combine bellow two insns and then further remove
1804 ;; unnecessary sign_extend operations:
1805 ;; (set (reg:DI 134 [ _1 ])
1806 ;; (unspec:DI [
1807 ;; (const_int 19 [0x13])
1808 ;; (const_int 8 [0x8])
1809 ;; (const_int 5 [0x5])
1810 ;; (const_int 2 [0x2]) repeated x2
1811 ;; ] UNSPEC_VSETVL))
1812 ;; (set (reg/v:DI 135 [ <retval> ])
1813 ;; (sign_extend:DI (subreg:SI (reg:DI 134 [ _1 ]) 0)))
1814 ;;
1815 ;; The reason we can remove signe_extend is because currently the vl value
1816 ;; returned by the vsetvl instruction ranges from 0 to 65536 (uint16_t), and
1817 ;; bits 17 to 63 (including 31) are always 0, so there is no change after
1818 ;; sign_extend. Note that for HI and QI modes we cannot do this.
1819 ;; Of course, if the range of instructions returned by vsetvl later expands
1820 ;; to 32bits, then this combine pattern needs to be removed. But that could be
1821 ;; a long time from now.
1822 (define_insn_and_split "*vsetvldi_no_side_effects_si_extend"
1823 [(set (match_operand:DI 0 "register_operand")
1824 (sign_extend:DI
1825 (subreg:SI
1826 (unspec:DI [(match_operand:P 1 "vector_length_operand")
1827 (match_operand 2 "const_int_operand")
1828 (match_operand 3 "const_int_operand")
1829 (match_operand 4 "const_int_operand")
1830 (match_operand 5 "const_int_operand")] UNSPEC_VSETVL) 0)))]
1831 "TARGET_VECTOR && TARGET_64BIT"
1832 "#"
1833 "&& 1"
1834 [(set (match_dup 0)
1835 (unspec:DI [(match_dup 1)
1836 (match_dup 2)
1837 (match_dup 3)
1838 (match_dup 4)
1839 (match_dup 5)] UNSPEC_VSETVL))]
1840 ""
1841 [(set_attr "type" "vsetvl")
1842 (set_attr "mode" "SI")])
1843
1844 ;; RVV machine description matching format
1845 ;; (define_insn ""
1846 ;; [(set (match_operand:MODE 0)
1847 ;; (if_then_else:MODE
1848 ;; (unspec:<MODE:VM>
1849 ;; [(match_operand:<VM> 1 "vector_mask_operand")
1850 ;; (match_operand N + 4 "vector_length_operand")
1851 ;; (match_operand N + 5 "const_int_operand")
1852 ;; (match_operand N + 6 "const_int_operand")
1853 ;; (reg:SI VL_REGNUM)
1854 ;; (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1855 ;; (instruction operation:MODE
1856 ;; (match_operand 3
1857 ;; (match_operand 4
1858 ;; (match_operand 5
1859 ;; ................
1860 ;; (match_operand N + 3)
1861 ;; (match_operand:MODE 2 "vector_reg_or_const0_operand")))]
1862 ;;
1863 ;; (unspec:[........] UNSPEC_VPREDICATE) is a predicate wrapper.
1864 ;; Include mask predicate && length predicate && vector policy.
1865
1866 ;; -------------------------------------------------------------------------------
1867 ;; ---- Predicated Mov
1868 ;; -------------------------------------------------------------------------------
1869 ;; Includes:
1870 ;; - 7.4. Vector Unit-Stride Instructions
1871 ;; - 11.15 Vector Integer Merge Instructions
1872 ;; - 11.16 Vector Integer Move Instructions
1873 ;; - 13.16 Vector Floating-Point Move Instruction
1874 ;; - 15.1 Vector Mask-Register Logical Instructions
1875 ;; -------------------------------------------------------------------------------
1876
1877 ;; vle.v/vse.v/vmv.v.v.
1878 ;; For vle.v/vmv.v.v, we may need merge and mask operand.
1879 ;; For vse.v, we don't need merge operand, so it should always match "vu".
1880 ;; constraint alternative 0 ~ 1 match vle.v.
1881 ;; constraint alternative 2 match vse.v.
1882 ;; constraint alternative 3 match vmv.v.v.
1883
1884 ;; If operand 3 is a const_vector, then it is left to pred_broadcast patterns.
1885 (define_expand "@pred_mov<mode>"
1886 [(set (match_operand:V_VLS 0 "nonimmediate_operand")
1887 (if_then_else:V_VLS
1888 (unspec:<VM>
1889 [(match_operand:<VM> 1 "vector_mask_operand")
1890 (match_operand 4 "vector_length_operand")
1891 (match_operand 5 "const_int_operand")
1892 (match_operand 6 "const_int_operand")
1893 (match_operand 7 "const_int_operand")
1894 (reg:SI VL_REGNUM)
1895 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1896 (match_operand:V_VLS 3 "vector_move_operand")
1897 (match_operand:V_VLS 2 "vector_merge_operand")))]
1898 "TARGET_VECTOR"
1899 {})
1900
1901 ;; vle.v/vse.v,vmv.v.v
1902 (define_insn_and_split "*pred_mov<mode>"
1903 [(set (match_operand:V_VLS 0 "nonimmediate_operand" "=vr, vr, vd, m, vr, vr")
1904 (if_then_else:V_VLS
1905 (unspec:<VM>
1906 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm, vmWc1, Wc1, Wc1")
1907 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl")
1908 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
1909 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
1910 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
1911 (reg:SI VL_REGNUM)
1912 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1913 (match_operand:V_VLS 3 "reg_or_mem_operand" " m, m, m, vr, vr, vr")
1914 (match_operand:V_VLS 2 "vector_merge_operand" " 0, vu, vu, vu, vu, 0")))]
1915 "(TARGET_VECTOR
1916 && (register_operand (operands[0], <MODE>mode)
1917 || register_operand (operands[3], <MODE>mode)))"
1918 "@
1919 vle<sew>.v\t%0,%3%p1
1920 vle<sew>.v\t%0,%3
1921 vle<sew>.v\t%0,%3,%1.t
1922 vse<sew>.v\t%3,%0%p1
1923 vmv.v.v\t%0,%3
1924 vmv.v.v\t%0,%3"
1925 "&& riscv_vector::whole_reg_to_reg_move_p (operands, <MODE>mode, 7)"
1926 [(set (match_dup 0) (match_dup 3))]
1927 ""
1928 [(set_attr "type" "vlde,vlde,vlde,vste,vimov,vimov")
1929 (set_attr "mode" "<MODE>")])
1930
1931 ;; Dedicated pattern for vse.v instruction since we can't reuse pred_mov pattern to include
1932 ;; memory operand as input which will produce inferior codegen.
1933 (define_insn "@pred_store<mode>"
1934 [(set (match_operand:V 0 "memory_operand" "+m")
1935 (if_then_else:V
1936 (unspec:<VM>
1937 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
1938 (match_operand 3 "vector_length_operand" " rvl")
1939 (match_operand 4 "const_int_operand" " i")
1940 (reg:SI VL_REGNUM)
1941 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1942 (match_operand:V 2 "register_operand" " vr")
1943 (match_dup 0)))]
1944 "TARGET_VECTOR"
1945 "vse<sew>.v\t%2,%0%p1"
1946 [(set_attr "type" "vste")
1947 (set_attr "mode" "<MODE>")
1948 (set (attr "avl_type_idx") (const_int 4))
1949 (set_attr "vl_op_idx" "3")])
1950
1951 ;; vlm.v/vsm.v/vmclr.m/vmset.m.
1952 ;; constraint alternative 0 match vlm.v.
1953 ;; constraint alternative 1 match vsm.v.
1954 ;; constraint alternative 3 match vmclr.m.
1955 ;; constraint alternative 4 match vmset.m.
1956 (define_insn_and_split "@pred_mov<mode>"
1957 [(set (match_operand:VB_VLS 0 "nonimmediate_operand" "=vr, m, vr, vr, vr")
1958 (if_then_else:VB_VLS
1959 (unspec:VB_VLS
1960 [(match_operand:VB_VLS 1 "vector_all_trues_mask_operand" "Wc1, Wc1, Wc1, Wc1, Wc1")
1961 (match_operand 4 "vector_length_operand" "rvl, rvl, rvl, rvl, rvl")
1962 (match_operand 5 "const_int_operand" " i, i, i, i, i")
1963 (reg:SI VL_REGNUM)
1964 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1965 (match_operand:VB_VLS 3 "vector_move_operand" " m, vr, vr, Wc0, Wc1")
1966 (match_operand:VB_VLS 2 "vector_undef_operand" " vu, vu, vu, vu, vu")))]
1967 "TARGET_VECTOR"
1968 "@
1969 vlm.v\t%0,%3
1970 vsm.v\t%3,%0
1971 vmmv.m\t%0,%3
1972 vmclr.m\t%0
1973 vmset.m\t%0"
1974 "&& riscv_vector::whole_reg_to_reg_move_p (operands, <MODE>mode, 5)"
1975 [(set (match_dup 0) (match_dup 3))]
1976 ""
1977 [(set_attr "type" "vldm,vstm,vmalu,vmalu,vmalu")
1978 (set_attr "mode" "<MODE>")])
1979
1980 ;; Dedicated pattern for vsm.v instruction since we can't reuse pred_mov pattern to include
1981 ;; memory operand as input which will produce inferior codegen.
1982 (define_insn "@pred_store<mode>"
1983 [(set (match_operand:VB 0 "memory_operand" "+m")
1984 (if_then_else:VB
1985 (unspec:VB
1986 [(match_operand:VB 1 "vector_all_trues_mask_operand" "Wc1")
1987 (match_operand 3 "vector_length_operand" "rvl")
1988 (match_operand 4 "const_int_operand" " i")
1989 (reg:SI VL_REGNUM)
1990 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
1991 (match_operand:VB 2 "register_operand" " vr")
1992 (match_dup 0)))]
1993 "TARGET_VECTOR"
1994 "vsm.v\t%2,%0"
1995 [(set_attr "type" "vstm")
1996 (set_attr "mode" "<MODE>")
1997 (set (attr "avl_type_idx") (const_int 4))
1998 (set_attr "vl_op_idx" "3")])
1999
2000 (define_insn "@pred_merge<mode>"
2001 [(set (match_operand:V_VLS 0 "register_operand" "=vd,vd,vd,vd")
2002 (if_then_else:V_VLS
2003 (unspec:<VM>
2004 [(match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2005 (match_operand 6 "const_int_operand" " i, i, i, i")
2006 (match_operand 7 "const_int_operand" " i, i, i, i")
2007 (reg:SI VL_REGNUM)
2008 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2009 (vec_merge:V_VLS
2010 (match_operand:V_VLS 3 "vector_arith_operand" " vr,vr,vi,vi")
2011 (match_operand:V_VLS 2 "register_operand" " vr,vr,vr,vr")
2012 (match_operand:<VM> 4 "register_operand" " vm,vm,vm,vm"))
2013 (match_operand:V_VLS 1 "vector_merge_operand" " vu, 0,vu, 0")))]
2014 "TARGET_VECTOR"
2015 "vmerge.v%o3m\t%0,%2,%v3,%4"
2016 [(set_attr "type" "vimerge")
2017 (set_attr "mode" "<MODE>")])
2018
2019 (define_insn "@pred_merge<mode>_scalar"
2020 [(set (match_operand:V_VLSI_QHS 0 "register_operand" "=vd,vd")
2021 (if_then_else:V_VLSI_QHS
2022 (unspec:<VM>
2023 [(match_operand 5 "vector_length_operand" "rvl,rvl")
2024 (match_operand 6 "const_int_operand" " i, i")
2025 (match_operand 7 "const_int_operand" " i, i")
2026 (reg:SI VL_REGNUM)
2027 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2028 (vec_merge:V_VLSI_QHS
2029 (vec_duplicate:V_VLSI_QHS
2030 (match_operand:<VEL> 3 "register_operand" " r, r"))
2031 (match_operand:V_VLSI_QHS 2 "register_operand" " vr,vr")
2032 (match_operand:<VM> 4 "register_operand" " vm,vm"))
2033 (match_operand:V_VLSI_QHS 1 "vector_merge_operand" " vu, 0")))]
2034 "TARGET_VECTOR"
2035 "vmerge.vxm\t%0,%2,%3,%4"
2036 [(set_attr "type" "vimerge")
2037 (set_attr "mode" "<MODE>")])
2038
2039 (define_expand "@pred_merge<mode>_scalar"
2040 [(set (match_operand:V_VLSI_D 0 "register_operand")
2041 (if_then_else:V_VLSI_D
2042 (unspec:<VM>
2043 [(match_operand 5 "vector_length_operand")
2044 (match_operand 6 "const_int_operand")
2045 (match_operand 7 "const_int_operand")
2046 (reg:SI VL_REGNUM)
2047 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2048 (vec_merge:V_VLSI_D
2049 (vec_duplicate:V_VLSI_D
2050 (match_operand:<VEL> 3 "reg_or_int_operand"))
2051 (match_operand:V_VLSI_D 2 "register_operand")
2052 (match_operand:<VM> 4 "register_operand"))
2053 (match_operand:V_VLSI_D 1 "vector_merge_operand")))]
2054 "TARGET_VECTOR"
2055 {
2056 if (riscv_vector::sew64_scalar_helper (
2057 operands,
2058 /* scalar op */&operands[3],
2059 /* vl */operands[5],
2060 <MODE>mode,
2061 riscv_vector::simm5_p (operands[3]),
2062 [] (rtx *operands, rtx broadcast_scalar) {
2063 emit_insn (gen_pred_merge<mode> (operands[0], operands[1],
2064 operands[2], broadcast_scalar, operands[4], operands[5],
2065 operands[6], operands[7]));
2066 },
2067 (riscv_vector::avl_type) INTVAL (operands[7])))
2068 DONE;
2069 })
2070
2071 (define_insn "*pred_merge<mode>_scalar"
2072 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd")
2073 (if_then_else:V_VLSI_D
2074 (unspec:<VM>
2075 [(match_operand 5 "vector_length_operand" "rvl,rvl")
2076 (match_operand 6 "const_int_operand" " i, i")
2077 (match_operand 7 "const_int_operand" " i, i")
2078 (reg:SI VL_REGNUM)
2079 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2080 (vec_merge:V_VLSI_D
2081 (vec_duplicate:V_VLSI_D
2082 (match_operand:<VEL> 3 "register_operand" " r, r"))
2083 (match_operand:V_VLSI_D 2 "register_operand" " vr,vr")
2084 (match_operand:<VM> 4 "register_operand" " vm,vm"))
2085 (match_operand:V_VLSI_D 1 "vector_merge_operand" " vu, 0")))]
2086 "TARGET_VECTOR"
2087 "vmerge.vxm\t%0,%2,%3,%4"
2088 [(set_attr "type" "vimerge")
2089 (set_attr "mode" "<MODE>")])
2090
2091 (define_insn "*pred_merge<mode>_extended_scalar"
2092 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd")
2093 (if_then_else:V_VLSI_D
2094 (unspec:<VM>
2095 [(match_operand 5 "vector_length_operand" "rvl,rvl")
2096 (match_operand 6 "const_int_operand" " i, i")
2097 (match_operand 7 "const_int_operand" " i, i")
2098 (reg:SI VL_REGNUM)
2099 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2100 (vec_merge:V_VLSI_D
2101 (vec_duplicate:V_VLSI_D
2102 (sign_extend:<VEL>
2103 (match_operand:<VSUBEL> 3 "register_operand" " r, r")))
2104 (match_operand:V_VLSI_D 2 "register_operand" " vr,vr")
2105 (match_operand:<VM> 4 "register_operand" " vm,vm"))
2106 (match_operand:V_VLSI_D 1 "vector_merge_operand" " vu, 0")))]
2107 "TARGET_VECTOR && !TARGET_64BIT"
2108 "vmerge.vxm\t%0,%2,%3,%4"
2109 [(set_attr "type" "vimerge")
2110 (set_attr "mode" "<MODE>")])
2111
2112 ;; -------------------------------------------------------------------------------
2113 ;; ---- Predicated Broadcast
2114 ;; -------------------------------------------------------------------------------
2115 ;; Includes:
2116 ;; - 7.5. Vector Strided Instructions (zero stride)
2117 ;; - 11.16 Vector Integer Move Instructions (vmv.v.x)
2118 ;; - 13.16 Vector Floating-Point Move Instruction (vfmv.v.f)
2119 ;; - 16.1 Integer Scalar Move Instructions (vmv.s.x)
2120 ;; - 16.2 Floating-Point Scalar Move Instructions (vfmv.s.f)
2121 ;; -------------------------------------------------------------------------------
2122
2123 ;; According to RVV ISA, vector-scalar instruction doesn't support
2124 ;; operand fetched from 2 consecutive registers, so we should use
2125 ;; vlse.v which is a memory access to broadcast a DImode scalar into a vector.
2126 ;;
2127 ;; Since the optimization flow in GCC is as follows:
2128 ;; expand --> LICM (Loop invariant) --> split.
2129 ;; To use LICM optimization, we postpone generation of vlse.v to split stage since
2130 ;; a memory access instruction can not be optimized by LICM (Loop invariant).
2131 (define_expand "@pred_broadcast<mode>"
2132 [(set (match_operand:V_VLS 0 "register_operand")
2133 (if_then_else:V_VLS
2134 (unspec:<VM>
2135 [(match_operand:<VM> 1 "vector_broadcast_mask_operand")
2136 (match_operand 4 "vector_length_operand")
2137 (match_operand 5 "const_int_operand")
2138 (match_operand 6 "const_int_operand")
2139 (match_operand 7 "const_int_operand")
2140 (reg:SI VL_REGNUM)
2141 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2142 (vec_duplicate:V_VLS
2143 (match_operand:<VEL> 3 "direct_broadcast_operand"))
2144 (match_operand:V_VLS 2 "vector_merge_operand")))]
2145 "TARGET_VECTOR"
2146 {
2147 /* Transform vmv.v.x/vfmv.v.f (avl = 1) into vmv.s.x since vmv.s.x/vfmv.s.f
2148 has better chances to do vsetvl fusion in vsetvl pass. */
2149 if (riscv_vector::splat_to_scalar_move_p (operands))
2150 {
2151 operands[1] = riscv_vector::gen_scalar_move_mask (<VM>mode);
2152 operands[3] = force_reg (<VEL>mode, operands[3]);
2153 }
2154 /* Handle vmv.s.x instruction (Wb1 mask) which has memory scalar. */
2155 else if (satisfies_constraint_Wdm (operands[3]))
2156 {
2157 if (satisfies_constraint_Wb1 (operands[1]))
2158 {
2159 /* Case 1: vmv.s.x (TA, x == memory) ==> vlse.v (TA) */
2160 if (satisfies_constraint_vu (operands[2]))
2161 operands[1] = CONSTM1_RTX (<VM>mode);
2162 else if (GET_MODE_BITSIZE (<VEL>mode) > GET_MODE_BITSIZE (Pmode))
2163 {
2164 /* Case 2: vmv.s.x (TU, x == memory) ==>
2165 vl = 0 or 1; + vlse.v (TU) in RV32 system */
2166 operands[4] = riscv_vector::gen_avl_for_scalar_move (operands[4]);
2167 operands[1] = CONSTM1_RTX (<VM>mode);
2168 }
2169 else
2170 /* Case 3: load x (memory) to register. */
2171 operands[3] = force_reg (<VEL>mode, operands[3]);
2172 }
2173 }
2174 else if (GET_MODE_BITSIZE (<VEL>mode) > GET_MODE_BITSIZE (Pmode)
2175 && (immediate_operand (operands[3], Pmode)
2176 || (CONST_POLY_INT_P (operands[3])
2177 && known_ge (rtx_to_poly_int64 (operands[3]), 0U)
2178 && known_le (rtx_to_poly_int64 (operands[3]), GET_MODE_SIZE (<MODE>mode)))))
2179 {
2180 rtx tmp = gen_reg_rtx (Pmode);
2181 poly_int64 value = rtx_to_poly_int64 (operands[3]);
2182 emit_move_insn (tmp, gen_int_mode (value, Pmode));
2183 operands[3] = gen_rtx_SIGN_EXTEND (<VEL>mode, tmp);
2184 }
2185 /* Never load (const_int 0) into a register, that's silly. */
2186 else if (operands[3] == CONST0_RTX (<VEL>mode))
2187 ;
2188 /* If we're broadcasting [-16..15] across more than just
2189 element 0, then we can use vmv.v.i directly, thus avoiding
2190 the load of the constant into a GPR. */
2191 else if (CONST_INT_P (operands[3])
2192 && IN_RANGE (INTVAL (operands[3]), -16, 15)
2193 && !satisfies_constraint_Wb1 (operands[1]))
2194 ;
2195 else
2196 operands[3] = force_reg (<VEL>mode, operands[3]);
2197 })
2198
2199 (define_insn_and_split "*pred_broadcast<mode>"
2200 [(set (match_operand:V_VLSI 0 "register_operand" "=vr, vr, vd, vd, vr, vr, vr, vr")
2201 (if_then_else:V_VLSI
2202 (unspec:<VM>
2203 [(match_operand:<VM> 1 "vector_broadcast_mask_operand" "Wc1,Wc1, vm, vm,Wc1,Wc1,Wb1,Wb1")
2204 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl,rvl,rvl,rvl,rvl")
2205 (match_operand 5 "const_int_operand" " i, i, i, i, i, i, i, i")
2206 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i")
2207 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i")
2208 (reg:SI VL_REGNUM)
2209 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2210 (vec_duplicate:V_VLSI
2211 (match_operand:<VEL> 3 "direct_broadcast_operand" "rP,rP,Wdm,Wdm,Wdm,Wdm, rJ, rJ"))
2212 (match_operand:V_VLSI 2 "vector_merge_operand" "vu, 0, vu, 0, vu, 0, vu, 0")))]
2213 "TARGET_VECTOR"
2214 "@
2215 vmv.v.%o3\t%0,%3
2216 vmv.v.%o3\t%0,%3
2217 vlse<sew>.v\t%0,%3,zero,%1.t
2218 vlse<sew>.v\t%0,%3,zero,%1.t
2219 vlse<sew>.v\t%0,%3,zero
2220 vlse<sew>.v\t%0,%3,zero
2221 vmv.s.x\t%0,%z3
2222 vmv.s.x\t%0,%z3"
2223 "(register_operand (operands[3], <VEL>mode)
2224 || CONST_POLY_INT_P (operands[3]))
2225 && GET_MODE_BITSIZE (<VEL>mode) > GET_MODE_BITSIZE (Pmode)"
2226 [(set (match_dup 0)
2227 (if_then_else:V_VLSI (unspec:<VM> [(match_dup 1) (match_dup 4)
2228 (match_dup 5) (match_dup 6) (match_dup 7)
2229 (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2230 (vec_duplicate:V_VLSI (match_dup 3))
2231 (match_dup 2)))]
2232 {
2233 gcc_assert (can_create_pseudo_p ());
2234 if (CONST_POLY_INT_P (operands[3]))
2235 {
2236 rtx tmp = gen_reg_rtx (<VEL>mode);
2237 emit_move_insn (tmp, operands[3]);
2238 operands[3] = tmp;
2239 }
2240 rtx m = assign_stack_local (<VEL>mode, GET_MODE_SIZE (<VEL>mode),
2241 GET_MODE_ALIGNMENT (<VEL>mode));
2242 m = validize_mem (m);
2243 emit_move_insn (m, operands[3]);
2244 m = gen_rtx_MEM (<VEL>mode, force_reg (Pmode, XEXP (m, 0)));
2245 operands[3] = m;
2246
2247 /* For SEW = 64 in RV32 system, we expand vmv.s.x:
2248 andi a2,a2,1
2249 vsetvl zero,a2,e64
2250 vlse64.v */
2251 if (satisfies_constraint_Wb1 (operands[1]))
2252 {
2253 operands[4] = riscv_vector::gen_avl_for_scalar_move (operands[4]);
2254 operands[1] = CONSTM1_RTX (<VM>mode);
2255 }
2256 }
2257 [(set_attr "type" "vimov,vimov,vlds,vlds,vlds,vlds,vimovxv,vimovxv")
2258 (set_attr "mode" "<MODE>")])
2259
2260 (define_insn "*pred_broadcast<mode>_zvfh"
2261 [(set (match_operand:V_VLSF 0 "register_operand" "=vr, vr, vr, vr")
2262 (if_then_else:V_VLSF
2263 (unspec:<VM>
2264 [(match_operand:<VM> 1 "vector_broadcast_mask_operand" "Wc1, Wc1, Wb1, Wb1")
2265 (match_operand 4 "vector_length_operand" "rvl, rvl, rvl, rvl")
2266 (match_operand 5 "const_int_operand" " i, i, i, i")
2267 (match_operand 6 "const_int_operand" " i, i, i, i")
2268 (match_operand 7 "const_int_operand" " i, i, i, i")
2269 (reg:SI VL_REGNUM)
2270 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2271 (vec_duplicate:V_VLSF
2272 (match_operand:<VEL> 3 "direct_broadcast_operand" " f, f, f, f"))
2273 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
2274 "TARGET_VECTOR"
2275 "@
2276 vfmv.v.f\t%0,%3
2277 vfmv.v.f\t%0,%3
2278 vfmv.s.f\t%0,%3
2279 vfmv.s.f\t%0,%3"
2280 [(set_attr "type" "vfmov,vfmov,vfmovfv,vfmovfv")
2281 (set_attr "mode" "<MODE>")])
2282
2283 (define_insn "*pred_broadcast<mode>_zvfhmin"
2284 [(set (match_operand:V_VLSF_ZVFHMIN 0 "register_operand" "=vr, vr, vr, vr")
2285 (if_then_else:V_VLSF_ZVFHMIN
2286 (unspec:<VM>
2287 [(match_operand:<VM> 1 "vector_broadcast_mask_operand" " vm, vm, Wc1, Wc1")
2288 (match_operand 4 "vector_length_operand" "rvl, rvl, rvl, rvl")
2289 (match_operand 5 "const_int_operand" " i, i, i, i")
2290 (match_operand 6 "const_int_operand" " i, i, i, i")
2291 (match_operand 7 "const_int_operand" " i, i, i, i")
2292 (reg:SI VL_REGNUM)
2293 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2294 (vec_duplicate:V_VLSF_ZVFHMIN
2295 (match_operand:<VEL> 3 "direct_broadcast_operand" "Wdm, Wdm, Wdm, Wdm"))
2296 (match_operand:V_VLSF_ZVFHMIN 2 "vector_merge_operand" " vu, 0, vu, 0")))]
2297 "TARGET_VECTOR"
2298 "@
2299 vlse<sew>.v\t%0,%3,zero,%1.t
2300 vlse<sew>.v\t%0,%3,zero,%1.t
2301 vlse<sew>.v\t%0,%3,zero
2302 vlse<sew>.v\t%0,%3,zero"
2303 [(set_attr "type" "vlds,vlds,vlds,vlds")
2304 (set_attr "mode" "<MODE>")])
2305
2306 (define_insn "*pred_broadcast<mode>_extended_scalar"
2307 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vr, vr, vr, vr")
2308 (if_then_else:V_VLSI_D
2309 (unspec:<VM>
2310 [(match_operand:<VM> 1 "vector_broadcast_mask_operand" "Wc1,Wc1,Wb1,Wb1")
2311 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
2312 (match_operand 5 "const_int_operand" " i, i, i, i")
2313 (match_operand 6 "const_int_operand" " i, i, i, i")
2314 (match_operand 7 "const_int_operand" " i, i, i, i")
2315 (reg:SI VL_REGNUM)
2316 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2317 (vec_duplicate:V_VLSI_D
2318 (sign_extend:<VEL>
2319 (match_operand:<VSUBEL> 3 "register_operand" " r, r, r, r")))
2320 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2321 "TARGET_VECTOR && !TARGET_64BIT"
2322 "@
2323 vmv.v.x\t%0,%3
2324 vmv.v.x\t%0,%3
2325 vmv.s.x\t%0,%3
2326 vmv.s.x\t%0,%3"
2327 [(set_attr "type" "vimov,vimov,vimovxv,vimovxv")
2328 (set_attr "mode" "<MODE>")])
2329
2330 (define_insn "*pred_broadcast<mode>_zero"
2331 [(set (match_operand:V_VLS 0 "register_operand" "=vr, vr")
2332 (if_then_else:V_VLS
2333 (unspec:<VM>
2334 [(match_operand:<VM> 1 "vector_least_significant_set_mask_operand" "Wb1, Wb1")
2335 (match_operand 4 "vector_length_operand" "rvl, rvl")
2336 (match_operand 5 "const_int_operand" " i, i")
2337 (match_operand 6 "const_int_operand" " i, i")
2338 (match_operand 7 "const_int_operand" " i, i")
2339 (reg:SI VL_REGNUM)
2340 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2341 (match_operand:V_VLS 3 "vector_const_0_operand" "Wc0, Wc0")
2342 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0")))]
2343 "TARGET_VECTOR"
2344 "vmv.s.x\t%0,zero"
2345 [(set_attr "type" "vimovxv,vimovxv")
2346 (set_attr "mode" "<MODE>")])
2347
2348 ;; Because (vec_duplicate imm) will be converted to (const_vector imm),
2349 ;; This pattern is used to handle this case.
2350 (define_insn "*pred_broadcast<mode>_imm"
2351 [(set (match_operand:V_VLS 0 "register_operand" "=vr, vr")
2352 (if_then_else:V_VLS
2353 (unspec:<VM>
2354 [(match_operand:<VM> 1 "vector_all_trues_mask_operand" " Wc1, Wc1")
2355 (match_operand 4 "vector_length_operand" " rvl, rvl")
2356 (match_operand 5 "const_int_operand" " i, i")
2357 (match_operand 6 "const_int_operand" " i, i")
2358 (match_operand 7 "const_int_operand" " i, i")
2359 (reg:SI VL_REGNUM)
2360 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2361 (match_operand:V_VLS 3 "vector_const_int_or_double_0_operand" "viWc0, viWc0")
2362 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0")))]
2363 "TARGET_VECTOR"
2364 "vmv.v.i\t%0,%v3"
2365 [(set_attr "type" "vimov,vimov")
2366 (set_attr "mode" "<MODE>")])
2367
2368 ;; -------------------------------------------------------------------------------
2369 ;; ---- Predicated Strided loads/stores
2370 ;; -------------------------------------------------------------------------------
2371 ;; Includes:
2372 ;; - 7.5. Vector Strided Instructions
2373 ;; -------------------------------------------------------------------------------
2374
2375 (define_insn "@pred_strided_load<mode>"
2376 [(set (match_operand:V_VLS 0 "register_operand" "=vr, vr, vd, vr, vr, vd")
2377 (if_then_else:V_VLS
2378 (unspec:<VM>
2379 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm, vmWc1, Wc1, vm")
2380 (match_operand 5 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl")
2381 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
2382 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
2383 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
2384 (reg:SI VL_REGNUM)
2385 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2386 (unspec:V_VLS
2387 [(match_operand:V_VLS 3 "memory_operand" " m, m, m, m, m, m")
2388 (mem:BLK (scratch))
2389 (match_operand 4 "<V_VLS:stride_predicate>" "<V_VLS:stride_load_constraint>")] UNSPEC_STRIDED)
2390 (match_operand:V_VLS 2 "vector_merge_operand" " 0, vu, vu, 0, vu, vu")))]
2391 "TARGET_VECTOR"
2392 "@
2393 vlse<sew>.v\t%0,%3,%z4%p1
2394 vlse<sew>.v\t%0,%3,%z4
2395 vlse<sew>.v\t%0,%3,%z4,%1.t
2396 vle<sew>.v\t%0,%3%p1
2397 vle<sew>.v\t%0,%3
2398 vle<sew>.v\t%0,%3,%1.t"
2399 [(set_attr "type" "vlds")
2400 (set_attr "mode" "<MODE>")])
2401
2402 (define_insn "@pred_strided_store<mode>"
2403 [(set (mem:BLK (scratch))
2404 (unspec:BLK
2405 [(match_operand:V_VLS 0 "memory_operand" " +m, m")
2406 (unspec:<VM>
2407 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, vmWc1")
2408 (match_operand 4 "vector_length_operand" " rvl, rvl")
2409 (match_operand 5 "const_int_operand" " i, i")
2410 (reg:SI VL_REGNUM)
2411 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2412 (match_operand 2 "<V_VLS:stride_predicate>" "<V_VLS:stride_store_constraint>")
2413 (match_operand:V_VLS 3 "register_operand" " vr, vr")] UNSPEC_STRIDED))]
2414 "TARGET_VECTOR"
2415 "@
2416 vsse<sew>.v\t%3,%0,%z2%p1
2417 vse<sew>.v\t%3,%0%p1"
2418 [(set_attr "type" "vsts")
2419 (set_attr "mode" "<MODE>")
2420 (set (attr "avl_type_idx") (const_int 5))])
2421
2422 ;; -------------------------------------------------------------------------------
2423 ;; ---- Predicated indexed loads/stores
2424 ;; -------------------------------------------------------------------------------
2425 ;; Includes:
2426 ;; - 7.6. Vector Indexed Instructions
2427 ;; -------------------------------------------------------------------------------
2428
2429 ;; DEST eew is same as SOURCE eew, DEST register can overlap SOURCE.
2430 (define_insn "@pred_indexed_<order>load<mode>_same_eew"
2431 [(set (match_operand:VINDEXED 0 "register_operand" "=vd, vr,vd, vr")
2432 (if_then_else:VINDEXED
2433 (unspec:<VM>
2434 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1,vm,Wc1")
2435 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2436 (match_operand 6 "const_int_operand" " i, i, i, i")
2437 (match_operand 7 "const_int_operand" " i, i, i, i")
2438 (match_operand 8 "const_int_operand" " i, i, i, i")
2439 (reg:SI VL_REGNUM)
2440 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2441 (unspec:VINDEXED
2442 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ,rJ, rJ")
2443 (mem:BLK (scratch))
2444 (match_operand:<VINDEX> 4 "register_operand" " vr, vr,vr, vr")] ORDER)
2445 (match_operand:VINDEXED 2 "vector_merge_operand" " vu, vu, 0, 0")))]
2446 "TARGET_VECTOR"
2447 "vl<order>xei<sew>.v\t%0,(%z3),%4%p1"
2448 [(set_attr "type" "vld<order>x")
2449 (set_attr "mode" "<MODE>")])
2450
2451 ;; DEST eew is greater than SOURCE eew.
2452 (define_insn "@pred_indexed_<order>load<mode>_x2_greater_eew"
2453 [(set (match_operand:VEEWEXT2 0 "register_operand" "=&vr, &vr")
2454 (if_then_else:VEEWEXT2
2455 (unspec:<VM>
2456 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
2457 (match_operand 5 "vector_length_operand" " rvl, rvl")
2458 (match_operand 6 "const_int_operand" " i, i")
2459 (match_operand 7 "const_int_operand" " i, i")
2460 (match_operand 8 "const_int_operand" " i, i")
2461 (reg:SI VL_REGNUM)
2462 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2463 (unspec:VEEWEXT2
2464 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
2465 (mem:BLK (scratch))
2466 (match_operand:<VINDEX_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")] ORDER)
2467 (match_operand:VEEWEXT2 2 "vector_merge_operand" " vu, 0")))]
2468 "TARGET_VECTOR"
2469 "vl<order>xei<double_trunc_sew>.v\t%0,(%z3),%4%p1"
2470 [(set_attr "type" "vld<order>x")
2471 (set_attr "mode" "<MODE>")])
2472
2473 (define_insn "@pred_indexed_<order>load<mode>_x4_greater_eew"
2474 [(set (match_operand:VEEWEXT4 0 "register_operand" "=&vr, &vr")
2475 (if_then_else:VEEWEXT4
2476 (unspec:<VM>
2477 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
2478 (match_operand 5 "vector_length_operand" " rvl, rvl")
2479 (match_operand 6 "const_int_operand" " i, i")
2480 (match_operand 7 "const_int_operand" " i, i")
2481 (match_operand 8 "const_int_operand" " i, i")
2482 (reg:SI VL_REGNUM)
2483 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2484 (unspec:VEEWEXT4
2485 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
2486 (mem:BLK (scratch))
2487 (match_operand:<VINDEX_QUAD_TRUNC> 4 "register_operand" " vr, vr")] ORDER)
2488 (match_operand:VEEWEXT4 2 "vector_merge_operand" " vu, 0")))]
2489 "TARGET_VECTOR"
2490 "vl<order>xei<quad_trunc_sew>.v\t%0,(%z3),%4%p1"
2491 [(set_attr "type" "vld<order>x")
2492 (set_attr "mode" "<MODE>")])
2493
2494 (define_insn "@pred_indexed_<order>load<mode>_x8_greater_eew"
2495 [(set (match_operand:VEEWEXT8 0 "register_operand" "=&vr, &vr")
2496 (if_then_else:VEEWEXT8
2497 (unspec:<VM>
2498 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
2499 (match_operand 5 "vector_length_operand" " rvl, rvl")
2500 (match_operand 6 "const_int_operand" " i, i")
2501 (match_operand 7 "const_int_operand" " i, i")
2502 (match_operand 8 "const_int_operand" " i, i")
2503 (reg:SI VL_REGNUM)
2504 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2505 (unspec:VEEWEXT8
2506 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
2507 (mem:BLK (scratch))
2508 (match_operand:<VINDEX_OCT_TRUNC> 4 "register_operand" " vr, vr")] ORDER)
2509 (match_operand:VEEWEXT8 2 "vector_merge_operand" " vu, 0")))]
2510 "TARGET_VECTOR"
2511 "vl<order>xei<oct_trunc_sew>.v\t%0,(%z3),%4%p1"
2512 [(set_attr "type" "vld<order>x")
2513 (set_attr "mode" "<MODE>")])
2514
2515 ;; DEST eew is smaller than SOURCE eew.
2516 (define_insn "@pred_indexed_<order>load<mode>_x2_smaller_eew"
2517 [(set (match_operand:VEEWTRUNC2 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
2518 (if_then_else:VEEWTRUNC2
2519 (unspec:<VM>
2520 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
2521 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
2522 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
2523 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
2524 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
2525 (reg:SI VL_REGNUM)
2526 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2527 (unspec:VEEWTRUNC2
2528 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ, rJ, rJ, rJ, rJ")
2529 (mem:BLK (scratch))
2530 (match_operand:<VINDEX_DOUBLE_EXT> 4 "register_operand" " 0, 0, 0, 0, vr, vr")] ORDER)
2531 (match_operand:VEEWTRUNC2 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
2532 "TARGET_VECTOR"
2533 "vl<order>xei<double_ext_sew>.v\t%0,(%z3),%4%p1"
2534 [(set_attr "type" "vld<order>x")
2535 (set_attr "mode" "<MODE>")])
2536
2537 (define_insn "@pred_indexed_<order>load<mode>_x4_smaller_eew"
2538 [(set (match_operand:VEEWTRUNC4 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
2539 (if_then_else:VEEWTRUNC4
2540 (unspec:<VM>
2541 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
2542 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
2543 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
2544 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
2545 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
2546 (reg:SI VL_REGNUM)
2547 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2548 (unspec:VEEWTRUNC4
2549 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ, rJ, rJ, rJ, rJ")
2550 (mem:BLK (scratch))
2551 (match_operand:<VINDEX_QUAD_EXT> 4 "register_operand" " 0, 0, 0, 0, vr, vr")] ORDER)
2552 (match_operand:VEEWTRUNC4 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
2553 "TARGET_VECTOR"
2554 "vl<order>xei<quad_ext_sew>.v\t%0,(%z3),%4%p1"
2555 [(set_attr "type" "vld<order>x")
2556 (set_attr "mode" "<MODE>")])
2557
2558 (define_insn "@pred_indexed_<order>load<mode>_x8_smaller_eew"
2559 [(set (match_operand:VEEWTRUNC8 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
2560 (if_then_else:VEEWTRUNC8
2561 (unspec:<VM>
2562 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
2563 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
2564 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
2565 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
2566 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
2567 (reg:SI VL_REGNUM)
2568 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2569 (unspec:VEEWTRUNC8
2570 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ, rJ, rJ, rJ, rJ")
2571 (mem:BLK (scratch))
2572 (match_operand:<VINDEX_OCT_EXT> 4 "register_operand" " 0, 0, 0, 0, vr, vr")] ORDER)
2573 (match_operand:VEEWTRUNC8 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
2574 "TARGET_VECTOR"
2575 "vl<order>xei<oct_ext_sew>.v\t%0,(%z3),%4%p1"
2576 [(set_attr "type" "vld<order>x")
2577 (set_attr "mode" "<MODE>")])
2578
2579 (define_insn "@pred_indexed_<order>store<RATIO64:mode><RATIO64I:mode>"
2580 [(set (mem:BLK (scratch))
2581 (unspec:BLK
2582 [(unspec:<VM>
2583 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2584 (match_operand 4 "vector_length_operand" " rvl")
2585 (match_operand 5 "const_int_operand" " i")
2586 (reg:SI VL_REGNUM)
2587 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2588 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2589 (match_operand:RATIO64I 2 "register_operand" " vr")
2590 (match_operand:RATIO64 3 "register_operand" " vr")] ORDER))]
2591 "TARGET_VECTOR"
2592 "vs<order>xei<RATIO64I:sew>.v\t%3,(%z1),%2%p0"
2593 [(set_attr "type" "vst<order>x")
2594 (set_attr "mode" "<RATIO64:MODE>")])
2595
2596 (define_insn "@pred_indexed_<order>store<RATIO32:mode><RATIO32I:mode>"
2597 [(set (mem:BLK (scratch))
2598 (unspec:BLK
2599 [(unspec:<VM>
2600 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2601 (match_operand 4 "vector_length_operand" " rvl")
2602 (match_operand 5 "const_int_operand" " i")
2603 (reg:SI VL_REGNUM)
2604 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2605 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2606 (match_operand:RATIO32I 2 "register_operand" " vr")
2607 (match_operand:RATIO32 3 "register_operand" " vr")] ORDER))]
2608 "TARGET_VECTOR"
2609 "vs<order>xei<RATIO32I:sew>.v\t%3,(%z1),%2%p0"
2610 [(set_attr "type" "vst<order>x")
2611 (set_attr "mode" "<RATIO32:MODE>")])
2612
2613 (define_insn "@pred_indexed_<order>store<RATIO16:mode><RATIO16I:mode>"
2614 [(set (mem:BLK (scratch))
2615 (unspec:BLK
2616 [(unspec:<VM>
2617 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2618 (match_operand 4 "vector_length_operand" " rvl")
2619 (match_operand 5 "const_int_operand" " i")
2620 (reg:SI VL_REGNUM)
2621 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2622 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2623 (match_operand:RATIO16I 2 "register_operand" " vr")
2624 (match_operand:RATIO16 3 "register_operand" " vr")] ORDER))]
2625 "TARGET_VECTOR"
2626 "vs<order>xei<RATIO16I:sew>.v\t%3,(%z1),%2%p0"
2627 [(set_attr "type" "vst<order>x")
2628 (set_attr "mode" "<RATIO16:MODE>")])
2629
2630 (define_insn "@pred_indexed_<order>store<RATIO8:mode><RATIO8I:mode>"
2631 [(set (mem:BLK (scratch))
2632 (unspec:BLK
2633 [(unspec:<VM>
2634 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2635 (match_operand 4 "vector_length_operand" " rvl")
2636 (match_operand 5 "const_int_operand" " i")
2637 (reg:SI VL_REGNUM)
2638 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2639 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2640 (match_operand:RATIO8I 2 "register_operand" " vr")
2641 (match_operand:RATIO8 3 "register_operand" " vr")] ORDER))]
2642 "TARGET_VECTOR"
2643 "vs<order>xei<RATIO8I:sew>.v\t%3,(%z1),%2%p0"
2644 [(set_attr "type" "vst<order>x")
2645 (set_attr "mode" "<RATIO8:MODE>")])
2646
2647 (define_insn "@pred_indexed_<order>store<RATIO4:mode><RATIO4I:mode>"
2648 [(set (mem:BLK (scratch))
2649 (unspec:BLK
2650 [(unspec:<VM>
2651 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2652 (match_operand 4 "vector_length_operand" " rvl")
2653 (match_operand 5 "const_int_operand" " i")
2654 (reg:SI VL_REGNUM)
2655 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2656 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2657 (match_operand:RATIO4I 2 "register_operand" " vr")
2658 (match_operand:RATIO4 3 "register_operand" " vr")] ORDER))]
2659 "TARGET_VECTOR"
2660 "vs<order>xei<RATIO4I:sew>.v\t%3,(%z1),%2%p0"
2661 [(set_attr "type" "vst<order>x")
2662 (set_attr "mode" "<RATIO4:MODE>")])
2663
2664 (define_insn "@pred_indexed_<order>store<RATIO2:mode><RATIO2I:mode>"
2665 [(set (mem:BLK (scratch))
2666 (unspec:BLK
2667 [(unspec:<VM>
2668 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2669 (match_operand 4 "vector_length_operand" " rvl")
2670 (match_operand 5 "const_int_operand" " i")
2671 (reg:SI VL_REGNUM)
2672 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2673 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2674 (match_operand:RATIO2I 2 "register_operand" " vr")
2675 (match_operand:RATIO2 3 "register_operand" " vr")] ORDER))]
2676 "TARGET_VECTOR"
2677 "vs<order>xei<RATIO2I:sew>.v\t%3,(%z1),%2%p0"
2678 [(set_attr "type" "vst<order>x")
2679 (set_attr "mode" "<RATIO2:MODE>")])
2680
2681 (define_insn "@pred_indexed_<order>store<RATIO1:mode><RATIO1:mode>"
2682 [(set (mem:BLK (scratch))
2683 (unspec:BLK
2684 [(unspec:<VM>
2685 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
2686 (match_operand 4 "vector_length_operand" " rvl")
2687 (match_operand 5 "const_int_operand" " i")
2688 (reg:SI VL_REGNUM)
2689 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2690 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
2691 (match_operand:RATIO1 2 "register_operand" " vr")
2692 (match_operand:RATIO1 3 "register_operand" " vr")] ORDER))]
2693 "TARGET_VECTOR"
2694 "vs<order>xei<RATIO1:sew>.v\t%3,(%z1),%2%p0"
2695 [(set_attr "type" "vst<order>x")
2696 (set_attr "mode" "<RATIO1:MODE>")])
2697
2698 ;; -------------------------------------------------------------------------------
2699 ;; ---- Predicated integer binary operations
2700 ;; -------------------------------------------------------------------------------
2701 ;; Includes:
2702 ;; - 11.1 Vector Single-Width Integer Add and Subtract
2703 ;; - 11.4 Vector Integer Add-with-Carry/Subtract-with-Borrow Instructions
2704 ;; - 11.5 Vector Bitwise Logical Instructions
2705 ;; - 11.6 Vector Single-Width Bit Shift Instructions
2706 ;; - 11.9 Vector Integer Min/Max Instructions
2707 ;; - 11.10 Vector Single-Width Integer Multiply Instructions
2708 ;; - 11.11 Vector Integer Divide Instructions
2709 ;; -------------------------------------------------------------------------------
2710
2711 (define_insn "@pred_<optab><mode>"
2712 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr, vd, vd, vr, vr, vd, vd, vr, vr")
2713 (if_then_else:V_VLSI
2714 (unspec:<VM>
2715 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1, Wc1, vm, vm,Wc1,Wc1, vm, vm,Wc1,Wc1")
2716 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl, rvl,rvl,rvl,rvl,rvl,rvl,rvl,rvl,rvl")
2717 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
2718 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
2719 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
2720 (reg:SI VL_REGNUM)
2721 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2722 (any_int_binop:V_VLSI
2723 (match_operand:V_VLSI 3 "<binop_rhs1_predicate>" "<binop_rhs1_constraint>")
2724 (match_operand:V_VLSI 4 "<binop_rhs2_predicate>" "<binop_rhs2_constraint>"))
2725 (match_operand:V_VLSI 2 "vector_merge_operand" "vu,0,vu,0,vu,0,vu,0,vu,0,vu,0")))]
2726 "TARGET_VECTOR"
2727 "@
2728 v<insn>.vv\t%0,%3,%4%p1
2729 v<insn>.vv\t%0,%3,%4%p1
2730 v<insn>.vv\t%0,%3,%4%p1
2731 v<insn>.vv\t%0,%3,%4%p1
2732 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
2733 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
2734 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
2735 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
2736 v<binop_reverse_vi_variant_insn>\t%0,<binop_reverse_vi_variant_op>%p1
2737 v<binop_reverse_vi_variant_insn>\t%0,<binop_reverse_vi_variant_op>%p1
2738 v<binop_reverse_vi_variant_insn>\t%0,<binop_reverse_vi_variant_op>%p1
2739 v<binop_reverse_vi_variant_insn>\t%0,<binop_reverse_vi_variant_op>%p1"
2740 [(set_attr "type" "<int_binop_insn_type>")
2741 (set_attr "mode" "<MODE>")])
2742
2743 ;; vx instructions patterns.
2744 ;; Note: Unlike vv patterns, we should split them since they are variant.
2745 ;; For vsll.vx/vsra.vx/vsrl.vx the scalar mode should be Pmode whereas the
2746 ;; scalar mode is inner mode of the RVV mode for other vx patterns.
2747 (define_insn "@pred_<optab><mode>_scalar"
2748 [(set (match_operand:V_VLSI 0 "register_operand" "=vd,vd, vr, vr,vd,vd, vr, vr")
2749 (if_then_else:V_VLSI
2750 (unspec:<VM>
2751 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1,vm,vm,Wc1,Wc1")
2752 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl,rvl,rvl,rvl,rvl")
2753 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i")
2754 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i")
2755 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i")
2756 (reg:SI VL_REGNUM)
2757 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2758 (any_shift:V_VLSI
2759 (match_operand:V_VLSI 3 "register_operand" "vr,vr, vr, vr,vr,vr, vr, vr")
2760 (match_operand 4 "pmode_reg_or_uimm5_operand" " r, r, r, r, K, K, K, K"))
2761 (match_operand:V_VLSI 2 "vector_merge_operand" "vu, 0, vu, 0,vu, 0, vu, 0")))]
2762 "TARGET_VECTOR"
2763 "v<insn>.v%o4\t%0,%3,%4%p1"
2764 [(set_attr "type" "vshift")
2765 (set_attr "mode" "<MODE>")])
2766
2767 ;; Handle GET_MODE_INNER (mode) = QImode, HImode, SImode.
2768 (define_insn "@pred_<optab><mode>_scalar"
2769 [(set (match_operand:V_VLSI_QHS 0 "register_operand" "=vd,vd, vr, vr")
2770 (if_then_else:V_VLSI_QHS
2771 (unspec:<VM>
2772 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2773 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2774 (match_operand 6 "const_int_operand" " i, i, i, i")
2775 (match_operand 7 "const_int_operand" " i, i, i, i")
2776 (match_operand 8 "const_int_operand" " i, i, i, i")
2777 (reg:SI VL_REGNUM)
2778 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2779 (any_commutative_binop:V_VLSI_QHS
2780 (vec_duplicate:V_VLSI_QHS
2781 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
2782 (match_operand:V_VLSI_QHS 3 "register_operand" "vr,vr, vr, vr"))
2783 (match_operand:V_VLSI_QHS 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2784 "TARGET_VECTOR"
2785 "v<insn>.vx\t%0,%3,%z4%p1"
2786 [(set_attr "type" "<int_binop_insn_type>")
2787 (set_attr "mode" "<MODE>")])
2788
2789 (define_insn "@pred_<optab><mode>_scalar"
2790 [(set (match_operand:V_VLSI_QHS 0 "register_operand" "=vd,vd, vr, vr")
2791 (if_then_else:V_VLSI_QHS
2792 (unspec:<VM>
2793 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2794 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2795 (match_operand 6 "const_int_operand" " i, i, i, i")
2796 (match_operand 7 "const_int_operand" " i, i, i, i")
2797 (match_operand 8 "const_int_operand" " i, i, i, i")
2798 (reg:SI VL_REGNUM)
2799 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2800 (any_non_commutative_binop:V_VLSI_QHS
2801 (match_operand:V_VLSI_QHS 3 "register_operand" "vr,vr, vr, vr")
2802 (vec_duplicate:V_VLSI_QHS
2803 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ")))
2804 (match_operand:V_VLSI_QHS 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2805 "TARGET_VECTOR"
2806 "v<insn>.vx\t%0,%3,%z4%p1"
2807 [(set_attr "type" "<int_binop_insn_type>")
2808 (set_attr "mode" "<MODE>")])
2809
2810 (define_insn "@pred_sub<mode>_reverse_scalar"
2811 [(set (match_operand:V_VLSI_QHS 0 "register_operand" "=vd,vd, vr, vr")
2812 (if_then_else:V_VLSI_QHS
2813 (unspec:<VM>
2814 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2815 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2816 (match_operand 6 "const_int_operand" " i, i, i, i")
2817 (match_operand 7 "const_int_operand" " i, i, i, i")
2818 (match_operand 8 "const_int_operand" " i, i, i, i")
2819 (reg:SI VL_REGNUM)
2820 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2821 (minus:V_VLSI_QHS
2822 (vec_duplicate:V_VLSI_QHS
2823 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
2824 (match_operand:V_VLSI_QHS 3 "register_operand" "vr,vr, vr, vr"))
2825 (match_operand:V_VLSI_QHS 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2826 "TARGET_VECTOR"
2827 "vrsub.vx\t%0,%3,%z4%p1"
2828 [(set_attr "type" "vialu")
2829 (set_attr "mode" "<MODE>")])
2830
2831 ;; Handle GET_MODE_INNER (mode) = DImode. We need to split them since
2832 ;; we need to deal with SEW = 64 in RV32 system.
2833 (define_expand "@pred_<optab><mode>_scalar"
2834 [(set (match_operand:V_VLSI_D 0 "register_operand")
2835 (if_then_else:V_VLSI_D
2836 (unspec:<VM>
2837 [(match_operand:<VM> 1 "vector_mask_operand")
2838 (match_operand 5 "vector_length_operand")
2839 (match_operand 6 "const_int_operand")
2840 (match_operand 7 "const_int_operand")
2841 (match_operand 8 "const_int_operand")
2842 (reg:SI VL_REGNUM)
2843 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2844 (any_commutative_binop:V_VLSI_D
2845 (vec_duplicate:V_VLSI_D
2846 (match_operand:<VEL> 4 "reg_or_int_operand"))
2847 (match_operand:V_VLSI_D 3 "register_operand"))
2848 (match_operand:V_VLSI_D 2 "vector_merge_operand")))]
2849 "TARGET_VECTOR"
2850 {
2851 if (riscv_vector::sew64_scalar_helper (
2852 operands,
2853 /* scalar op */&operands[4],
2854 /* vl */operands[5],
2855 <MODE>mode,
2856 riscv_vector::has_vi_variant_p (<CODE>, operands[4]),
2857 [] (rtx *operands, rtx broadcast_scalar) {
2858 emit_insn (gen_pred_<optab><mode> (operands[0], operands[1],
2859 operands[2], operands[3], broadcast_scalar, operands[5],
2860 operands[6], operands[7], operands[8]));
2861 },
2862 (riscv_vector::avl_type) INTVAL (operands[8])))
2863 DONE;
2864 })
2865
2866 (define_insn "*pred_<optab><mode>_scalar"
2867 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
2868 (if_then_else:V_VLSI_D
2869 (unspec:<VM>
2870 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2871 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2872 (match_operand 6 "const_int_operand" " i, i, i, i")
2873 (match_operand 7 "const_int_operand" " i, i, i, i")
2874 (match_operand 8 "const_int_operand" " i, i, i, i")
2875 (reg:SI VL_REGNUM)
2876 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2877 (any_commutative_binop:V_VLSI_D
2878 (vec_duplicate:V_VLSI_D
2879 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
2880 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr"))
2881 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2882 "TARGET_VECTOR"
2883 "v<insn>.vx\t%0,%3,%z4%p1"
2884 [(set_attr "type" "<int_binop_insn_type>")
2885 (set_attr "mode" "<MODE>")])
2886
2887 (define_insn "*pred_<optab><mode>_extended_scalar"
2888 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
2889 (if_then_else:V_VLSI_D
2890 (unspec:<VM>
2891 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2892 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2893 (match_operand 6 "const_int_operand" " i, i, i, i")
2894 (match_operand 7 "const_int_operand" " i, i, i, i")
2895 (match_operand 8 "const_int_operand" " i, i, i, i")
2896 (reg:SI VL_REGNUM)
2897 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2898 (any_commutative_binop:V_VLSI_D
2899 (vec_duplicate:V_VLSI_D
2900 (sign_extend:<VEL>
2901 (match_operand:<VSUBEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ")))
2902 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr"))
2903 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2904 "TARGET_VECTOR && !TARGET_64BIT"
2905 "v<insn>.vx\t%0,%3,%z4%p1"
2906 [(set_attr "type" "<int_binop_insn_type>")
2907 (set_attr "mode" "<MODE>")])
2908
2909 (define_expand "@pred_<optab><mode>_scalar"
2910 [(set (match_operand:V_VLSI_D 0 "register_operand")
2911 (if_then_else:V_VLSI_D
2912 (unspec:<VM>
2913 [(match_operand:<VM> 1 "vector_mask_operand")
2914 (match_operand 5 "vector_length_operand")
2915 (match_operand 6 "const_int_operand")
2916 (match_operand 7 "const_int_operand")
2917 (match_operand 8 "const_int_operand")
2918 (reg:SI VL_REGNUM)
2919 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2920 (any_non_commutative_binop:V_VLSI_D
2921 (match_operand:V_VLSI_D 3 "register_operand")
2922 (vec_duplicate:V_VLSI_D
2923 (match_operand:<VEL> 4 "reg_or_int_operand")))
2924 (match_operand:V_VLSI_D 2 "vector_merge_operand")))]
2925 "TARGET_VECTOR"
2926 {
2927 if (riscv_vector::sew64_scalar_helper (
2928 operands,
2929 /* scalar op */&operands[4],
2930 /* vl */operands[5],
2931 <MODE>mode,
2932 riscv_vector::has_vi_variant_p (<CODE>, operands[4]),
2933 [] (rtx *operands, rtx broadcast_scalar) {
2934 emit_insn (gen_pred_<optab><mode> (operands[0], operands[1],
2935 operands[2], operands[3], broadcast_scalar, operands[5],
2936 operands[6], operands[7], operands[8]));
2937 },
2938 (riscv_vector::avl_type) INTVAL (operands[8])))
2939 DONE;
2940 })
2941
2942 (define_insn "*pred_<optab><mode>_scalar"
2943 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
2944 (if_then_else:V_VLSI_D
2945 (unspec:<VM>
2946 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2947 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2948 (match_operand 6 "const_int_operand" " i, i, i, i")
2949 (match_operand 7 "const_int_operand" " i, i, i, i")
2950 (match_operand 8 "const_int_operand" " i, i, i, i")
2951 (reg:SI VL_REGNUM)
2952 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2953 (any_non_commutative_binop:V_VLSI_D
2954 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr")
2955 (vec_duplicate:V_VLSI_D
2956 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ")))
2957 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2958 "TARGET_VECTOR"
2959 "v<insn>.vx\t%0,%3,%z4%p1"
2960 [(set_attr "type" "<int_binop_insn_type>")
2961 (set_attr "mode" "<MODE>")])
2962
2963 (define_insn "*pred_<optab><mode>_extended_scalar"
2964 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
2965 (if_then_else:V_VLSI_D
2966 (unspec:<VM>
2967 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
2968 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
2969 (match_operand 6 "const_int_operand" " i, i, i, i")
2970 (match_operand 7 "const_int_operand" " i, i, i, i")
2971 (match_operand 8 "const_int_operand" " i, i, i, i")
2972 (reg:SI VL_REGNUM)
2973 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2974 (any_non_commutative_binop:V_VLSI_D
2975 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr")
2976 (vec_duplicate:V_VLSI_D
2977 (sign_extend:<VEL>
2978 (match_operand:<VSUBEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))))
2979 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
2980 "TARGET_VECTOR && !TARGET_64BIT"
2981 "v<insn>.vx\t%0,%3,%z4%p1"
2982 [(set_attr "type" "<int_binop_insn_type>")
2983 (set_attr "mode" "<MODE>")])
2984
2985 (define_expand "@pred_sub<mode>_reverse_scalar"
2986 [(set (match_operand:V_VLSI_D 0 "register_operand")
2987 (if_then_else:V_VLSI_D
2988 (unspec:<VM>
2989 [(match_operand:<VM> 1 "vector_mask_operand")
2990 (match_operand 5 "vector_length_operand")
2991 (match_operand 6 "const_int_operand")
2992 (match_operand 7 "const_int_operand")
2993 (match_operand 8 "const_int_operand")
2994 (reg:SI VL_REGNUM)
2995 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
2996 (minus:V_VLSI_D
2997 (vec_duplicate:V_VLSI_D
2998 (match_operand:<VEL> 4 "reg_or_int_operand"))
2999 (match_operand:V_VLSI_D 3 "register_operand"))
3000 (match_operand:V_VLSI_D 2 "vector_merge_operand")))]
3001 "TARGET_VECTOR"
3002 {
3003 if (riscv_vector::sew64_scalar_helper (
3004 operands,
3005 /* scalar op */&operands[4],
3006 /* vl */operands[5],
3007 <MODE>mode,
3008 riscv_vector::neg_simm5_p (operands[4]),
3009 [] (rtx *operands, rtx broadcast_scalar) {
3010 emit_insn (gen_pred_sub<mode> (operands[0], operands[1],
3011 operands[2], broadcast_scalar, operands[3], operands[5],
3012 operands[6], operands[7], operands[8]));
3013 },
3014 (riscv_vector::avl_type) INTVAL (operands[8])))
3015 DONE;
3016 })
3017
3018 (define_insn "*pred_sub<mode>_reverse_scalar"
3019 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
3020 (if_then_else:V_VLSI_D
3021 (unspec:<VM>
3022 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3023 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3024 (match_operand 6 "const_int_operand" " i, i, i, i")
3025 (match_operand 7 "const_int_operand" " i, i, i, i")
3026 (match_operand 8 "const_int_operand" " i, i, i, i")
3027 (reg:SI VL_REGNUM)
3028 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3029 (minus:V_VLSI_D
3030 (vec_duplicate:V_VLSI_D
3031 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
3032 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr"))
3033 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3034 "TARGET_VECTOR"
3035 "vrsub.vx\t%0,%3,%z4%p1"
3036 [(set_attr "type" "vialu")
3037 (set_attr "mode" "<MODE>")])
3038
3039 (define_insn "*pred_sub<mode>_extended_reverse_scalar"
3040 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd,vd, vr, vr")
3041 (if_then_else:V_VLSI_D
3042 (unspec:<VM>
3043 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3044 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3045 (match_operand 6 "const_int_operand" " i, i, i, i")
3046 (match_operand 7 "const_int_operand" " i, i, i, i")
3047 (match_operand 8 "const_int_operand" " i, i, i, i")
3048 (reg:SI VL_REGNUM)
3049 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3050 (minus:V_VLSI_D
3051 (vec_duplicate:V_VLSI_D
3052 (sign_extend:<VEL>
3053 (match_operand:<VSUBEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ")))
3054 (match_operand:V_VLSI_D 3 "register_operand" "vr,vr, vr, vr"))
3055 (match_operand:V_VLSI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3056 "TARGET_VECTOR && !TARGET_64BIT"
3057 "vrsub.vx\t%0,%3,%z4%p1"
3058 [(set_attr "type" "vialu")
3059 (set_attr "mode" "<MODE>")])
3060
3061 ;; Multiply High instructions.
3062 (define_insn "@pred_mulh<v_su><mode>"
3063 [(set (match_operand:VFULLI 0 "register_operand" "=vd,vd, vr, vr")
3064 (if_then_else:VFULLI
3065 (unspec:<VM>
3066 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3067 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3068 (match_operand 6 "const_int_operand" " i, i, i, i")
3069 (match_operand 7 "const_int_operand" " i, i, i, i")
3070 (match_operand 8 "const_int_operand" " i, i, i, i")
3071 (reg:SI VL_REGNUM)
3072 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3073 (unspec:VFULLI
3074 [(match_operand:VFULLI 3 "register_operand" "vr,vr, vr, vr")
3075 (match_operand:VFULLI 4 "register_operand" "vr,vr, vr, vr")] VMULH)
3076 (match_operand:VFULLI 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3077 "TARGET_VECTOR"
3078 "vmulh<v_su>.vv\t%0,%3,%4%p1"
3079 [(set_attr "type" "vimul")
3080 (set_attr "mode" "<MODE>")])
3081
3082 (define_insn "@pred_mulh<v_su><mode>_scalar"
3083 [(set (match_operand:VI_QHS 0 "register_operand" "=vd,vd, vr, vr")
3084 (if_then_else:VI_QHS
3085 (unspec:<VM>
3086 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3087 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3088 (match_operand 6 "const_int_operand" " i, i, i, i")
3089 (match_operand 7 "const_int_operand" " i, i, i, i")
3090 (match_operand 8 "const_int_operand" " i, i, i, i")
3091 (reg:SI VL_REGNUM)
3092 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3093 (unspec:VI_QHS
3094 [(vec_duplicate:VI_QHS
3095 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
3096 (match_operand:VI_QHS 3 "register_operand" "vr,vr, vr, vr")] VMULH)
3097 (match_operand:VI_QHS 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3098 "TARGET_VECTOR"
3099 "vmulh<v_su>.vx\t%0,%3,%z4%p1"
3100 [(set_attr "type" "vimul")
3101 (set_attr "mode" "<MODE>")])
3102
3103 (define_expand "@pred_mulh<v_su><mode>_scalar"
3104 [(set (match_operand:VFULLI_D 0 "register_operand")
3105 (if_then_else:VFULLI_D
3106 (unspec:<VM>
3107 [(match_operand:<VM> 1 "vector_mask_operand")
3108 (match_operand 5 "vector_length_operand")
3109 (match_operand 6 "const_int_operand")
3110 (match_operand 7 "const_int_operand")
3111 (match_operand 8 "const_int_operand")
3112 (reg:SI VL_REGNUM)
3113 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3114 (unspec:VFULLI_D
3115 [(vec_duplicate:VFULLI_D
3116 (match_operand:<VEL> 4 "reg_or_int_operand"))
3117 (match_operand:VFULLI_D 3 "register_operand")] VMULH)
3118 (match_operand:VFULLI_D 2 "vector_merge_operand")))]
3119 "TARGET_VECTOR"
3120 {
3121 if (riscv_vector::sew64_scalar_helper (
3122 operands,
3123 /* scalar op */&operands[4],
3124 /* vl */operands[5],
3125 <MODE>mode,
3126 false,
3127 [] (rtx *operands, rtx broadcast_scalar) {
3128 emit_insn (gen_pred_mulh<v_su><mode> (operands[0], operands[1],
3129 operands[2], operands[3], broadcast_scalar, operands[5],
3130 operands[6], operands[7], operands[8]));
3131 },
3132 (riscv_vector::avl_type) INTVAL (operands[8])))
3133 DONE;
3134 })
3135
3136 (define_insn "*pred_mulh<v_su><mode>_scalar"
3137 [(set (match_operand:VFULLI_D 0 "register_operand" "=vd,vd, vr, vr")
3138 (if_then_else:VFULLI_D
3139 (unspec:<VM>
3140 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3141 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3142 (match_operand 6 "const_int_operand" " i, i, i, i")
3143 (match_operand 7 "const_int_operand" " i, i, i, i")
3144 (match_operand 8 "const_int_operand" " i, i, i, i")
3145 (reg:SI VL_REGNUM)
3146 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3147 (unspec:VFULLI_D
3148 [(vec_duplicate:VFULLI_D
3149 (match_operand:<VEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ"))
3150 (match_operand:VFULLI_D 3 "register_operand" "vr,vr, vr, vr")] VMULH)
3151 (match_operand:VFULLI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3152 "TARGET_VECTOR"
3153 "vmulh<v_su>.vx\t%0,%3,%z4%p1"
3154 [(set_attr "type" "vimul")
3155 (set_attr "mode" "<MODE>")])
3156
3157 (define_insn "*pred_mulh<v_su><mode>_extended_scalar"
3158 [(set (match_operand:VFULLI_D 0 "register_operand" "=vd,vd, vr, vr")
3159 (if_then_else:VFULLI_D
3160 (unspec:<VM>
3161 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3162 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3163 (match_operand 6 "const_int_operand" " i, i, i, i")
3164 (match_operand 7 "const_int_operand" " i, i, i, i")
3165 (match_operand 8 "const_int_operand" " i, i, i, i")
3166 (reg:SI VL_REGNUM)
3167 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3168 (unspec:VFULLI_D
3169 [(vec_duplicate:VFULLI_D
3170 (sign_extend:<VEL>
3171 (match_operand:<VSUBEL> 4 "reg_or_0_operand" "rJ,rJ, rJ, rJ")))
3172 (match_operand:VFULLI_D 3 "register_operand" "vr,vr, vr, vr")] VMULH)
3173 (match_operand:VFULLI_D 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3174 "TARGET_VECTOR && !TARGET_64BIT"
3175 "vmulh<v_su>.vx\t%0,%3,%z4%p1"
3176 [(set_attr "type" "vimul")
3177 (set_attr "mode" "<MODE>")])
3178
3179 ;; Vector Integer Add-with-Carry / Subtract-with-Borrow Instructions
3180 (define_insn "@pred_adc<mode>"
3181 [(set (match_operand:VI 0 "register_operand" "=vd,vd,vd,vd")
3182 (if_then_else:VI
3183 (unspec:<VM>
3184 [(match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
3185 (match_operand 6 "const_int_operand" " i, i, i, i")
3186 (match_operand 7 "const_int_operand" " i, i, i, i")
3187 (reg:SI VL_REGNUM)
3188 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3189 (unspec:VI
3190 [(plus:VI
3191 (match_operand:VI 2 "register_operand" "vr,vr,vr,vr")
3192 (match_operand:VI 3 "vector_arith_operand" "vr,vr,vi,vi"))
3193 (match_operand:<VM> 4 "register_operand" "vm,vm,vm,vm")] UNSPEC_VADC)
3194 (match_operand:VI 1 "vector_merge_operand" "vu, 0,vu, 0")))]
3195 "TARGET_VECTOR"
3196 "vadc.v%o3m\t%0,%2,%v3,%4"
3197 [(set_attr "type" "vicalu")
3198 (set_attr "mode" "<MODE>")
3199 (set_attr "merge_op_idx" "1")
3200 (set_attr "vl_op_idx" "5")
3201 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3202 (set (attr "avl_type_idx") (const_int 7))])
3203
3204 (define_insn "@pred_sbc<mode>"
3205 [(set (match_operand:VI 0 "register_operand" "=vd,vd")
3206 (if_then_else:VI
3207 (unspec:<VM>
3208 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3209 (match_operand 6 "const_int_operand" " i, i")
3210 (match_operand 7 "const_int_operand" " i, i")
3211 (reg:SI VL_REGNUM)
3212 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3213 (unspec:VI
3214 [(minus:VI
3215 (match_operand:VI 2 "register_operand" "vr,vr")
3216 (match_operand:VI 3 "register_operand" "vr,vr"))
3217 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VSBC)
3218 (match_operand:VI 1 "vector_merge_operand" "vu, 0")))]
3219 "TARGET_VECTOR"
3220 "vsbc.vvm\t%0,%2,%3,%4"
3221 [(set_attr "type" "vicalu")
3222 (set_attr "mode" "<MODE>")
3223 (set_attr "merge_op_idx" "1")
3224 (set_attr "vl_op_idx" "5")
3225 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3226 (set (attr "avl_type_idx") (const_int 7))])
3227
3228 (define_insn "@pred_adc<mode>_scalar"
3229 [(set (match_operand:VI_QHS 0 "register_operand" "=vd,vd")
3230 (if_then_else:VI_QHS
3231 (unspec:<VM>
3232 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3233 (match_operand 6 "const_int_operand" " i, i")
3234 (match_operand 7 "const_int_operand" " i, i")
3235 (reg:SI VL_REGNUM)
3236 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3237 (unspec:VI_QHS
3238 [(plus:VI_QHS
3239 (vec_duplicate:VI_QHS
3240 (match_operand:<VEL> 3 "register_operand" " r, r"))
3241 (match_operand:VI_QHS 2 "register_operand" "vr,vr"))
3242 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VADC)
3243 (match_operand:VI_QHS 1 "vector_merge_operand" "vu, 0")))]
3244 "TARGET_VECTOR"
3245 "vadc.vxm\t%0,%2,%3,%4"
3246 [(set_attr "type" "vicalu")
3247 (set_attr "mode" "<MODE>")
3248 (set_attr "merge_op_idx" "1")
3249 (set_attr "vl_op_idx" "5")
3250 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3251 (set (attr "avl_type_idx") (const_int 7))])
3252
3253 (define_insn "@pred_sbc<mode>_scalar"
3254 [(set (match_operand:VI_QHS 0 "register_operand" "=vd,vd")
3255 (if_then_else:VI_QHS
3256 (unspec:<VM>
3257 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3258 (match_operand 6 "const_int_operand" " i, i")
3259 (match_operand 7 "const_int_operand" " i, i")
3260 (reg:SI VL_REGNUM)
3261 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3262 (unspec:VI_QHS
3263 [(minus:VI_QHS
3264 (match_operand:VI_QHS 2 "register_operand" "vr,vr")
3265 (vec_duplicate:VI_QHS
3266 (match_operand:<VEL> 3 "reg_or_0_operand" "rJ,rJ")))
3267 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VSBC)
3268 (match_operand:VI_QHS 1 "vector_merge_operand" "vu, 0")))]
3269 "TARGET_VECTOR"
3270 "vsbc.vxm\t%0,%2,%z3,%4"
3271 [(set_attr "type" "vicalu")
3272 (set_attr "mode" "<MODE>")
3273 (set_attr "merge_op_idx" "1")
3274 (set_attr "vl_op_idx" "5")
3275 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3276 (set (attr "avl_type_idx") (const_int 7))])
3277
3278 (define_expand "@pred_adc<mode>_scalar"
3279 [(set (match_operand:VI_D 0 "register_operand")
3280 (if_then_else:VI_D
3281 (unspec:<VM>
3282 [(match_operand 5 "vector_length_operand")
3283 (match_operand 6 "const_int_operand")
3284 (match_operand 7 "const_int_operand")
3285 (reg:SI VL_REGNUM)
3286 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3287 (unspec:VI_D
3288 [(plus:VI_D
3289 (vec_duplicate:VI_D
3290 (match_operand:<VEL> 3 "reg_or_int_operand"))
3291 (match_operand:VI_D 2 "register_operand"))
3292 (match_operand:<VM> 4 "register_operand")] UNSPEC_VADC)
3293 (match_operand:VI_D 1 "vector_merge_operand")))]
3294 "TARGET_VECTOR"
3295 {
3296 if (riscv_vector::sew64_scalar_helper (
3297 operands,
3298 /* scalar op */&operands[3],
3299 /* vl */operands[5],
3300 <MODE>mode,
3301 riscv_vector::simm5_p (operands[3]),
3302 [] (rtx *operands, rtx broadcast_scalar) {
3303 emit_insn (gen_pred_adc<mode> (operands[0], operands[1],
3304 operands[2], broadcast_scalar, operands[4], operands[5],
3305 operands[6], operands[7]));
3306 },
3307 (riscv_vector::avl_type) INTVAL (operands[7])))
3308 DONE;
3309 })
3310
3311 (define_insn "*pred_adc<mode>_scalar"
3312 [(set (match_operand:VI_D 0 "register_operand" "=vd,vd")
3313 (if_then_else:VI_D
3314 (unspec:<VM>
3315 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3316 (match_operand 6 "const_int_operand" " i, i")
3317 (match_operand 7 "const_int_operand" " i, i")
3318 (reg:SI VL_REGNUM)
3319 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3320 (unspec:VI_D
3321 [(plus:VI_D
3322 (vec_duplicate:VI_D
3323 (match_operand:<VEL> 3 "reg_or_0_operand" "rJ,rJ"))
3324 (match_operand:VI_D 2 "register_operand" "vr,vr"))
3325 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VADC)
3326 (match_operand:VI_D 1 "vector_merge_operand" "vu, 0")))]
3327 "TARGET_VECTOR"
3328 "vadc.vxm\t%0,%2,%z3,%4"
3329 [(set_attr "type" "vicalu")
3330 (set_attr "mode" "<MODE>")
3331 (set_attr "merge_op_idx" "1")
3332 (set_attr "vl_op_idx" "5")
3333 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3334 (set (attr "avl_type_idx") (const_int 7))])
3335
3336 (define_insn "*pred_adc<mode>_extended_scalar"
3337 [(set (match_operand:VI_D 0 "register_operand" "=vd,vd")
3338 (if_then_else:VI_D
3339 (unspec:<VM>
3340 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3341 (match_operand 6 "const_int_operand" " i, i")
3342 (match_operand 7 "const_int_operand" " i, i")
3343 (reg:SI VL_REGNUM)
3344 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3345 (unspec:VI_D
3346 [(plus:VI_D
3347 (vec_duplicate:VI_D
3348 (sign_extend:<VEL>
3349 (match_operand:<VSUBEL> 3 "reg_or_0_operand" "rJ,rJ")))
3350 (match_operand:VI_D 2 "register_operand" "vr,vr"))
3351 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VADC)
3352 (match_operand:VI_D 1 "vector_merge_operand" "vu, 0")))]
3353 "TARGET_VECTOR && !TARGET_64BIT"
3354 "vadc.vxm\t%0,%2,%z3,%4"
3355 [(set_attr "type" "vicalu")
3356 (set_attr "mode" "<MODE>")
3357 (set_attr "merge_op_idx" "1")
3358 (set_attr "vl_op_idx" "5")
3359 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3360 (set (attr "avl_type_idx") (const_int 7))])
3361
3362 (define_expand "@pred_sbc<mode>_scalar"
3363 [(set (match_operand:VI_D 0 "register_operand")
3364 (if_then_else:VI_D
3365 (unspec:<VM>
3366 [(match_operand 5 "vector_length_operand")
3367 (match_operand 6 "const_int_operand")
3368 (match_operand 7 "const_int_operand")
3369 (reg:SI VL_REGNUM)
3370 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3371 (unspec:VI_D
3372 [(minus:VI_D
3373 (match_operand:VI_D 2 "register_operand")
3374 (vec_duplicate:VI_D
3375 (match_operand:<VEL> 3 "reg_or_int_operand")))
3376 (match_operand:<VM> 4 "register_operand")] UNSPEC_VSBC)
3377 (match_operand:VI_D 1 "vector_merge_operand")))]
3378 "TARGET_VECTOR"
3379 {
3380 if (riscv_vector::sew64_scalar_helper (
3381 operands,
3382 /* scalar op */&operands[3],
3383 /* vl */operands[5],
3384 <MODE>mode,
3385 false,
3386 [] (rtx *operands, rtx broadcast_scalar) {
3387 emit_insn (gen_pred_sbc<mode> (operands[0], operands[1],
3388 operands[2], broadcast_scalar, operands[4], operands[5],
3389 operands[6], operands[7]));
3390 },
3391 (riscv_vector::avl_type) INTVAL (operands[7])))
3392 DONE;
3393 })
3394
3395 (define_insn "*pred_sbc<mode>_scalar"
3396 [(set (match_operand:VI_D 0 "register_operand" "=vd,vd")
3397 (if_then_else:VI_D
3398 (unspec:<VM>
3399 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3400 (match_operand 6 "const_int_operand" " i, i")
3401 (match_operand 7 "const_int_operand" " i, i")
3402 (reg:SI VL_REGNUM)
3403 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3404 (unspec:VI_D
3405 [(minus:VI_D
3406 (match_operand:VI_D 2 "register_operand" "vr,vr")
3407 (vec_duplicate:VI_D
3408 (match_operand:<VEL> 3 "reg_or_0_operand" "rJ,rJ")))
3409 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VSBC)
3410 (match_operand:VI_D 1 "vector_merge_operand" "vu, 0")))]
3411 "TARGET_VECTOR"
3412 "vsbc.vxm\t%0,%2,%z3,%4"
3413 [(set_attr "type" "vicalu")
3414 (set_attr "mode" "<MODE>")
3415 (set_attr "merge_op_idx" "1")
3416 (set_attr "vl_op_idx" "5")
3417 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3418 (set (attr "avl_type_idx") (const_int 7))])
3419
3420 (define_insn "*pred_sbc<mode>_extended_scalar"
3421 [(set (match_operand:VI_D 0 "register_operand" "=vd,vd")
3422 (if_then_else:VI_D
3423 (unspec:<VM>
3424 [(match_operand 5 "vector_length_operand" "rvl,rvl")
3425 (match_operand 6 "const_int_operand" " i, i")
3426 (match_operand 7 "const_int_operand" " i, i")
3427 (reg:SI VL_REGNUM)
3428 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3429 (unspec:VI_D
3430 [(minus:VI_D
3431 (match_operand:VI_D 2 "register_operand" "vr,vr")
3432 (vec_duplicate:VI_D
3433 (sign_extend:<VEL>
3434 (match_operand:<VSUBEL> 3 "reg_or_0_operand" "rJ,rJ"))))
3435 (match_operand:<VM> 4 "register_operand" "vm,vm")] UNSPEC_VSBC)
3436 (match_operand:VI_D 1 "vector_merge_operand" "vu, 0")))]
3437 "TARGET_VECTOR && !TARGET_64BIT"
3438 "vsbc.vxm\t%0,%2,%z3,%4"
3439 [(set_attr "type" "vicalu")
3440 (set_attr "mode" "<MODE>")
3441 (set_attr "merge_op_idx" "1")
3442 (set_attr "vl_op_idx" "5")
3443 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
3444 (set (attr "avl_type_idx") (const_int 7))])
3445
3446 (define_insn "@pred_madc<mode>"
3447 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr, &vr")
3448 (unspec:<VM>
3449 [(plus:VI
3450 (match_operand:VI 1 "register_operand" " %0, vr, vr")
3451 (match_operand:VI 2 "vector_arith_operand" "vrvi, vr, vi"))
3452 (match_operand:<VM> 3 "register_operand" " vm, vm, vm")
3453 (unspec:<VM>
3454 [(match_operand 4 "vector_length_operand" " rvl, rvl, rvl")
3455 (match_operand 5 "const_int_operand" " i, i, i")
3456 (reg:SI VL_REGNUM)
3457 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMADC))]
3458 "TARGET_VECTOR"
3459 "vmadc.v%o2m\t%0,%1,%v2,%3"
3460 [(set_attr "type" "vicalu")
3461 (set_attr "mode" "<MODE>")
3462 (set_attr "vl_op_idx" "4")
3463 (set (attr "avl_type_idx") (const_int 5))
3464 (set_attr "spec_restriction" "thv,none,none")])
3465
3466 (define_insn "@pred_msbc<mode>"
3467 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr")
3468 (unspec:<VM>
3469 [(minus:VI
3470 (match_operand:VI 1 "register_operand" " 0, vr, vr")
3471 (match_operand:VI 2 "register_operand" " vr, 0, vr"))
3472 (match_operand:<VM> 3 "register_operand" " vm, vm, vm")
3473 (unspec:<VM>
3474 [(match_operand 4 "vector_length_operand" "rvl,rvl, rvl")
3475 (match_operand 5 "const_int_operand" " i, i, i")
3476 (reg:SI VL_REGNUM)
3477 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMSBC))]
3478 "TARGET_VECTOR"
3479 "vmsbc.vvm\t%0,%1,%2,%3"
3480 [(set_attr "type" "vicalu")
3481 (set_attr "mode" "<MODE>")
3482 (set_attr "vl_op_idx" "4")
3483 (set (attr "avl_type_idx") (const_int 5))
3484 (set_attr "spec_restriction" "thv,thv,none")])
3485
3486 (define_insn "@pred_madc<mode>_scalar"
3487 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3488 (unspec:<VM>
3489 [(plus:VI_QHS
3490 (vec_duplicate:VI_QHS
3491 (match_operand:<VEL> 2 "register_operand" " r, r"))
3492 (match_operand:VI_QHS 1 "register_operand" " 0, vr"))
3493 (match_operand:<VM> 3 "register_operand" " vm, vm")
3494 (unspec:<VM>
3495 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3496 (match_operand 5 "const_int_operand" " i, i")
3497 (reg:SI VL_REGNUM)
3498 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMADC))]
3499 "TARGET_VECTOR"
3500 "vmadc.vxm\t%0,%1,%2,%3"
3501 [(set_attr "type" "vicalu")
3502 (set_attr "mode" "<MODE>")
3503 (set_attr "vl_op_idx" "4")
3504 (set (attr "avl_type_idx") (const_int 5))
3505 (set_attr "spec_restriction" "thv,none")])
3506
3507 (define_insn "@pred_msbc<mode>_scalar"
3508 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3509 (unspec:<VM>
3510 [(minus:VI_QHS
3511 (vec_duplicate:VI_QHS
3512 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3513 (match_operand:VI_QHS 1 "register_operand" " 0, vr"))
3514 (match_operand:<VM> 3 "register_operand" " vm, vm")
3515 (unspec:<VM>
3516 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3517 (match_operand 5 "const_int_operand" " i, i")
3518 (reg:SI VL_REGNUM)
3519 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMSBC))]
3520 "TARGET_VECTOR"
3521 "vmsbc.vxm\t%0,%1,%z2,%3"
3522 [(set_attr "type" "vicalu")
3523 (set_attr "mode" "<MODE>")
3524 (set_attr "vl_op_idx" "4")
3525 (set (attr "avl_type_idx") (const_int 5))
3526 (set_attr "spec_restriction" "thv,none")])
3527
3528 (define_expand "@pred_madc<mode>_scalar"
3529 [(set (match_operand:<VM> 0 "register_operand")
3530 (unspec:<VM>
3531 [(plus:VI_D
3532 (vec_duplicate:VI_D
3533 (match_operand:<VEL> 2 "reg_or_int_operand"))
3534 (match_operand:VI_D 1 "register_operand"))
3535 (match_operand:<VM> 3 "register_operand")
3536 (unspec:<VM>
3537 [(match_operand 4 "vector_length_operand")
3538 (match_operand 5 "const_int_operand")
3539 (reg:SI VL_REGNUM)
3540 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMADC))]
3541 "TARGET_VECTOR"
3542 {
3543 if (riscv_vector::sew64_scalar_helper (
3544 operands,
3545 /* scalar op */&operands[2],
3546 /* vl */operands[4],
3547 <MODE>mode,
3548 riscv_vector::simm5_p (operands[2]),
3549 [] (rtx *operands, rtx broadcast_scalar) {
3550 emit_insn (gen_pred_madc<mode> (operands[0], operands[1],
3551 broadcast_scalar, operands[3], operands[4], operands[5]));
3552 },
3553 (riscv_vector::avl_type) INTVAL (operands[5])))
3554 DONE;
3555 })
3556
3557 (define_insn "*pred_madc<mode>_scalar"
3558 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3559 (unspec:<VM>
3560 [(plus:VI_D
3561 (vec_duplicate:VI_D
3562 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3563 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3564 (match_operand:<VM> 3 "register_operand" " vm, vm")
3565 (unspec:<VM>
3566 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3567 (match_operand 5 "const_int_operand" " i, i")
3568 (reg:SI VL_REGNUM)
3569 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMADC))]
3570 "TARGET_VECTOR"
3571 "vmadc.vxm\t%0,%1,%z2,%3"
3572 [(set_attr "type" "vicalu")
3573 (set_attr "mode" "<MODE>")
3574 (set_attr "vl_op_idx" "4")
3575 (set (attr "avl_type_idx") (const_int 5))
3576 (set_attr "spec_restriction" "thv,none")])
3577
3578 (define_insn "*pred_madc<mode>_extended_scalar"
3579 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3580 (unspec:<VM>
3581 [(plus:VI_D
3582 (vec_duplicate:VI_D
3583 (sign_extend:<VEL>
3584 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
3585 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3586 (match_operand:<VM> 3 "register_operand" " vm, vm")
3587 (unspec:<VM>
3588 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3589 (match_operand 5 "const_int_operand" " i, i")
3590 (reg:SI VL_REGNUM)
3591 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMADC))]
3592 "TARGET_VECTOR && !TARGET_64BIT"
3593 "vmadc.vxm\t%0,%1,%z2,%3"
3594 [(set_attr "type" "vicalu")
3595 (set_attr "mode" "<MODE>")
3596 (set_attr "vl_op_idx" "4")
3597 (set (attr "avl_type_idx") (const_int 5))
3598 (set_attr "spec_restriction" "thv,none")])
3599
3600 (define_expand "@pred_msbc<mode>_scalar"
3601 [(set (match_operand:<VM> 0 "register_operand")
3602 (unspec:<VM>
3603 [(minus:VI_D
3604 (vec_duplicate:VI_D
3605 (match_operand:<VEL> 2 "reg_or_int_operand"))
3606 (match_operand:VI_D 1 "register_operand"))
3607 (match_operand:<VM> 3 "register_operand")
3608 (unspec:<VM>
3609 [(match_operand 4 "vector_length_operand")
3610 (match_operand 5 "const_int_operand")
3611 (reg:SI VL_REGNUM)
3612 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMSBC))]
3613 "TARGET_VECTOR"
3614 {
3615 if (riscv_vector::sew64_scalar_helper (
3616 operands,
3617 /* scalar op */&operands[2],
3618 /* vl */operands[4],
3619 <MODE>mode,
3620 false,
3621 [] (rtx *operands, rtx broadcast_scalar) {
3622 emit_insn (gen_pred_msbc<mode> (operands[0], operands[1],
3623 broadcast_scalar, operands[3], operands[4], operands[5]));
3624 },
3625 (riscv_vector::avl_type) INTVAL (operands[5])))
3626 DONE;
3627 })
3628
3629 (define_insn "*pred_msbc<mode>_scalar"
3630 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3631 (unspec:<VM>
3632 [(minus:VI_D
3633 (vec_duplicate:VI_D
3634 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3635 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3636 (match_operand:<VM> 3 "register_operand" " vm, vm")
3637 (unspec:<VM>
3638 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3639 (match_operand 5 "const_int_operand" " i, i")
3640 (reg:SI VL_REGNUM)
3641 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMSBC))]
3642 "TARGET_VECTOR"
3643 "vmsbc.vxm\t%0,%1,%z2,%3"
3644 [(set_attr "type" "vicalu")
3645 (set_attr "mode" "<MODE>")
3646 (set_attr "vl_op_idx" "4")
3647 (set (attr "avl_type_idx") (const_int 5))
3648 (set_attr "spec_restriction" "thv,none")])
3649
3650 (define_insn "*pred_msbc<mode>_extended_scalar"
3651 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3652 (unspec:<VM>
3653 [(minus:VI_D
3654 (vec_duplicate:VI_D
3655 (sign_extend:<VEL>
3656 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
3657 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3658 (match_operand:<VM> 3 "register_operand" " vm, vm")
3659 (unspec:<VM>
3660 [(match_operand 4 "vector_length_operand" "rvl, rvl")
3661 (match_operand 5 "const_int_operand" " i, i")
3662 (reg:SI VL_REGNUM)
3663 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_VMSBC))]
3664 "TARGET_VECTOR && !TARGET_64BIT"
3665 "vmsbc.vxm\t%0,%1,%z2,%3"
3666 [(set_attr "type" "vicalu")
3667 (set_attr "mode" "<MODE>")
3668 (set_attr "vl_op_idx" "4")
3669 (set (attr "avl_type_idx") (const_int 5))
3670 (set_attr "spec_restriction" "thv,none")])
3671
3672 (define_insn "@pred_madc<mode>_overflow"
3673 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr, &vr")
3674 (unspec:<VM>
3675 [(plus:VI
3676 (match_operand:VI 1 "register_operand" " %0, vr, vr")
3677 (match_operand:VI 2 "vector_arith_operand" "vrvi, vr, vi"))
3678 (unspec:<VM>
3679 [(match_operand 3 "vector_length_operand" " rvl, rvl, rvl")
3680 (match_operand 4 "const_int_operand" " i, i, i")
3681 (reg:SI VL_REGNUM)
3682 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3683 "TARGET_VECTOR"
3684 "vmadc.v%o2\t%0,%1,%v2"
3685 [(set_attr "type" "vicalu")
3686 (set_attr "mode" "<MODE>")
3687 (set_attr "vl_op_idx" "3")
3688 (set (attr "avl_type_idx") (const_int 4))
3689 (set_attr "spec_restriction" "thv,none,none")])
3690
3691 (define_insn "@pred_msbc<mode>_overflow"
3692 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
3693 (unspec:<VM>
3694 [(minus:VI
3695 (match_operand:VI 1 "register_operand" " 0, vr, vr, vr")
3696 (match_operand:VI 2 "register_operand" " vr, 0, vr, vi"))
3697 (unspec:<VM>
3698 [(match_operand 3 "vector_length_operand" " rvl, rvl, rvl, rvl")
3699 (match_operand 4 "const_int_operand" " i, i, i, i")
3700 (reg:SI VL_REGNUM)
3701 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3702 "TARGET_VECTOR"
3703 "vmsbc.vv\t%0,%1,%2"
3704 [(set_attr "type" "vicalu")
3705 (set_attr "mode" "<MODE>")
3706 (set_attr "vl_op_idx" "3")
3707 (set (attr "avl_type_idx") (const_int 4))
3708 (set_attr "spec_restriction" "thv,thv,none,none")])
3709
3710 (define_insn "@pred_madc<mode>_overflow_scalar"
3711 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3712 (unspec:<VM>
3713 [(plus:VI_QHS
3714 (vec_duplicate:VI_QHS
3715 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3716 (match_operand:VI_QHS 1 "register_operand" " 0, vr"))
3717 (unspec:<VM>
3718 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3719 (match_operand 4 "const_int_operand" " i, i")
3720 (reg:SI VL_REGNUM)
3721 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3722 "TARGET_VECTOR"
3723 "vmadc.vx\t%0,%1,%z2"
3724 [(set_attr "type" "vicalu")
3725 (set_attr "mode" "<MODE>")
3726 (set_attr "vl_op_idx" "3")
3727 (set (attr "avl_type_idx") (const_int 4))
3728 (set_attr "spec_restriction" "thv,none")])
3729
3730 (define_insn "@pred_msbc<mode>_overflow_scalar"
3731 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3732 (unspec:<VM>
3733 [(minus:VI_QHS
3734 (vec_duplicate:VI_QHS
3735 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3736 (match_operand:VI_QHS 1 "register_operand" " 0, vr"))
3737 (unspec:<VM>
3738 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3739 (match_operand 4 "const_int_operand" " i, i")
3740 (reg:SI VL_REGNUM)
3741 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3742 "TARGET_VECTOR"
3743 "vmsbc.vx\t%0,%1,%z2"
3744 [(set_attr "type" "vicalu")
3745 (set_attr "mode" "<MODE>")
3746 (set_attr "vl_op_idx" "3")
3747 (set (attr "avl_type_idx") (const_int 4))
3748 (set_attr "spec_restriction" "thv,none")])
3749
3750 (define_expand "@pred_madc<mode>_overflow_scalar"
3751 [(set (match_operand:<VM> 0 "register_operand")
3752 (unspec:<VM>
3753 [(plus:VI_D
3754 (vec_duplicate:VI_D
3755 (match_operand:<VEL> 2 "reg_or_int_operand"))
3756 (match_operand:VI_D 1 "register_operand"))
3757 (unspec:<VM>
3758 [(match_operand 3 "vector_length_operand")
3759 (match_operand 4 "const_int_operand")
3760 (reg:SI VL_REGNUM)
3761 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3762 "TARGET_VECTOR"
3763 {
3764 if (riscv_vector::sew64_scalar_helper (
3765 operands,
3766 /* scalar op */&operands[2],
3767 /* vl */operands[3],
3768 <MODE>mode,
3769 riscv_vector::simm5_p (operands[2]),
3770 [] (rtx *operands, rtx broadcast_scalar) {
3771 emit_insn (gen_pred_madc<mode>_overflow (operands[0], operands[1],
3772 broadcast_scalar, operands[3], operands[4]));
3773 },
3774 (riscv_vector::avl_type) INTVAL (operands[4])))
3775 DONE;
3776 })
3777
3778 (define_insn "*pred_madc<mode>_overflow_scalar"
3779 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3780 (unspec:<VM>
3781 [(plus:VI_D
3782 (vec_duplicate:VI_D
3783 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3784 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3785 (unspec:<VM>
3786 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3787 (match_operand 4 "const_int_operand" " i, i")
3788 (reg:SI VL_REGNUM)
3789 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3790 "TARGET_VECTOR"
3791 "vmadc.vx\t%0,%1,%z2"
3792 [(set_attr "type" "vicalu")
3793 (set_attr "mode" "<MODE>")
3794 (set_attr "vl_op_idx" "3")
3795 (set (attr "avl_type_idx") (const_int 4))
3796 (set_attr "spec_restriction" "thv,none")])
3797
3798 (define_insn "*pred_madc<mode>_overflow_extended_scalar"
3799 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3800 (unspec:<VM>
3801 [(plus:VI_D
3802 (vec_duplicate:VI_D
3803 (sign_extend:<VEL>
3804 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
3805 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3806 (unspec:<VM>
3807 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3808 (match_operand 4 "const_int_operand" " i, i")
3809 (reg:SI VL_REGNUM)
3810 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3811 "TARGET_VECTOR && !TARGET_64BIT"
3812 "vmadc.vx\t%0,%1,%z2"
3813 [(set_attr "type" "vicalu")
3814 (set_attr "mode" "<MODE>")
3815 (set_attr "vl_op_idx" "3")
3816 (set (attr "avl_type_idx") (const_int 4))
3817 (set_attr "spec_restriction" "thv,none")])
3818
3819 (define_expand "@pred_msbc<mode>_overflow_scalar"
3820 [(set (match_operand:<VM> 0 "register_operand")
3821 (unspec:<VM>
3822 [(minus:VI_D
3823 (vec_duplicate:VI_D
3824 (match_operand:<VEL> 2 "reg_or_int_operand"))
3825 (match_operand:VI_D 1 "register_operand"))
3826 (unspec:<VM>
3827 [(match_operand 3 "vector_length_operand")
3828 (match_operand 4 "const_int_operand")
3829 (reg:SI VL_REGNUM)
3830 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3831 "TARGET_VECTOR"
3832 {
3833 if (riscv_vector::sew64_scalar_helper (
3834 operands,
3835 /* scalar op */&operands[2],
3836 /* vl */operands[3],
3837 <MODE>mode,
3838 false,
3839 [] (rtx *operands, rtx broadcast_scalar) {
3840 emit_insn (gen_pred_msbc<mode>_overflow (operands[0], operands[1],
3841 broadcast_scalar, operands[3], operands[4]));
3842 },
3843 (riscv_vector::avl_type) INTVAL (operands[4])))
3844 DONE;
3845 })
3846
3847 (define_insn "*pred_msbc<mode>_overflow_scalar"
3848 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3849 (unspec:<VM>
3850 [(minus:VI_D
3851 (vec_duplicate:VI_D
3852 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
3853 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3854 (unspec:<VM>
3855 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3856 (match_operand 4 "const_int_operand" " i, i")
3857 (reg:SI VL_REGNUM)
3858 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3859 "TARGET_VECTOR"
3860 "vmsbc.vx\t%0,%1,%z2"
3861 [(set_attr "type" "vicalu")
3862 (set_attr "mode" "<MODE>")
3863 (set_attr "vl_op_idx" "3")
3864 (set (attr "avl_type_idx") (const_int 4))
3865 (set_attr "spec_restriction" "thv,none")])
3866
3867 (define_insn "*pred_msbc<mode>_overflow_extended_scalar"
3868 [(set (match_operand:<VM> 0 "register_operand" "=vr, &vr")
3869 (unspec:<VM>
3870 [(minus:VI_D
3871 (vec_duplicate:VI_D
3872 (sign_extend:<VEL>
3873 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
3874 (match_operand:VI_D 1 "register_operand" " 0, vr"))
3875 (unspec:<VM>
3876 [(match_operand 3 "vector_length_operand" "rvl, rvl")
3877 (match_operand 4 "const_int_operand" " i, i")
3878 (reg:SI VL_REGNUM)
3879 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)] UNSPEC_OVERFLOW))]
3880 "TARGET_VECTOR && !TARGET_64BIT"
3881 "vmsbc.vx\t%0,%1,%z2"
3882 [(set_attr "type" "vicalu")
3883 (set_attr "mode" "<MODE>")
3884 (set_attr "vl_op_idx" "3")
3885 (set (attr "avl_type_idx") (const_int 4))
3886 (set_attr "spec_restriction" "thv,none")])
3887
3888 ;; -------------------------------------------------------------------------------
3889 ;; ---- Predicated integer unary operations
3890 ;; -------------------------------------------------------------------------------
3891 ;; Includes:
3892 ;; - vneg.v/vnot.v
3893 ;; -------------------------------------------------------------------------------
3894
3895 (define_insn "@pred_<optab><mode>"
3896 [(set (match_operand:V_VLSI 0 "register_operand" "=vd,vd, vr, vr")
3897 (if_then_else:V_VLSI
3898 (unspec:<VM>
3899 [(match_operand:<VM> 1 "vector_mask_operand" "vm,vm,Wc1,Wc1")
3900 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
3901 (match_operand 5 "const_int_operand" " i, i, i, i")
3902 (match_operand 6 "const_int_operand" " i, i, i, i")
3903 (match_operand 7 "const_int_operand" " i, i, i, i")
3904 (reg:SI VL_REGNUM)
3905 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3906 (any_int_unop:V_VLSI
3907 (match_operand:V_VLSI 3 "register_operand" "vr,vr, vr, vr"))
3908 (match_operand:V_VLSI 2 "vector_merge_operand" "vu, 0, vu, 0")))]
3909 "TARGET_VECTOR"
3910 {
3911 /* vneg.v = vrsub vd,vs,x0 = vrsub vd,vs,0. */
3912 return (<CODE> == NEG) ? "vrsub.vi\t%0,%3,0%p1" : "v<insn>.v\t%0,%3%p1";
3913 }
3914 [(set_attr "type" "vialu")
3915 (set_attr "mode" "<MODE>")
3916 (set_attr "vl_op_idx" "4")
3917 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
3918 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
3919 (set (attr "avl_type_idx") (const_int 7))])
3920
3921 ;; -------------------------------------------------------------------------------
3922 ;; ---- Predicated integer widening binary operations
3923 ;; -------------------------------------------------------------------------------
3924 ;; Includes:
3925 ;; - 11.2 Vector Widening Integer Add/Subtract
3926 ;; - 11.3 Vector Integer Extension
3927 ;; - 11.12 Vector Widening Integer Multiply Instructions
3928 ;; -------------------------------------------------------------------------------
3929
3930 ;; Vector Double-Widening Sign-extend and Zero-extend.
3931 (define_insn "@pred_<optab><mode>_vf2"
3932 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
3933 (if_then_else:VWEXTI
3934 (unspec:<VM>
3935 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
3936 (match_operand 4 "vector_length_operand" " rvl, rvl")
3937 (match_operand 5 "const_int_operand" " i, i")
3938 (match_operand 6 "const_int_operand" " i, i")
3939 (match_operand 7 "const_int_operand" " i, i")
3940 (reg:SI VL_REGNUM)
3941 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3942 (any_extend:VWEXTI
3943 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
3944 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
3945 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
3946 "v<sz>ext.vf2\t%0,%3%p1"
3947 [(set_attr "type" "vext")
3948 (set_attr "mode" "<MODE>")])
3949
3950 ;; Vector Quad-Widening Sign-extend and Zero-extend.
3951 (define_insn "@pred_<optab><mode>_vf4"
3952 [(set (match_operand:VQEXTI 0 "register_operand" "=&vr,&vr")
3953 (if_then_else:VQEXTI
3954 (unspec:<VM>
3955 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
3956 (match_operand 4 "vector_length_operand" " rvl, rvl")
3957 (match_operand 5 "const_int_operand" " i, i")
3958 (match_operand 6 "const_int_operand" " i, i")
3959 (match_operand 7 "const_int_operand" " i, i")
3960 (reg:SI VL_REGNUM)
3961 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3962 (any_extend:VQEXTI
3963 (match_operand:<V_QUAD_TRUNC> 3 "register_operand" " vr, vr"))
3964 (match_operand:VQEXTI 2 "vector_merge_operand" " vu, 0")))]
3965 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
3966 "v<sz>ext.vf4\t%0,%3%p1"
3967 [(set_attr "type" "vext")
3968 (set_attr "mode" "<MODE>")])
3969
3970 ;; Vector Oct-Widening Sign-extend and Zero-extend.
3971 (define_insn "@pred_<optab><mode>_vf8"
3972 [(set (match_operand:VOEXTI 0 "register_operand" "=&vr,&vr")
3973 (if_then_else:VOEXTI
3974 (unspec:<VM>
3975 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
3976 (match_operand 4 "vector_length_operand" " rvl, rvl")
3977 (match_operand 5 "const_int_operand" " i, i")
3978 (match_operand 6 "const_int_operand" " i, i")
3979 (match_operand 7 "const_int_operand" " i, i")
3980 (reg:SI VL_REGNUM)
3981 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
3982 (any_extend:VOEXTI
3983 (match_operand:<V_OCT_TRUNC> 3 "register_operand" " vr, vr"))
3984 (match_operand:VOEXTI 2 "vector_merge_operand" " vu, 0")))]
3985 "TARGET_VECTOR && !TARGET_XTHEADVECTOR"
3986 "v<sz>ext.vf8\t%0,%3%p1"
3987 [(set_attr "type" "vext")
3988 (set_attr "mode" "<MODE>")])
3989
3990 ;; Vector Widening Add/Subtract/Multiply.
3991 (define_insn "@pred_dual_widen_<any_widen_binop:optab><any_extend:su><mode>"
3992 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
3993 (if_then_else:VWEXTI
3994 (unspec:<VM>
3995 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
3996 (match_operand 5 "vector_length_operand" " rvl, rvl")
3997 (match_operand 6 "const_int_operand" " i, i")
3998 (match_operand 7 "const_int_operand" " i, i")
3999 (match_operand 8 "const_int_operand" " i, i")
4000 (reg:SI VL_REGNUM)
4001 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4002 (any_widen_binop:VWEXTI
4003 (any_extend:VWEXTI
4004 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
4005 (any_extend:VWEXTI
4006 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")))
4007 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4008 "TARGET_VECTOR"
4009 "vw<any_widen_binop:insn><any_extend:u>.vv\t%0,%3,%4%p1"
4010 [(set_attr "type" "vi<widen_binop_insn_type>")
4011 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4012
4013 (define_insn "@pred_dual_widen_<any_widen_binop:optab><any_extend:su><mode>_scalar"
4014 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4015 (if_then_else:VWEXTI
4016 (unspec:<VM>
4017 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4018 (match_operand 5 "vector_length_operand" " rvl, rvl")
4019 (match_operand 6 "const_int_operand" " i, i")
4020 (match_operand 7 "const_int_operand" " i, i")
4021 (match_operand 8 "const_int_operand" " i, i")
4022 (reg:SI VL_REGNUM)
4023 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4024 (any_widen_binop:VWEXTI
4025 (any_extend:VWEXTI
4026 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
4027 (any_extend:VWEXTI
4028 (vec_duplicate:<V_DOUBLE_TRUNC>
4029 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ, rJ"))))
4030 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4031 "TARGET_VECTOR"
4032 "vw<any_widen_binop:insn><any_extend:u>.vx\t%0,%3,%z4%p1"
4033 [(set_attr "type" "vi<widen_binop_insn_type>")
4034 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4035
4036 (define_insn "@pred_single_widen_sub<any_extend:su><mode>"
4037 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4038 (if_then_else:VWEXTI
4039 (unspec:<VM>
4040 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4041 (match_operand 5 "vector_length_operand" " rvl, rvl")
4042 (match_operand 6 "const_int_operand" " i, i")
4043 (match_operand 7 "const_int_operand" " i, i")
4044 (match_operand 8 "const_int_operand" " i, i")
4045 (reg:SI VL_REGNUM)
4046 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4047 (minus:VWEXTI
4048 (match_operand:VWEXTI 3 "register_operand" " vr, vr")
4049 (any_extend:VWEXTI
4050 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")))
4051 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4052 "TARGET_VECTOR"
4053 "vwsub<any_extend:u>.wv\t%0,%3,%4%p1"
4054 [(set_attr "type" "viwalu")
4055 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4056
4057 (define_insn "@pred_single_widen_add<any_extend:su><mode>"
4058 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4059 (if_then_else:VWEXTI
4060 (unspec:<VM>
4061 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4062 (match_operand 5 "vector_length_operand" " rvl, rvl")
4063 (match_operand 6 "const_int_operand" " i, i")
4064 (match_operand 7 "const_int_operand" " i, i")
4065 (match_operand 8 "const_int_operand" " i, i")
4066 (reg:SI VL_REGNUM)
4067 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4068 (plus:VWEXTI
4069 (any_extend:VWEXTI
4070 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr"))
4071 (match_operand:VWEXTI 3 "register_operand" " vr, vr"))
4072 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4073 "TARGET_VECTOR"
4074 "vwadd<any_extend:u>.wv\t%0,%3,%4%p1"
4075 [(set_attr "type" "viwalu")
4076 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4077
4078 (define_insn "@pred_single_widen_<plus_minus:optab><any_extend:su><mode>_scalar"
4079 [(set (match_operand:VWEXTI 0 "register_operand" "=vd,vd, vr, vr")
4080 (if_then_else:VWEXTI
4081 (unspec:<VM>
4082 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1")
4083 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4084 (match_operand 6 "const_int_operand" " i, i, i, i")
4085 (match_operand 7 "const_int_operand" " i, i, i, i")
4086 (match_operand 8 "const_int_operand" " i, i, i, i")
4087 (reg:SI VL_REGNUM)
4088 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4089 (plus_minus:VWEXTI
4090 (match_operand:VWEXTI 3 "register_operand" " vr,vr, vr, vr")
4091 (any_extend:VWEXTI
4092 (vec_duplicate:<V_DOUBLE_TRUNC>
4093 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ,rJ, rJ, rJ"))))
4094 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4095 "TARGET_VECTOR"
4096 "vw<plus_minus:insn><any_extend:u>.wx\t%0,%3,%z4%p1"
4097 [(set_attr "type" "vi<widen_binop_insn_type>")
4098 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4099
4100 (define_insn "@pred_single_widen_add<any_extend:su><mode>_extended_scalar"
4101 [(set (match_operand:VWEXTI 0 "register_operand" "=vd,vd, vr, vr")
4102 (if_then_else:VWEXTI
4103 (unspec:<VM>
4104 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1")
4105 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4106 (match_operand 6 "const_int_operand" " i, i, i, i")
4107 (match_operand 7 "const_int_operand" " i, i, i, i")
4108 (match_operand 8 "const_int_operand" " i, i, i, i")
4109 (reg:SI VL_REGNUM)
4110 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4111 (plus:VWEXTI
4112 (vec_duplicate:VWEXTI
4113 (any_extend:<VEL>
4114 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ,rJ, rJ, rJ")))
4115 (match_operand:VWEXTI 3 "register_operand" " vr,vr, vr, vr"))
4116 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4117 "TARGET_VECTOR"
4118 "vwadd<any_extend:u>.wx\t%0,%3,%z4%p1"
4119 [(set_attr "type" "viwalu")
4120 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4121
4122 (define_insn "@pred_single_widen_sub<any_extend:su><mode>_extended_scalar"
4123 [(set (match_operand:VWEXTI 0 "register_operand" "=vd,vd, vr, vr")
4124 (if_then_else:VWEXTI
4125 (unspec:<VM>
4126 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1")
4127 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4128 (match_operand 6 "const_int_operand" " i, i, i, i")
4129 (match_operand 7 "const_int_operand" " i, i, i, i")
4130 (match_operand 8 "const_int_operand" " i, i, i, i")
4131 (reg:SI VL_REGNUM)
4132 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4133 (minus:VWEXTI
4134 (match_operand:VWEXTI 3 "register_operand" " vr,vr, vr, vr")
4135 (vec_duplicate:VWEXTI
4136 (any_extend:<VEL>
4137 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ,rJ, rJ, rJ"))))
4138 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4139 "TARGET_VECTOR"
4140 "vwsub<any_extend:u>.wx\t%0,%3,%z4%p1"
4141 [(set_attr "type" "viwalu")
4142 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4143
4144 (define_insn "@pred_widen_mulsu<mode>"
4145 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4146 (if_then_else:VWEXTI
4147 (unspec:<VM>
4148 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4149 (match_operand 5 "vector_length_operand" " rvl, rvl")
4150 (match_operand 6 "const_int_operand" " i, i")
4151 (match_operand 7 "const_int_operand" " i, i")
4152 (match_operand 8 "const_int_operand" " i, i")
4153 (reg:SI VL_REGNUM)
4154 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4155 (mult:VWEXTI
4156 (sign_extend:VWEXTI
4157 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
4158 (zero_extend:VWEXTI
4159 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")))
4160 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4161 "TARGET_VECTOR"
4162 "vwmulsu.vv\t%0,%3,%4%p1"
4163 [(set_attr "type" "viwmul")
4164 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4165
4166 (define_insn "@pred_widen_mulsu<mode>_scalar"
4167 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4168 (if_then_else:VWEXTI
4169 (unspec:<VM>
4170 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4171 (match_operand 5 "vector_length_operand" " rvl, rvl")
4172 (match_operand 6 "const_int_operand" " i, i")
4173 (match_operand 7 "const_int_operand" " i, i")
4174 (match_operand 8 "const_int_operand" " i, i")
4175 (reg:SI VL_REGNUM)
4176 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4177 (mult:VWEXTI
4178 (sign_extend:VWEXTI
4179 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
4180 (zero_extend:VWEXTI
4181 (vec_duplicate:<V_DOUBLE_TRUNC>
4182 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ, rJ"))))
4183 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4184 "TARGET_VECTOR"
4185 "vwmulsu.vx\t%0,%3,%z4%p1"
4186 [(set_attr "type" "viwmul")
4187 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
4188
4189 ;; vwcvt<u>.x.x.v
4190 (define_insn "@pred_<optab><mode>"
4191 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr,&vr")
4192 (if_then_else:VWEXTI
4193 (unspec:<VM>
4194 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
4195 (match_operand 4 "vector_length_operand" " rvl, rvl")
4196 (match_operand 5 "const_int_operand" " i, i")
4197 (match_operand 6 "const_int_operand" " i, i")
4198 (match_operand 7 "const_int_operand" " i, i")
4199 (reg:SI VL_REGNUM)
4200 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4201 (plus:VWEXTI
4202 (any_extend:VWEXTI
4203 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
4204 (vec_duplicate:VWEXTI
4205 (reg:<VEL> X0_REGNUM)))
4206 (match_operand:VWEXTI 2 "vector_merge_operand" " vu, 0")))]
4207 "TARGET_VECTOR"
4208 "vwcvt<u>.x.x.v\t%0,%3%p1"
4209 [(set_attr "type" "viwalu")
4210 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4211 (set_attr "vl_op_idx" "4")
4212 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
4213 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
4214 (set (attr "avl_type_idx") (const_int 7))])
4215
4216 ;; -------------------------------------------------------------------------------
4217 ;; ---- Predicated integer Narrowing operations
4218 ;; -------------------------------------------------------------------------------
4219 ;; Includes:
4220 ;; - 11.7 Vector Narrowing Integer Right Shift Instructions
4221 ;; -------------------------------------------------------------------------------
4222
4223 ;; The destination EEW is smaller than the source EEW and the overlap is in the
4224 ;; lowest-numbered part of the source register group
4225 ;; e.g, when LMUL = 1, vnsrl.wi v0,v0,3 is legal but a destination of v1 is not.
4226 (define_insn "@pred_narrow_<optab><mode>"
4227 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd,vd, vr, vr,vd, vr, &vr, &vr, vd, vr, &vr, &vr")
4228 (if_then_else:<V_DOUBLE_TRUNC>
4229 (unspec:<VM>
4230 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1,vm,Wc1,vmWc1,vmWc1, vm,Wc1,vmWc1,vmWc1")
4231 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl,rvl,rvl, rvl, rvl,rvl,rvl, rvl, rvl")
4232 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4233 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4234 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4235 (reg:SI VL_REGNUM)
4236 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4237 (truncate:<V_DOUBLE_TRUNC>
4238 (any_shiftrt:VWEXTI
4239 (match_operand:VWEXTI 3 "register_operand" " vr,vr, vr, vr, 0, 0, vr, vr, 0, 0, vr, vr")
4240 (match_operand:<V_DOUBLE_TRUNC> 4 "vector_shift_operand" " 0, 0, 0, 0,vr, vr, vr, vr, vk, vk, vk, vk")))
4241 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " 0,vu, 0, vu,vu, vu, vu, 0, vu, vu, vu, 0")))]
4242 "TARGET_VECTOR"
4243 "vn<insn>.w%o4\t%0,%3,%v4%p1"
4244 [(set_attr "type" "vnshift")
4245 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4246 (set_attr "spec_restriction" "none,none,thv,thv,none,thv,none,none,none,thv,none,none")])
4247
4248 (define_insn "@pred_narrow_<optab><mode>_scalar"
4249 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
4250 (if_then_else:<V_DOUBLE_TRUNC>
4251 (unspec:<VM>
4252 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
4253 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
4254 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
4255 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
4256 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
4257 (reg:SI VL_REGNUM)
4258 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4259 (truncate:<V_DOUBLE_TRUNC>
4260 (any_shiftrt:VWEXTI
4261 (match_operand:VWEXTI 3 "register_operand" " 0, 0, 0, 0, vr, vr")
4262 (match_operand 4 "pmode_reg_or_uimm5_operand" " rK, rK, rK, rK, rK, rK")))
4263 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
4264 "TARGET_VECTOR"
4265 {
4266 /* vnsrl vd,vs,x0 = vnsrl vd,vs,0. */
4267 if (REG_P (operands[4]) && REGNO (operands[4]) == 0)
4268 return "vn<insn>.wi\t%0,%3,0%p1";
4269
4270 return "vn<insn>.w%o4\t%0,%3,%4%p1";
4271 }
4272 [(set_attr "type" "vnshift")
4273 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4274 (set_attr "spec_restriction" "none,none,thv,thv,none,none")])
4275
4276 ;; vncvt.x.x.w
4277 (define_insn "@pred_trunc<mode>"
4278 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
4279 (if_then_else:<V_DOUBLE_TRUNC>
4280 (unspec:<VM>
4281 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
4282 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
4283 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
4284 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
4285 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
4286 (reg:SI VL_REGNUM)
4287 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4288 (truncate:<V_DOUBLE_TRUNC>
4289 (match_operand:VWEXTI 3 "register_operand" " 0, 0, 0, 0, vr, vr"))
4290 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
4291 "TARGET_VECTOR"
4292 ;; vncvt.x.x.w = vnsrl vd,vs,x0 = vnsrl vd,vs,0
4293 "vnsrl.wi\t%0,%3,0%p1";
4294 [(set_attr "type" "vnshift")
4295 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4296 (set_attr "vl_op_idx" "4")
4297 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
4298 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
4299 (set (attr "avl_type_idx") (const_int 7))
4300 (set_attr "spec_restriction" "none,none,thv,thv,none,none")])
4301
4302 ;; -------------------------------------------------------------------------------
4303 ;; ---- Predicated fixed-point operations
4304 ;; -------------------------------------------------------------------------------
4305 ;; Includes:
4306 ;; - 12.1 Vector Single-Width Saturating Add and Subtract
4307 ;; - 12.2 Vector Single-Width Averaging Add and Subtract
4308 ;; - 12.3 Vector Single-Width Fractional Multiply with Rounding and Saturation
4309 ;; - 12.4 Vector Single-Width Scaling Shift Instructions
4310 ;; - 12.5 Vector Narrowing Fixed-Point Clip Instructions
4311 ;; -------------------------------------------------------------------------------
4312
4313 ;; Saturating Add and Subtract
4314 (define_insn "@pred_<optab><mode>"
4315 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr, vd, vd, vr, vr")
4316 (if_then_else:V_VLSI
4317 (unspec:<VM>
4318 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1, vm, vm,Wc1,Wc1")
4319 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl,rvl,rvl,rvl,rvl")
4320 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i")
4321 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i")
4322 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i")
4323 (reg:SI VL_REGNUM)
4324 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4325 (any_sat_int_binop:V_VLSI
4326 (match_operand:V_VLSI 3 "<binop_rhs1_predicate>" " vr, vr, vr, vr, vr, vr, vr, vr")
4327 (match_operand:V_VLSI 4 "<binop_rhs2_predicate>" "<binop_rhs2_constraint>"))
4328 (match_operand:V_VLSI 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0, vu, 0")))]
4329 "TARGET_VECTOR"
4330 "@
4331 v<insn>.vv\t%0,%3,%4%p1
4332 v<insn>.vv\t%0,%3,%4%p1
4333 v<insn>.vv\t%0,%3,%4%p1
4334 v<insn>.vv\t%0,%3,%4%p1
4335 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
4336 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
4337 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1
4338 v<binop_vi_variant_insn>\t%0,<binop_vi_variant_op>%p1"
4339 [(set_attr "type" "<int_binop_insn_type>")
4340 (set_attr "mode" "<MODE>")])
4341
4342 ;; Handle GET_MODE_INNER (mode) = QImode, HImode, SImode.
4343 (define_insn "@pred_<optab><mode>_scalar"
4344 [(set (match_operand:VI_QHS 0 "register_operand" "=vd, vd, vr, vr")
4345 (if_then_else:VI_QHS
4346 (unspec:<VM>
4347 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4348 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4349 (match_operand 6 "const_int_operand" " i, i, i, i")
4350 (match_operand 7 "const_int_operand" " i, i, i, i")
4351 (match_operand 8 "const_int_operand" " i, i, i, i")
4352 (reg:SI VL_REGNUM)
4353 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4354 (sat_int_plus_binop:VI_QHS
4355 (vec_duplicate:VI_QHS
4356 (match_operand:<VEL> 4 "register_operand" " r, r, r, r"))
4357 (match_operand:VI_QHS 3 "register_operand" " vr, vr, vr, vr"))
4358 (match_operand:VI_QHS 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4359 "TARGET_VECTOR"
4360 "v<insn>.vx\t%0,%3,%4%p1"
4361 [(set_attr "type" "<int_binop_insn_type>")
4362 (set_attr "mode" "<MODE>")])
4363
4364 (define_insn "@pred_<optab><mode>_scalar"
4365 [(set (match_operand:VI_QHS 0 "register_operand" "=vd, vd, vr, vr")
4366 (if_then_else:VI_QHS
4367 (unspec:<VM>
4368 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4369 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4370 (match_operand 6 "const_int_operand" " i, i, i, i")
4371 (match_operand 7 "const_int_operand" " i, i, i, i")
4372 (match_operand 8 "const_int_operand" " i, i, i, i")
4373 (reg:SI VL_REGNUM)
4374 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4375 (sat_int_minus_binop:VI_QHS
4376 (match_operand:VI_QHS 3 "register_operand" " vr, vr, vr, vr")
4377 (vec_duplicate:VI_QHS
4378 (match_operand:<VEL> 4 "register_operand" " r, r, r, r")))
4379 (match_operand:VI_QHS 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4380 "TARGET_VECTOR"
4381 "v<insn>.vx\t%0,%3,%4%p1"
4382 [(set_attr "type" "<int_binop_insn_type>")
4383 (set_attr "mode" "<MODE>")])
4384
4385 (define_expand "@pred_<optab><mode>_scalar"
4386 [(set (match_operand:VI_D 0 "register_operand")
4387 (if_then_else:VI_D
4388 (unspec:<VM>
4389 [(match_operand:<VM> 1 "vector_mask_operand")
4390 (match_operand 5 "vector_length_operand")
4391 (match_operand 6 "const_int_operand")
4392 (match_operand 7 "const_int_operand")
4393 (match_operand 8 "const_int_operand")
4394 (reg:SI VL_REGNUM)
4395 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4396 (sat_int_plus_binop:VI_D
4397 (vec_duplicate:VI_D
4398 (match_operand:<VEL> 4 "reg_or_int_operand"))
4399 (match_operand:VI_D 3 "register_operand"))
4400 (match_operand:VI_D 2 "vector_merge_operand")))]
4401 "TARGET_VECTOR"
4402 {
4403 if (riscv_vector::sew64_scalar_helper (
4404 operands,
4405 /* scalar op */&operands[4],
4406 /* vl */operands[5],
4407 <MODE>mode,
4408 riscv_vector::has_vi_variant_p (<CODE>, operands[4]),
4409 [] (rtx *operands, rtx broadcast_scalar) {
4410 emit_insn (gen_pred_<optab><mode> (operands[0], operands[1],
4411 operands[2], operands[3], broadcast_scalar, operands[5],
4412 operands[6], operands[7], operands[8]));
4413 },
4414 (riscv_vector::avl_type) INTVAL (operands[8])))
4415 DONE;
4416 })
4417
4418 (define_insn "*pred_<optab><mode>_scalar"
4419 [(set (match_operand:VI_D 0 "register_operand" "=vd, vd, vr, vr")
4420 (if_then_else:VI_D
4421 (unspec:<VM>
4422 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4423 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4424 (match_operand 6 "const_int_operand" " i, i, i, i")
4425 (match_operand 7 "const_int_operand" " i, i, i, i")
4426 (match_operand 8 "const_int_operand" " i, i, i, i")
4427 (reg:SI VL_REGNUM)
4428 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4429 (sat_int_plus_binop:VI_D
4430 (vec_duplicate:VI_D
4431 (match_operand:<VEL> 4 "register_operand" " r, r, r, r"))
4432 (match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr"))
4433 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4434 "TARGET_VECTOR"
4435 "v<insn>.vx\t%0,%3,%4%p1"
4436 [(set_attr "type" "<int_binop_insn_type>")
4437 (set_attr "mode" "<MODE>")])
4438
4439 (define_insn "*pred_<optab><mode>_extended_scalar"
4440 [(set (match_operand:VI_D 0 "register_operand" "=vd, vd, vr, vr")
4441 (if_then_else:VI_D
4442 (unspec:<VM>
4443 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4444 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4445 (match_operand 6 "const_int_operand" " i, i, i, i")
4446 (match_operand 7 "const_int_operand" " i, i, i, i")
4447 (match_operand 8 "const_int_operand" " i, i, i, i")
4448 (reg:SI VL_REGNUM)
4449 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4450 (sat_int_plus_binop:VI_D
4451 (vec_duplicate:VI_D
4452 (sign_extend:<VEL>
4453 (match_operand:<VSUBEL> 4 "register_operand" " r, r, r, r")))
4454 (match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr"))
4455 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4456 "TARGET_VECTOR && !TARGET_64BIT"
4457 "v<insn>.vx\t%0,%3,%4%p1"
4458 [(set_attr "type" "<int_binop_insn_type>")
4459 (set_attr "mode" "<MODE>")])
4460
4461 (define_expand "@pred_<optab><mode>_scalar"
4462 [(set (match_operand:VI_D 0 "register_operand")
4463 (if_then_else:VI_D
4464 (unspec:<VM>
4465 [(match_operand:<VM> 1 "vector_mask_operand")
4466 (match_operand 5 "vector_length_operand")
4467 (match_operand 6 "const_int_operand")
4468 (match_operand 7 "const_int_operand")
4469 (match_operand 8 "const_int_operand")
4470 (reg:SI VL_REGNUM)
4471 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4472 (sat_int_minus_binop:VI_D
4473 (match_operand:VI_D 3 "register_operand")
4474 (vec_duplicate:VI_D
4475 (match_operand:<VEL> 4 "reg_or_int_operand")))
4476 (match_operand:VI_D 2 "vector_merge_operand")))]
4477 "TARGET_VECTOR"
4478 {
4479 if (riscv_vector::sew64_scalar_helper (
4480 operands,
4481 /* scalar op */&operands[4],
4482 /* vl */operands[5],
4483 <MODE>mode,
4484 riscv_vector::has_vi_variant_p (<CODE>, operands[4]),
4485 [] (rtx *operands, rtx broadcast_scalar) {
4486 emit_insn (gen_pred_<optab><mode> (operands[0], operands[1],
4487 operands[2], operands[3], broadcast_scalar, operands[5],
4488 operands[6], operands[7], operands[8]));
4489 },
4490 (riscv_vector::avl_type) INTVAL (operands[8])))
4491 DONE;
4492 })
4493
4494 (define_insn "*pred_<optab><mode>_scalar"
4495 [(set (match_operand:VI_D 0 "register_operand" "=vd, vd, vr, vr")
4496 (if_then_else:VI_D
4497 (unspec:<VM>
4498 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4499 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4500 (match_operand 6 "const_int_operand" " i, i, i, i")
4501 (match_operand 7 "const_int_operand" " i, i, i, i")
4502 (match_operand 8 "const_int_operand" " i, i, i, i")
4503 (reg:SI VL_REGNUM)
4504 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4505 (sat_int_minus_binop:VI_D
4506 (match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr")
4507 (vec_duplicate:VI_D
4508 (match_operand:<VEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ")))
4509 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4510 "TARGET_VECTOR"
4511 "v<insn>.vx\t%0,%3,%z4%p1"
4512 [(set_attr "type" "<int_binop_insn_type>")
4513 (set_attr "mode" "<MODE>")])
4514
4515 (define_insn "*pred_<optab><mode>_extended_scalar"
4516 [(set (match_operand:VI_D 0 "register_operand" "=vd, vd, vr, vr")
4517 (if_then_else:VI_D
4518 (unspec:<VM>
4519 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4520 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4521 (match_operand 6 "const_int_operand" " i, i, i, i")
4522 (match_operand 7 "const_int_operand" " i, i, i, i")
4523 (match_operand 8 "const_int_operand" " i, i, i, i")
4524 (reg:SI VL_REGNUM)
4525 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4526 (sat_int_minus_binop:VI_D
4527 (match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr")
4528 (vec_duplicate:VI_D
4529 (sign_extend:<VEL>
4530 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ"))))
4531 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4532 "TARGET_VECTOR && !TARGET_64BIT"
4533 "v<insn>.vx\t%0,%3,%z4%p1"
4534 [(set_attr "type" "<int_binop_insn_type>")
4535 (set_attr "mode" "<MODE>")])
4536
4537 (define_insn "@pred_<sat_op><mode>"
4538 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr")
4539 (if_then_else:V_VLSI
4540 (unspec:<VM>
4541 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4542 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4543 (match_operand 6 "const_int_operand" " i, i, i, i")
4544 (match_operand 7 "const_int_operand" " i, i, i, i")
4545 (match_operand 8 "const_int_operand" " i, i, i, i")
4546 (match_operand 9 "const_int_operand" " i, i, i, i")
4547 (reg:SI VL_REGNUM)
4548 (reg:SI VTYPE_REGNUM)
4549 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4550 (unspec:V_VLSI
4551 [(match_operand:V_VLSI 3 "register_operand" " vr, vr, vr, vr")
4552 (match_operand:V_VLSI 4 "register_operand" " vr, vr, vr, vr")] VSAT_OP)
4553 (match_operand:V_VLSI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4554 "TARGET_VECTOR"
4555 "v<sat_op>.vv\t%0,%3,%4%p1"
4556 [(set_attr "type" "<sat_insn_type>")
4557 (set_attr "mode" "<MODE>")])
4558
4559 ;; Handle GET_MODE_INNER (mode) = QImode, HImode, SImode.
4560 (define_insn "@pred_<sat_op><mode>_scalar"
4561 [(set (match_operand:VI_QHS 0 "register_operand" "=vd, vr, vd, vr")
4562 (if_then_else:VI_QHS
4563 (unspec:<VM>
4564 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4565 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4566 (match_operand 6 "const_int_operand" " i, i, i, i")
4567 (match_operand 7 "const_int_operand" " i, i, i, i")
4568 (match_operand 8 "const_int_operand" " i, i, i, i")
4569 (match_operand 9 "const_int_operand" " i, i, i, i")
4570 (reg:SI VL_REGNUM)
4571 (reg:SI VTYPE_REGNUM)
4572 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4573 (unspec:VI_QHS
4574 [(match_operand:VI_QHS 3 "register_operand" " vr, vr, vr, vr")
4575 (match_operand:<VEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ")] VSAT_ARITH_OP)
4576 (match_operand:VI_QHS 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4577 "TARGET_VECTOR"
4578 "v<sat_op>.vx\t%0,%3,%z4%p1"
4579 [(set_attr "type" "<sat_insn_type>")
4580 (set_attr "mode" "<MODE>")])
4581
4582 (define_insn "@pred_<sat_op><mode>_scalar"
4583 [(set (match_operand:VI 0 "register_operand" "=vd, vr, vd, vr")
4584 (if_then_else:VI
4585 (unspec:<VM>
4586 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4587 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4588 (match_operand 6 "const_int_operand" " i, i, i, i")
4589 (match_operand 7 "const_int_operand" " i, i, i, i")
4590 (match_operand 8 "const_int_operand" " i, i, i, i")
4591 (match_operand 9 "const_int_operand" " i, i, i, i")
4592 (reg:SI VL_REGNUM)
4593 (reg:SI VTYPE_REGNUM)
4594 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4595 (unspec:VI
4596 [(match_operand:VI 3 "register_operand" " vr, vr, vr, vr")
4597 (match_operand 4 "pmode_reg_or_uimm5_operand" " rK, rK, rK, rK")] VSAT_SHIFT_OP)
4598 (match_operand:VI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4599 "TARGET_VECTOR"
4600 "v<sat_op>.v%o4\t%0,%3,%4%p1"
4601 [(set_attr "type" "<sat_insn_type>")
4602 (set_attr "mode" "<MODE>")])
4603
4604 ;; Handle GET_MODE_INNER (mode) = DImode. We need to split them since
4605 ;; we need to deal with SEW = 64 in RV32 system.
4606 (define_expand "@pred_<sat_op><mode>_scalar"
4607 [(set (match_operand:VI_D 0 "register_operand")
4608 (if_then_else:VI_D
4609 (unspec:<VM>
4610 [(match_operand:<VM> 1 "vector_mask_operand")
4611 (match_operand 5 "vector_length_operand")
4612 (match_operand 6 "const_int_operand")
4613 (match_operand 7 "const_int_operand")
4614 (match_operand 8 "const_int_operand")
4615 (match_operand 9 "const_int_operand")
4616 (reg:SI VL_REGNUM)
4617 (reg:SI VTYPE_REGNUM)
4618 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4619 (unspec:VI_D
4620 [(match_operand:VI_D 3 "register_operand")
4621 (match_operand:<VEL> 4 "reg_or_int_operand")] VSAT_ARITH_OP)
4622 (match_operand:VI_D 2 "vector_merge_operand")))]
4623 "TARGET_VECTOR"
4624 {
4625 if (riscv_vector::sew64_scalar_helper (
4626 operands,
4627 /* scalar op */&operands[4],
4628 /* vl */operands[5],
4629 <MODE>mode,
4630 false,
4631 [] (rtx *operands, rtx broadcast_scalar) {
4632 emit_insn (gen_pred_<sat_op><mode> (operands[0], operands[1],
4633 operands[2], operands[3], broadcast_scalar, operands[5],
4634 operands[6], operands[7], operands[8], operands[9]));
4635 },
4636 (riscv_vector::avl_type) INTVAL (operands[8])))
4637 DONE;
4638 })
4639
4640 (define_insn "*pred_<sat_op><mode>_scalar"
4641 [(set (match_operand:VI_D 0 "register_operand" "=vd, vr, vd, vr")
4642 (if_then_else:VI_D
4643 (unspec:<VM>
4644 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4645 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4646 (match_operand 6 "const_int_operand" " i, i, i, i")
4647 (match_operand 7 "const_int_operand" " i, i, i, i")
4648 (match_operand 8 "const_int_operand" " i, i, i, i")
4649 (match_operand 9 "const_int_operand" " i, i, i, i")
4650 (reg:SI VL_REGNUM)
4651 (reg:SI VTYPE_REGNUM)
4652 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4653 (unspec:VI_D
4654 [(match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr")
4655 (match_operand:<VEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ")] VSAT_ARITH_OP)
4656 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4657 "TARGET_VECTOR"
4658 "v<sat_op>.vx\t%0,%3,%z4%p1"
4659 [(set_attr "type" "<sat_insn_type>")
4660 (set_attr "mode" "<MODE>")])
4661
4662 (define_insn "*pred_<sat_op><mode>_extended_scalar"
4663 [(set (match_operand:VI_D 0 "register_operand" "=vd, vr, vd, vr")
4664 (if_then_else:VI_D
4665 (unspec:<VM>
4666 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
4667 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
4668 (match_operand 6 "const_int_operand" " i, i, i, i")
4669 (match_operand 7 "const_int_operand" " i, i, i, i")
4670 (match_operand 8 "const_int_operand" " i, i, i, i")
4671 (match_operand 9 "const_int_operand" " i, i, i, i")
4672 (reg:SI VL_REGNUM)
4673 (reg:SI VTYPE_REGNUM)
4674 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4675 (unspec:VI_D
4676 [(match_operand:VI_D 3 "register_operand" " vr, vr, vr, vr")
4677 (sign_extend:<VEL>
4678 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ"))] VSAT_ARITH_OP)
4679 (match_operand:VI_D 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4680 "TARGET_VECTOR && !TARGET_64BIT"
4681 "v<sat_op>.vx\t%0,%3,%z4%p1"
4682 [(set_attr "type" "<sat_insn_type>")
4683 (set_attr "mode" "<MODE>")])
4684
4685 ;; CLIP
4686 (define_insn "@pred_narrow_clip<v_su><mode>"
4687 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd,vd, vr, vr,vd, vr, &vr, &vr, vd, vr, &vr, &vr")
4688 (if_then_else:<V_DOUBLE_TRUNC>
4689 (unspec:<VM>
4690 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1,vm,Wc1,vmWc1,vmWc1, vm,Wc1,vmWc1,vmWc1")
4691 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl,rvl,rvl, rvl, rvl,rvl,rvl, rvl, rvl")
4692 (match_operand 6 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4693 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4694 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4695 (match_operand 9 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
4696 (reg:SI VL_REGNUM)
4697 (reg:SI VTYPE_REGNUM)
4698 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4699 (unspec:<V_DOUBLE_TRUNC>
4700 [(match_operand:VWEXTI 3 "register_operand" " vr,vr, vr, vr, 0, 0, vr, vr, 0, 0, vr, vr")
4701 (match_operand:<V_DOUBLE_TRUNC> 4 "vector_shift_operand" " 0, 0, 0, 0,vr, vr, vr, vr, vk, vk, vk, vk")] VNCLIP)
4702 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " 0,vu, 0, vu,vu, vu, vu, 0, vu, vu, vu, 0")))]
4703 "TARGET_VECTOR"
4704 "vnclip<v_su>.w%o4\t%0,%3,%v4%p1"
4705 [(set_attr "type" "vnclip")
4706 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4707 (set_attr "spec_restriction" "thv,thv,thv,thv,thv,thv,none,none,thv,thv,none,none")])
4708
4709 (define_insn "@pred_narrow_clip<v_su><mode>_scalar"
4710 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
4711 (if_then_else:<V_DOUBLE_TRUNC>
4712 (unspec:<VM>
4713 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
4714 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
4715 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
4716 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
4717 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
4718 (match_operand 9 "const_int_operand" " i, i, i, i, i, i")
4719 (reg:SI VL_REGNUM)
4720 (reg:SI VTYPE_REGNUM)
4721 (reg:SI VXRM_REGNUM)] UNSPEC_VPREDICATE)
4722 (unspec:<V_DOUBLE_TRUNC>
4723 [(match_operand:VWEXTI 3 "register_operand" " 0, 0, 0, 0, vr, vr")
4724 (match_operand 4 "pmode_reg_or_uimm5_operand" " rK, rK, rK, rK, rK, rK")] VNCLIP)
4725 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
4726 "TARGET_VECTOR"
4727 "vnclip<v_su>.w%o4\t%0,%3,%4%p1"
4728 [(set_attr "type" "vnclip")
4729 (set_attr "mode" "<V_DOUBLE_TRUNC>")
4730 (set_attr "spec_restriction" "thv,thv,thv,thv,none,none")])
4731
4732 ;; -------------------------------------------------------------------------------
4733 ;; ---- Predicated integer comparison operations
4734 ;; -------------------------------------------------------------------------------
4735 ;; Includes:
4736 ;; - 11.8 Vector Integer Comparison Instructions
4737 ;; -------------------------------------------------------------------------------
4738
4739 (define_expand "@pred_cmp<mode>"
4740 [(set (match_operand:<VM> 0 "register_operand")
4741 (if_then_else:<VM>
4742 (unspec:<VM>
4743 [(match_operand:<VM> 1 "vector_mask_operand")
4744 (match_operand 6 "vector_length_operand")
4745 (match_operand 7 "const_int_operand")
4746 (match_operand 8 "const_int_operand")
4747 (reg:SI VL_REGNUM)
4748 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4749 (match_operator:<VM> 3 "comparison_except_ltge_operator"
4750 [(match_operand:V_VLSI 4 "register_operand")
4751 (match_operand:V_VLSI 5 "vector_arith_operand")])
4752 (match_operand:<VM> 2 "vector_merge_operand")))]
4753 "TARGET_VECTOR"
4754 {})
4755
4756 (define_insn "*pred_cmp<mode>_merge_tie_mask"
4757 [(set (match_operand:<VM> 0 "register_operand" "=vm")
4758 (if_then_else:<VM>
4759 (unspec:<VM>
4760 [(match_operand:<VM> 1 "register_operand" " 0")
4761 (match_operand 5 "vector_length_operand" " rvl")
4762 (match_operand 6 "const_int_operand" " i")
4763 (match_operand 7 "const_int_operand" " i")
4764 (reg:SI VL_REGNUM)
4765 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4766 (match_operator:<VM> 2 "comparison_except_ltge_operator"
4767 [(match_operand:V_VLSI 3 "register_operand" " vr")
4768 (match_operand:V_VLSI 4 "vector_arith_operand" "vrvi")])
4769 (match_dup 1)))]
4770 "TARGET_VECTOR"
4771 "vms%B2.v%o4\t%0,%3,%v4,v0.t"
4772 [(set_attr "type" "vicmp")
4773 (set_attr "mode" "<MODE>")
4774 (set_attr "merge_op_idx" "1")
4775 (set_attr "vl_op_idx" "5")
4776 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
4777 (set (attr "avl_type_idx") (const_int 7))])
4778
4779 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
4780 (define_insn "*pred_cmp<mode>"
4781 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, vr, vr, &vr, &vr, &vr, &vr")
4782 (if_then_else:<VM>
4783 (unspec:<VM>
4784 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
4785 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl")
4786 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i")
4787 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i")
4788 (reg:SI VL_REGNUM)
4789 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4790 (match_operator:<VM> 3 "comparison_except_ltge_operator"
4791 [(match_operand:V_VLSI 4 "register_operand" " vr, vr, vr, vr, vr, vr, vr, vr")
4792 (match_operand:V_VLSI 5 "vector_arith_operand" " vr, vr, vi, vi, vr, vr, vi, vi")])
4793 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0, vu, 0")))]
4794 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
4795 "vms%B3.v%o5\t%0,%4,%v5%p1"
4796 [(set_attr "type" "vicmp")
4797 (set_attr "mode" "<MODE>")
4798 (set_attr "spec_restriction" "thv,thv,thv,thv,rvv,rvv,rvv,rvv")])
4799
4800 ;; We use early-clobber for source LMUL > dest LMUL.
4801 (define_insn "*pred_cmp<mode>_narrow"
4802 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, vr, vr, vr, vr, &vr, &vr")
4803 (if_then_else:<VM>
4804 (unspec:<VM>
4805 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
4806 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl")
4807 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i")
4808 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i")
4809 (reg:SI VL_REGNUM)
4810 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4811 (match_operator:<VM> 3 "comparison_except_ltge_operator"
4812 [(match_operand:V_VLSI 4 "register_operand" " vr, 0, vr, 0, 0, vr, 0, vr, vr")
4813 (match_operand:V_VLSI 5 "vector_arith_operand" " vrvi, vrvi, 0, 0, vrvi, 0, 0, vrvi, vrvi")])
4814 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, vu, vu, 0, 0, 0, vu, 0")))]
4815 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
4816 "vms%B3.v%o5\t%0,%4,%v5%p1"
4817 [(set_attr "type" "vicmp")
4818 (set_attr "mode" "<MODE>")
4819 (set_attr "spec_restriction" "none,thv,thv,thv,thv,thv,thv,none,none")])
4820
4821 (define_expand "@pred_ltge<mode>"
4822 [(set (match_operand:<VM> 0 "register_operand")
4823 (if_then_else:<VM>
4824 (unspec:<VM>
4825 [(match_operand:<VM> 1 "vector_mask_operand")
4826 (match_operand 6 "vector_length_operand")
4827 (match_operand 7 "const_int_operand")
4828 (match_operand 8 "const_int_operand")
4829 (reg:SI VL_REGNUM)
4830 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4831 (match_operator:<VM> 3 "ltge_operator"
4832 [(match_operand:V_VLSI 4 "register_operand")
4833 (match_operand:V_VLSI 5 "vector_neg_arith_operand")])
4834 (match_operand:<VM> 2 "vector_merge_operand")))]
4835 "TARGET_VECTOR"
4836 {})
4837
4838 (define_insn "*pred_ltge<mode>_merge_tie_mask"
4839 [(set (match_operand:<VM> 0 "register_operand" "=vm")
4840 (if_then_else:<VM>
4841 (unspec:<VM>
4842 [(match_operand:<VM> 1 "register_operand" " 0")
4843 (match_operand 5 "vector_length_operand" " rvl")
4844 (match_operand 6 "const_int_operand" " i")
4845 (match_operand 7 "const_int_operand" " i")
4846 (reg:SI VL_REGNUM)
4847 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4848 (match_operator:<VM> 2 "ltge_operator"
4849 [(match_operand:V_VLSI 3 "register_operand" " vr")
4850 (match_operand:V_VLSI 4 "vector_neg_arith_operand" "vrvj")])
4851 (match_dup 1)))]
4852 "TARGET_VECTOR"
4853 "vms%B2.v%o4\t%0,%3,%v4,v0.t"
4854 [(set_attr "type" "vicmp")
4855 (set_attr "mode" "<MODE>")
4856 (set_attr "merge_op_idx" "1")
4857 (set_attr "vl_op_idx" "5")
4858 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
4859 (set (attr "avl_type_idx") (const_int 7))])
4860
4861 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
4862 (define_insn "*pred_ltge<mode>"
4863 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, vr, vr, &vr, &vr, &vr, &vr")
4864 (if_then_else:<VM>
4865 (unspec:<VM>
4866 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
4867 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl")
4868 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i")
4869 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i")
4870 (reg:SI VL_REGNUM)
4871 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4872 (match_operator:<VM> 3 "ltge_operator"
4873 [(match_operand:V_VLSI 4 "register_operand" " vr, vr, vr, vr, vr, vr, vr, vr")
4874 (match_operand:V_VLSI 5 "vector_neg_arith_operand" " vr, vr, vj, vj, vr, vr, vj, vj")])
4875 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0, vu, 0")))]
4876 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
4877 "vms%B3.v%o5\t%0,%4,%v5%p1"
4878 [(set_attr "type" "vicmp")
4879 (set_attr "mode" "<MODE>")
4880 (set_attr "spec_restriction" "thv,thv,thv,thv,rvv,rvv,rvv,rvv")])
4881
4882 ;; We use early-clobber for source LMUL > dest LMUL.
4883 (define_insn "*pred_ltge<mode>_narrow"
4884 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, vr, vr, vr, vr, &vr, &vr")
4885 (if_then_else:<VM>
4886 (unspec:<VM>
4887 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
4888 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl")
4889 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i")
4890 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i")
4891 (reg:SI VL_REGNUM)
4892 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4893 (match_operator:<VM> 3 "ltge_operator"
4894 [(match_operand:V_VLSI 4 "register_operand" " vr, 0, vr, 0, 0, vr, 0, vr, vr")
4895 (match_operand:V_VLSI 5 "vector_neg_arith_operand" " vrvj, vrvj, 0, 0, vrvj, 0, 0, vrvj, vrvj")])
4896 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, vu, vu, 0, 0, 0, vu, 0")))]
4897 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
4898 "vms%B3.v%o5\t%0,%4,%v5%p1"
4899 [(set_attr "type" "vicmp")
4900 (set_attr "mode" "<MODE>")
4901 (set_attr "spec_restriction" "none,thv,thv,thv,thv,thv,thv,none,none")])
4902
4903 (define_expand "@pred_cmp<mode>_scalar"
4904 [(set (match_operand:<VM> 0 "register_operand")
4905 (if_then_else:<VM>
4906 (unspec:<VM>
4907 [(match_operand:<VM> 1 "vector_mask_operand")
4908 (match_operand 6 "vector_length_operand")
4909 (match_operand 7 "const_int_operand")
4910 (match_operand 8 "const_int_operand")
4911 (reg:SI VL_REGNUM)
4912 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4913 (match_operator:<VM> 3 "comparison_except_ge_operator"
4914 [(match_operand:V_VLSI_QHS 4 "register_operand")
4915 (vec_duplicate:V_VLSI_QHS
4916 (match_operand:<VEL> 5 "register_operand"))])
4917 (match_operand:<VM> 2 "vector_merge_operand")))]
4918 "TARGET_VECTOR"
4919 {})
4920
4921 (define_insn "*pred_cmp<mode>_scalar_merge_tie_mask"
4922 [(set (match_operand:<VM> 0 "register_operand" "=vm")
4923 (if_then_else:<VM>
4924 (unspec:<VM>
4925 [(match_operand:<VM> 1 "register_operand" " 0")
4926 (match_operand 5 "vector_length_operand" "rvl")
4927 (match_operand 6 "const_int_operand" " i")
4928 (match_operand 7 "const_int_operand" " i")
4929 (reg:SI VL_REGNUM)
4930 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4931 (match_operator:<VM> 2 "comparison_except_ge_operator"
4932 [(match_operand:V_VLSI_QHS 3 "register_operand" " vr")
4933 (vec_duplicate:V_VLSI_QHS
4934 (match_operand:<VEL> 4 "register_operand" " r"))])
4935 (match_dup 1)))]
4936 "TARGET_VECTOR"
4937 "vms%B2.vx\t%0,%3,%4,v0.t"
4938 [(set_attr "type" "vicmp")
4939 (set_attr "mode" "<MODE>")
4940 (set_attr "merge_op_idx" "1")
4941 (set_attr "vl_op_idx" "5")
4942 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
4943 (set (attr "avl_type_idx") (const_int 7))])
4944
4945 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
4946 (define_insn "*pred_cmp<mode>_scalar"
4947 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
4948 (if_then_else:<VM>
4949 (unspec:<VM>
4950 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1")
4951 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl")
4952 (match_operand 7 "const_int_operand" " i, i, i, i")
4953 (match_operand 8 "const_int_operand" " i, i, i, i")
4954 (reg:SI VL_REGNUM)
4955 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4956 (match_operator:<VM> 3 "comparison_except_ge_operator"
4957 [(match_operand:V_VLSI_QHS 4 "register_operand" " vr, vr, vr, vr")
4958 (vec_duplicate:V_VLSI_QHS
4959 (match_operand:<VEL> 5 "register_operand" " r, r, r, r"))])
4960 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
4961 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
4962 "vms%B3.vx\t%0,%4,%5%p1"
4963 [(set_attr "type" "vicmp")
4964 (set_attr "mode" "<MODE>")
4965 (set_attr "spec_restriction" "thv,thv,rvv,rvv")])
4966
4967 ;; We use early-clobber for source LMUL > dest LMUL.
4968 (define_insn "*pred_cmp<mode>_scalar_narrow"
4969 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, &vr, &vr")
4970 (if_then_else:<VM>
4971 (unspec:<VM>
4972 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1")
4973 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl")
4974 (match_operand 7 "const_int_operand" " i, i, i, i, i")
4975 (match_operand 8 "const_int_operand" " i, i, i, i, i")
4976 (reg:SI VL_REGNUM)
4977 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
4978 (match_operator:<VM> 3 "comparison_except_ge_operator"
4979 [(match_operand:V_VLSI_QHS 4 "register_operand" " vr, 0, 0, vr, vr")
4980 (vec_duplicate:V_VLSI_QHS
4981 (match_operand:<VEL> 5 "register_operand" " r, r, r, r, r"))])
4982 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, 0, vu, 0")))]
4983 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
4984 "vms%B3.vx\t%0,%4,%5%p1"
4985 [(set_attr "type" "vicmp")
4986 (set_attr "mode" "<MODE>")
4987 (set_attr "spec_restriction" "none,thv,thv,none,none")])
4988
4989 ;; Handle GET_MODE_INNER (mode) = DImode. We need to split them since
4990 ;; we need to deal with SEW = 64 in RV32 system.
4991 (define_expand "@pred_cmp<mode>_scalar"
4992 [(set (match_operand:<VM> 0 "register_operand")
4993 (if_then_else:<VM>
4994 (unspec:<VM>
4995 [(match_operand:<VM> 1 "vector_mask_operand")
4996 (match_operand 6 "vector_length_operand")
4997 (match_operand 7 "const_int_operand")
4998 (match_operand 8 "const_int_operand")
4999 (reg:SI VL_REGNUM)
5000 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5001 (match_operator:<VM> 3 "comparison_except_ge_operator"
5002 [(match_operand:V_VLSI_D 4 "register_operand")
5003 (vec_duplicate:V_VLSI_D
5004 (match_operand:<VEL> 5 "reg_or_int_operand"))])
5005 (match_operand:<VM> 2 "vector_merge_operand")))]
5006 "TARGET_VECTOR"
5007 {
5008 enum rtx_code code = GET_CODE (operands[3]);
5009 if (riscv_vector::sew64_scalar_helper (
5010 operands,
5011 /* scalar op */&operands[5],
5012 /* vl */operands[6],
5013 <MODE>mode,
5014 riscv_vector::has_vi_variant_p (code, operands[5]),
5015 code == LT || code == LTU ?
5016 [] (rtx *operands, rtx broadcast_scalar) {
5017 emit_insn (gen_pred_ltge<mode> (operands[0], operands[1],
5018 operands[2], operands[3], operands[4], broadcast_scalar,
5019 operands[6], operands[7], operands[8]));
5020 }
5021 :
5022 [] (rtx *operands, rtx broadcast_scalar) {
5023 emit_insn (gen_pred_cmp<mode> (operands[0], operands[1],
5024 operands[2], operands[3], operands[4], broadcast_scalar,
5025 operands[6], operands[7], operands[8]));
5026 },
5027 (riscv_vector::avl_type) INTVAL (operands[8])))
5028 DONE;
5029 })
5030
5031 (define_insn "*pred_cmp<mode>_scalar_merge_tie_mask"
5032 [(set (match_operand:<VM> 0 "register_operand" "=vm")
5033 (if_then_else:<VM>
5034 (unspec:<VM>
5035 [(match_operand:<VM> 1 "register_operand" " 0")
5036 (match_operand 5 "vector_length_operand" "rvl")
5037 (match_operand 6 "const_int_operand" " i")
5038 (match_operand 7 "const_int_operand" " i")
5039 (reg:SI VL_REGNUM)
5040 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5041 (match_operator:<VM> 2 "comparison_except_ge_operator"
5042 [(match_operand:V_VLSI_D 3 "register_operand" " vr")
5043 (vec_duplicate:V_VLSI_D
5044 (match_operand:<VEL> 4 "register_operand" " r"))])
5045 (match_dup 1)))]
5046 "TARGET_VECTOR"
5047 "vms%B2.vx\t%0,%3,%4,v0.t"
5048 [(set_attr "type" "vicmp")
5049 (set_attr "mode" "<MODE>")
5050 (set_attr "merge_op_idx" "1")
5051 (set_attr "vl_op_idx" "5")
5052 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
5053 (set (attr "avl_type_idx") (const_int 7))])
5054
5055 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
5056 (define_insn "*pred_cmp<mode>_scalar"
5057 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
5058 (if_then_else:<VM>
5059 (unspec:<VM>
5060 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1")
5061 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl")
5062 (match_operand 7 "const_int_operand" " i, i, i, i")
5063 (match_operand 8 "const_int_operand" " i, i, i, i")
5064 (reg:SI VL_REGNUM)
5065 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5066 (match_operator:<VM> 3 "comparison_except_ge_operator"
5067 [(match_operand:V_VLSI_D 4 "register_operand" " vr, vr, vr, vr")
5068 (vec_duplicate:V_VLSI_D
5069 (match_operand:<VEL> 5 "register_operand" " r, r, r, r"))])
5070 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
5071 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
5072 "vms%B3.vx\t%0,%4,%5%p1"
5073 [(set_attr "type" "vicmp")
5074 (set_attr "mode" "<MODE>")
5075 (set_attr "spec_restriction" "thv,thv,rvv,rvv")])
5076
5077 ;; We use early-clobber for source LMUL > dest LMUL.
5078 (define_insn "*pred_cmp<mode>_scalar_narrow"
5079 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, &vr, &vr")
5080 (if_then_else:<VM>
5081 (unspec:<VM>
5082 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1")
5083 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl")
5084 (match_operand 7 "const_int_operand" " i, i, i, i, i")
5085 (match_operand 8 "const_int_operand" " i, i, i, i, i")
5086 (reg:SI VL_REGNUM)
5087 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5088 (match_operator:<VM> 3 "comparison_except_ge_operator"
5089 [(match_operand:V_VLSI_D 4 "register_operand" " vr, 0, 0, vr, vr")
5090 (vec_duplicate:V_VLSI_D
5091 (match_operand:<VEL> 5 "register_operand" " r, r, r, r, r"))])
5092 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, 0, vu, 0")))]
5093 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
5094 "vms%B3.vx\t%0,%4,%5%p1"
5095 [(set_attr "type" "vicmp")
5096 (set_attr "mode" "<MODE>")
5097 (set_attr "spec_restriction" "none,thv,thv,none,none")])
5098
5099 (define_insn "*pred_cmp<mode>_extended_scalar_merge_tie_mask"
5100 [(set (match_operand:<VM> 0 "register_operand" "=vm")
5101 (if_then_else:<VM>
5102 (unspec:<VM>
5103 [(match_operand:<VM> 1 "register_operand" " 0")
5104 (match_operand 5 "vector_length_operand" "rvl")
5105 (match_operand 6 "const_int_operand" " i")
5106 (match_operand 7 "const_int_operand" " i")
5107 (reg:SI VL_REGNUM)
5108 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5109 (match_operator:<VM> 2 "comparison_except_ge_operator"
5110 [(match_operand:V_VLSI_D 3 "register_operand" " vr")
5111 (vec_duplicate:V_VLSI_D
5112 (sign_extend:<VEL>
5113 (match_operand:<VSUBEL> 4 "register_operand" " r")))])
5114 (match_dup 1)))]
5115 "TARGET_VECTOR && !TARGET_64BIT"
5116 "vms%B2.vx\t%0,%3,%4,v0.t"
5117 [(set_attr "type" "vicmp")
5118 (set_attr "mode" "<MODE>")
5119 (set_attr "merge_op_idx" "1")
5120 (set_attr "vl_op_idx" "5")
5121 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
5122 (set (attr "avl_type_idx") (const_int 7))])
5123
5124 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
5125 (define_insn "*pred_cmp<mode>_extended_scalar"
5126 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
5127 (if_then_else:<VM>
5128 (unspec:<VM>
5129 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1")
5130 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl")
5131 (match_operand 7 "const_int_operand" " i, i, i, i")
5132 (match_operand 8 "const_int_operand" " i, i, i, i")
5133 (reg:SI VL_REGNUM)
5134 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5135 (match_operator:<VM> 3 "comparison_except_ge_operator"
5136 [(match_operand:V_VLSI_D 4 "register_operand" " vr, vr, vr, vr")
5137 (vec_duplicate:V_VLSI_D
5138 (sign_extend:<VEL>
5139 (match_operand:<VSUBEL> 5 "register_operand" " r, r, r, r")))])
5140 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
5141 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode) && !TARGET_64BIT"
5142 "vms%B3.vx\t%0,%4,%5%p1"
5143 [(set_attr "type" "vicmp")
5144 (set_attr "mode" "<MODE>")
5145 (set_attr "spec_restriction" "thv,thv,rvv,rvv")])
5146
5147 (define_insn "*pred_cmp<mode>_extended_scalar_narrow"
5148 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, &vr, &vr")
5149 (if_then_else:<VM>
5150 (unspec:<VM>
5151 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1")
5152 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl")
5153 (match_operand 7 "const_int_operand" " i, i, i, i, i")
5154 (match_operand 8 "const_int_operand" " i, i, i, i, i")
5155 (reg:SI VL_REGNUM)
5156 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5157 (match_operator:<VM> 3 "comparison_except_ge_operator"
5158 [(match_operand:V_VLSI_D 4 "register_operand" " vr, 0, 0, vr, vr")
5159 (vec_duplicate:V_VLSI_D
5160 (sign_extend:<VEL>
5161 (match_operand:<VSUBEL> 5 "register_operand" " r, r, r, r, r")))])
5162 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, 0, vu, 0")))]
5163 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode) && !TARGET_64BIT"
5164 "vms%B3.vx\t%0,%4,%5%p1"
5165 [(set_attr "type" "vicmp")
5166 (set_attr "mode" "<MODE>")
5167 (set_attr "spec_restriction" "none,thv,thv,none,none")])
5168
5169 ;; GE, vmsge.vx/vmsgeu.vx
5170 ;;
5171 ;; unmasked va >= x
5172 ;; - pseudoinstruction: vmsge{u}.vx vd, va, x
5173 ;; - expansion: vmslt{u}.vx vd, va, x; vmnand.mm vd, vd, vd
5174 ;;
5175 ;; masked va >= x, vd != v0
5176 ;; - pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t
5177 ;; - expansion: vmslt{u}.vx vd, va, x, v0.t; vmxor.mm vd, vd, v0
5178 ;;
5179 ;; masked va >= x, vd == v0
5180 ;; - pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t, vt
5181 ;; - expansion: vmslt{u}.vx vt, va, x; vmandn.mm vd, vd, vt
5182 (define_expand "@pred_ge<mode>_scalar"
5183 [(set (match_operand:<VM> 0 "register_operand")
5184 (if_then_else:<VM>
5185 (unspec:<VM>
5186 [(match_operand:<VM> 1 "vector_mask_operand")
5187 (match_operand 6 "vector_length_operand")
5188 (match_operand 7 "const_int_operand")
5189 (match_operand 8 "const_int_operand")
5190 (reg:SI VL_REGNUM)
5191 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5192 (match_operator:<VM> 3 "ge_operator"
5193 [(match_operand:V_VLSI 4 "register_operand")
5194 (vec_duplicate:V_VLSI
5195 (match_operand:<VEL> 5 "reg_or_int_operand"))])
5196 (match_operand:<VM> 2 "vector_merge_operand")))]
5197 "TARGET_VECTOR"
5198 {
5199 enum rtx_code code = GET_CODE (operands[3]);
5200 rtx undef = RVV_VUNDEF (<VM>mode);
5201 rtx tmp = gen_reg_rtx (<VM>mode);
5202 if (code == GEU && rtx_equal_p (operands[5], const0_rtx))
5203 {
5204 /* If vmsgeu with 0 immediate, expand it to vmset. */
5205 if (satisfies_constraint_Wc1 (operands[1]))
5206 emit_insn (
5207 gen_pred_mov (<VM>mode, operands[0], CONSTM1_RTX (<VM>mode), undef,
5208 CONSTM1_RTX (<VM>mode), operands[6], operands[8]));
5209 else
5210 {
5211 /* If vmsgeu_mask with 0 immediate, expand it to vmor mask, maskedoff.
5212 */
5213 if (rtx_equal_p (operands[1], operands[2]))
5214 emit_move_insn (operands[0], operands[1]);
5215 else if (register_operand (operands[2], <VM>mode))
5216 emit_insn (gen_pred (IOR, <VM>mode, operands[0],
5217 CONSTM1_RTX (<VM>mode), undef, operands[1],
5218 operands[2], operands[6], operands[8]));
5219 else
5220 emit_insn (gen_pred (IOR, <VM>mode, operands[0],
5221 CONSTM1_RTX (<VM>mode), undef, operands[1],
5222 operands[1], operands[6], operands[8]));
5223 }
5224 }
5225 else if (riscv_vector::neg_simm5_p (operands[5]))
5226 emit_insn (
5227 gen_pred_ltge<mode> (operands[0], operands[1], operands[2], operands[3],
5228 operands[4],
5229 gen_const_vec_duplicate (<MODE>mode, operands[5]),
5230 operands[6], operands[7], operands[8]));
5231 else
5232 {
5233 if (code == GE)
5234 operands[3] = gen_rtx_fmt_ee (LT, <VM>mode, XEXP (operands[3], 0),
5235 XEXP (operands[3], 1));
5236 else
5237 operands[3] = gen_rtx_fmt_ee (LTU, <VM>mode, XEXP (operands[3], 0),
5238 XEXP (operands[3], 1));
5239 if (GET_MODE_BITSIZE (<VEL>mode) <= GET_MODE_BITSIZE (Pmode))
5240 operands[5] = force_reg (<VEL>mode, operands[5]);
5241
5242 if (satisfies_constraint_Wc1 (operands[1]))
5243 {
5244 /* unmasked va >= x
5245 - pseudoinstruction: vmsge{u}.vx vd, va, x
5246 - expansion: vmslt{u}.vx vd, va, x; vmnand.mm vd, vd, vd. */
5247 emit_insn (
5248 gen_pred_cmp<mode>_scalar (tmp, operands[1], operands[2],
5249 operands[3], operands[4], operands[5],
5250 operands[6], operands[7], operands[8]));
5251 emit_insn (gen_pred_nand<vm> (operands[0], CONSTM1_RTX (<VM>mode),
5252 undef, tmp, tmp, operands[6], operands[8]));
5253 }
5254 else
5255 {
5256 if (rtx_equal_p (operands[1], operands[2]))
5257 {
5258 /* masked va >= x, vd == v0
5259 - pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t, vt
5260 - expansion: vmslt{u}.vx vt, va, x; vmandn.mm vd, vd, vt. */
5261 emit_insn (gen_pred_cmp<mode>_scalar (
5262 tmp, CONSTM1_RTX (<VM>mode), undef, operands[3], operands[4],
5263 operands[5], operands[6], operands[7], operands[8]));
5264 emit_insn (
5265 gen_pred_andnot<vm> (operands[0], CONSTM1_RTX (<VM>mode), undef,
5266 operands[1], tmp, operands[6], operands[8]));
5267 }
5268 else
5269 {
5270 /* masked va >= x, vd != v0
5271 - pseudoinstruction: vmsge{u}.vx vd, va, x, v0.t
5272 - expansion: vmslt{u}.vx vd, va, x, v0.t; vmxor.mm vd, vd, v0.
5273 */
5274 emit_insn (gen_pred_cmp<mode>_scalar (
5275 tmp, operands[1], operands[2], operands[3], operands[4],
5276 operands[5], operands[6], operands[7], operands[8]));
5277 emit_insn (gen_pred (XOR, <VM>mode, operands[0],
5278 CONSTM1_RTX (<VM>mode), undef, tmp,
5279 operands[1], operands[6], operands[8]));
5280 }
5281 }
5282 }
5283 DONE;
5284 })
5285
5286 ;; -------------------------------------------------------------------------------
5287 ;; ---- Predicated integer ternary operations
5288 ;; -------------------------------------------------------------------------------
5289 ;; Includes:
5290 ;; - 11.13 Vector Single-Width Integer Multiply-Add Instructions
5291 ;; -------------------------------------------------------------------------------
5292
5293 (define_expand "@pred_mul_plus<mode>"
5294 [(set (match_operand:V_VLSI 0 "register_operand")
5295 (if_then_else:V_VLSI
5296 (unspec:<VM>
5297 [(match_operand:<VM> 1 "vector_mask_operand")
5298 (match_operand 6 "vector_length_operand")
5299 (match_operand 7 "const_int_operand")
5300 (match_operand 8 "const_int_operand")
5301 (match_operand 9 "const_int_operand")
5302 (reg:SI VL_REGNUM)
5303 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5304 (plus:V_VLSI
5305 (mult:V_VLSI
5306 (match_operand:V_VLSI 2 "register_operand")
5307 (match_operand:V_VLSI 3 "register_operand"))
5308 (match_operand:V_VLSI 4 "register_operand"))
5309 (match_operand:V_VLSI 5 "vector_merge_operand")))]
5310 "TARGET_VECTOR"
5311 {
5312 riscv_vector::prepare_ternary_operands (operands);
5313 })
5314
5315 (define_insn "*pred_mul_plus<mode>_undef"
5316 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr")
5317 (if_then_else:V_VLSI
5318 (unspec:<VM>
5319 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm, Wc1,Wc1")
5320 (match_operand 6 "vector_length_operand" "rvl,rvl, rvl,rvl")
5321 (match_operand 7 "const_int_operand" " i, i, i, i")
5322 (match_operand 8 "const_int_operand" " i, i, i, i")
5323 (match_operand 9 "const_int_operand" " i, i, i, i")
5324 (reg:SI VL_REGNUM)
5325 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5326 (plus:V_VLSI
5327 (mult:V_VLSI
5328 (match_operand:V_VLSI 3 "register_operand" " 0, vr, 0, vr")
5329 (match_operand:V_VLSI 4 "register_operand" " vr, vr, vr, vr"))
5330 (match_operand:V_VLSI 5 "register_operand" " vr, 0, vr, 0"))
5331 (match_operand:V_VLSI 2 "vector_undef_operand")))]
5332 "TARGET_VECTOR"
5333 "@
5334 vmadd.vv\t%0,%4,%5%p1
5335 vmacc.vv\t%0,%3,%4%p1
5336 vmadd.vv\t%0,%4,%5%p1
5337 vmacc.vv\t%0,%3,%4%p1"
5338 [(set_attr "type" "vimuladd")
5339 (set_attr "mode" "<MODE>")])
5340
5341 (define_insn "*pred_madd<mode>"
5342 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5343 (if_then_else:V_VLSI
5344 (unspec:<VM>
5345 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5346 (match_operand 5 "vector_length_operand" "rvl,rvl")
5347 (match_operand 6 "const_int_operand" " i, i")
5348 (match_operand 7 "const_int_operand" " i, i")
5349 (match_operand 8 "const_int_operand" " i, i")
5350 (reg:SI VL_REGNUM)
5351 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5352 (plus:V_VLSI
5353 (mult:V_VLSI
5354 (match_operand:V_VLSI 2 "register_operand" " 0, 0")
5355 (match_operand:V_VLSI 3 "register_operand" " vr, vr"))
5356 (match_operand:V_VLSI 4 "register_operand" " vr, vr"))
5357 (match_dup 2)))]
5358 "TARGET_VECTOR"
5359 "@
5360 vmadd.vv\t%0,%3,%4%p1
5361 vmadd.vv\t%0,%3,%4%p1"
5362 [(set_attr "type" "vimuladd")
5363 (set_attr "mode" "<MODE>")
5364 (set_attr "merge_op_idx" "2")
5365 (set_attr "vl_op_idx" "5")
5366 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5367 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5368 (set (attr "avl_type_idx") (const_int 8))])
5369
5370 (define_insn "*pred_macc<mode>"
5371 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5372 (if_then_else:V_VLSI
5373 (unspec:<VM>
5374 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5375 (match_operand 5 "vector_length_operand" "rvl,rvl")
5376 (match_operand 6 "const_int_operand" " i, i")
5377 (match_operand 7 "const_int_operand" " i, i")
5378 (match_operand 8 "const_int_operand" " i, i")
5379 (reg:SI VL_REGNUM)
5380 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5381 (plus:V_VLSI
5382 (mult:V_VLSI
5383 (match_operand:V_VLSI 2 "register_operand" " vr, vr")
5384 (match_operand:V_VLSI 3 "register_operand" " vr, vr"))
5385 (match_operand:V_VLSI 4 "register_operand" " 0, 0"))
5386 (match_dup 4)))]
5387 "TARGET_VECTOR"
5388 "vmacc.vv\t%0,%2,%3%p1"
5389 [(set_attr "type" "vimuladd")
5390 (set_attr "mode" "<MODE>")
5391 (set_attr "merge_op_idx" "4")
5392 (set_attr "vl_op_idx" "5")
5393 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5394 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5395 (set (attr "avl_type_idx") (const_int 8))])
5396
5397 (define_expand "@pred_mul_plus<mode>_scalar"
5398 [(set (match_operand:V_VLSI_QHS 0 "register_operand")
5399 (if_then_else:V_VLSI_QHS
5400 (unspec:<VM>
5401 [(match_operand:<VM> 1 "vector_mask_operand")
5402 (match_operand 6 "vector_length_operand")
5403 (match_operand 7 "const_int_operand")
5404 (match_operand 8 "const_int_operand")
5405 (match_operand 9 "const_int_operand")
5406 (reg:SI VL_REGNUM)
5407 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5408 (plus:V_VLSI_QHS
5409 (mult:V_VLSI_QHS
5410 (vec_duplicate:V_VLSI_QHS
5411 (match_operand:<VEL> 2 "register_operand"))
5412 (match_operand:V_VLSI_QHS 3 "register_operand"))
5413 (match_operand:V_VLSI_QHS 4 "register_operand"))
5414 (match_operand:V_VLSI_QHS 5 "register_operand")))]
5415 "TARGET_VECTOR"
5416 {})
5417
5418 (define_insn "*pred_madd<mode>_scalar"
5419 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5420 (if_then_else:V_VLSI
5421 (unspec:<VM>
5422 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5423 (match_operand 5 "vector_length_operand" "rvl,rvl")
5424 (match_operand 6 "const_int_operand" " i, i")
5425 (match_operand 7 "const_int_operand" " i, i")
5426 (match_operand 8 "const_int_operand" " i, i")
5427 (reg:SI VL_REGNUM)
5428 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5429 (plus:V_VLSI
5430 (mult:V_VLSI
5431 (vec_duplicate:V_VLSI
5432 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
5433 (match_operand:V_VLSI 3 "register_operand" " 0, 0"))
5434 (match_operand:V_VLSI 4 "register_operand" " vr, vr"))
5435 (match_dup 3)))]
5436 "TARGET_VECTOR"
5437 "@
5438 vmadd.vx\t%0,%z2,%4%p1
5439 vmadd.vx\t%0,%z2,%4%p1"
5440 [(set_attr "type" "vimuladd")
5441 (set_attr "mode" "<MODE>")
5442 (set_attr "merge_op_idx" "3")
5443 (set_attr "vl_op_idx" "5")
5444 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5445 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5446 (set (attr "avl_type_idx") (const_int 8))])
5447
5448 (define_insn "*pred_macc<mode>_scalar"
5449 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5450 (if_then_else:V_VLSI
5451 (unspec:<VM>
5452 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5453 (match_operand 5 "vector_length_operand" "rvl,rvl")
5454 (match_operand 6 "const_int_operand" " i, i")
5455 (match_operand 7 "const_int_operand" " i, i")
5456 (match_operand 8 "const_int_operand" " i, i")
5457 (reg:SI VL_REGNUM)
5458 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5459 (plus:V_VLSI
5460 (mult:V_VLSI
5461 (vec_duplicate:V_VLSI
5462 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
5463 (match_operand:V_VLSI 3 "register_operand" " vr, vr"))
5464 (match_operand:V_VLSI 4 "register_operand" " 0, 0"))
5465 (match_dup 4)))]
5466 "TARGET_VECTOR"
5467 "@
5468 vmacc.vx\t%0,%z2,%3%p1
5469 vmacc.vx\t%0,%z2,%3%p1"
5470 [(set_attr "type" "vimuladd")
5471 (set_attr "mode" "<MODE>")
5472 (set_attr "merge_op_idx" "4")
5473 (set_attr "vl_op_idx" "5")
5474 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5475 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5476 (set (attr "avl_type_idx") (const_int 8))])
5477
5478 (define_expand "@pred_mul_plus<mode>_scalar"
5479 [(set (match_operand:V_VLSI_D 0 "register_operand")
5480 (if_then_else:V_VLSI_D
5481 (unspec:<VM>
5482 [(match_operand:<VM> 1 "vector_mask_operand")
5483 (match_operand 6 "vector_length_operand")
5484 (match_operand 7 "const_int_operand")
5485 (match_operand 8 "const_int_operand")
5486 (match_operand 9 "const_int_operand")
5487 (reg:SI VL_REGNUM)
5488 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5489 (plus:V_VLSI_D
5490 (mult:V_VLSI_D
5491 (vec_duplicate:V_VLSI_D
5492 (match_operand:<VEL> 2 "reg_or_int_operand"))
5493 (match_operand:V_VLSI_D 3 "register_operand"))
5494 (match_operand:V_VLSI_D 4 "register_operand"))
5495 (match_operand:V_VLSI_D 5 "register_operand")))]
5496 "TARGET_VECTOR"
5497 {
5498 if (riscv_vector::sew64_scalar_helper (
5499 operands,
5500 /* scalar op */&operands[2],
5501 /* vl */operands[6],
5502 <MODE>mode,
5503 false,
5504 [] (rtx *operands, rtx broadcast_scalar) {
5505 emit_insn (gen_pred_mul_plus<mode> (operands[0], operands[1],
5506 broadcast_scalar, operands[3], operands[4], operands[5],
5507 operands[6], operands[7], operands[8], operands[9]));
5508 },
5509 (riscv_vector::avl_type) INTVAL (operands[9])))
5510 DONE;
5511 })
5512
5513 (define_insn "*pred_madd<mode>_extended_scalar"
5514 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd, vr")
5515 (if_then_else:V_VLSI_D
5516 (unspec:<VM>
5517 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5518 (match_operand 5 "vector_length_operand" "rvl,rvl")
5519 (match_operand 6 "const_int_operand" " i, i")
5520 (match_operand 7 "const_int_operand" " i, i")
5521 (match_operand 8 "const_int_operand" " i, i")
5522 (reg:SI VL_REGNUM)
5523 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5524 (plus:V_VLSI_D
5525 (mult:V_VLSI_D
5526 (vec_duplicate:V_VLSI_D
5527 (sign_extend:<VEL>
5528 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
5529 (match_operand:V_VLSI_D 3 "register_operand" " 0, 0"))
5530 (match_operand:V_VLSI_D 4 "register_operand" " vr, vr"))
5531 (match_dup 3)))]
5532 "TARGET_VECTOR && !TARGET_64BIT"
5533 "@
5534 vmadd.vx\t%0,%z2,%4%p1
5535 vmadd.vx\t%0,%z2,%4%p1"
5536 [(set_attr "type" "vimuladd")
5537 (set_attr "mode" "<MODE>")
5538 (set_attr "merge_op_idx" "3")
5539 (set_attr "vl_op_idx" "5")
5540 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5541 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5542 (set (attr "avl_type_idx") (const_int 8))])
5543
5544 (define_insn "*pred_macc<mode>_extended_scalar"
5545 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd, vr")
5546 (if_then_else:V_VLSI_D
5547 (unspec:<VM>
5548 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5549 (match_operand 5 "vector_length_operand" "rvl,rvl")
5550 (match_operand 6 "const_int_operand" " i, i")
5551 (match_operand 7 "const_int_operand" " i, i")
5552 (match_operand 8 "const_int_operand" " i, i")
5553 (reg:SI VL_REGNUM)
5554 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5555 (plus:V_VLSI_D
5556 (mult:V_VLSI_D
5557 (vec_duplicate:V_VLSI_D
5558 (sign_extend:<VEL>
5559 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
5560 (match_operand:V_VLSI_D 3 "register_operand" " vr, vr"))
5561 (match_operand:V_VLSI_D 4 "register_operand" " 0, 0"))
5562 (match_dup 4)))]
5563 "TARGET_VECTOR && !TARGET_64BIT"
5564 "@
5565 vmacc.vx\t%0,%z2,%3%p1
5566 vmacc.vx\t%0,%z2,%3%p1"
5567 [(set_attr "type" "vimuladd")
5568 (set_attr "mode" "<MODE>")
5569 (set_attr "merge_op_idx" "4")
5570 (set_attr "vl_op_idx" "5")
5571 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5572 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5573 (set (attr "avl_type_idx") (const_int 8))])
5574
5575 (define_expand "@pred_minus_mul<mode>"
5576 [(set (match_operand:V_VLSI 0 "register_operand")
5577 (if_then_else:V_VLSI
5578 (unspec:<VM>
5579 [(match_operand:<VM> 1 "vector_mask_operand")
5580 (match_operand 6 "vector_length_operand")
5581 (match_operand 7 "const_int_operand")
5582 (match_operand 8 "const_int_operand")
5583 (match_operand 9 "const_int_operand")
5584 (reg:SI VL_REGNUM)
5585 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5586 (minus:V_VLSI
5587 (match_operand:V_VLSI 4 "register_operand")
5588 (mult:V_VLSI
5589 (match_operand:V_VLSI 2 "register_operand")
5590 (match_operand:V_VLSI 3 "register_operand")))
5591 (match_operand:V_VLSI 5 "vector_merge_operand")))]
5592 "TARGET_VECTOR"
5593 {
5594 riscv_vector::prepare_ternary_operands (operands);
5595 })
5596
5597 (define_insn "*pred_minus_mul<mode>_undef"
5598 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr")
5599 (if_then_else:V_VLSI
5600 (unspec:<VM>
5601 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
5602 (match_operand 6 "vector_length_operand" "rvl,rvl,rvl,rvl")
5603 (match_operand 7 "const_int_operand" " i, i, i, i")
5604 (match_operand 8 "const_int_operand" " i, i, i, i")
5605 (match_operand 9 "const_int_operand" " i, i, i, i")
5606 (reg:SI VL_REGNUM)
5607 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5608 (minus:V_VLSI
5609 (match_operand:V_VLSI 5 "register_operand" " vr, 0, vr, 0")
5610 (mult:V_VLSI
5611 (match_operand:V_VLSI 3 "register_operand" " 0, vr, 0, vr")
5612 (match_operand:V_VLSI 4 "register_operand" " vr, vr, vr, vr")))
5613 (match_operand:V_VLSI 2 "vector_undef_operand")))]
5614 "TARGET_VECTOR"
5615 "@
5616 vnmsub.vv\t%0,%4,%5%p1
5617 vnmsac.vv\t%0,%3,%4%p1
5618 vnmsub.vv\t%0,%4,%5%p1
5619 vnmsac.vv\t%0,%3,%4%p1"
5620 [(set_attr "type" "vimuladd")
5621 (set_attr "mode" "<MODE>")])
5622
5623 (define_insn "*pred_nmsub<mode>"
5624 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5625 (if_then_else:V_VLSI
5626 (unspec:<VM>
5627 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5628 (match_operand 5 "vector_length_operand" "rvl,rvl")
5629 (match_operand 6 "const_int_operand" " i, i")
5630 (match_operand 7 "const_int_operand" " i, i")
5631 (match_operand 8 "const_int_operand" " i, i")
5632 (reg:SI VL_REGNUM)
5633 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5634 (minus:V_VLSI
5635 (match_operand:V_VLSI 4 "register_operand" " vr, vr")
5636 (mult:V_VLSI
5637 (match_operand:V_VLSI 2 "register_operand" " 0, 0")
5638 (match_operand:V_VLSI 3 "register_operand" " vr, vr")))
5639 (match_dup 2)))]
5640 "TARGET_VECTOR"
5641 "@
5642 vnmsub.vv\t%0,%3,%4%p1
5643 vnmsub.vv\t%0,%3,%4%p1"
5644 [(set_attr "type" "vimuladd")
5645 (set_attr "mode" "<MODE>")
5646 (set_attr "merge_op_idx" "2")
5647 (set_attr "vl_op_idx" "5")
5648 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5649 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5650 (set (attr "avl_type_idx") (const_int 8))])
5651
5652 (define_insn "*pred_nmsac<mode>"
5653 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5654 (if_then_else:V_VLSI
5655 (unspec:<VM>
5656 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5657 (match_operand 5 "vector_length_operand" "rvl,rvl")
5658 (match_operand 6 "const_int_operand" " i, i")
5659 (match_operand 7 "const_int_operand" " i, i")
5660 (match_operand 8 "const_int_operand" " i, i")
5661 (reg:SI VL_REGNUM)
5662 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5663 (minus:V_VLSI
5664 (match_operand:V_VLSI 4 "register_operand" " 0, 0")
5665 (mult:V_VLSI
5666 (match_operand:V_VLSI 2 "register_operand" " vr, vr")
5667 (match_operand:V_VLSI 3 "register_operand" " vr, vr")))
5668 (match_dup 4)))]
5669 "TARGET_VECTOR"
5670 "@
5671 vnmsac.vv\t%0,%2,%3%p1
5672 vnmsac.vv\t%0,%2,%3%p1"
5673 [(set_attr "type" "vimuladd")
5674 (set_attr "mode" "<MODE>")
5675 (set_attr "merge_op_idx" "4")
5676 (set_attr "vl_op_idx" "5")
5677 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5678 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5679 (set (attr "avl_type_idx") (const_int 8))])
5680
5681 (define_expand "@pred_minus_mul<mode>_scalar"
5682 [(set (match_operand:V_VLSI_QHS 0 "register_operand")
5683 (if_then_else:V_VLSI_QHS
5684 (unspec:<VM>
5685 [(match_operand:<VM> 1 "vector_mask_operand")
5686 (match_operand 6 "vector_length_operand")
5687 (match_operand 7 "const_int_operand")
5688 (match_operand 8 "const_int_operand")
5689 (match_operand 9 "const_int_operand")
5690 (reg:SI VL_REGNUM)
5691 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5692 (minus:V_VLSI_QHS
5693 (match_operand:V_VLSI_QHS 4 "register_operand")
5694 (mult:V_VLSI_QHS
5695 (vec_duplicate:V_VLSI_QHS
5696 (match_operand:<VEL> 2 "register_operand"))
5697 (match_operand:V_VLSI_QHS 3 "register_operand")))
5698 (match_operand:V_VLSI_QHS 5 "register_operand")))]
5699 "TARGET_VECTOR"
5700 {})
5701
5702 (define_insn "*pred_nmsub<mode>_scalar"
5703 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5704 (if_then_else:V_VLSI
5705 (unspec:<VM>
5706 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5707 (match_operand 5 "vector_length_operand" "rvl,rvl")
5708 (match_operand 6 "const_int_operand" " i, i")
5709 (match_operand 7 "const_int_operand" " i, i")
5710 (match_operand 8 "const_int_operand" " i, i")
5711 (reg:SI VL_REGNUM)
5712 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5713 (minus:V_VLSI
5714 (match_operand:V_VLSI 4 "register_operand" " vr, vr")
5715 (mult:V_VLSI
5716 (vec_duplicate:V_VLSI
5717 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
5718 (match_operand:V_VLSI 3 "register_operand" " 0, 0")))
5719 (match_dup 3)))]
5720 "TARGET_VECTOR"
5721 "@
5722 vnmsub.vx\t%0,%z2,%4%p1
5723 vnmsub.vx\t%0,%z2,%4%p1"
5724 [(set_attr "type" "vimuladd")
5725 (set_attr "mode" "<MODE>")
5726 (set_attr "merge_op_idx" "3")
5727 (set_attr "vl_op_idx" "5")
5728 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5729 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5730 (set (attr "avl_type_idx") (const_int 8))])
5731
5732 (define_insn "*pred_nmsac<mode>_scalar"
5733 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vr")
5734 (if_then_else:V_VLSI
5735 (unspec:<VM>
5736 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5737 (match_operand 5 "vector_length_operand" "rvl,rvl")
5738 (match_operand 6 "const_int_operand" " i, i")
5739 (match_operand 7 "const_int_operand" " i, i")
5740 (match_operand 8 "const_int_operand" " i, i")
5741 (reg:SI VL_REGNUM)
5742 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5743 (minus:V_VLSI
5744 (match_operand:V_VLSI 4 "register_operand" " 0, 0")
5745 (mult:V_VLSI
5746 (vec_duplicate:V_VLSI
5747 (match_operand:<VEL> 2 "reg_or_0_operand" " rJ, rJ"))
5748 (match_operand:V_VLSI 3 "register_operand" " vr, vr")))
5749 (match_dup 4)))]
5750 "TARGET_VECTOR"
5751 "@
5752 vnmsac.vx\t%0,%z2,%3%p1
5753 vnmsac.vx\t%0,%z2,%3%p1"
5754 [(set_attr "type" "vimuladd")
5755 (set_attr "mode" "<MODE>")
5756 (set_attr "merge_op_idx" "4")
5757 (set_attr "vl_op_idx" "5")
5758 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5759 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5760 (set (attr "avl_type_idx") (const_int 8))])
5761
5762 (define_expand "@pred_minus_mul<mode>_scalar"
5763 [(set (match_operand:V_VLSI_D 0 "register_operand")
5764 (if_then_else:V_VLSI_D
5765 (unspec:<VM>
5766 [(match_operand:<VM> 1 "vector_mask_operand")
5767 (match_operand 6 "vector_length_operand")
5768 (match_operand 7 "const_int_operand")
5769 (match_operand 8 "const_int_operand")
5770 (match_operand 9 "const_int_operand")
5771 (reg:SI VL_REGNUM)
5772 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5773 (minus:V_VLSI_D
5774 (match_operand:V_VLSI_D 4 "register_operand")
5775 (mult:V_VLSI_D
5776 (vec_duplicate:V_VLSI_D
5777 (match_operand:<VEL> 2 "reg_or_int_operand"))
5778 (match_operand:V_VLSI_D 3 "register_operand")))
5779 (match_operand:V_VLSI_D 5 "register_operand")))]
5780 "TARGET_VECTOR"
5781 {
5782 if (riscv_vector::sew64_scalar_helper (
5783 operands,
5784 /* scalar op */&operands[2],
5785 /* vl */operands[6],
5786 <MODE>mode,
5787 false,
5788 [] (rtx *operands, rtx broadcast_scalar) {
5789 emit_insn (gen_pred_minus_mul<mode> (operands[0], operands[1],
5790 broadcast_scalar, operands[3], operands[4], operands[5],
5791 operands[6], operands[7], operands[8], operands[9]));
5792 },
5793 (riscv_vector::avl_type) INTVAL (operands[9])))
5794 DONE;
5795 })
5796
5797 (define_insn "*pred_nmsub<mode>_extended_scalar"
5798 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd, vr")
5799 (if_then_else:V_VLSI_D
5800 (unspec:<VM>
5801 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5802 (match_operand 5 "vector_length_operand" "rvl,rvl")
5803 (match_operand 6 "const_int_operand" " i, i")
5804 (match_operand 7 "const_int_operand" " i, i")
5805 (match_operand 8 "const_int_operand" " i, i")
5806 (reg:SI VL_REGNUM)
5807 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5808 (minus:V_VLSI_D
5809 (match_operand:V_VLSI_D 4 "register_operand" " vr, vr")
5810 (mult:V_VLSI_D
5811 (vec_duplicate:V_VLSI_D
5812 (sign_extend:<VEL>
5813 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
5814 (match_operand:V_VLSI_D 3 "register_operand" " 0, 0")))
5815 (match_dup 3)))]
5816 "TARGET_VECTOR && !TARGET_64BIT"
5817 "@
5818 vnmsub.vx\t%0,%z2,%4%p1
5819 vnmsub.vx\t%0,%z2,%4%p1"
5820 [(set_attr "type" "vimuladd")
5821 (set_attr "mode" "<MODE>")
5822 (set_attr "merge_op_idx" "3")
5823 (set_attr "vl_op_idx" "5")
5824 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5825 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5826 (set (attr "avl_type_idx") (const_int 8))])
5827
5828 (define_insn "*pred_nmsac<mode>_extended_scalar"
5829 [(set (match_operand:V_VLSI_D 0 "register_operand" "=vd, vr")
5830 (if_then_else:V_VLSI_D
5831 (unspec:<VM>
5832 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
5833 (match_operand 5 "vector_length_operand" "rvl,rvl")
5834 (match_operand 6 "const_int_operand" " i, i")
5835 (match_operand 7 "const_int_operand" " i, i")
5836 (match_operand 8 "const_int_operand" " i, i")
5837 (reg:SI VL_REGNUM)
5838 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5839 (minus:V_VLSI_D
5840 (match_operand:V_VLSI_D 4 "register_operand" " 0, 0")
5841 (mult:V_VLSI_D
5842 (vec_duplicate:V_VLSI_D
5843 (sign_extend:<VEL>
5844 (match_operand:<VSUBEL> 2 "reg_or_0_operand" " rJ, rJ")))
5845 (match_operand:V_VLSI_D 3 "register_operand" " vr, vr")))
5846 (match_dup 4)))]
5847 "TARGET_VECTOR && !TARGET_64BIT"
5848 "@
5849 vnmsac.vx\t%0,%z2,%3%p1
5850 vnmsac.vx\t%0,%z2,%3%p1"
5851 [(set_attr "type" "vimuladd")
5852 (set_attr "mode" "<MODE>")
5853 (set_attr "merge_op_idx" "4")
5854 (set_attr "vl_op_idx" "5")
5855 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
5856 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
5857 (set (attr "avl_type_idx") (const_int 8))])
5858
5859 ;; -------------------------------------------------------------------------------
5860 ;; ---- Predicated widen integer ternary operations
5861 ;; -------------------------------------------------------------------------------
5862 ;; Includes:
5863 ;; - 11.14 Vector Widening Integer Multiply-Add Instructions
5864 ;; -------------------------------------------------------------------------------
5865
5866 (define_insn "@pred_widen_mul_plus<su><mode>"
5867 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr")
5868 (if_then_else:VWEXTI
5869 (unspec:<VM>
5870 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
5871 (match_operand 5 "vector_length_operand" " rvl")
5872 (match_operand 6 "const_int_operand" " i")
5873 (match_operand 7 "const_int_operand" " i")
5874 (match_operand 8 "const_int_operand" " i")
5875 (reg:SI VL_REGNUM)
5876 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5877 (plus:VWEXTI
5878 (mult:VWEXTI
5879 (any_extend:VWEXTI
5880 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr"))
5881 (any_extend:VWEXTI
5882 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
5883 (match_operand:VWEXTI 2 "register_operand" " 0"))
5884 (match_dup 2)))]
5885 "TARGET_VECTOR"
5886 "vwmacc<u>.vv\t%0,%3,%4%p1"
5887 [(set_attr "type" "viwmuladd")
5888 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
5889
5890 (define_insn "@pred_widen_mul_plus<su><mode>_scalar"
5891 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr")
5892 (if_then_else:VWEXTI
5893 (unspec:<VM>
5894 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
5895 (match_operand 5 "vector_length_operand" " rvl")
5896 (match_operand 6 "const_int_operand" " i")
5897 (match_operand 7 "const_int_operand" " i")
5898 (match_operand 8 "const_int_operand" " i")
5899 (reg:SI VL_REGNUM)
5900 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5901 (plus:VWEXTI
5902 (mult:VWEXTI
5903 (any_extend:VWEXTI
5904 (vec_duplicate:<V_DOUBLE_TRUNC>
5905 (match_operand:<VSUBEL> 3 "register_operand" " r")))
5906 (any_extend:VWEXTI
5907 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
5908 (match_operand:VWEXTI 2 "register_operand" " 0"))
5909 (match_dup 2)))]
5910 "TARGET_VECTOR"
5911 "vwmacc<u>.vx\t%0,%3,%4%p1"
5912 [(set_attr "type" "viwmuladd")
5913 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
5914
5915 (define_insn "@pred_widen_mul_plussu<mode>"
5916 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr")
5917 (if_then_else:VWEXTI
5918 (unspec:<VM>
5919 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
5920 (match_operand 5 "vector_length_operand" " rvl")
5921 (match_operand 6 "const_int_operand" " i")
5922 (match_operand 7 "const_int_operand" " i")
5923 (match_operand 8 "const_int_operand" " i")
5924 (reg:SI VL_REGNUM)
5925 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5926 (plus:VWEXTI
5927 (mult:VWEXTI
5928 (sign_extend:VWEXTI
5929 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr"))
5930 (zero_extend:VWEXTI
5931 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
5932 (match_operand:VWEXTI 2 "register_operand" " 0"))
5933 (match_dup 2)))]
5934 "TARGET_VECTOR"
5935 "vwmaccsu.vv\t%0,%3,%4%p1"
5936 [(set_attr "type" "viwmuladd")
5937 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
5938
5939 (define_insn "@pred_widen_mul_plussu<mode>_scalar"
5940 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr")
5941 (if_then_else:VWEXTI
5942 (unspec:<VM>
5943 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
5944 (match_operand 5 "vector_length_operand" " rvl")
5945 (match_operand 6 "const_int_operand" " i")
5946 (match_operand 7 "const_int_operand" " i")
5947 (match_operand 8 "const_int_operand" " i")
5948 (reg:SI VL_REGNUM)
5949 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5950 (plus:VWEXTI
5951 (mult:VWEXTI
5952 (sign_extend:VWEXTI
5953 (vec_duplicate:<V_DOUBLE_TRUNC>
5954 (match_operand:<VSUBEL> 3 "register_operand" " r")))
5955 (zero_extend:VWEXTI
5956 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
5957 (match_operand:VWEXTI 2 "register_operand" " 0"))
5958 (match_dup 2)))]
5959 "TARGET_VECTOR"
5960 "vwmaccsu.vx\t%0,%3,%4%p1"
5961 [(set_attr "type" "viwmuladd")
5962 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
5963
5964 (define_insn "@pred_widen_mul_plusus<mode>_scalar"
5965 [(set (match_operand:VWEXTI 0 "register_operand" "=&vr")
5966 (if_then_else:VWEXTI
5967 (unspec:<VM>
5968 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
5969 (match_operand 5 "vector_length_operand" " rvl")
5970 (match_operand 6 "const_int_operand" " i")
5971 (match_operand 7 "const_int_operand" " i")
5972 (match_operand 8 "const_int_operand" " i")
5973 (reg:SI VL_REGNUM)
5974 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
5975 (plus:VWEXTI
5976 (mult:VWEXTI
5977 (zero_extend:VWEXTI
5978 (vec_duplicate:<V_DOUBLE_TRUNC>
5979 (match_operand:<VSUBEL> 3 "register_operand" " r")))
5980 (sign_extend:VWEXTI
5981 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
5982 (match_operand:VWEXTI 2 "register_operand" " 0"))
5983 (match_dup 2)))]
5984 "TARGET_VECTOR"
5985 "vwmaccus.vx\t%0,%3,%4%p1"
5986 [(set_attr "type" "viwmuladd")
5987 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
5988
5989 ;; -------------------------------------------------------------------------------
5990 ;; ---- Predicated BOOL mask operations
5991 ;; -------------------------------------------------------------------------------
5992 ;; Includes:
5993 ;; - 15.1 Vector Mask-Register Logical Instructions
5994 ;; - 15.2 Vector count population in mask vcpop.m
5995 ;; - 15.3 vfirst find-first-set mask bit
5996 ;; - 15.4 vmsbf.m set-before-first mask bit
5997 ;; - 15.5 vmsif.m set-including-first mask bit
5998 ;; - 15.6 vmsof.m set-only-first mask bit
5999 ;; - 15.8 Vector Iota Instruction
6000 ;; - 15.9 Vector Element Index Instruction
6001 ;; -------------------------------------------------------------------------------
6002
6003 ;; We keep this pattern same as pred_mov so that we can gain more optimizations.
6004 ;; For example, if we have vmxor.mm v1,v1,v1. It will be optimized as vmclr.m which
6005 ;; is generated by pred_mov.
6006 (define_insn "@pred_<optab><mode>"
6007 [(set (match_operand:VB_VLS 0 "register_operand" "=vr")
6008 (if_then_else:VB_VLS
6009 (unspec:VB_VLS
6010 [(match_operand:VB_VLS 1 "vector_all_trues_mask_operand" "Wc1")
6011 (match_operand 5 "vector_length_operand" "rvl")
6012 (match_operand 6 "const_int_operand" " i")
6013 (reg:SI VL_REGNUM)
6014 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6015 (any_bitwise:VB_VLS
6016 (match_operand:VB_VLS 3 "register_operand" " vr")
6017 (match_operand:VB_VLS 4 "register_operand" " vr"))
6018 (match_operand:VB_VLS 2 "vector_undef_operand" " vu")))]
6019 "TARGET_VECTOR"
6020 "vm<insn>.mm\t%0,%3,%4"
6021 [(set_attr "type" "vmalu")
6022 (set_attr "mode" "<MODE>")
6023 (set_attr "vl_op_idx" "5")
6024 (set (attr "avl_type_idx") (const_int 6))])
6025
6026 (define_insn "@pred_n<optab><mode>"
6027 [(set (match_operand:VB_VLS 0 "register_operand" "=vr")
6028 (if_then_else:VB_VLS
6029 (unspec:VB_VLS
6030 [(match_operand:VB_VLS 1 "vector_all_trues_mask_operand" "Wc1")
6031 (match_operand 5 "vector_length_operand" "rvl")
6032 (match_operand 6 "const_int_operand" " i")
6033 (reg:SI VL_REGNUM)
6034 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6035 (not:VB_VLS
6036 (any_bitwise:VB_VLS
6037 (match_operand:VB_VLS 3 "register_operand" " vr")
6038 (match_operand:VB_VLS 4 "register_operand" " vr")))
6039 (match_operand:VB_VLS 2 "vector_undef_operand" " vu")))]
6040 "TARGET_VECTOR"
6041 "vm<ninsn>.mm\t%0,%3,%4"
6042 [(set_attr "type" "vmalu")
6043 (set_attr "mode" "<MODE>")
6044 (set_attr "vl_op_idx" "5")
6045 (set (attr "avl_type_idx") (const_int 6))])
6046
6047 (define_insn "@pred_<optab>not<mode>"
6048 [(set (match_operand:VB_VLS 0 "register_operand" "=vr")
6049 (if_then_else:VB_VLS
6050 (unspec:VB_VLS
6051 [(match_operand:VB_VLS 1 "vector_all_trues_mask_operand" "Wc1")
6052 (match_operand 5 "vector_length_operand" "rvl")
6053 (match_operand 6 "const_int_operand" " i")
6054 (reg:SI VL_REGNUM)
6055 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6056 (and_ior:VB_VLS
6057 (match_operand:VB_VLS 3 "register_operand" " vr")
6058 (not:VB_VLS
6059 (match_operand:VB_VLS 4 "register_operand" " vr")))
6060 (match_operand:VB_VLS 2 "vector_undef_operand" " vu")))]
6061 "TARGET_VECTOR"
6062 "vm<insn>n.mm\t%0,%3,%4"
6063 [(set_attr "type" "vmalu")
6064 (set_attr "mode" "<MODE>")
6065 (set_attr "vl_op_idx" "5")
6066 (set (attr "avl_type_idx") (const_int 6))])
6067
6068 (define_insn "@pred_not<mode>"
6069 [(set (match_operand:VB_VLS 0 "register_operand" "=vr")
6070 (if_then_else:VB_VLS
6071 (unspec:VB_VLS
6072 [(match_operand:VB_VLS 1 "vector_all_trues_mask_operand" "Wc1")
6073 (match_operand 4 "vector_length_operand" "rvl")
6074 (match_operand 5 "const_int_operand" " i")
6075 (reg:SI VL_REGNUM)
6076 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6077 (not:VB_VLS
6078 (match_operand:VB_VLS 3 "register_operand" " vr"))
6079 (match_operand:VB_VLS 2 "vector_undef_operand" " vu")))]
6080 "TARGET_VECTOR"
6081 "vmnot.m\t%0,%3"
6082 [(set_attr "type" "vmalu")
6083 (set_attr "mode" "<MODE>")
6084 (set_attr "vl_op_idx" "4")
6085 (set (attr "avl_type_idx") (const_int 5))])
6086
6087 (define_insn "@pred_popcount<VB_VLS:mode><P:mode>"
6088 [(set (match_operand:P 0 "register_operand" "=r")
6089 (popcount:P
6090 (unspec:VB_VLS
6091 [(and:VB_VLS
6092 (match_operand:VB_VLS 1 "vector_mask_operand" "vmWc1")
6093 (match_operand:VB_VLS 2 "register_operand" " vr"))
6094 (match_operand 3 "vector_length_operand" " rvl")
6095 (match_operand 4 "const_int_operand" " i")
6096 (reg:SI VL_REGNUM)
6097 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))]
6098 "TARGET_VECTOR"
6099 "vcpop.m\t%0,%2%p1"
6100 [(set_attr "type" "vmpop")
6101 (set_attr "mode" "<VB_VLS:MODE>")])
6102
6103 (define_insn "@pred_ffs<VB:mode><P:mode>"
6104 [(set (match_operand:P 0 "register_operand" "=r")
6105 (plus:P
6106 (ffs:P
6107 (unspec:VB
6108 [(and:VB
6109 (match_operand:VB 1 "vector_mask_operand" "vmWc1")
6110 (match_operand:VB 2 "register_operand" " vr"))
6111 (match_operand 3 "vector_length_operand" " rvl")
6112 (match_operand 4 "const_int_operand" " i")
6113 (reg:SI VL_REGNUM)
6114 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE))
6115 (const_int -1)))]
6116 "TARGET_VECTOR"
6117 "vfirst.m\t%0,%2%p1"
6118 [(set_attr "type" "vmffs")
6119 (set_attr "mode" "<VB:MODE>")])
6120
6121 (define_insn "@pred_<misc_op><mode>"
6122 [(set (match_operand:VB 0 "register_operand" "=&vr, &vr")
6123 (if_then_else:VB
6124 (unspec:VB
6125 [(match_operand:VB 1 "vector_mask_operand" "vmWc1,vmWc1")
6126 (match_operand 4 "vector_length_operand" " rvl, rvl")
6127 (match_operand 5 "const_int_operand" " i, i")
6128 (match_operand 6 "const_int_operand" " i, i")
6129 (reg:SI VL_REGNUM)
6130 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6131 (unspec:VB
6132 [(match_operand:VB 3 "register_operand" " vr, vr")] VMISC)
6133 (match_operand:VB 2 "vector_merge_operand" " vu, 0")))]
6134 "TARGET_VECTOR"
6135 "vm<misc_op>.m\t%0,%3%p1"
6136 [(set_attr "type" "vmsfs")
6137 (set_attr "mode" "<MODE>")])
6138
6139 (define_insn "@pred_iota<mode>"
6140 [(set (match_operand:VI 0 "register_operand" "=&vr, &vr")
6141 (if_then_else:VI
6142 (unspec:<VM>
6143 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
6144 (match_operand 4 "vector_length_operand" " rvl, rvl")
6145 (match_operand 5 "const_int_operand" " i, i")
6146 (match_operand 6 "const_int_operand" " i, i")
6147 (match_operand 7 "const_int_operand" " i, i")
6148 (reg:SI VL_REGNUM)
6149 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6150 (unspec:VI
6151 [(match_operand:<VM> 3 "register_operand" " vr, vr")] UNSPEC_VIOTA)
6152 (match_operand:VI 2 "vector_merge_operand" " vu, 0")))]
6153 "TARGET_VECTOR"
6154 "viota.m\t%0,%3%p1"
6155 [(set_attr "type" "vmiota")
6156 (set_attr "mode" "<MODE>")])
6157
6158 (define_insn "@pred_series<mode>"
6159 [(set (match_operand:V_VLSI 0 "register_operand" "=vd, vd, vr, vr")
6160 (if_then_else:V_VLSI
6161 (unspec:<VM>
6162 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6163 (match_operand 3 "vector_length_operand" "rvl,rvl,rvl,rvl")
6164 (match_operand 4 "const_int_operand" " i, i, i, i")
6165 (match_operand 5 "const_int_operand" " i, i, i, i")
6166 (match_operand 6 "const_int_operand" " i, i, i, i")
6167 (reg:SI VL_REGNUM)
6168 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6169 (vec_series:V_VLSI (const_int 0) (const_int 1))
6170 (match_operand:V_VLSI 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6171 "TARGET_VECTOR"
6172 "vid.v\t%0%p1"
6173 [(set_attr "type" "vmidx")
6174 (set_attr "mode" "<MODE>")])
6175
6176 ;; -------------------------------------------------------------------------------
6177 ;; ---- Predicated floating-point binary operations
6178 ;; -------------------------------------------------------------------------------
6179 ;; Includes:
6180 ;; - 13.2 Vector Single-Width Floating-Point Add/Subtract Instructions
6181 ;; - 13.4 Vector Single-Width Floating-Point Multiply/Divide Instructions
6182 ;; - 13.11 Vector Floating-Point MIN/MAX Instructions
6183 ;; - 13.12 Vector Floating-Point Sign-Injection Instructions
6184 ;; -------------------------------------------------------------------------------
6185
6186 (define_insn "@pred_<optab><mode>"
6187 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6188 (if_then_else:V_VLSF
6189 (unspec:<VM>
6190 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6191 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6192 (match_operand 6 "const_int_operand" " i, i, i, i")
6193 (match_operand 7 "const_int_operand" " i, i, i, i")
6194 (match_operand 8 "const_int_operand" " i, i, i, i")
6195 (match_operand 9 "const_int_operand" " i, i, i, i")
6196 (reg:SI VL_REGNUM)
6197 (reg:SI VTYPE_REGNUM)
6198 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6199 (any_float_binop:V_VLSF
6200 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
6201 (match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr"))
6202 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6203 "TARGET_VECTOR"
6204 "vf<insn>.vv\t%0,%3,%4%p1"
6205 [(set_attr "type" "<float_insn_type>")
6206 (set_attr "mode" "<MODE>")
6207 (set (attr "frm_mode")
6208 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6209
6210 (define_insn "@pred_<optab><mode>"
6211 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6212 (if_then_else:V_VLSF
6213 (unspec:<VM>
6214 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6215 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6216 (match_operand 6 "const_int_operand" " i, i, i, i")
6217 (match_operand 7 "const_int_operand" " i, i, i, i")
6218 (match_operand 8 "const_int_operand" " i, i, i, i")
6219 (reg:SI VL_REGNUM)
6220 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6221 (any_float_binop_nofrm:V_VLSF
6222 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
6223 (match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr"))
6224 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6225 "TARGET_VECTOR"
6226 "vf<insn>.vv\t%0,%3,%4%p1"
6227 [(set_attr "type" "<float_insn_type>")
6228 (set_attr "mode" "<MODE>")])
6229
6230 (define_insn "@pred_<ieee_fmaxmin_op><mode>"
6231 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6232 (if_then_else:V_VLSF
6233 (unspec:<VM>
6234 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6235 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6236 (match_operand 6 "const_int_operand" " i, i, i, i")
6237 (match_operand 7 "const_int_operand" " i, i, i, i")
6238 (match_operand 8 "const_int_operand" " i, i, i, i")
6239 (reg:SI VL_REGNUM)
6240 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6241 (unspec:V_VLSF
6242 [(match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
6243 (match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr")]
6244 UNSPEC_VFMAXMIN)
6245 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6246 "TARGET_VECTOR"
6247 "v<ieee_fmaxmin_op>.vv\t%0,%3,%4%p1"
6248 [(set_attr "type" "vfminmax")
6249 (set_attr "mode" "<MODE>")])
6250
6251 (define_insn "@pred_<optab><mode>_scalar"
6252 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6253 (if_then_else:VF
6254 (unspec:<VM>
6255 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6256 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6257 (match_operand 6 "const_int_operand" " i, i, i, i")
6258 (match_operand 7 "const_int_operand" " i, i, i, i")
6259 (match_operand 8 "const_int_operand" " i, i, i, i")
6260 (match_operand 9 "const_int_operand" " i, i, i, i")
6261 (reg:SI VL_REGNUM)
6262 (reg:SI VTYPE_REGNUM)
6263 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6264 (commutative_float_binop:VF
6265 (vec_duplicate:VF
6266 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))
6267 (match_operand:VF 3 "register_operand" " vr, vr, vr, vr"))
6268 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6269 "TARGET_VECTOR"
6270 "vf<insn>.vf\t%0,%3,%4%p1"
6271 [(set_attr "type" "<float_insn_type>")
6272 (set_attr "mode" "<MODE>")
6273 (set (attr "frm_mode")
6274 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6275
6276 (define_insn "@pred_<optab><mode>_scalar"
6277 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6278 (if_then_else:VF
6279 (unspec:<VM>
6280 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6281 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6282 (match_operand 6 "const_int_operand" " i, i, i, i")
6283 (match_operand 7 "const_int_operand" " i, i, i, i")
6284 (match_operand 8 "const_int_operand" " i, i, i, i")
6285 (reg:SI VL_REGNUM)
6286 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6287 (commutative_float_binop_nofrm:VF
6288 (vec_duplicate:VF
6289 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))
6290 (match_operand:VF 3 "register_operand" " vr, vr, vr, vr"))
6291 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6292 "TARGET_VECTOR"
6293 "vf<insn>.vf\t%0,%3,%4%p1"
6294 [(set_attr "type" "<float_insn_type>")
6295 (set_attr "mode" "<MODE>")])
6296
6297 (define_insn "@pred_<ieee_fmaxmin_op><mode>_scalar"
6298 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6299 (if_then_else:VF
6300 (unspec:<VM>
6301 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6302 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6303 (match_operand 6 "const_int_operand" " i, i, i, i")
6304 (match_operand 7 "const_int_operand" " i, i, i, i")
6305 (match_operand 8 "const_int_operand" " i, i, i, i")
6306 (reg:SI VL_REGNUM)
6307 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6308 (unspec:VF
6309 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")
6310 (vec_duplicate:VF
6311 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))]
6312 UNSPEC_VFMAXMIN)
6313 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6314 "TARGET_VECTOR"
6315 "v<ieee_fmaxmin_op>.vf\t%0,%3,%4%p1"
6316 [(set_attr "type" "vfminmax")
6317 (set_attr "mode" "<MODE>")])
6318
6319 (define_insn "@pred_<optab><mode>_scalar"
6320 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6321 (if_then_else:VF
6322 (unspec:<VM>
6323 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6324 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6325 (match_operand 6 "const_int_operand" " i, i, i, i")
6326 (match_operand 7 "const_int_operand" " i, i, i, i")
6327 (match_operand 8 "const_int_operand" " i, i, i, i")
6328 (match_operand 9 "const_int_operand" " i, i, i, i")
6329 (reg:SI VL_REGNUM)
6330 (reg:SI VTYPE_REGNUM)
6331 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6332 (non_commutative_float_binop:VF
6333 (match_operand:VF 3 "register_operand" " vr, vr, vr, vr")
6334 (vec_duplicate:VF
6335 (match_operand:<VEL> 4 "register_operand" " f, f, f, f")))
6336 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6337 "TARGET_VECTOR"
6338 "vf<insn>.vf\t%0,%3,%4%p1"
6339 [(set_attr "type" "<float_insn_type>")
6340 (set_attr "mode" "<MODE>")
6341 (set (attr "frm_mode")
6342 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6343
6344 (define_insn "@pred_<optab><mode>_reverse_scalar"
6345 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6346 (if_then_else:VF
6347 (unspec:<VM>
6348 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6349 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6350 (match_operand 6 "const_int_operand" " i, i, i, i")
6351 (match_operand 7 "const_int_operand" " i, i, i, i")
6352 (match_operand 8 "const_int_operand" " i, i, i, i")
6353 (match_operand 9 "const_int_operand" " i, i, i, i")
6354 (reg:SI VL_REGNUM)
6355 (reg:SI VTYPE_REGNUM)
6356 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6357 (non_commutative_float_binop:VF
6358 (vec_duplicate:VF
6359 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))
6360 (match_operand:VF 3 "register_operand" " vr, vr, vr, vr"))
6361 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6362 "TARGET_VECTOR"
6363 "vfr<insn>.vf\t%0,%3,%4%p1"
6364 [(set_attr "type" "<float_insn_type>")
6365 (set_attr "mode" "<MODE>")
6366 (set (attr "frm_mode")
6367 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6368
6369 (define_insn "@pred_<copysign><mode>"
6370 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6371 (if_then_else:V_VLSF
6372 (unspec:<VM>
6373 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6374 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6375 (match_operand 6 "const_int_operand" " i, i, i, i")
6376 (match_operand 7 "const_int_operand" " i, i, i, i")
6377 (match_operand 8 "const_int_operand" " i, i, i, i")
6378 (reg:SI VL_REGNUM)
6379 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6380 (unspec:V_VLSF
6381 [(match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
6382 (match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr")] VCOPYSIGNS)
6383 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6384 "TARGET_VECTOR"
6385 "vfsgnj<nx>.vv\t%0,%3,%4%p1"
6386 [(set_attr "type" "vfsgnj")
6387 (set_attr "mode" "<MODE>")])
6388
6389 (define_insn "@pred_ncopysign<mode>"
6390 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6391 (if_then_else:VF
6392 (unspec:<VM>
6393 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6394 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6395 (match_operand 6 "const_int_operand" " i, i, i, i")
6396 (match_operand 7 "const_int_operand" " i, i, i, i")
6397 (match_operand 8 "const_int_operand" " i, i, i, i")
6398 (reg:SI VL_REGNUM)
6399 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6400 (neg:VF
6401 (unspec:VF
6402 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")
6403 (match_operand:VF 4 "register_operand" " vr, vr, vr, vr")] UNSPEC_VCOPYSIGN))
6404 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6405 "TARGET_VECTOR"
6406 "vfsgnjn.vv\t%0,%3,%4%p1"
6407 [(set_attr "type" "vfsgnj")
6408 (set_attr "mode" "<MODE>")])
6409
6410 (define_insn "@pred_<copysign><mode>_scalar"
6411 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6412 (if_then_else:V_VLSF
6413 (unspec:<VM>
6414 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6415 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6416 (match_operand 6 "const_int_operand" " i, i, i, i")
6417 (match_operand 7 "const_int_operand" " i, i, i, i")
6418 (match_operand 8 "const_int_operand" " i, i, i, i")
6419 (reg:SI VL_REGNUM)
6420 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6421 (unspec:V_VLSF
6422 [(match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
6423 (vec_duplicate:V_VLSF
6424 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))] VCOPYSIGNS)
6425 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6426 "TARGET_VECTOR"
6427 "vfsgnj<nx>.vf\t%0,%3,%4%p1"
6428 [(set_attr "type" "vfsgnj")
6429 (set_attr "mode" "<MODE>")])
6430
6431 (define_insn "@pred_ncopysign<mode>_scalar"
6432 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6433 (if_then_else:VF
6434 (unspec:<VM>
6435 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6436 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
6437 (match_operand 6 "const_int_operand" " i, i, i, i")
6438 (match_operand 7 "const_int_operand" " i, i, i, i")
6439 (match_operand 8 "const_int_operand" " i, i, i, i")
6440 (reg:SI VL_REGNUM)
6441 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6442 (neg:VF
6443 (unspec:VF
6444 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")
6445 (vec_duplicate:VF
6446 (match_operand:<VEL> 4 "register_operand" " f, f, f, f"))] UNSPEC_VCOPYSIGN))
6447 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6448 "TARGET_VECTOR"
6449 "vfsgnjn.vf\t%0,%3,%4%p1"
6450 [(set_attr "type" "vfsgnj")
6451 (set_attr "mode" "<MODE>")])
6452
6453 ;; -------------------------------------------------------------------------------
6454 ;; ---- Predicated floating-point ternary operations
6455 ;; -------------------------------------------------------------------------------
6456 ;; Includes:
6457 ;; - 13.6 Vector Single-Width Floating-Point Fused Multiply-Add Instructions
6458 ;; -------------------------------------------------------------------------------
6459
6460 (define_expand "@pred_mul_<optab><mode>"
6461 [(set (match_operand:V_VLSF 0 "register_operand")
6462 (if_then_else:V_VLSF
6463 (unspec:<VM>
6464 [(match_operand:<VM> 1 "vector_mask_operand")
6465 (match_operand 6 "vector_length_operand")
6466 (match_operand 7 "const_int_operand")
6467 (match_operand 8 "const_int_operand")
6468 (match_operand 9 "const_int_operand")
6469 (match_operand 10 "const_int_operand")
6470 (reg:SI VL_REGNUM)
6471 (reg:SI VTYPE_REGNUM)
6472 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6473 (plus_minus:V_VLSF
6474 (mult:V_VLSF
6475 (match_operand:V_VLSF 2 "register_operand")
6476 (match_operand:V_VLSF 3 "register_operand"))
6477 (match_operand:V_VLSF 4 "register_operand"))
6478 (match_operand:V_VLSF 5 "vector_merge_operand")))]
6479 "TARGET_VECTOR"
6480 {
6481 riscv_vector::prepare_ternary_operands (operands);
6482 })
6483
6484 (define_insn "*pred_mul_<optab><mode>_undef"
6485 [(set (match_operand:V_VLSF 0 "register_operand" "=vd,vd, vr, vr")
6486 (if_then_else:V_VLSF
6487 (unspec:<VM>
6488 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1")
6489 (match_operand 6 "vector_length_operand" "rvl,rvl,rvl,rvl")
6490 (match_operand 7 "const_int_operand" " i, i, i, i")
6491 (match_operand 8 "const_int_operand" " i, i, i, i")
6492 (match_operand 9 "const_int_operand" " i, i, i, i")
6493 (match_operand 10 "const_int_operand" " i, i, i, i")
6494 (reg:SI VL_REGNUM)
6495 (reg:SI VTYPE_REGNUM)
6496 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6497 (plus_minus:V_VLSF
6498 (mult:V_VLSF
6499 (match_operand:V_VLSF 3 "register_operand" " 0,vr, 0, vr")
6500 (match_operand:V_VLSF 4 "register_operand" " vr,vr, vr, vr"))
6501 (match_operand:V_VLSF 5 "register_operand" " vr, 0, vr, 0"))
6502 (match_operand:V_VLSF 2 "vector_undef_operand")))]
6503 "TARGET_VECTOR"
6504 "@
6505 vf<madd_msub>.vv\t%0,%4,%5%p1
6506 vf<macc_msac>.vv\t%0,%3,%4%p1
6507 vf<madd_msub>.vv\t%0,%4,%5%p1
6508 vf<macc_msac>.vv\t%0,%3,%4%p1"
6509 [(set_attr "type" "vfmuladd")
6510 (set_attr "mode" "<MODE>")
6511 (set (attr "frm_mode")
6512 (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))])
6513
6514 (define_insn "*pred_<madd_msub><mode>"
6515 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6516 (if_then_else:V_VLSF
6517 (unspec:<VM>
6518 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6519 (match_operand 5 "vector_length_operand" "rvl,rvl")
6520 (match_operand 6 "const_int_operand" " i, i")
6521 (match_operand 7 "const_int_operand" " i, i")
6522 (match_operand 8 "const_int_operand" " i, i")
6523 (match_operand 9 "const_int_operand" " i, i")
6524 (reg:SI VL_REGNUM)
6525 (reg:SI VTYPE_REGNUM)
6526 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6527 (plus_minus:V_VLSF
6528 (mult:V_VLSF
6529 (match_operand:V_VLSF 2 "register_operand" " 0, 0")
6530 (match_operand:V_VLSF 3 "register_operand" " vr, vr"))
6531 (match_operand:V_VLSF 4 "register_operand" " vr, vr"))
6532 (match_dup 2)))]
6533 "TARGET_VECTOR"
6534 "@
6535 vf<madd_msub>.vv\t%0,%3,%4%p1
6536 vf<madd_msub>.vv\t%0,%3,%4%p1"
6537 [(set_attr "type" "vfmuladd")
6538 (set_attr "mode" "<MODE>")
6539 (set_attr "merge_op_idx" "2")
6540 (set_attr "vl_op_idx" "5")
6541 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6542 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6543 (set (attr "avl_type_idx") (const_int 8))
6544 (set (attr "frm_mode")
6545 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6546
6547 (define_insn "*pred_<macc_msac><mode>"
6548 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6549 (if_then_else:V_VLSF
6550 (unspec:<VM>
6551 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6552 (match_operand 5 "vector_length_operand" "rvl,rvl")
6553 (match_operand 6 "const_int_operand" " i, i")
6554 (match_operand 7 "const_int_operand" " i, i")
6555 (match_operand 8 "const_int_operand" " i, i")
6556 (match_operand 9 "const_int_operand" " i, i")
6557 (reg:SI VL_REGNUM)
6558 (reg:SI VTYPE_REGNUM)
6559 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6560 (plus_minus:V_VLSF
6561 (mult:V_VLSF
6562 (match_operand:V_VLSF 2 "register_operand" " vr, vr")
6563 (match_operand:V_VLSF 3 "register_operand" " vr, vr"))
6564 (match_operand:V_VLSF 4 "register_operand" " 0, 0"))
6565 (match_dup 4)))]
6566 "TARGET_VECTOR"
6567 "@
6568 vf<macc_msac>.vv\t%0,%2,%3%p1
6569 vf<macc_msac>.vv\t%0,%2,%3%p1"
6570 [(set_attr "type" "vfmuladd")
6571 (set_attr "mode" "<MODE>")
6572 (set_attr "merge_op_idx" "4")
6573 (set_attr "vl_op_idx" "5")
6574 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6575 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6576 (set (attr "avl_type_idx") (const_int 8))
6577 (set (attr "frm_mode")
6578 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6579
6580 (define_expand "@pred_mul_<optab><mode>_scalar"
6581 [(set (match_operand:V_VLSF 0 "register_operand")
6582 (if_then_else:V_VLSF
6583 (unspec:<VM>
6584 [(match_operand:<VM> 1 "vector_mask_operand")
6585 (match_operand 6 "vector_length_operand")
6586 (match_operand 7 "const_int_operand")
6587 (match_operand 8 "const_int_operand")
6588 (match_operand 9 "const_int_operand")
6589 (match_operand 10 "const_int_operand")
6590 (reg:SI VL_REGNUM)
6591 (reg:SI VTYPE_REGNUM)
6592 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6593 (plus_minus:V_VLSF
6594 (mult:V_VLSF
6595 (vec_duplicate:V_VLSF
6596 (match_operand:<VEL> 2 "register_operand"))
6597 (match_operand:V_VLSF 3 "register_operand"))
6598 (match_operand:V_VLSF 4 "register_operand"))
6599 (match_operand:V_VLSF 5 "register_operand")))]
6600 "TARGET_VECTOR"
6601 {})
6602
6603 (define_insn "*pred_<madd_msub><mode>_scalar"
6604 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6605 (if_then_else:V_VLSF
6606 (unspec:<VM>
6607 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6608 (match_operand 5 "vector_length_operand" "rvl,rvl")
6609 (match_operand 6 "const_int_operand" " i, i")
6610 (match_operand 7 "const_int_operand" " i, i")
6611 (match_operand 8 "const_int_operand" " i, i")
6612 (match_operand 9 "const_int_operand" " i, i")
6613 (reg:SI VL_REGNUM)
6614 (reg:SI VTYPE_REGNUM)
6615 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6616 (plus_minus:V_VLSF
6617 (mult:V_VLSF
6618 (vec_duplicate:V_VLSF
6619 (match_operand:<VEL> 2 "register_operand" " f, f"))
6620 (match_operand:V_VLSF 3 "register_operand" " 0, 0"))
6621 (match_operand:V_VLSF 4 "register_operand" " vr, vr"))
6622 (match_dup 3)))]
6623 "TARGET_VECTOR"
6624 "@
6625 vf<madd_msub>.vf\t%0,%2,%4%p1
6626 vf<madd_msub>.vf\t%0,%2,%4%p1"
6627 [(set_attr "type" "vfmuladd")
6628 (set_attr "mode" "<MODE>")
6629 (set_attr "merge_op_idx" "3")
6630 (set_attr "vl_op_idx" "5")
6631 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6632 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6633 (set (attr "avl_type_idx") (const_int 8))
6634 (set (attr "frm_mode")
6635 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6636
6637 (define_insn "*pred_<macc_msac><mode>_scalar"
6638 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6639 (if_then_else:V_VLSF
6640 (unspec:<VM>
6641 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6642 (match_operand 5 "vector_length_operand" "rvl,rvl")
6643 (match_operand 6 "const_int_operand" " i, i")
6644 (match_operand 7 "const_int_operand" " i, i")
6645 (match_operand 8 "const_int_operand" " i, i")
6646 (match_operand 9 "const_int_operand" " i, i")
6647 (reg:SI VL_REGNUM)
6648 (reg:SI VTYPE_REGNUM)
6649 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6650 (plus_minus:V_VLSF
6651 (mult:V_VLSF
6652 (vec_duplicate:V_VLSF
6653 (match_operand:<VEL> 2 "register_operand" " f, f"))
6654 (match_operand:V_VLSF 3 "register_operand" "vr, vr"))
6655 (match_operand:V_VLSF 4 "register_operand" " 0, 0"))
6656 (match_dup 4)))]
6657 "TARGET_VECTOR"
6658 "@
6659 vf<macc_msac>.vf\t%0,%2,%3%p1
6660 vf<macc_msac>.vf\t%0,%2,%3%p1"
6661 [(set_attr "type" "vfmuladd")
6662 (set_attr "mode" "<MODE>")
6663 (set_attr "merge_op_idx" "4")
6664 (set_attr "vl_op_idx" "5")
6665 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6666 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6667 (set (attr "avl_type_idx") (const_int 8))
6668 (set (attr "frm_mode")
6669 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6670
6671 (define_expand "@pred_mul_neg_<optab><mode>"
6672 [(set (match_operand:V_VLSF 0 "register_operand")
6673 (if_then_else:V_VLSF
6674 (unspec:<VM>
6675 [(match_operand:<VM> 1 "vector_mask_operand")
6676 (match_operand 6 "vector_length_operand")
6677 (match_operand 7 "const_int_operand")
6678 (match_operand 8 "const_int_operand")
6679 (match_operand 9 "const_int_operand")
6680 (match_operand 10 "const_int_operand")
6681 (reg:SI VL_REGNUM)
6682 (reg:SI VTYPE_REGNUM)
6683 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6684 (plus_minus:V_VLSF
6685 (neg:V_VLSF
6686 (mult:V_VLSF
6687 (match_operand:V_VLSF 2 "register_operand")
6688 (match_operand:V_VLSF 3 "register_operand")))
6689 (match_operand:V_VLSF 4 "register_operand"))
6690 (match_operand:V_VLSF 5 "vector_merge_operand")))]
6691 "TARGET_VECTOR"
6692 {
6693 riscv_vector::prepare_ternary_operands (operands);
6694 })
6695
6696 (define_insn "*pred_mul_neg_<optab><mode>_undef"
6697 [(set (match_operand:V_VLSF 0 "register_operand" "=vd,vd,vr, vr")
6698 (if_then_else:V_VLSF
6699 (unspec:<VM>
6700 [(match_operand:<VM> 1 "vector_mask_operand" " vm,vm,Wc1,Wc1")
6701 (match_operand 6 "vector_length_operand" "rvl,rvl,rvl,rvl")
6702 (match_operand 7 "const_int_operand" " i, i, i, i")
6703 (match_operand 8 "const_int_operand" " i, i, i, i")
6704 (match_operand 9 "const_int_operand" " i, i, i, i")
6705 (match_operand 10 "const_int_operand" " i, i, i, i")
6706 (reg:SI VL_REGNUM)
6707 (reg:SI VTYPE_REGNUM)
6708 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6709 (plus_minus:V_VLSF
6710 (neg:V_VLSF
6711 (mult:V_VLSF
6712 (match_operand:V_VLSF 3 "register_operand" " 0,vr, 0, vr")
6713 (match_operand:V_VLSF 4 "register_operand" " vr,vr, vr, vr")))
6714 (match_operand:V_VLSF 5 "register_operand" " vr, 0, vr, 0"))
6715 (match_operand:V_VLSF 2 "vector_undef_operand")))]
6716 "TARGET_VECTOR"
6717 "@
6718 vf<nmsub_nmadd>.vv\t%0,%4,%5%p1
6719 vf<nmsac_nmacc>.vv\t%0,%3,%4%p1
6720 vf<nmsub_nmadd>.vv\t%0,%4,%5%p1
6721 vf<nmsac_nmacc>.vv\t%0,%3,%4%p1"
6722 [(set_attr "type" "vfmuladd")
6723 (set_attr "mode" "<MODE>")
6724 (set (attr "frm_mode")
6725 (symbol_ref "riscv_vector::get_frm_mode (operands[10])"))])
6726
6727 (define_insn "*pred_<nmsub_nmadd><mode>"
6728 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6729 (if_then_else:V_VLSF
6730 (unspec:<VM>
6731 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6732 (match_operand 5 "vector_length_operand" "rvl,rvl")
6733 (match_operand 6 "const_int_operand" " i, i")
6734 (match_operand 7 "const_int_operand" " i, i")
6735 (match_operand 8 "const_int_operand" " i, i")
6736 (match_operand 9 "const_int_operand" " i, i")
6737 (reg:SI VL_REGNUM)
6738 (reg:SI VTYPE_REGNUM)
6739 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6740 (plus_minus:V_VLSF
6741 (neg:V_VLSF
6742 (mult:V_VLSF
6743 (match_operand:V_VLSF 2 "register_operand" " 0, 0")
6744 (match_operand:V_VLSF 3 "register_operand" " vr, vr")))
6745 (match_operand:V_VLSF 4 "register_operand" " vr, vr"))
6746 (match_dup 2)))]
6747 "TARGET_VECTOR"
6748 "@
6749 vf<nmsub_nmadd>.vv\t%0,%3,%4%p1
6750 vf<nmsub_nmadd>.vv\t%0,%3,%4%p1"
6751 [(set_attr "type" "vfmuladd")
6752 (set_attr "mode" "<MODE>")
6753 (set_attr "merge_op_idx" "2")
6754 (set_attr "vl_op_idx" "5")
6755 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6756 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6757 (set (attr "avl_type_idx") (const_int 8))
6758 (set (attr "frm_mode")
6759 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6760
6761 (define_insn "*pred_<nmsac_nmacc><mode>"
6762 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6763 (if_then_else:V_VLSF
6764 (unspec:<VM>
6765 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6766 (match_operand 5 "vector_length_operand" "rvl,rvl")
6767 (match_operand 6 "const_int_operand" " i, i")
6768 (match_operand 7 "const_int_operand" " i, i")
6769 (match_operand 8 "const_int_operand" " i, i")
6770 (match_operand 9 "const_int_operand" " i, i")
6771 (reg:SI VL_REGNUM)
6772 (reg:SI VTYPE_REGNUM)
6773 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6774 (plus_minus:V_VLSF
6775 (neg:V_VLSF
6776 (mult:V_VLSF
6777 (match_operand:V_VLSF 2 "register_operand" " vr, vr")
6778 (match_operand:V_VLSF 3 "register_operand" " vr, vr")))
6779 (match_operand:V_VLSF 4 "register_operand" " 0, 0"))
6780 (match_dup 4)))]
6781 "TARGET_VECTOR"
6782 "@
6783 vf<nmsac_nmacc>.vv\t%0,%2,%3%p1
6784 vf<nmsac_nmacc>.vv\t%0,%2,%3%p1"
6785 [(set_attr "type" "vfmuladd")
6786 (set_attr "mode" "<MODE>")
6787 (set_attr "merge_op_idx" "4")
6788 (set_attr "vl_op_idx" "5")
6789 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6790 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6791 (set (attr "avl_type_idx") (const_int 8))
6792 (set (attr "frm_mode")
6793 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6794
6795 (define_expand "@pred_mul_neg_<optab><mode>_scalar"
6796 [(set (match_operand:V_VLSF 0 "register_operand")
6797 (if_then_else:V_VLSF
6798 (unspec:<VM>
6799 [(match_operand:<VM> 1 "vector_mask_operand")
6800 (match_operand 6 "vector_length_operand")
6801 (match_operand 7 "const_int_operand")
6802 (match_operand 8 "const_int_operand")
6803 (match_operand 9 "const_int_operand")
6804 (match_operand 10 "const_int_operand")
6805 (reg:SI VL_REGNUM)
6806 (reg:SI VTYPE_REGNUM)
6807 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6808 (plus_minus:V_VLSF
6809 (neg:V_VLSF
6810 (mult:V_VLSF
6811 (vec_duplicate:V_VLSF
6812 (match_operand:<VEL> 2 "register_operand"))
6813 (match_operand:V_VLSF 3 "register_operand")))
6814 (match_operand:V_VLSF 4 "register_operand"))
6815 (match_operand:V_VLSF 5 "register_operand")))]
6816 "TARGET_VECTOR"
6817 {})
6818
6819 (define_insn "*pred_<nmsub_nmadd><mode>_scalar"
6820 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6821 (if_then_else:V_VLSF
6822 (unspec:<VM>
6823 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6824 (match_operand 5 "vector_length_operand" "rvl,rvl")
6825 (match_operand 6 "const_int_operand" " i, i")
6826 (match_operand 7 "const_int_operand" " i, i")
6827 (match_operand 8 "const_int_operand" " i, i")
6828 (match_operand 9 "const_int_operand" " i, i")
6829 (reg:SI VL_REGNUM)
6830 (reg:SI VTYPE_REGNUM)
6831 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6832 (plus_minus:V_VLSF
6833 (neg:V_VLSF
6834 (mult:V_VLSF
6835 (vec_duplicate:V_VLSF
6836 (match_operand:<VEL> 2 "register_operand" " f, f"))
6837 (match_operand:V_VLSF 3 "register_operand" " 0, 0")))
6838 (match_operand:V_VLSF 4 "register_operand" " vr, vr"))
6839 (match_dup 3)))]
6840 "TARGET_VECTOR"
6841 "@
6842 vf<nmsub_nmadd>.vf\t%0,%2,%4%p1
6843 vf<nmsub_nmadd>.vf\t%0,%2,%4%p1"
6844 [(set_attr "type" "vfmuladd")
6845 (set_attr "mode" "<MODE>")
6846 (set_attr "merge_op_idx" "3")
6847 (set_attr "vl_op_idx" "5")
6848 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6849 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6850 (set (attr "avl_type_idx") (const_int 8))
6851 (set (attr "frm_mode")
6852 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6853
6854 (define_insn "*pred_<nmsac_nmacc><mode>_scalar"
6855 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vr")
6856 (if_then_else:V_VLSF
6857 (unspec:<VM>
6858 [(match_operand:<VM> 1 "vector_mask_operand" " vm,Wc1")
6859 (match_operand 5 "vector_length_operand" "rvl,rvl")
6860 (match_operand 6 "const_int_operand" " i, i")
6861 (match_operand 7 "const_int_operand" " i, i")
6862 (match_operand 8 "const_int_operand" " i, i")
6863 (match_operand 9 "const_int_operand" " i, i")
6864 (reg:SI VL_REGNUM)
6865 (reg:SI VTYPE_REGNUM)
6866 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6867 (plus_minus:V_VLSF
6868 (neg:V_VLSF
6869 (mult:V_VLSF
6870 (vec_duplicate:V_VLSF
6871 (match_operand:<VEL> 2 "register_operand" " f, f"))
6872 (match_operand:V_VLSF 3 "register_operand" " vr, vr")))
6873 (match_operand:V_VLSF 4 "register_operand" " 0, 0"))
6874 (match_dup 4)))]
6875 "TARGET_VECTOR"
6876 "@
6877 vf<nmsac_nmacc>.vf\t%0,%2,%3%p1
6878 vf<nmsac_nmacc>.vf\t%0,%2,%3%p1"
6879 [(set_attr "type" "vfmuladd")
6880 (set_attr "mode" "<MODE>")
6881 (set_attr "merge_op_idx" "4")
6882 (set_attr "vl_op_idx" "5")
6883 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[6])"))
6884 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[7])"))
6885 (set (attr "avl_type_idx") (const_int 8))
6886 (set (attr "frm_mode")
6887 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
6888
6889 ;; -------------------------------------------------------------------------------
6890 ;; ---- Predicated floating-point unary operations
6891 ;; -------------------------------------------------------------------------------
6892 ;; Includes:
6893 ;; - 13.8 Vector Floating-Point Square-Root Instruction
6894 ;; - 13.9 Vector Floating-Point Reciprocal Square-Root Estimate Instruction
6895 ;; - 13.10 Vector Floating-Point Reciprocal Estimate Instruction
6896 ;; - 13.12 Vector Floating-Point Sign-Injection Instructions (vfneg.v/vfabs.v)
6897 ;; - 13.14 Vector Floating-Point Classify Instruction
6898 ;; -------------------------------------------------------------------------------
6899
6900 (define_insn "@pred_<optab><mode>"
6901 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6902 (if_then_else:V_VLSF
6903 (unspec:<VM>
6904 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6905 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
6906 (match_operand 5 "const_int_operand" " i, i, i, i")
6907 (match_operand 6 "const_int_operand" " i, i, i, i")
6908 (match_operand 7 "const_int_operand" " i, i, i, i")
6909 (match_operand 8 "const_int_operand" " i, i, i, i")
6910 (reg:SI VL_REGNUM)
6911 (reg:SI VTYPE_REGNUM)
6912 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6913 (any_float_unop:V_VLSF
6914 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr"))
6915 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6916 "TARGET_VECTOR"
6917 "vf<insn>.v\t%0,%3%p1"
6918 [(set_attr "type" "<float_insn_type>")
6919 (set_attr "mode" "<MODE>")
6920 (set_attr "vl_op_idx" "4")
6921 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
6922 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
6923 (set (attr "avl_type_idx") (const_int 7))
6924 (set (attr "frm_mode")
6925 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
6926
6927 (define_insn "@pred_<optab><mode>"
6928 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
6929 (if_then_else:V_VLSF
6930 (unspec:<VM>
6931 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6932 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
6933 (match_operand 5 "const_int_operand" " i, i, i, i")
6934 (match_operand 6 "const_int_operand" " i, i, i, i")
6935 (match_operand 7 "const_int_operand" " i, i, i, i")
6936 (reg:SI VL_REGNUM)
6937 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6938 (any_float_unop_nofrm:V_VLSF
6939 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr"))
6940 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6941 "TARGET_VECTOR"
6942 "vf<insn>.v\t%0,%3%p1"
6943 [(set_attr "type" "<float_insn_type>")
6944 (set_attr "mode" "<MODE>")
6945 (set_attr "vl_op_idx" "4")
6946 (set (attr "ta") (symbol_ref "riscv_vector::get_ta(operands[5])"))
6947 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
6948 (set (attr "avl_type_idx") (const_int 7))])
6949
6950 (define_insn "@pred_<misc_op><mode>"
6951 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6952 (if_then_else:VF
6953 (unspec:<VM>
6954 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6955 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
6956 (match_operand 5 "const_int_operand" " i, i, i, i")
6957 (match_operand 6 "const_int_operand" " i, i, i, i")
6958 (match_operand 7 "const_int_operand" " i, i, i, i")
6959 (reg:SI VL_REGNUM)
6960 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
6961 (unspec:VF
6962 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")] VFMISC)
6963 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6964 "TARGET_VECTOR"
6965 "vf<misc_op>.v\t%0,%3%p1"
6966 [(set_attr "type" "<float_insn_type>")
6967 (set_attr "mode" "<MODE>")])
6968
6969 (define_insn "@pred_<misc_frm_op><mode>"
6970 [(set (match_operand:VF 0 "register_operand" "=vd, vd, vr, vr")
6971 (if_then_else:VF
6972 (unspec:<VM>
6973 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6974 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
6975 (match_operand 5 "const_int_operand" " i, i, i, i")
6976 (match_operand 6 "const_int_operand" " i, i, i, i")
6977 (match_operand 7 "const_int_operand" " i, i, i, i")
6978 (match_operand 8 "const_int_operand" " i, i, i, i")
6979 (reg:SI VL_REGNUM)
6980 (reg:SI VTYPE_REGNUM)
6981 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
6982 (unspec:VF
6983 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")] VFMISC_FRM)
6984 (match_operand:VF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
6985 "TARGET_VECTOR"
6986 "vf<misc_frm_op>.v\t%0,%3%p1"
6987 [(set_attr "type" "<float_frm_insn_type>")
6988 (set_attr "mode" "<MODE>")
6989 (set (attr "frm_mode")
6990 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
6991
6992 (define_insn "@pred_class<mode>"
6993 [(set (match_operand:<VCONVERT> 0 "register_operand" "=vd, vd, vr, vr")
6994 (if_then_else:<VCONVERT>
6995 (unspec:<VM>
6996 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
6997 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
6998 (match_operand 5 "const_int_operand" " i, i, i, i")
6999 (match_operand 6 "const_int_operand" " i, i, i, i")
7000 (match_operand 7 "const_int_operand" " i, i, i, i")
7001 (reg:SI VL_REGNUM)
7002 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7003 (unspec:<VCONVERT>
7004 [(match_operand:VF 3 "register_operand" " vr, vr, vr, vr")] UNSPEC_VFCLASS)
7005 (match_operand:<VCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7006 "TARGET_VECTOR"
7007 "vfclass.v\t%0,%3%p1"
7008 [(set_attr "type" "vfclass")
7009 (set_attr "mode" "<MODE>")])
7010
7011 ;; -------------------------------------------------------------------------------
7012 ;; ---- Predicated floating-point widen binary operations
7013 ;; -------------------------------------------------------------------------------
7014 ;; Includes:
7015 ;; - 13.3 Vector Widening Floating-Point Add/Subtract Instructions
7016 ;; - 13.5 Vector Widening Floating-Point Multiply
7017 ;; -------------------------------------------------------------------------------
7018
7019 ;; Vector Widening Add/Subtract/Multiply.
7020 (define_insn "@pred_dual_widen_<optab><mode>"
7021 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr")
7022 (if_then_else:VWEXTF
7023 (unspec:<VM>
7024 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7025 (match_operand 5 "vector_length_operand" " rvl, rvl")
7026 (match_operand 6 "const_int_operand" " i, i")
7027 (match_operand 7 "const_int_operand" " i, i")
7028 (match_operand 8 "const_int_operand" " i, i")
7029 (match_operand 9 "const_int_operand" " i, i")
7030 (reg:SI VL_REGNUM)
7031 (reg:SI VTYPE_REGNUM)
7032 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7033 (any_widen_binop:VWEXTF
7034 (float_extend:VWEXTF
7035 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
7036 (float_extend:VWEXTF
7037 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")))
7038 (match_operand:VWEXTF 2 "vector_merge_operand" " vu, 0")))]
7039 "TARGET_VECTOR"
7040 "vfw<insn>.vv\t%0,%3,%4%p1"
7041 [(set_attr "type" "vf<widen_binop_insn_type>")
7042 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7043 (set (attr "frm_mode")
7044 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7045
7046 (define_insn "@pred_dual_widen_<optab><mode>_scalar"
7047 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr")
7048 (if_then_else:VWEXTF
7049 (unspec:<VM>
7050 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7051 (match_operand 5 "vector_length_operand" " rvl, rvl")
7052 (match_operand 6 "const_int_operand" " i, i")
7053 (match_operand 7 "const_int_operand" " i, i")
7054 (match_operand 8 "const_int_operand" " i, i")
7055 (match_operand 9 "const_int_operand" " i, i")
7056 (reg:SI VL_REGNUM)
7057 (reg:SI VTYPE_REGNUM)
7058 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7059 (any_widen_binop:VWEXTF
7060 (float_extend:VWEXTF
7061 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
7062 (float_extend:VWEXTF
7063 (vec_duplicate:<V_DOUBLE_TRUNC>
7064 (match_operand:<VSUBEL> 4 "register_operand" " f, f"))))
7065 (match_operand:VWEXTF 2 "vector_merge_operand" " vu, 0")))]
7066 "TARGET_VECTOR"
7067 "vfw<insn>.vf\t%0,%3,%4%p1"
7068 [(set_attr "type" "vf<widen_binop_insn_type>")
7069 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7070 (set (attr "frm_mode")
7071 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7072
7073 (define_insn "@pred_single_widen_add<mode>"
7074 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr")
7075 (if_then_else:VWEXTF
7076 (unspec:<VM>
7077 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7078 (match_operand 5 "vector_length_operand" " rvl, rvl")
7079 (match_operand 6 "const_int_operand" " i, i")
7080 (match_operand 7 "const_int_operand" " i, i")
7081 (match_operand 8 "const_int_operand" " i, i")
7082 (match_operand 9 "const_int_operand" " i, i")
7083 (reg:SI VL_REGNUM)
7084 (reg:SI VTYPE_REGNUM)
7085 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7086 (plus:VWEXTF
7087 (float_extend:VWEXTF
7088 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr"))
7089 (match_operand:VWEXTF 3 "register_operand" " vr, vr"))
7090 (match_operand:VWEXTF 2 "vector_merge_operand" " vu, 0")))]
7091 "TARGET_VECTOR"
7092 "vfwadd.wv\t%0,%3,%4%p1"
7093 [(set_attr "type" "vfwalu")
7094 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7095 (set (attr "frm_mode")
7096 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7097
7098 (define_insn "@pred_single_widen_sub<mode>"
7099 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr, &vr")
7100 (if_then_else:VWEXTF
7101 (unspec:<VM>
7102 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7103 (match_operand 5 "vector_length_operand" " rvl, rvl")
7104 (match_operand 6 "const_int_operand" " i, i")
7105 (match_operand 7 "const_int_operand" " i, i")
7106 (match_operand 8 "const_int_operand" " i, i")
7107 (match_operand 9 "const_int_operand" " i, i")
7108 (reg:SI VL_REGNUM)
7109 (reg:SI VTYPE_REGNUM)
7110 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7111 (minus:VWEXTF
7112 (match_operand:VWEXTF 3 "register_operand" " vr, vr")
7113 (float_extend:VWEXTF
7114 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr, vr")))
7115 (match_operand:VWEXTF 2 "vector_merge_operand" " vu, 0")))]
7116 "TARGET_VECTOR"
7117 "vfwsub.wv\t%0,%3,%4%p1"
7118 [(set_attr "type" "vfwalu")
7119 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7120 (set (attr "frm_mode")
7121 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7122
7123 (define_insn "@pred_single_widen_<plus_minus:optab><mode>_scalar"
7124 [(set (match_operand:VWEXTF 0 "register_operand" "=vd, vd, vr, vr")
7125 (if_then_else:VWEXTF
7126 (unspec:<VM>
7127 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
7128 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
7129 (match_operand 6 "const_int_operand" " i, i, i, i")
7130 (match_operand 7 "const_int_operand" " i, i, i, i")
7131 (match_operand 8 "const_int_operand" " i, i, i, i")
7132 (match_operand 9 "const_int_operand" " i, i, i, i")
7133 (reg:SI VL_REGNUM)
7134 (reg:SI VTYPE_REGNUM)
7135 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7136 (plus_minus:VWEXTF
7137 (match_operand:VWEXTF 3 "register_operand" " vr, vr, vr, vr")
7138 (float_extend:VWEXTF
7139 (vec_duplicate:<V_DOUBLE_TRUNC>
7140 (match_operand:<VSUBEL> 4 "register_operand" " f, f, f, f"))))
7141 (match_operand:VWEXTF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7142 "TARGET_VECTOR"
7143 "vfw<insn>.wf\t%0,%3,%4%p1"
7144 [(set_attr "type" "vf<widen_binop_insn_type>")
7145 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7146 (set (attr "frm_mode")
7147 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7148
7149 ;; -------------------------------------------------------------------------------
7150 ;; ---- Predicated widen floating-point ternary operations
7151 ;; -------------------------------------------------------------------------------
7152 ;; Includes:
7153 ;; - 13.7 Vector Widening Floating-Point Fused Multiply-Add Instructions
7154 ;; -------------------------------------------------------------------------------
7155
7156 (define_insn "@pred_widen_mul_<optab><mode>"
7157 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr")
7158 (if_then_else:VWEXTF
7159 (unspec:<VM>
7160 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7161 (match_operand 5 "vector_length_operand" " rvl")
7162 (match_operand 6 "const_int_operand" " i")
7163 (match_operand 7 "const_int_operand" " i")
7164 (match_operand 8 "const_int_operand" " i")
7165 (match_operand 9 "const_int_operand" " i")
7166 (reg:SI VL_REGNUM)
7167 (reg:SI VTYPE_REGNUM)
7168 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7169 (plus_minus:VWEXTF
7170 (mult:VWEXTF
7171 (float_extend:VWEXTF
7172 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr"))
7173 (float_extend:VWEXTF
7174 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
7175 (match_operand:VWEXTF 2 "register_operand" " 0"))
7176 (match_dup 2)))]
7177 "TARGET_VECTOR"
7178 "vfw<macc_msac>.vv\t%0,%3,%4%p1"
7179 [(set_attr "type" "vfwmuladd")
7180 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7181 (set (attr "frm_mode")
7182 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7183
7184 (define_insn "@pred_widen_mul_<optab><mode>_scalar"
7185 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr")
7186 (if_then_else:VWEXTF
7187 (unspec:<VM>
7188 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7189 (match_operand 5 "vector_length_operand" " rvl")
7190 (match_operand 6 "const_int_operand" " i")
7191 (match_operand 7 "const_int_operand" " i")
7192 (match_operand 8 "const_int_operand" " i")
7193 (match_operand 9 "const_int_operand" " i")
7194 (reg:SI VL_REGNUM)
7195 (reg:SI VTYPE_REGNUM)
7196 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7197 (plus_minus:VWEXTF
7198 (mult:VWEXTF
7199 (float_extend:VWEXTF
7200 (vec_duplicate:<V_DOUBLE_TRUNC>
7201 (match_operand:<VSUBEL> 3 "register_operand" " f")))
7202 (float_extend:VWEXTF
7203 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr")))
7204 (match_operand:VWEXTF 2 "register_operand" " 0"))
7205 (match_dup 2)))]
7206 "TARGET_VECTOR"
7207 "vfw<macc_msac>.vf\t%0,%3,%4%p1"
7208 [(set_attr "type" "vfwmuladd")
7209 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7210 (set (attr "frm_mode")
7211 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7212
7213 (define_insn "@pred_widen_mul_neg_<optab><mode>"
7214 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr")
7215 (if_then_else:VWEXTF
7216 (unspec:<VM>
7217 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7218 (match_operand 5 "vector_length_operand" " rvl")
7219 (match_operand 6 "const_int_operand" " i")
7220 (match_operand 7 "const_int_operand" " i")
7221 (match_operand 8 "const_int_operand" " i")
7222 (match_operand 9 "const_int_operand" " i")
7223 (reg:SI VL_REGNUM)
7224 (reg:SI VTYPE_REGNUM)
7225 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7226 (plus_minus:VWEXTF
7227 (neg:VWEXTF
7228 (mult:VWEXTF
7229 (float_extend:VWEXTF
7230 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr"))
7231 (float_extend:VWEXTF
7232 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr"))))
7233 (match_operand:VWEXTF 2 "register_operand" " 0"))
7234 (match_dup 2)))]
7235 "TARGET_VECTOR"
7236 "vfw<nmsac_nmacc>.vv\t%0,%3,%4%p1"
7237 [(set_attr "type" "vfwmuladd")
7238 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7239 (set (attr "frm_mode")
7240 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7241
7242 (define_insn "@pred_widen_mul_neg_<optab><mode>_scalar"
7243 [(set (match_operand:VWEXTF 0 "register_operand" "=&vr")
7244 (if_then_else:VWEXTF
7245 (unspec:<VM>
7246 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7247 (match_operand 5 "vector_length_operand" " rvl")
7248 (match_operand 6 "const_int_operand" " i")
7249 (match_operand 7 "const_int_operand" " i")
7250 (match_operand 8 "const_int_operand" " i")
7251 (match_operand 9 "const_int_operand" " i")
7252 (reg:SI VL_REGNUM)
7253 (reg:SI VTYPE_REGNUM)
7254 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7255 (plus_minus:VWEXTF
7256 (neg:VWEXTF
7257 (mult:VWEXTF
7258 (float_extend:VWEXTF
7259 (vec_duplicate:<V_DOUBLE_TRUNC>
7260 (match_operand:<VSUBEL> 3 "register_operand" " f")))
7261 (float_extend:VWEXTF
7262 (match_operand:<V_DOUBLE_TRUNC> 4 "register_operand" " vr"))))
7263 (match_operand:VWEXTF 2 "register_operand" " 0"))
7264 (match_dup 2)))]
7265 "TARGET_VECTOR"
7266 "vfw<nmsac_nmacc>.vf\t%0,%3,%4%p1"
7267 [(set_attr "type" "vfwmuladd")
7268 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7269 (set (attr "frm_mode")
7270 (symbol_ref "riscv_vector::get_frm_mode (operands[9])"))])
7271
7272 ;; -------------------------------------------------------------------------------
7273 ;; ---- Predicated floating-point comparison operations
7274 ;; -------------------------------------------------------------------------------
7275 ;; Includes:
7276 ;; - 13.13 Vector Floating-Point Compare Instructions
7277 ;; -------------------------------------------------------------------------------
7278
7279 (define_expand "@pred_cmp<mode>"
7280 [(set (match_operand:<VM> 0 "register_operand")
7281 (if_then_else:<VM>
7282 (unspec:<VM>
7283 [(match_operand:<VM> 1 "vector_mask_operand")
7284 (match_operand 6 "vector_length_operand")
7285 (match_operand 7 "const_int_operand")
7286 (match_operand 8 "const_int_operand")
7287 (reg:SI VL_REGNUM)
7288 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7289 (match_operator:<VM> 3 "signed_order_operator"
7290 [(match_operand:V_VLSF 4 "register_operand")
7291 (match_operand:V_VLSF 5 "register_operand")])
7292 (match_operand:<VM> 2 "vector_merge_operand")))]
7293 "TARGET_VECTOR"
7294 {})
7295
7296 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
7297 (define_insn "*pred_cmp<mode>"
7298 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
7299 (if_then_else:<VM>
7300 (unspec:<VM>
7301 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1")
7302 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl")
7303 (match_operand 7 "const_int_operand" " i, i, i, i")
7304 (match_operand 8 "const_int_operand" " i, i, i, i")
7305 (reg:SI VL_REGNUM)
7306 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7307 (match_operator:<VM> 3 "signed_order_operator"
7308 [(match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr")
7309 (match_operand:V_VLSF 5 "register_operand" " vr, vr, vr, vr")])
7310 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7311 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
7312 "vmf%B3.vv\t%0,%4,%5%p1"
7313 [(set_attr "type" "vfcmp")
7314 (set_attr "mode" "<MODE>")
7315 (set_attr "spec_restriction" "thv,thv,rvv,rvv")])
7316
7317 (define_insn "*pred_cmp<mode>_narrow_merge_tie_mask"
7318 [(set (match_operand:<VM> 0 "register_operand" "=vm")
7319 (if_then_else:<VM>
7320 (unspec:<VM>
7321 [(match_operand:<VM> 1 "register_operand" " 0")
7322 (match_operand 5 "vector_length_operand" "rvl")
7323 (match_operand 6 "const_int_operand" " i")
7324 (match_operand 7 "const_int_operand" " i")
7325 (reg:SI VL_REGNUM)
7326 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7327 (match_operator:<VM> 2 "signed_order_operator"
7328 [(match_operand:V_VLSF 3 "register_operand" " vr")
7329 (match_operand:V_VLSF 4 "register_operand" " vr")])
7330 (match_dup 1)))]
7331 "TARGET_VECTOR"
7332 "vmf%B2.vv\t%0,%3,%4,v0.t"
7333 [(set_attr "type" "vfcmp")
7334 (set_attr "mode" "<MODE>")
7335 (set_attr "merge_op_idx" "1")
7336 (set_attr "vl_op_idx" "5")
7337 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
7338 (set (attr "avl_type_idx") (const_int 7))])
7339
7340 ;; We use early-clobber for source LMUL > dest LMUL.
7341 (define_insn "*pred_cmp<mode>_narrow"
7342 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, vr, vr, vr, vr, &vr, &vr")
7343 (if_then_else:<VM>
7344 (unspec:<VM>
7345 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1,vmWc1")
7346 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl, rvl")
7347 (match_operand 7 "const_int_operand" " i, i, i, i, i, i, i, i, i")
7348 (match_operand 8 "const_int_operand" " i, i, i, i, i, i, i, i, i")
7349 (reg:SI VL_REGNUM)
7350 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7351 (match_operator:<VM> 3 "signed_order_operator"
7352 [(match_operand:V_VLSF 4 "register_operand" " vr, 0, vr, 0, 0, vr, 0, vr, vr")
7353 (match_operand:V_VLSF 5 "register_operand" " vr, vr, 0, 0, vr, 0, 0, vr, vr")])
7354 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, vu, vu, 0, 0, 0, vu, 0")))]
7355 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
7356 "vmf%B3.vv\t%0,%4,%5%p1"
7357 [(set_attr "type" "vfcmp")
7358 (set_attr "mode" "<MODE>")
7359 (set_attr "spec_restriction" "none,thv,thv,thv,thv,thv,thv,none,none")])
7360
7361 (define_expand "@pred_cmp<mode>_scalar"
7362 [(set (match_operand:<VM> 0 "register_operand")
7363 (if_then_else:<VM>
7364 (unspec:<VM>
7365 [(match_operand:<VM> 1 "vector_mask_operand")
7366 (match_operand 6 "vector_length_operand")
7367 (match_operand 7 "const_int_operand")
7368 (match_operand 8 "const_int_operand")
7369 (reg:SI VL_REGNUM)
7370 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7371 (match_operator:<VM> 3 "signed_order_operator"
7372 [(match_operand:V_VLSF 4 "register_operand")
7373 (vec_duplicate:V_VLSF
7374 (match_operand:<VEL> 5 "register_operand"))])
7375 (match_operand:<VM> 2 "vector_merge_operand")))]
7376 "TARGET_VECTOR"
7377 {})
7378
7379 (define_insn "*pred_cmp<mode>_scalar_merge_tie_mask"
7380 [(set (match_operand:<VM> 0 "register_operand" "=vm")
7381 (if_then_else:<VM>
7382 (unspec:<VM>
7383 [(match_operand:<VM> 1 "register_operand" " 0")
7384 (match_operand 5 "vector_length_operand" "rvl")
7385 (match_operand 6 "const_int_operand" " i")
7386 (match_operand 7 "const_int_operand" " i")
7387 (reg:SI VL_REGNUM)
7388 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7389 (match_operator:<VM> 2 "signed_order_operator"
7390 [(match_operand:V_VLSF 3 "register_operand" " vr")
7391 (vec_duplicate:V_VLSF
7392 (match_operand:<VEL> 4 "register_operand" " f"))])
7393 (match_dup 1)))]
7394 "TARGET_VECTOR"
7395 "vmf%B2.vf\t%0,%3,%4,v0.t"
7396 [(set_attr "type" "vfcmp")
7397 (set_attr "mode" "<MODE>")
7398 (set_attr "merge_op_idx" "1")
7399 (set_attr "vl_op_idx" "5")
7400 (set (attr "ma") (symbol_ref "riscv_vector::get_ma(operands[6])"))
7401 (set (attr "avl_type_idx") (const_int 7))])
7402
7403 ;; We don't use early-clobber for LMUL <= 1 to get better codegen.
7404 (define_insn "*pred_cmp<mode>_scalar"
7405 [(set (match_operand:<VM> 0 "register_operand" "=vr, vr, &vr, &vr")
7406 (if_then_else:<VM>
7407 (unspec:<VM>
7408 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1,vmWc1,vmWc1")
7409 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl")
7410 (match_operand 7 "const_int_operand" " i, i, i, i")
7411 (match_operand 8 "const_int_operand" " i, i, i, i")
7412 (reg:SI VL_REGNUM)
7413 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7414 (match_operator:<VM> 3 "signed_order_operator"
7415 [(match_operand:V_VLSF 4 "register_operand" " vr, vr, vr, vr")
7416 (vec_duplicate:V_VLSF
7417 (match_operand:<VEL> 5 "register_operand" " f, f, f, f"))])
7418 (match_operand:<VM> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7419 "TARGET_VECTOR && riscv_vector::cmp_lmul_le_one (<MODE>mode)"
7420 "vmf%B3.vf\t%0,%4,%5%p1"
7421 [(set_attr "type" "vfcmp")
7422 (set_attr "mode" "<MODE>")
7423 (set_attr "spec_restriction" "thv,thv,rvv,rvv")])
7424
7425 ;; We use early-clobber for source LMUL > dest LMUL.
7426 (define_insn "*pred_cmp<mode>_scalar_narrow"
7427 [(set (match_operand:<VM> 0 "register_operand" "=vm, vr, vr, &vr, &vr")
7428 (if_then_else:<VM>
7429 (unspec:<VM>
7430 [(match_operand:<VM> 1 "vector_mask_operand" " 0,vmWc1,vmWc1,vmWc1,vmWc1")
7431 (match_operand 6 "vector_length_operand" " rvl, rvl, rvl, rvl, rvl")
7432 (match_operand 7 "const_int_operand" " i, i, i, i, i")
7433 (match_operand 8 "const_int_operand" " i, i, i, i, i")
7434 (reg:SI VL_REGNUM)
7435 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7436 (match_operator:<VM> 3 "signed_order_operator"
7437 [(match_operand:V_VLSF 4 "register_operand" " vr, 0, 0, vr, vr")
7438 (vec_duplicate:V_VLSF
7439 (match_operand:<VEL> 5 "register_operand" " f, f, f, f, f"))])
7440 (match_operand:<VM> 2 "vector_merge_operand" " vu, vu, 0, vu, 0")))]
7441 "TARGET_VECTOR && riscv_vector::cmp_lmul_gt_one (<MODE>mode)"
7442 "vmf%B3.vf\t%0,%4,%5%p1"
7443 [(set_attr "type" "vfcmp")
7444 (set_attr "mode" "<MODE>")
7445 (set_attr "spec_restriction" "none,thv,thv,none,none")])
7446
7447 ;; -------------------------------------------------------------------------------
7448 ;; ---- Predicated floating-point merge
7449 ;; -------------------------------------------------------------------------------
7450 ;; Includes:
7451 ;; - 13.15 Vector Floating-Point Merge Instruction
7452 ;; -------------------------------------------------------------------------------
7453
7454 (define_insn "@pred_merge<mode>_scalar"
7455 [(set (match_operand:V_VLSF 0 "register_operand" "=vd,vd")
7456 (if_then_else:V_VLSF
7457 (unspec:<VM>
7458 [(match_operand 5 "vector_length_operand" "rvl,rvl")
7459 (match_operand 6 "const_int_operand" " i, i")
7460 (match_operand 7 "const_int_operand" " i, i")
7461 (reg:SI VL_REGNUM)
7462 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7463 (vec_merge:V_VLSF
7464 (vec_duplicate:V_VLSF
7465 (match_operand:<VEL> 3 "register_operand" " f, f"))
7466 (match_operand:V_VLSF 2 "register_operand" " vr,vr")
7467 (match_operand:<VM> 4 "register_operand" " vm,vm"))
7468 (match_operand:V_VLSF 1 "vector_merge_operand" " vu, 0")))]
7469 "TARGET_VECTOR"
7470 "vfmerge.vfm\t%0,%2,%3,%4"
7471 [(set_attr "type" "vfmerge")
7472 (set_attr "mode" "<MODE>")])
7473
7474 ;; -------------------------------------------------------------------------------
7475 ;; ---- Predicated floating-point conversions
7476 ;; -------------------------------------------------------------------------------
7477 ;; Includes:
7478 ;; - 13.17 Single-Width Floating-Point/Integer Type-Convert Instructions
7479 ;; -------------------------------------------------------------------------------
7480
7481 (define_insn "@pred_fcvt_x<v_su>_f<mode>"
7482 [(set (match_operand:<VCONVERT> 0 "register_operand" "=vd, vd, vr, vr")
7483 (if_then_else:<VCONVERT>
7484 (unspec:<VM>
7485 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
7486 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
7487 (match_operand 5 "const_int_operand" " i, i, i, i")
7488 (match_operand 6 "const_int_operand" " i, i, i, i")
7489 (match_operand 7 "const_int_operand" " i, i, i, i")
7490 (match_operand 8 "const_int_operand" " i, i, i, i")
7491 (reg:SI VL_REGNUM)
7492 (reg:SI VTYPE_REGNUM)
7493 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7494 (unspec:<VCONVERT>
7495 [(match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")] VFCVTS)
7496 (match_operand:<VCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7497 "TARGET_VECTOR"
7498 "vfcvt.x<v_su>.f.v\t%0,%3%p1"
7499 [(set_attr "type" "vfcvtftoi")
7500 (set_attr "mode" "<MODE>")
7501 (set (attr "frm_mode")
7502 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7503
7504 (define_insn "@pred_<fix_cvt><mode>"
7505 [(set (match_operand:<VCONVERT> 0 "register_operand" "=vd, vd, vr, vr")
7506 (if_then_else:<VCONVERT>
7507 (unspec:<VM>
7508 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
7509 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
7510 (match_operand 5 "const_int_operand" " i, i, i, i")
7511 (match_operand 6 "const_int_operand" " i, i, i, i")
7512 (match_operand 7 "const_int_operand" " i, i, i, i")
7513 (reg:SI VL_REGNUM)
7514 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7515 (any_fix:<VCONVERT>
7516 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr"))
7517 (match_operand:<VCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7518 "TARGET_VECTOR"
7519 "vfcvt.rtz.x<u>.f.v\t%0,%3%p1"
7520 [(set_attr "type" "vfcvtftoi")
7521 (set_attr "mode" "<MODE>")])
7522
7523 (define_insn "@pred_<float_cvt><mode>"
7524 [(set (match_operand:V_VLSF 0 "register_operand" "=vd, vd, vr, vr")
7525 (if_then_else:V_VLSF
7526 (unspec:<VM>
7527 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
7528 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl")
7529 (match_operand 5 "const_int_operand" " i, i, i, i")
7530 (match_operand 6 "const_int_operand" " i, i, i, i")
7531 (match_operand 7 "const_int_operand" " i, i, i, i")
7532 (match_operand 8 "const_int_operand" " i, i, i, i")
7533 (reg:SI VL_REGNUM)
7534 (reg:SI VTYPE_REGNUM)
7535 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7536 (any_float:V_VLSF
7537 (match_operand:<VCONVERT> 3 "register_operand" " vr, vr, vr, vr"))
7538 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")))]
7539 "TARGET_VECTOR"
7540 "vfcvt.f.x<u>.v\t%0,%3%p1"
7541 [(set_attr "type" "vfcvtitof")
7542 (set_attr "mode" "<MODE>")
7543 (set (attr "frm_mode")
7544 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7545
7546 ;; -------------------------------------------------------------------------------
7547 ;; ---- Predicated floating-point widen conversions
7548 ;; -------------------------------------------------------------------------------
7549 ;; Includes:
7550 ;; - 13.18 Widening Floating-Point/Integer Type-Convert Instructions
7551 ;; -------------------------------------------------------------------------------
7552
7553 (define_insn "@pred_widen_fcvt_x<v_su>_f<mode>"
7554 [(set (match_operand:VWCONVERTI 0 "register_operand" "=&vr, &vr")
7555 (if_then_else:VWCONVERTI
7556 (unspec:<VM>
7557 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7558 (match_operand 4 "vector_length_operand" " rvl, rvl")
7559 (match_operand 5 "const_int_operand" " i, i")
7560 (match_operand 6 "const_int_operand" " i, i")
7561 (match_operand 7 "const_int_operand" " i, i")
7562 (match_operand 8 "const_int_operand" " i, i")
7563 (reg:SI VL_REGNUM)
7564 (reg:SI VTYPE_REGNUM)
7565 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7566 (unspec:VWCONVERTI
7567 [(match_operand:<VNCONVERT> 3 "register_operand" " vr, vr")] VFCVTS)
7568 (match_operand:VWCONVERTI 2 "vector_merge_operand" " vu, 0")))]
7569 "TARGET_VECTOR"
7570 "vfwcvt.x<v_su>.f.v\t%0,%3%p1"
7571 [(set_attr "type" "vfwcvtftoi")
7572 (set_attr "mode" "<VNCONVERT>")
7573 (set (attr "frm_mode")
7574 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7575
7576 (define_insn "@pred_widen_<fix_cvt><mode>"
7577 [(set (match_operand:VWCONVERTI 0 "register_operand" "=&vr, &vr")
7578 (if_then_else:VWCONVERTI
7579 (unspec:<VM>
7580 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7581 (match_operand 4 "vector_length_operand" " rvl, rvl")
7582 (match_operand 5 "const_int_operand" " i, i")
7583 (match_operand 6 "const_int_operand" " i, i")
7584 (match_operand 7 "const_int_operand" " i, i")
7585 (reg:SI VL_REGNUM)
7586 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7587 (any_fix:VWCONVERTI
7588 (match_operand:<VNCONVERT> 3 "register_operand" " vr, vr"))
7589 (match_operand:VWCONVERTI 2 "vector_merge_operand" " vu, 0")))]
7590 "TARGET_VECTOR"
7591 "vfwcvt.rtz.x<u>.f.v\t%0,%3%p1"
7592 [(set_attr "type" "vfwcvtftoi")
7593 (set_attr "mode" "<VNCONVERT>")])
7594
7595 (define_insn "@pred_widen_<float_cvt><mode>"
7596 [(set (match_operand:V_VLSF 0 "register_operand" "=&vr, &vr")
7597 (if_then_else:V_VLSF
7598 (unspec:<VM>
7599 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7600 (match_operand 4 "vector_length_operand" " rvl, rvl")
7601 (match_operand 5 "const_int_operand" " i, i")
7602 (match_operand 6 "const_int_operand" " i, i")
7603 (match_operand 7 "const_int_operand" " i, i")
7604 (reg:SI VL_REGNUM)
7605 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7606 (any_float:V_VLSF
7607 (match_operand:<VNCONVERT> 3 "register_operand" " vr, vr"))
7608 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0")))]
7609 "TARGET_VECTOR"
7610 "vfwcvt.f.x<u>.v\t%0,%3%p1"
7611 [(set_attr "type" "vfwcvtitof")
7612 (set_attr "mode" "<VNCONVERT>")])
7613
7614 (define_insn "@pred_extend<mode>"
7615 [(set (match_operand:VWEXTF_ZVFHMIN 0 "register_operand" "=&vr, &vr")
7616 (if_then_else:VWEXTF_ZVFHMIN
7617 (unspec:<VM>
7618 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7619 (match_operand 4 "vector_length_operand" " rvl, rvl")
7620 (match_operand 5 "const_int_operand" " i, i")
7621 (match_operand 6 "const_int_operand" " i, i")
7622 (match_operand 7 "const_int_operand" " i, i")
7623 (reg:SI VL_REGNUM)
7624 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7625 (float_extend:VWEXTF_ZVFHMIN
7626 (match_operand:<V_DOUBLE_TRUNC> 3 "register_operand" " vr, vr"))
7627 (match_operand:VWEXTF_ZVFHMIN 2 "vector_merge_operand" " vu, 0")))]
7628 "TARGET_VECTOR"
7629 "vfwcvt.f.f.v\t%0,%3%p1"
7630 [(set_attr "type" "vfwcvtftof")
7631 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
7632
7633 ;; -------------------------------------------------------------------------------
7634 ;; ---- Predicated floating-point narrow conversions
7635 ;; -------------------------------------------------------------------------------
7636 ;; Includes:
7637 ;; - 13.19 Narrowing Floating-Point/Integer Type-Convert Instructions
7638 ;; -------------------------------------------------------------------------------
7639
7640 (define_insn "@pred_narrow_fcvt_x<v_su>_f<mode>"
7641 [(set (match_operand:<VNCONVERT> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
7642 (if_then_else:<VNCONVERT>
7643 (unspec:<VM>
7644 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
7645 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
7646 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
7647 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
7648 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
7649 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
7650 (reg:SI VL_REGNUM)
7651 (reg:SI VTYPE_REGNUM)
7652 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7653 (unspec:<VNCONVERT>
7654 [(match_operand:V_VLSF 3 "register_operand" " 0, 0, 0, 0, vr, vr")] VFCVTS)
7655 (match_operand:<VNCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
7656 "TARGET_VECTOR"
7657 "vfncvt.x<v_su>.f.w\t%0,%3%p1"
7658 [(set_attr "type" "vfncvtftoi")
7659 (set_attr "mode" "<VNCONVERT>")
7660 (set (attr "frm_mode")
7661 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))
7662 (set_attr "spec_restriction" "none,none,thv,thv,none,none")])
7663
7664 (define_insn "@pred_narrow_<fix_cvt><mode>"
7665 [(set (match_operand:<VNCONVERT> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
7666 (if_then_else:<VNCONVERT>
7667 (unspec:<VM>
7668 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
7669 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
7670 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
7671 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
7672 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
7673 (reg:SI VL_REGNUM)
7674 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7675 (any_fix:<VNCONVERT>
7676 (match_operand:V_VLSF 3 "register_operand" " 0, 0, 0, 0, vr, vr"))
7677 (match_operand:<VNCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
7678 "TARGET_VECTOR"
7679 "vfncvt.rtz.x<u>.f.w\t%0,%3%p1"
7680 [(set_attr "type" "vfncvtftoi")
7681 (set_attr "mode" "<VNCONVERT>")])
7682
7683 (define_insn "@pred_narrow_<float_cvt><mode>"
7684 [(set (match_operand:<VNCONVERT> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
7685 (if_then_else:<VNCONVERT>
7686 (unspec:<VM>
7687 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
7688 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
7689 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
7690 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
7691 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
7692 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
7693 (reg:SI VL_REGNUM)
7694 (reg:SI VTYPE_REGNUM)
7695 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7696 (any_float:<VNCONVERT>
7697 (match_operand:VWCONVERTI 3 "register_operand" " 0, 0, 0, 0, vr, vr"))
7698 (match_operand:<VNCONVERT> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
7699 "TARGET_VECTOR"
7700 "vfncvt.f.x<u>.w\t%0,%3%p1"
7701 [(set_attr "type" "vfncvtitof")
7702 (set_attr "mode" "<VNCONVERT>")
7703 (set (attr "frm_mode")
7704 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))
7705 (set_attr "spec_restriction" "none,none,thv,thv,none,none")])
7706
7707 (define_insn "@pred_trunc<mode>"
7708 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
7709 (if_then_else:<V_DOUBLE_TRUNC>
7710 (unspec:<VM>
7711 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
7712 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
7713 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
7714 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
7715 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
7716 (match_operand 8 "const_int_operand" " i, i, i, i, i, i")
7717 (reg:SI VL_REGNUM)
7718 (reg:SI VTYPE_REGNUM)
7719 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7720 (float_truncate:<V_DOUBLE_TRUNC>
7721 (match_operand:VWEXTF_ZVFHMIN 3 "register_operand" " 0, 0, 0, 0, vr, vr"))
7722 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
7723 "TARGET_VECTOR"
7724 "vfncvt.f.f.w\t%0,%3%p1"
7725 [(set_attr "type" "vfncvtftof")
7726 (set_attr "mode" "<V_DOUBLE_TRUNC>")
7727 (set (attr "frm_mode")
7728 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))
7729 (set_attr "spec_restriction" "none,none,thv,thv,none,none")])
7730
7731 (define_insn "@pred_rod_trunc<mode>"
7732 [(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vd, vd, vr, vr, &vr, &vr")
7733 (if_then_else:<V_DOUBLE_TRUNC>
7734 (unspec:<VM>
7735 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1,vmWc1,vmWc1")
7736 (match_operand 4 "vector_length_operand" "rvl,rvl,rvl,rvl, rvl, rvl")
7737 (match_operand 5 "const_int_operand" " i, i, i, i, i, i")
7738 (match_operand 6 "const_int_operand" " i, i, i, i, i, i")
7739 (match_operand 7 "const_int_operand" " i, i, i, i, i, i")
7740 (reg:SI VL_REGNUM)
7741 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7742 (unspec:<V_DOUBLE_TRUNC>
7743 [(float_truncate:<V_DOUBLE_TRUNC>
7744 (match_operand:VWEXTF_ZVFHMIN 3 "register_operand" " 0, 0, 0, 0, vr, vr"))] UNSPEC_ROD)
7745 (match_operand:<V_DOUBLE_TRUNC> 2 "vector_merge_operand" " vu, 0, vu, 0, vu, 0")))]
7746 "TARGET_VECTOR"
7747 "vfncvt.rod.f.f.w\t%0,%3%p1"
7748 [(set_attr "type" "vfncvtftof")
7749 (set_attr "mode" "<V_DOUBLE_TRUNC>")])
7750
7751 ;; -------------------------------------------------------------------------------
7752 ;; ---- Predicated reduction operations
7753 ;; -------------------------------------------------------------------------------
7754 ;; Includes:
7755 ;; - 14.1 Vector Single-Width Integer Reduction Instructions
7756 ;; - 14.2 Vector Widening Integer Reduction Instructions
7757 ;; - 14.3 Vector Single-Width Floating-Point Reduction Instructions
7758 ;; - 14.4 Vector Widening Floating-Point Reduction Instructions
7759 ;; -------------------------------------------------------------------------------
7760 ;;
7761 ;; NOTE for VL0 safe variantreduction:
7762 ;; The VL0 safe variantis used by the auto vectorizer to generate vectorized code
7763 ;; only, because the auto vectorizer expect reduction should propgat the start
7764 ;; value to dest even VL=0, the only way is force vd=vs1 by constraint.
7765
7766 ;; Integer Reduction (vred(sum|maxu|max|minu|min|and|or|xor).vs)
7767 (define_insn "@pred_<reduc_op_pat_name><mode>"
7768 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr, vr")
7769 (unspec:<V_LMUL1>
7770 [(unspec:<VM>
7771 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7772 (match_operand 5 "vector_length_operand" " rvl, rvl")
7773 (match_operand 6 "const_int_operand" " i, i")
7774 (match_operand 7 "const_int_operand" " i, i")
7775 (reg:SI VL_REGNUM)
7776 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7777 (unspec:<V_LMUL1> [
7778 (match_operand:V_VLSI 3 "register_operand" " vr, vr")
7779 (match_operand:<V_LMUL1> 4 "register_operand" " vr, vr")
7780 ] ANY_REDUC)
7781 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))]
7782 "TARGET_VECTOR"
7783 "v<reduc_op>.vs\t%0,%3,%4%p1"
7784 [(set_attr "type" "vired")
7785 (set_attr "mode" "<MODE>")])
7786
7787 ;; Integer Reduction (vred(sum|maxu|max|minu|min|and|or|xor).vs)
7788 ;; but for auto vectorizer (see "NOTE for VL0 safe variantreduction" for detail)
7789 (define_insn "@pred_<reduc_op_pat_name><mode>"
7790 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr")
7791 (unspec:<V_LMUL1>
7792 [(unspec:<VM>
7793 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7794 (match_operand 5 "vector_length_operand" " rvl")
7795 (match_operand 6 "const_int_operand" " i")
7796 (match_operand 7 "const_int_operand" " i")
7797 (reg:SI VL_REGNUM)
7798 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7799 (unspec:<V_LMUL1> [
7800 (match_operand:V_VLSI 3 "register_operand" " vr")
7801 (match_operand:<V_LMUL1> 4 "register_operand" " 0")
7802 ] ANY_REDUC_VL0_SAFE)
7803 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu")] UNSPEC_REDUC))]
7804 "TARGET_VECTOR"
7805 "v<reduc_op>.vs\t%0,%3,%4%p1"
7806 [(set_attr "type" "vired")
7807 (set_attr "mode" "<MODE>")])
7808
7809 ;; Integer Widen Reduction Sum (vwredsum[u].vs)
7810 (define_insn "@pred_<reduc_op_pat_name><mode>"
7811 [(set (match_operand:<V_EXT_LMUL1> 0 "register_operand" "=vr, vr")
7812 (unspec:<V_EXT_LMUL1>
7813 [(unspec:<VM>
7814 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7815 (match_operand 5 "vector_length_operand" " rvl, rvl")
7816 (match_operand 6 "const_int_operand" " i, i")
7817 (match_operand 7 "const_int_operand" " i, i")
7818 (reg:SI VL_REGNUM)
7819 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7820 (unspec:<V_EXT_LMUL1> [
7821 (match_operand:VI_QHS 3 "register_operand" " vr, vr")
7822 (match_operand:<V_EXT_LMUL1> 4 "register_operand" " vr, vr")
7823 ] ANY_WREDUC)
7824 (match_operand:<V_EXT_LMUL1> 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))]
7825 "TARGET_VECTOR"
7826 "v<reduc_op>.vs\t%0,%3,%4%p1"
7827 [(set_attr "type" "viwred")
7828 (set_attr "mode" "<MODE>")])
7829
7830 ;; Integer Widen Reduction Sum (vwredsum[u].vs)
7831 ;; but for auto vectorizer (see "NOTE for VL0 safe variantreduction" for detail)
7832 (define_insn "@pred_<reduc_op_pat_name><mode>"
7833 [(set (match_operand:<V_EXT_LMUL1> 0 "register_operand" "=vr")
7834 (unspec:<V_EXT_LMUL1>
7835 [(unspec:<VM>
7836 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7837 (match_operand 5 "vector_length_operand" " rvl")
7838 (match_operand 6 "const_int_operand" " i")
7839 (match_operand 7 "const_int_operand" " i")
7840 (reg:SI VL_REGNUM)
7841 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7842 (unspec:<V_EXT_LMUL1> [
7843 (match_operand:VI_QHS 3 "register_operand" " vr")
7844 (match_operand:<V_EXT_LMUL1> 4 "register_operand" " 0")
7845 ] ANY_WREDUC_VL0_SAFE)
7846 (match_operand:<V_EXT_LMUL1> 2 "vector_merge_operand" " vu")] UNSPEC_REDUC))]
7847 "TARGET_VECTOR"
7848 "v<reduc_op>.vs\t%0,%3,%4%p1"
7849 [(set_attr "type" "viwred")
7850 (set_attr "mode" "<MODE>")])
7851
7852 ;; Float Reduction (vfred(max|min).vs)
7853 (define_insn "@pred_<reduc_op_pat_name><mode>"
7854 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr, vr")
7855 (unspec:<V_LMUL1>
7856 [(unspec:<VM>
7857 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7858 (match_operand 5 "vector_length_operand" " rvl, rvl")
7859 (match_operand 6 "const_int_operand" " i, i")
7860 (match_operand 7 "const_int_operand" " i, i")
7861 (reg:SI VL_REGNUM)
7862 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7863 (unspec:<V_LMUL1> [
7864 (match_operand:V_VLSF 3 "register_operand" " vr, vr")
7865 (match_operand:<V_LMUL1> 4 "register_operand" " vr, vr")
7866 ] ANY_FREDUC)
7867 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))]
7868 "TARGET_VECTOR"
7869 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7870 [(set_attr "type" "vfredu")
7871 (set_attr "mode" "<MODE>")])
7872
7873 ;; Float Reduction (vfred(max|min).vs)
7874 ;; but for auto vectorizer (see "NOTE for VL0 safe variantreduction" for detail)
7875 (define_insn "@pred_<reduc_op_pat_name><mode>"
7876 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr")
7877 (unspec:<V_LMUL1>
7878 [(unspec:<VM>
7879 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7880 (match_operand 5 "vector_length_operand" " rvl")
7881 (match_operand 6 "const_int_operand" " i")
7882 (match_operand 7 "const_int_operand" " i")
7883 (reg:SI VL_REGNUM)
7884 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
7885 (unspec:<V_LMUL1> [
7886 (match_operand:V_VLSF 3 "register_operand" " vr")
7887 (match_operand:<V_LMUL1> 4 "register_operand" " 0")
7888 ] ANY_FREDUC_VL0_SAFE)
7889 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu")] UNSPEC_REDUC))]
7890 "TARGET_VECTOR"
7891 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7892 [(set_attr "type" "vfredu")
7893 (set_attr "mode" "<MODE>")])
7894
7895 ;; Float Reduction Sum (vfred[ou]sum.vs)
7896 (define_insn "@pred_<reduc_op_pat_name><mode>"
7897 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr,vr")
7898 (unspec:<V_LMUL1>
7899 [(unspec:<VM>
7900 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7901 (match_operand 5 "vector_length_operand" " rvl, rvl")
7902 (match_operand 6 "const_int_operand" " i, i")
7903 (match_operand 7 "const_int_operand" " i, i")
7904 (match_operand 8 "const_int_operand" " i, i")
7905 (reg:SI VL_REGNUM)
7906 (reg:SI VTYPE_REGNUM)
7907 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7908 (unspec:<V_LMUL1> [
7909 (match_operand:V_VLSF 3 "register_operand" " vr, vr")
7910 (match_operand:<V_LMUL1> 4 "register_operand" " vr, vr")
7911 ] ANY_FREDUC_SUM)
7912 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))]
7913 "TARGET_VECTOR"
7914 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7915 [(set_attr "type" "vfred<order>")
7916 (set_attr "mode" "<MODE>")
7917 (set (attr "frm_mode")
7918 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7919
7920 ;; Float Reduction Sum (vfred[ou]sum.vs)
7921 ;; but for auto vectorizer (see "NOTE for VL0 safe variantreduction" for detail)
7922 (define_insn "@pred_<reduc_op_pat_name><mode>"
7923 [(set (match_operand:<V_LMUL1> 0 "register_operand" "=vr")
7924 (unspec:<V_LMUL1>
7925 [(unspec:<VM>
7926 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7927 (match_operand 5 "vector_length_operand" " rvl")
7928 (match_operand 6 "const_int_operand" " i")
7929 (match_operand 7 "const_int_operand" " i")
7930 (match_operand 8 "const_int_operand" " i")
7931 (reg:SI VL_REGNUM)
7932 (reg:SI VTYPE_REGNUM)
7933 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7934 (unspec:<V_LMUL1> [
7935 (match_operand:V_VLSF 3 "register_operand" " vr")
7936 (match_operand:<V_LMUL1> 4 "register_operand" " 0")
7937 ] ANY_FREDUC_SUM_VL0_SAFE)
7938 (match_operand:<V_LMUL1> 2 "vector_merge_operand" " vu")] UNSPEC_REDUC))]
7939 "TARGET_VECTOR"
7940 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7941 [(set_attr "type" "vfred<order>")
7942 (set_attr "mode" "<MODE>")
7943 (set (attr "frm_mode")
7944 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7945
7946 ;; Float Widen Reduction Sum (vfwred[ou]sum.vs)
7947 (define_insn "@pred_<reduc_op_pat_name><mode>"
7948 [(set (match_operand:<V_EXT_LMUL1> 0 "register_operand" "=vr, vr")
7949 (unspec:<V_EXT_LMUL1>
7950 [(unspec:<VM>
7951 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
7952 (match_operand 5 "vector_length_operand" " rvl, rvl")
7953 (match_operand 6 "const_int_operand" " i, i")
7954 (match_operand 7 "const_int_operand" " i, i")
7955 (match_operand 8 "const_int_operand" " i, i")
7956 (reg:SI VL_REGNUM)
7957 (reg:SI VTYPE_REGNUM)
7958 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7959 (unspec:<V_EXT_LMUL1> [
7960 (match_operand:VF_HS 3 "register_operand" " vr, vr")
7961 (match_operand:<V_EXT_LMUL1> 4 "register_operand" " vr, vr")
7962 ] ANY_FWREDUC_SUM)
7963 (match_operand:<V_EXT_LMUL1> 2 "vector_merge_operand" " vu, 0")] UNSPEC_REDUC))]
7964 "TARGET_VECTOR"
7965 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7966 [(set_attr "type" "vfwred<order>")
7967 (set_attr "mode" "<MODE>")
7968 (set (attr "frm_mode")
7969 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7970
7971 ;; Float Widen Reduction Sum (vfwred[ou]sum.vs)
7972 ;; but for auto vectorizer (see "NOTE for VL0 safe variantreduction" for detail)
7973 (define_insn "@pred_<reduc_op_pat_name><mode>"
7974 [(set (match_operand:<V_EXT_LMUL1> 0 "register_operand" "=vr")
7975 (unspec:<V_EXT_LMUL1>
7976 [(unspec:<VM>
7977 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1")
7978 (match_operand 5 "vector_length_operand" " rvl")
7979 (match_operand 6 "const_int_operand" " i")
7980 (match_operand 7 "const_int_operand" " i")
7981 (match_operand 8 "const_int_operand" " i")
7982 (reg:SI VL_REGNUM)
7983 (reg:SI VTYPE_REGNUM)
7984 (reg:SI FRM_REGNUM)] UNSPEC_VPREDICATE)
7985 (unspec:<V_EXT_LMUL1> [
7986 (match_operand:VF_HS 3 "register_operand" " vr")
7987 (match_operand:<V_EXT_LMUL1> 4 "register_operand" " 0")
7988 ] ANY_FWREDUC_SUM_VL0_SAFE)
7989 (match_operand:<V_EXT_LMUL1> 2 "vector_merge_operand" " vu")] UNSPEC_REDUC))]
7990 "TARGET_VECTOR"
7991 "vf<reduc_op>.vs\t%0,%3,%4%p1"
7992 [(set_attr "type" "vfwred<order>")
7993 (set_attr "mode" "<MODE>")
7994 (set (attr "frm_mode")
7995 (symbol_ref "riscv_vector::get_frm_mode (operands[8])"))])
7996
7997 ;; -------------------------------------------------------------------------------
7998 ;; ---- Predicated permutation operations
7999 ;; -------------------------------------------------------------------------------
8000 ;; Includes:
8001 ;; - 16.1 Integer Scalar Move Instructions
8002 ;; - 16.2 Floating-Point Scalar Move Instructions
8003 ;; - 16.3 Vector Slide Instructions
8004 ;; - 16.4 Vector Register Gather Instructions
8005 ;; - 16.5 Vector Compress Instruction
8006 ;; -------------------------------------------------------------------------------
8007
8008 (define_expand "@pred_extract_first<mode>"
8009 [(set (match_operand:<VEL> 0 "register_operand")
8010 (unspec:<VEL>
8011 [(vec_select:<VEL>
8012 (match_operand:V_VLSI 1 "reg_or_mem_operand")
8013 (parallel [(const_int 0)]))
8014 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE))]
8015 "TARGET_VECTOR"
8016 {
8017 if (MEM_P (operands[1]))
8018 {
8019 /* Combine vle.v + vmv.x.s ==> lw. */
8020 emit_move_insn (operands[0], gen_rtx_MEM (<VEL>mode, XEXP (operands[1], 0)));
8021 DONE;
8022 }
8023 })
8024
8025 (define_insn_and_split "*pred_extract_first<mode>"
8026 [(set (match_operand:<VEL> 0 "register_operand" "=r")
8027 (unspec:<VEL>
8028 [(vec_select:<VEL>
8029 (match_operand:V_VLSI 1 "register_operand" "vr")
8030 (parallel [(const_int 0)]))
8031 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE))]
8032 "TARGET_VECTOR"
8033 "vmv.x.s\t%0,%1"
8034 "known_gt (GET_MODE_BITSIZE (<VEL>mode), GET_MODE_BITSIZE (Pmode))"
8035 [(const_int 0)]
8036 {
8037 /* In rv32 system, we can't use vmv.x.s directly.
8038 Instead, we should generate this following code sequence:
8039 vsrl.vx v16,v8,a0
8040 vmv.x.s a1,v16
8041 vmv.x.s a0,v8 */
8042 rtx nbits = force_reg (Pmode, gen_int_mode (GET_MODE_BITSIZE (Pmode), Pmode));
8043 rtx high_bits = gen_reg_rtx (<MODE>mode);
8044 emit_insn (gen_pred_scalar (LSHIFTRT, <MODE>mode, high_bits, CONSTM1_RTX (<VM>mode),
8045 RVV_VUNDEF (<MODE>mode), operands[1], nbits, /* vl */ const1_rtx,
8046 gen_int_mode (riscv_vector::TAIL_ANY, Pmode),
8047 gen_int_mode (riscv_vector::MASK_ANY, Pmode),
8048 gen_int_mode (riscv_vector::NONVLMAX, Pmode)));
8049 emit_insn (gen_pred_extract_first_trunc (<MODE>mode,
8050 gen_highpart (SImode, operands[0]), high_bits));
8051 emit_insn (gen_pred_extract_first_trunc (<MODE>mode,
8052 gen_lowpart (SImode, operands[0]), operands[1]));
8053 DONE;
8054 }
8055 [(set_attr "type" "vimovvx")
8056 (set_attr "mode" "<MODE>")])
8057
8058 (define_insn "@pred_extract_first_trunc<mode>"
8059 [(set (match_operand:SI 0 "register_operand" "=r")
8060 (truncate:SI
8061 (unspec:<VEL>
8062 [(vec_select:<VEL>
8063 (match_operand:V_VLSI_D 1 "register_operand" "vr")
8064 (parallel [(const_int 0)]))
8065 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))]
8066 "TARGET_VECTOR"
8067 "vmv.x.s\t%0,%1"
8068 [(set_attr "type" "vimovvx")
8069 (set_attr "mode" "<MODE>")])
8070
8071 (define_expand "@pred_extract_first<mode>"
8072 [(set (match_operand:<VEL> 0 "register_operand")
8073 (unspec:<VEL>
8074 [(vec_select:<VEL>
8075 (match_operand:V_VLSF 1 "reg_or_mem_operand")
8076 (parallel [(const_int 0)]))
8077 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE))]
8078 "TARGET_VECTOR"
8079 {
8080 if (MEM_P (operands[1]))
8081 {
8082 /* Combine vle.v + vmv.f.s ==> flw. */
8083 emit_move_insn (operands[0], gen_rtx_MEM (<VEL>mode, XEXP (operands[1], 0)));
8084 DONE;
8085 }
8086 })
8087
8088 (define_insn "*pred_extract_first<mode>"
8089 [(set (match_operand:<VEL> 0 "register_operand" "=f")
8090 (unspec:<VEL>
8091 [(vec_select:<VEL>
8092 (match_operand:V_VLSF 1 "register_operand" "vr")
8093 (parallel [(const_int 0)]))
8094 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE))]
8095 "TARGET_VECTOR"
8096 "vfmv.f.s\t%0,%1"
8097 [(set_attr "type" "vfmovvf")
8098 (set_attr "mode" "<MODE>")])
8099
8100 ;; vslide instructions
8101 (define_insn "@pred_slide<ud><mode>"
8102 [(set (match_operand:V_VLS 0 "register_operand" "<ud_constraint>")
8103 (unspec:V_VLS
8104 [(unspec:<VM>
8105 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
8106 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
8107 (match_operand 6 "const_int_operand" " i, i, i, i")
8108 (match_operand 7 "const_int_operand" " i, i, i, i")
8109 (match_operand 8 "const_int_operand" " i, i, i, i")
8110 (reg:SI VL_REGNUM)
8111 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8112 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0, vu, 0")
8113 (match_operand:V_VLS 3 "register_operand" " vr, vr, vr, vr")
8114 (match_operand 4 "pmode_reg_or_uimm5_operand" " rK, rK, rK, rK")] VSLIDES))]
8115 "TARGET_VECTOR"
8116 "vslide<ud>.v%o4\t%0,%3,%4%p1"
8117 [(set_attr "type" "vslide<ud>")
8118 (set_attr "mode" "<MODE>")])
8119
8120 ;; vslide1 instructions
8121 (define_insn "@pred_slide<ud><mode>"
8122 [(set (match_operand:V_VLSI_QHS 0 "register_operand" "<ud_constraint>")
8123 (unspec:V_VLSI_QHS
8124 [(unspec:<VM>
8125 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
8126 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
8127 (match_operand 6 "const_int_operand" " i, i, i, i")
8128 (match_operand 7 "const_int_operand" " i, i, i, i")
8129 (match_operand 8 "const_int_operand" " i, i, i, i")
8130 (reg:SI VL_REGNUM)
8131 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8132 (match_operand:V_VLSI_QHS 2 "vector_merge_operand" " vu, 0, vu, 0")
8133 (match_operand:V_VLSI_QHS 3 "register_operand" " vr, vr, vr, vr")
8134 (match_operand:<VEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ")] VSLIDES1))]
8135 "TARGET_VECTOR"
8136 "vslide<ud>.vx\t%0,%3,%z4%p1"
8137 [(set_attr "type" "vislide<ud>")
8138 (set_attr "mode" "<MODE>")])
8139
8140 (define_expand "@pred_slide<ud><mode>"
8141 [(set (match_operand:V_VLSI_D 0 "register_operand")
8142 (unspec:V_VLSI_D
8143 [(unspec:<VM>
8144 [(match_operand:<VM> 1 "vector_mask_operand")
8145 (match_operand 5 "reg_or_int_operand")
8146 (match_operand 6 "const_int_operand")
8147 (match_operand 7 "const_int_operand")
8148 (match_operand 8 "const_int_operand")
8149 (reg:SI VL_REGNUM)
8150 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8151 (match_operand:V_VLSI_D 2 "vector_merge_operand")
8152 (match_operand:V_VLSI_D 3 "register_operand")
8153 (match_operand:<VEL> 4 "reg_or_int_operand")] VSLIDES1))]
8154 "TARGET_VECTOR"
8155 {
8156 poly_uint64 nunits = GET_MODE_NUNITS (<MODE>mode) * 2;
8157 machine_mode vsimode = riscv_vector::get_vector_mode (SImode, nunits).require ();
8158 machine_mode vbimode = riscv_vector::get_vector_mode (BImode, nunits).require ();
8159 if (riscv_vector::slide1_sew64_helper (<UNSPEC>, <MODE>mode,
8160 vsimode, vbimode,
8161 operands))
8162 DONE;
8163 })
8164
8165 (define_insn "*pred_slide<ud><mode>"
8166 [(set (match_operand:V_VLSI_D 0 "register_operand" "<ud_constraint>")
8167 (unspec:V_VLSI_D
8168 [(unspec:<VM>
8169 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
8170 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
8171 (match_operand 6 "const_int_operand" " i, i, i, i")
8172 (match_operand 7 "const_int_operand" " i, i, i, i")
8173 (match_operand 8 "const_int_operand" " i, i, i, i")
8174 (reg:SI VL_REGNUM)
8175 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8176 (match_operand:V_VLSI_D 2 "vector_merge_operand" " vu, 0, vu, 0")
8177 (match_operand:V_VLSI_D 3 "register_operand" " vr, vr, vr, vr")
8178 (match_operand:<VEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ")] VSLIDES1))]
8179 "TARGET_VECTOR"
8180 "vslide<ud>.vx\t%0,%3,%z4%p1"
8181 [(set_attr "type" "vislide<ud>")
8182 (set_attr "mode" "<MODE>")])
8183
8184 (define_insn "*pred_slide<ud><mode>_extended"
8185 [(set (match_operand:V_VLSI_D 0 "register_operand" "<ud_constraint>")
8186 (unspec:V_VLSI_D
8187 [(unspec:<VM>
8188 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
8189 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
8190 (match_operand 6 "const_int_operand" " i, i, i, i")
8191 (match_operand 7 "const_int_operand" " i, i, i, i")
8192 (match_operand 8 "const_int_operand" " i, i, i, i")
8193 (reg:SI VL_REGNUM)
8194 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8195 (match_operand:V_VLSI_D 2 "vector_merge_operand" " vu, 0, vu, 0")
8196 (match_operand:V_VLSI_D 3 "register_operand" " vr, vr, vr, vr")
8197 (sign_extend:<VEL>
8198 (match_operand:<VSUBEL> 4 "reg_or_0_operand" " rJ, rJ, rJ, rJ"))] VSLIDES1))]
8199 "TARGET_VECTOR && !TARGET_64BIT"
8200 "vslide<ud>.vx\t%0,%3,%z4%p1"
8201 [(set_attr "type" "vislide<ud>")
8202 (set_attr "mode" "<MODE>")])
8203
8204 ;; vfslide1 instructions
8205 (define_insn "@pred_slide<ud><mode>"
8206 [(set (match_operand:V_VLSF 0 "register_operand" "<ud_constraint>")
8207 (unspec:V_VLSF
8208 [(unspec:<VM>
8209 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm,Wc1,Wc1")
8210 (match_operand 5 "vector_length_operand" "rvl,rvl,rvl,rvl")
8211 (match_operand 6 "const_int_operand" " i, i, i, i")
8212 (match_operand 7 "const_int_operand" " i, i, i, i")
8213 (match_operand 8 "const_int_operand" " i, i, i, i")
8214 (reg:SI VL_REGNUM)
8215 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8216 (match_operand:V_VLSF 2 "vector_merge_operand" " vu, 0, vu, 0")
8217 (match_operand:V_VLSF 3 "register_operand" " vr, vr, vr, vr")
8218 (match_operand:<VEL> 4 "register_operand" " f, f, f, f")] VFSLIDES1))]
8219 "TARGET_VECTOR"
8220 "vfslide<ud>.vf\t%0,%3,%4%p1"
8221 [(set_attr "type" "vfslide<ud>")
8222 (set_attr "mode" "<MODE>")])
8223
8224 ;; vrgather
8225 (define_insn "@pred_gather<mode>"
8226 [(set (match_operand:V_VLS 0 "register_operand" "=&vr, &vr")
8227 (if_then_else:V_VLS
8228 (unspec:<VM>
8229 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8230 (match_operand 5 "vector_length_operand" " rvl, rvl")
8231 (match_operand 6 "const_int_operand" " i, i")
8232 (match_operand 7 "const_int_operand" " i, i")
8233 (match_operand 8 "const_int_operand" " i, i")
8234 (reg:SI VL_REGNUM)
8235 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8236 (unspec:V_VLS
8237 [(match_operand:V_VLS 3 "register_operand" " vr, vr")
8238 (match_operand:<VINDEX> 4 "register_operand" " vr, vr")] UNSPEC_VRGATHER)
8239 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0")))]
8240 "TARGET_VECTOR"
8241 "vrgather.vv\t%0,%3,%4%p1"
8242 [(set_attr "type" "vgather")
8243 (set_attr "mode" "<MODE>")])
8244
8245 (define_insn "@pred_gather<mode>_scalar"
8246 [(set (match_operand:V_VLS 0 "register_operand" "=&vr, &vr")
8247 (if_then_else:V_VLS
8248 (unspec:<VM>
8249 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8250 (match_operand 5 "vector_length_operand" " rvl, rvl")
8251 (match_operand 6 "const_int_operand" " i, i")
8252 (match_operand 7 "const_int_operand" " i, i")
8253 (match_operand 8 "const_int_operand" " i, i")
8254 (reg:SI VL_REGNUM)
8255 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8256 (unspec:V_VLS
8257 [(match_operand:V_VLS 3 "register_operand" " vr, vr")
8258 (match_operand 4 "pmode_reg_or_uimm5_operand" " rK, rK")] UNSPEC_VRGATHER)
8259 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0")))]
8260 "TARGET_VECTOR"
8261 "vrgather.v%o4\t%0,%3,%4%p1"
8262 [(set_attr "type" "vgather")
8263 (set_attr "mode" "<MODE>")])
8264
8265 ;; vrgatherei16
8266 (define_insn "@pred_gatherei16<mode>"
8267 [(set (match_operand:VEI16 0 "register_operand" "=&vr, &vr")
8268 (if_then_else:VEI16
8269 (unspec:<VM>
8270 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8271 (match_operand 5 "vector_length_operand" " rvl, rvl")
8272 (match_operand 6 "const_int_operand" " i, i")
8273 (match_operand 7 "const_int_operand" " i, i")
8274 (match_operand 8 "const_int_operand" " i, i")
8275 (reg:SI VL_REGNUM)
8276 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8277 (unspec:VEI16
8278 [(match_operand:VEI16 3 "register_operand" " vr, vr")
8279 (match_operand:<VINDEXEI16> 4 "register_operand" " vr, vr")] UNSPEC_VRGATHEREI16)
8280 (match_operand:VEI16 2 "vector_merge_operand" " vu, 0")))]
8281 "TARGET_VECTOR"
8282 "vrgatherei16.vv\t%0,%3,%4%p1"
8283 [(set_attr "type" "vgather")
8284 (set_attr "mode" "<MODE>")])
8285
8286 ;; vcompress
8287 (define_insn "@pred_compress<mode>"
8288 [(set (match_operand:V_VLS 0 "register_operand" "=&vr, &vr")
8289 (unspec:V_VLS
8290 [(unspec:<VM>
8291 [(match_operand:<VM> 3 "register_operand" " vm, vm")
8292 (match_operand 4 "vector_length_operand" " rvl, rvl")
8293 (match_operand 5 "const_int_operand" " i, i")
8294 (match_operand 6 "const_int_operand" " i, i")
8295 (reg:SI VL_REGNUM)
8296 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8297 (match_operand:V_VLS 2 "register_operand" " vr, vr")
8298 (match_operand:V_VLS 1 "vector_merge_operand" " vu, 0")] UNSPEC_VCOMPRESS))]
8299 "TARGET_VECTOR"
8300 "vcompress.vm\t%0,%2,%3"
8301 [(set_attr "type" "vcompress")
8302 (set_attr "mode" "<MODE>")])
8303
8304 ;; -------------------------------------------------------------------------------
8305 ;; ---- Predicated Fault-Only-First loads
8306 ;; -------------------------------------------------------------------------------
8307 ;; Includes:
8308 ;; - 7.7. Unit-stride Fault-Only-First Loads
8309 ;; -------------------------------------------------------------------------------
8310
8311 (define_insn "@read_vl<mode>"
8312 [(set (match_operand:P 0 "register_operand" "=r")
8313 (unspec:P [(reg:SI VL_REGNUM)] UNSPEC_READ_VL))]
8314 "TARGET_VECTOR"
8315 "csrr\t%0,vl"
8316 [(set_attr "type" "rdvl")
8317 (set_attr "mode" "<MODE>")])
8318
8319 (define_insn "@pred_fault_load<mode>"
8320 [(set (match_operand:V 0 "register_operand" "=vd, vd, vr, vr")
8321 (if_then_else:V
8322 (unspec:<VM>
8323 [(match_operand:<VM> 1 "vector_mask_operand" " vm, vm, Wc1, Wc1")
8324 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl, rvl")
8325 (match_operand 5 "const_int_operand" " i, i, i, i")
8326 (match_operand 6 "const_int_operand" " i, i, i, i")
8327 (match_operand 7 "const_int_operand" " i, i, i, i")
8328 (reg:SI VL_REGNUM)
8329 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8330 (unspec:V
8331 [(match_operand:V 3 "memory_operand" " m, m, m, m")] UNSPEC_VLEFF)
8332 (match_operand:V 2 "vector_merge_operand" " vu, 0, vu, 0")))
8333 (set (reg:SI VL_REGNUM)
8334 (unspec:SI
8335 [(if_then_else:V
8336 (unspec:<VM>
8337 [(match_dup 1) (match_dup 4) (match_dup 5)
8338 (match_dup 6) (match_dup 7)
8339 (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8340 (unspec:V [(match_dup 3)] UNSPEC_VLEFF)
8341 (match_dup 2))] UNSPEC_MODIFY_VL))]
8342 "TARGET_VECTOR"
8343 "vle<sew>ff.v\t%0,%3%p1"
8344 [(set_attr "type" "vldff")
8345 (set_attr "mode" "<MODE>")])
8346
8347 (define_insn "@pred_fault_load_set_vl<V_VLS:mode><P:mode>"
8348 [(set (match_operand:V_VLS 0 "register_operand" "= vd, vd, vr, vr")
8349 (if_then_else:V_VLS
8350 (unspec:<V_VLS:VM>
8351 [(match_operand:<V_VLS:VM> 1 "vector_mask_operand" " vm, vm, Wc1, Wc1")
8352 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl, rvl")
8353 (match_operand 5 "const_int_operand" " i, i, i, i")
8354 (match_operand 6 "const_int_operand" " i, i, i, i")
8355 (match_operand 7 "const_int_operand" " i, i, i, i")
8356 (reg:SI VL_REGNUM)
8357 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8358 (unspec:V_VLS
8359 [(match_operand:V_VLS 3 "memory_operand" " m, m, m, m")] UNSPEC_VLEFF)
8360 (match_operand:V_VLS 2 "vector_merge_operand" " vu, 0, vu, 0")))
8361 (set (reg:SI VL_REGNUM)
8362 (unspec:SI
8363 [(if_then_else:V_VLS
8364 (unspec:<V_VLS:VM>
8365 [(match_dup 1) (match_dup 4) (match_dup 5)
8366 (match_dup 6) (match_dup 7)
8367 (reg:SI VL_REGNUM) (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8368 (unspec:V_VLS [(match_dup 3)] UNSPEC_VLEFF)
8369 (match_dup 2))] UNSPEC_MODIFY_VL))
8370 (set (match_operand:P 8 "register_operand" "= r, r, r, r")
8371 (unspec:P [(reg:SI VL_REGNUM)] UNSPEC_READ_VL))]
8372 "TARGET_VECTOR"
8373 "vle<sew>ff.v\t%0,%3%p1"
8374 [(set_attr "type" "vldff")
8375 (set_attr "mode" "<V_VLS:MODE>")])
8376
8377
8378 ;; -------------------------------------------------------------------------------
8379 ;; ---- Predicated Segment loads/stores
8380 ;; -------------------------------------------------------------------------------
8381 ;; Includes:
8382 ;; - 7.8.1. Vector Unit-Stride Segment Loads and Stores
8383 ;; - 7.8.2. Vector Strided Segment Loads and Stores
8384 ;; - 7.8.3. Vector Indexed Segment Loads and Stores
8385 ;; -------------------------------------------------------------------------------
8386
8387 (define_insn "@pred_unit_strided_load<mode>"
8388 [(set (match_operand:VT 0 "register_operand" "=vr, vr, vd")
8389 (if_then_else:VT
8390 (unspec:<VM>
8391 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm")
8392 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl")
8393 (match_operand 5 "const_int_operand" " i, i, i")
8394 (match_operand 6 "const_int_operand" " i, i, i")
8395 (match_operand 7 "const_int_operand" " i, i, i")
8396 (reg:SI VL_REGNUM)
8397 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8398 (unspec:VT
8399 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ, rJ")
8400 (mem:BLK (scratch))] UNSPEC_UNIT_STRIDED)
8401 (match_operand:VT 2 "vector_merge_operand" " 0, vu, vu")))]
8402 "TARGET_VECTOR"
8403 "vlseg<nf>e<sew>.v\t%0,(%z3)%p1"
8404 [(set_attr "type" "vlsegde")
8405 (set_attr "mode" "<MODE>")])
8406
8407 (define_insn "@pred_unit_strided_store<mode>"
8408 [(set (mem:BLK (scratch))
8409 (unspec:BLK
8410 [(unspec:<VM>
8411 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8412 (match_operand 3 "vector_length_operand" " rvl")
8413 (match_operand 4 "const_int_operand" " i")
8414 (reg:SI VL_REGNUM)
8415 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8416 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8417 (match_operand:VT 2 "register_operand" " vr")
8418 (mem:BLK (scratch))] UNSPEC_UNIT_STRIDED))]
8419 "TARGET_VECTOR"
8420 "vsseg<nf>e<sew>.v\t%2,(%z1)%p0"
8421 [(set_attr "type" "vssegte")
8422 (set_attr "mode" "<MODE>")])
8423
8424 (define_insn "@pred_strided_load<mode>"
8425 [(set (match_operand:VT 0 "register_operand" "=vr, vr, vd")
8426 (if_then_else:VT
8427 (unspec:<VM>
8428 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm")
8429 (match_operand 5 "vector_length_operand" " rvl, rvl, rvl")
8430 (match_operand 6 "const_int_operand" " i, i, i")
8431 (match_operand 7 "const_int_operand" " i, i, i")
8432 (match_operand 8 "const_int_operand" " i, i, i")
8433 (reg:SI VL_REGNUM)
8434 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8435 (unspec:VT
8436 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ, rJ")
8437 (match_operand 4 "pmode_reg_or_0_operand" " rJ, rJ, rJ")
8438 (mem:BLK (scratch))] UNSPEC_STRIDED)
8439 (match_operand:VT 2 "vector_merge_operand" " 0, vu, vu")))]
8440 "TARGET_VECTOR"
8441 "vlsseg<nf>e<sew>.v\t%0,(%z3),%z4%p1"
8442 [(set_attr "type" "vlsegds")
8443 (set_attr "mode" "<MODE>")])
8444
8445 (define_insn "@pred_strided_store<mode>"
8446 [(set (mem:BLK (scratch))
8447 (unspec:BLK
8448 [(unspec:<VM>
8449 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8450 (match_operand 4 "vector_length_operand" " rvl")
8451 (match_operand 5 "const_int_operand" " i")
8452 (reg:SI VL_REGNUM)
8453 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8454 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8455 (match_operand 2 "pmode_reg_or_0_operand" " rJ")
8456 (match_operand:VT 3 "register_operand" " vr")
8457 (mem:BLK (scratch))] UNSPEC_STRIDED))]
8458 "TARGET_VECTOR"
8459 "vssseg<nf>e<sew>.v\t%3,(%z1),%z2%p0"
8460 [(set_attr "type" "vssegts")
8461 (set_attr "mode" "<MODE>")])
8462
8463 (define_insn "@pred_fault_load<mode>"
8464 [(set (match_operand:VT 0 "register_operand" "=vr, vr, vd")
8465 (if_then_else:VT
8466 (unspec:<VM>
8467 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm")
8468 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl")
8469 (match_operand 5 "const_int_operand" " i, i, i")
8470 (match_operand 6 "const_int_operand" " i, i, i")
8471 (match_operand 7 "const_int_operand" " i, i, i")
8472 (reg:SI VL_REGNUM)
8473 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8474 (unspec:VT
8475 [(match_operand:VT 3 "memory_operand" " m, m, m")
8476 (mem:BLK (scratch))] UNSPEC_VLEFF)
8477 (match_operand:VT 2 "vector_merge_operand" " 0, vu, vu")))
8478 (set (reg:SI VL_REGNUM)
8479 (unspec:SI
8480 [(if_then_else:VT
8481 (unspec:<VM>
8482 [(match_dup 1) (match_dup 4) (match_dup 5)
8483 (match_dup 6) (match_dup 7)
8484 (reg:SI VL_REGNUM)
8485 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8486 (unspec:VT
8487 [(match_dup 3) (mem:BLK (scratch))] UNSPEC_VLEFF)
8488 (match_dup 2))] UNSPEC_MODIFY_VL))]
8489 "TARGET_VECTOR"
8490 "vlseg<nf>e<sew>ff.v\t%0,%3%p1"
8491 [(set_attr "type" "vlsegdff")
8492 (set_attr "mode" "<MODE>")])
8493
8494 (define_insn "@pred_fault_load_set_vl<VT:mode><P:mode>"
8495 [(set (match_operand:VT 0 "register_operand" "= vr, vr, vd")
8496 (if_then_else:VT
8497 (unspec:<VT:VM>
8498 [(match_operand:<VT:VM> 1 "vector_mask_operand" "vmWc1, Wc1, vm")
8499 (match_operand 4 "vector_length_operand" " rvl, rvl, rvl")
8500 (match_operand 5 "const_int_operand" " i, i, i")
8501 (match_operand 6 "const_int_operand" " i, i, i")
8502 (match_operand 7 "const_int_operand" " i, i, i")
8503 (reg:SI VL_REGNUM)
8504 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8505 (unspec:VT
8506 [(match_operand:VT 3 "memory_operand" " m, m, m")
8507 (mem:BLK (scratch))] UNSPEC_VLEFF)
8508 (match_operand:VT 2 "vector_merge_operand" " 0, vu, vu")))
8509 (set (reg:SI VL_REGNUM)
8510 (unspec:SI
8511 [(if_then_else:VT
8512 (unspec:<VT:VM>
8513 [(match_dup 1) (match_dup 4) (match_dup 5)
8514 (match_dup 6) (match_dup 7)
8515 (reg:SI VL_REGNUM)
8516 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8517 (unspec:VT
8518 [(match_dup 3) (mem:BLK (scratch))] UNSPEC_VLEFF)
8519 (match_dup 2))] UNSPEC_MODIFY_VL))
8520 (set (match_operand:P 8 "register_operand" "= r, r, r")
8521 (unspec:P [(reg:SI VL_REGNUM)] UNSPEC_READ_VL))]
8522 "TARGET_VECTOR"
8523 "vlseg<nf>e<sew>ff.v\t%0,%3%p1"
8524 [(set_attr "type" "vlsegdff")
8525 (set_attr "mode" "<VT:MODE>")])
8526
8527 (define_insn "@pred_indexed_<order>load<V1T:mode><RATIO64I:mode>"
8528 [(set (match_operand:V1T 0 "register_operand" "=&vr, &vr")
8529 (if_then_else:V1T
8530 (unspec:<VM>
8531 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8532 (match_operand 5 "vector_length_operand" " rvl, rvl")
8533 (match_operand 6 "const_int_operand" " i, i")
8534 (match_operand 7 "const_int_operand" " i, i")
8535 (match_operand 8 "const_int_operand" " i, i")
8536 (reg:SI VL_REGNUM)
8537 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8538 (unspec:V1T
8539 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8540 (mem:BLK (scratch))
8541 (match_operand:RATIO64I 4 "register_operand" " vr, vr")] ORDER)
8542 (match_operand:V1T 2 "vector_merge_operand" " vu, 0")))]
8543 "TARGET_VECTOR"
8544 "vl<order>xseg<nf>ei<RATIO64I:sew>.v\t%0,(%z3),%4%p1"
8545 [(set_attr "type" "vlsegd<order>x")
8546 (set_attr "mode" "<V1T:MODE>")])
8547
8548 (define_insn "@pred_indexed_<order>load<V2T:mode><RATIO32I:mode>"
8549 [(set (match_operand:V2T 0 "register_operand" "=&vr, &vr")
8550 (if_then_else:V2T
8551 (unspec:<VM>
8552 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8553 (match_operand 5 "vector_length_operand" " rvl, rvl")
8554 (match_operand 6 "const_int_operand" " i, i")
8555 (match_operand 7 "const_int_operand" " i, i")
8556 (match_operand 8 "const_int_operand" " i, i")
8557 (reg:SI VL_REGNUM)
8558 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8559 (unspec:V2T
8560 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8561 (mem:BLK (scratch))
8562 (match_operand:RATIO32I 4 "register_operand" " vr, vr")] ORDER)
8563 (match_operand:V2T 2 "vector_merge_operand" " vu, 0")))]
8564 "TARGET_VECTOR"
8565 "vl<order>xseg<nf>ei<RATIO32I:sew>.v\t%0,(%z3),%4%p1"
8566 [(set_attr "type" "vlsegd<order>x")
8567 (set_attr "mode" "<V2T:MODE>")])
8568
8569 (define_insn "@pred_indexed_<order>load<V4T:mode><RATIO16I:mode>"
8570 [(set (match_operand:V4T 0 "register_operand" "=&vr, &vr")
8571 (if_then_else:V4T
8572 (unspec:<VM>
8573 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8574 (match_operand 5 "vector_length_operand" " rvl, rvl")
8575 (match_operand 6 "const_int_operand" " i, i")
8576 (match_operand 7 "const_int_operand" " i, i")
8577 (match_operand 8 "const_int_operand" " i, i")
8578 (reg:SI VL_REGNUM)
8579 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8580 (unspec:V4T
8581 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8582 (mem:BLK (scratch))
8583 (match_operand:RATIO16I 4 "register_operand" " vr, vr")] ORDER)
8584 (match_operand:V4T 2 "vector_merge_operand" " vu, 0")))]
8585 "TARGET_VECTOR"
8586 "vl<order>xseg<nf>ei<RATIO16I:sew>.v\t%0,(%z3),%4%p1"
8587 [(set_attr "type" "vlsegd<order>x")
8588 (set_attr "mode" "<V4T:MODE>")])
8589
8590 (define_insn "@pred_indexed_<order>load<V8T:mode><RATIO8I:mode>"
8591 [(set (match_operand:V8T 0 "register_operand" "=&vr, &vr")
8592 (if_then_else:V8T
8593 (unspec:<VM>
8594 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8595 (match_operand 5 "vector_length_operand" " rvl, rvl")
8596 (match_operand 6 "const_int_operand" " i, i")
8597 (match_operand 7 "const_int_operand" " i, i")
8598 (match_operand 8 "const_int_operand" " i, i")
8599 (reg:SI VL_REGNUM)
8600 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8601 (unspec:V8T
8602 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8603 (mem:BLK (scratch))
8604 (match_operand:RATIO8I 4 "register_operand" " vr, vr")] ORDER)
8605 (match_operand:V8T 2 "vector_merge_operand" " vu, 0")))]
8606 "TARGET_VECTOR"
8607 "vl<order>xseg<nf>ei<RATIO8I:sew>.v\t%0,(%z3),%4%p1"
8608 [(set_attr "type" "vlsegd<order>x")
8609 (set_attr "mode" "<V8T:MODE>")])
8610
8611 (define_insn "@pred_indexed_<order>load<V16T:mode><RATIO4I:mode>"
8612 [(set (match_operand:V16T 0 "register_operand" "=&vr, &vr")
8613 (if_then_else:V16T
8614 (unspec:<VM>
8615 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8616 (match_operand 5 "vector_length_operand" " rvl, rvl")
8617 (match_operand 6 "const_int_operand" " i, i")
8618 (match_operand 7 "const_int_operand" " i, i")
8619 (match_operand 8 "const_int_operand" " i, i")
8620 (reg:SI VL_REGNUM)
8621 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8622 (unspec:V16T
8623 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8624 (mem:BLK (scratch))
8625 (match_operand:RATIO4I 4 "register_operand" " vr, vr")] ORDER)
8626 (match_operand:V16T 2 "vector_merge_operand" " vu, 0")))]
8627 "TARGET_VECTOR"
8628 "vl<order>xseg<nf>ei<RATIO4I:sew>.v\t%0,(%z3),%4%p1"
8629 [(set_attr "type" "vlsegd<order>x")
8630 (set_attr "mode" "<V16T:MODE>")])
8631
8632 (define_insn "@pred_indexed_<order>load<V32T:mode><RATIO2I:mode>"
8633 [(set (match_operand:V32T 0 "register_operand" "=&vr, &vr")
8634 (if_then_else:V32T
8635 (unspec:<VM>
8636 [(match_operand:<VM> 1 "vector_mask_operand" "vmWc1,vmWc1")
8637 (match_operand 5 "vector_length_operand" " rvl, rvl")
8638 (match_operand 6 "const_int_operand" " i, i")
8639 (match_operand 7 "const_int_operand" " i, i")
8640 (match_operand 8 "const_int_operand" " i, i")
8641 (reg:SI VL_REGNUM)
8642 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8643 (unspec:V32T
8644 [(match_operand 3 "pmode_reg_or_0_operand" " rJ, rJ")
8645 (mem:BLK (scratch))
8646 (match_operand:RATIO2I 4 "register_operand" " vr, vr")] ORDER)
8647 (match_operand:V32T 2 "vector_merge_operand" " vu, 0")))]
8648 "TARGET_VECTOR"
8649 "vl<order>xseg<nf>ei<RATIO2I:sew>.v\t%0,(%z3),%4%p1"
8650 [(set_attr "type" "vlsegd<order>x")
8651 (set_attr "mode" "<V32T:MODE>")])
8652
8653 (define_insn "@pred_indexed_<order>store<V1T:mode><RATIO64I:mode>"
8654 [(set (mem:BLK (scratch))
8655 (unspec:BLK
8656 [(unspec:<VM>
8657 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8658 (match_operand 4 "vector_length_operand" " rvl")
8659 (match_operand 5 "const_int_operand" " i")
8660 (reg:SI VL_REGNUM)
8661 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8662 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8663 (match_operand:RATIO64I 2 "register_operand" " vr")
8664 (match_operand:V1T 3 "register_operand" " vr")] ORDER))]
8665 "TARGET_VECTOR"
8666 "vs<order>xseg<nf>ei<RATIO64I:sew>.v\t%3,(%z1),%2%p0"
8667 [(set_attr "type" "vssegt<order>x")
8668 (set_attr "mode" "<V1T:MODE>")])
8669
8670 (define_insn "@pred_indexed_<order>store<V2T:mode><RATIO32I:mode>"
8671 [(set (mem:BLK (scratch))
8672 (unspec:BLK
8673 [(unspec:<VM>
8674 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8675 (match_operand 4 "vector_length_operand" " rvl")
8676 (match_operand 5 "const_int_operand" " i")
8677 (reg:SI VL_REGNUM)
8678 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8679 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8680 (match_operand:RATIO32I 2 "register_operand" " vr")
8681 (match_operand:V2T 3 "register_operand" " vr")] ORDER))]
8682 "TARGET_VECTOR"
8683 "vs<order>xseg<nf>ei<RATIO32I:sew>.v\t%3,(%z1),%2%p0"
8684 [(set_attr "type" "vssegt<order>x")
8685 (set_attr "mode" "<V2T:MODE>")])
8686
8687 (define_insn "@pred_indexed_<order>store<V4T:mode><RATIO16I:mode>"
8688 [(set (mem:BLK (scratch))
8689 (unspec:BLK
8690 [(unspec:<VM>
8691 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8692 (match_operand 4 "vector_length_operand" " rvl")
8693 (match_operand 5 "const_int_operand" " i")
8694 (reg:SI VL_REGNUM)
8695 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8696 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8697 (match_operand:RATIO16I 2 "register_operand" " vr")
8698 (match_operand:V4T 3 "register_operand" " vr")] ORDER))]
8699 "TARGET_VECTOR"
8700 "vs<order>xseg<nf>ei<RATIO16I:sew>.v\t%3,(%z1),%2%p0"
8701 [(set_attr "type" "vssegt<order>x")
8702 (set_attr "mode" "<V4T:MODE>")])
8703
8704 (define_insn "@pred_indexed_<order>store<V8T:mode><RATIO8I:mode>"
8705 [(set (mem:BLK (scratch))
8706 (unspec:BLK
8707 [(unspec:<VM>
8708 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8709 (match_operand 4 "vector_length_operand" " rvl")
8710 (match_operand 5 "const_int_operand" " i")
8711 (reg:SI VL_REGNUM)
8712 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8713 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8714 (match_operand:RATIO8I 2 "register_operand" " vr")
8715 (match_operand:V8T 3 "register_operand" " vr")] ORDER))]
8716 "TARGET_VECTOR"
8717 "vs<order>xseg<nf>ei<RATIO8I:sew>.v\t%3,(%z1),%2%p0"
8718 [(set_attr "type" "vssegt<order>x")
8719 (set_attr "mode" "<V8T:MODE>")])
8720
8721 (define_insn "@pred_indexed_<order>store<V16T:mode><RATIO4I:mode>"
8722 [(set (mem:BLK (scratch))
8723 (unspec:BLK
8724 [(unspec:<VM>
8725 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8726 (match_operand 4 "vector_length_operand" " rvl")
8727 (match_operand 5 "const_int_operand" " i")
8728 (reg:SI VL_REGNUM)
8729 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8730 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8731 (match_operand:RATIO4I 2 "register_operand" " vr")
8732 (match_operand:V16T 3 "register_operand" " vr")] ORDER))]
8733 "TARGET_VECTOR"
8734 "vs<order>xseg<nf>ei<RATIO4I:sew>.v\t%3,(%z1),%2%p0"
8735 [(set_attr "type" "vssegt<order>x")
8736 (set_attr "mode" "<V16T:MODE>")])
8737
8738 (define_insn "@pred_indexed_<order>store<V32T:mode><RATIO2I:mode>"
8739 [(set (mem:BLK (scratch))
8740 (unspec:BLK
8741 [(unspec:<VM>
8742 [(match_operand:<VM> 0 "vector_mask_operand" "vmWc1")
8743 (match_operand 4 "vector_length_operand" " rvl")
8744 (match_operand 5 "const_int_operand" " i")
8745 (reg:SI VL_REGNUM)
8746 (reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
8747 (match_operand 1 "pmode_reg_or_0_operand" " rJ")
8748 (match_operand:RATIO2I 2 "register_operand" " vr")
8749 (match_operand:V32T 3 "register_operand" " vr")] ORDER))]
8750 "TARGET_VECTOR"
8751 "vs<order>xseg<nf>ei<RATIO2I:sew>.v\t%3,(%z1),%2%p0"
8752 [(set_attr "type" "vssegt<order>x")
8753 (set_attr "mode" "<V32T:MODE>")])
8754
8755 (include "autovec.md")
8756 (include "autovec-opt.md")
8757 (include "sifive-vector.md")