| 1 |
;; Machine description for optimization of RVV auto-vectorization. |
| 2 |
;; Copyright (C) 2023-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 |
;; ----------------------------------------------------------------------------- |
| 22 |
;; ---- Integer Compare Instructions Simplification |
| 23 |
;; ----------------------------------------------------------------------------- |
| 24 |
;; Simplify OP(V, V) Instructions to VMCLR.m Includes: |
| 25 |
;; - 1. VMSNE |
| 26 |
;; - 2. VMSLT |
| 27 |
;; - 3. VMSLTU |
| 28 |
;; - 4. VMSGT |
| 29 |
;; - 5. VMSGTU |
| 30 |
;; ----------------------------------------------------------------------------- |
| 31 |
;; Simplify OP(V, V) Instructions to VMSET.m Includes: |
| 32 |
;; - 1. VMSEQ |
| 33 |
;; - 2. VMSLE |
| 34 |
;; - 3. VMSLEU |
| 35 |
;; - 4. VMSGE |
| 36 |
;; - 5. VMSGEU |
| 37 |
;; ----------------------------------------------------------------------------- |
| 38 |
|
| 39 |
(define_split |
| 40 |
[(set (match_operand:VB 0 "register_operand") |
| 41 |
(if_then_else:VB |
| 42 |
(unspec:VB |
| 43 |
[(match_operand:VB 1 "vector_all_trues_mask_operand") |
| 44 |
(match_operand 4 "vector_length_operand") |
| 45 |
(match_operand 5 "const_int_operand") |
| 46 |
(match_operand 6 "const_int_operand") |
| 47 |
(reg:SI VL_REGNUM) |
| 48 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) |
| 49 |
(match_operand:VB 3 "vector_move_operand") |
| 50 |
(match_operand:VB 2 "vector_undef_operand")))] |
| 51 |
"TARGET_VECTOR" |
| 52 |
[(const_int 0)] |
| 53 |
{ |
| 54 |
emit_insn (gen_pred_mov (<MODE>mode, operands[0], CONST1_RTX (<MODE>mode), |
| 55 |
RVV_VUNDEF (<MODE>mode), operands[3], |
| 56 |
operands[4], operands[6])); |
| 57 |
DONE; |
| 58 |
} |
| 59 |
) |
| 60 |
|
| 61 |
;; ------------------------------------------------------------------------- |
| 62 |
;; ---- Sign-extension for vmv.x.s. |
| 63 |
;; ------------------------------------------------------------------------- |
| 64 |
(define_insn "*pred_extract_first_sextdi<mode>" |
| 65 |
[(set (match_operand:DI 0 "register_operand" "=r") |
| 66 |
(sign_extend:DI |
| 67 |
(unspec:<VEL> |
| 68 |
[(vec_select:<VEL> |
| 69 |
(match_operand:VI_QHS 1 "register_operand""vr") |
| 70 |
(parallel [(const_int 0)])) |
| 71 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))] |
| 72 |
"TARGET_VECTOR && Pmode == DImode" |
| 73 |
"vmv.x.s\t%0,%1" |
| 74 |
[(set_attr "type" "vimovvx") |
| 75 |
(set_attr "mode" "<MODE>")]) |
| 76 |
|
| 77 |
(define_insn "*pred_extract_first_sextsi<mode>" |
| 78 |
[(set (match_operand:SI 0 "register_operand" "=r") |
| 79 |
(sign_extend:SI |
| 80 |
(unspec:<VEL> |
| 81 |
[(vec_select:<VEL> |
| 82 |
(match_operand:VI_QH 1 "register_operand" "vr") |
| 83 |
(parallel [(const_int 0)])) |
| 84 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))] |
| 85 |
"TARGET_VECTOR && Pmode == SImode" |
| 86 |
"vmv.x.s\t%0,%1" |
| 87 |
[(set_attr "type" "vimovvx") |
| 88 |
(set_attr "mode" "<MODE>")]) |
| 89 |
|
| 90 |
;; ============================================================================= |
| 91 |
;; All combine patterns for combine pass. |
| 92 |
;; ============================================================================= |
| 93 |
|
| 94 |
;; ============================================================================= |
| 95 |
;; Combine op + vmerge to cond_op |
| 96 |
;; ============================================================================= |
| 97 |
|
| 98 |
;; Combine <op> and vcond_mask generated by midend into cond_len_<op> |
| 99 |
;; Currently supported operations: |
| 100 |
;; abs(FP) |
| 101 |
(define_insn_and_split "*cond_abs<mode>" |
| 102 |
[(set (match_operand:V_VLSF 0 "register_operand") |
| 103 |
(if_then_else:V_VLSF |
| 104 |
(match_operand:<VM> 1 "register_operand") |
| 105 |
(abs:V_VLSF (match_operand:V_VLSF 2 "nonmemory_operand")) |
| 106 |
(match_operand:V_VLSF 3 "register_operand")))] |
| 107 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 108 |
"#" |
| 109 |
"&& 1" |
| 110 |
[(const_int 0)] |
| 111 |
{ |
| 112 |
insn_code icode = code_for_pred (ABS, <MODE>mode); |
| 113 |
riscv_vector::expand_cond_unop (icode, operands); |
| 114 |
DONE; |
| 115 |
} |
| 116 |
[(set_attr "type" "vector")]) |
| 117 |
|
| 118 |
;; Combine vfsqrt.v and cond_mask |
| 119 |
(define_insn_and_split "*cond_<optab><mode>" |
| 120 |
[(set (match_operand:V_VLSF 0 "register_operand") |
| 121 |
(if_then_else:V_VLSF |
| 122 |
(match_operand:<VM> 1 "register_operand") |
| 123 |
(any_float_unop:V_VLSF |
| 124 |
(match_operand:V_VLSF 2 "register_operand")) |
| 125 |
(match_operand:V_VLSF 3 "register_operand")))] |
| 126 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 127 |
"#" |
| 128 |
"&& 1" |
| 129 |
[(const_int 0)] |
| 130 |
{ |
| 131 |
insn_code icode = code_for_pred (<CODE>, <MODE>mode); |
| 132 |
riscv_vector::expand_cond_unop (icode, operands); |
| 133 |
DONE; |
| 134 |
} |
| 135 |
[(set_attr "type" "vector")]) |
| 136 |
|
| 137 |
;; Combine sign_extend/zero_extend(vf2) and vcond_mask |
| 138 |
(define_insn_and_split "*cond_<optab><v_double_trunc><mode>" |
| 139 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 140 |
(if_then_else:VWEXTI |
| 141 |
(match_operand:<VM> 1 "register_operand") |
| 142 |
(any_extend:VWEXTI (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 143 |
(match_operand:VWEXTI 3 "register_operand")))] |
| 144 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 145 |
"#" |
| 146 |
"&& 1" |
| 147 |
[(const_int 0)] |
| 148 |
{ |
| 149 |
insn_code icode = code_for_pred_vf2 (<CODE>, <MODE>mode); |
| 150 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 151 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 152 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 153 |
DONE; |
| 154 |
} |
| 155 |
[(set_attr "type" "vector")]) |
| 156 |
|
| 157 |
;; Combine sign_extend/zero_extend(vf4) and vcond_mask |
| 158 |
(define_insn_and_split "*cond_<optab><v_quad_trunc><mode>" |
| 159 |
[(set (match_operand:VQEXTI 0 "register_operand") |
| 160 |
(if_then_else:VQEXTI |
| 161 |
(match_operand:<VM> 1 "register_operand") |
| 162 |
(any_extend:VQEXTI (match_operand:<V_QUAD_TRUNC> 2 "register_operand")) |
| 163 |
(match_operand:VQEXTI 3 "register_operand")))] |
| 164 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 165 |
"#" |
| 166 |
"&& 1" |
| 167 |
[(const_int 0)] |
| 168 |
{ |
| 169 |
insn_code icode = code_for_pred_vf4 (<CODE>, <MODE>mode); |
| 170 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 171 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 172 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 173 |
DONE; |
| 174 |
} |
| 175 |
[(set_attr "type" "vector")]) |
| 176 |
|
| 177 |
;; Combine sign_extend/zero_extend(vf8) and vcond_mask |
| 178 |
(define_insn_and_split "*cond_<optab><v_oct_trunc><mode>" |
| 179 |
[(set (match_operand:VOEXTI 0 "register_operand") |
| 180 |
(if_then_else:VOEXTI |
| 181 |
(match_operand:<VM> 1 "register_operand") |
| 182 |
(any_extend:VOEXTI (match_operand:<V_OCT_TRUNC> 2 "register_operand")) |
| 183 |
(match_operand:VOEXTI 3 "register_operand")))] |
| 184 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 185 |
"#" |
| 186 |
"&& 1" |
| 187 |
[(const_int 0)] |
| 188 |
{ |
| 189 |
insn_code icode = code_for_pred_vf8 (<CODE>, <MODE>mode); |
| 190 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 191 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 192 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 193 |
DONE; |
| 194 |
} |
| 195 |
[(set_attr "type" "vector")]) |
| 196 |
|
| 197 |
;; Combine sign_extend/zero_extend(vf2) and vcond_mask_len |
| 198 |
(define_insn_and_split "*cond_len_<optab><v_double_trunc><mode>" |
| 199 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 200 |
(if_then_else:VWEXTI |
| 201 |
(unspec:<VM> |
| 202 |
[(match_operand 4 "vector_length_operand") |
| 203 |
(match_operand 5 "const_int_operand") |
| 204 |
(match_operand 6 "const_int_operand") |
| 205 |
(reg:SI VL_REGNUM) |
| 206 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) |
| 207 |
(vec_merge:VWEXTI |
| 208 |
(any_extend:VWEXTI (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 209 |
(match_operand:VWEXTI 1 "vector_merge_operand") |
| 210 |
(match_operand:<VM> 3 "register_operand")) |
| 211 |
(match_dup 1)))] |
| 212 |
"TARGET_VECTOR" |
| 213 |
"#" |
| 214 |
"&& 1" |
| 215 |
[(const_int 0)] |
| 216 |
{ |
| 217 |
emit_insn (gen_pred_<optab><mode>_vf2 (operands[0], operands[3], operands[1], operands[2], |
| 218 |
operands[4], operands[5], operands[6], CONST0_RTX (Pmode))); |
| 219 |
DONE; |
| 220 |
} |
| 221 |
[(set_attr "type" "vector")]) |
| 222 |
|
| 223 |
;; Combine sign_extend/zero_extend(vf4) and vcond_mask_len |
| 224 |
(define_insn_and_split "*cond_len_<optab><v_quad_trunc><mode>" |
| 225 |
[(set (match_operand:VQEXTI 0 "register_operand") |
| 226 |
(if_then_else:VQEXTI |
| 227 |
(unspec:<VM> |
| 228 |
[(match_operand 4 "vector_length_operand") |
| 229 |
(match_operand 5 "const_int_operand") |
| 230 |
(match_operand 6 "const_int_operand") |
| 231 |
(reg:SI VL_REGNUM) |
| 232 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) |
| 233 |
(vec_merge:VQEXTI |
| 234 |
(any_extend:VQEXTI (match_operand:<V_QUAD_TRUNC> 2 "register_operand")) |
| 235 |
(match_operand:VQEXTI 1 "vector_merge_operand") |
| 236 |
(match_operand:<VM> 3 "register_operand")) |
| 237 |
(match_dup 1)))] |
| 238 |
"TARGET_VECTOR" |
| 239 |
"#" |
| 240 |
"&& 1" |
| 241 |
[(const_int 0)] |
| 242 |
{ |
| 243 |
emit_insn (gen_pred_<optab><mode>_vf4 (operands[0], operands[3], operands[1], operands[2], |
| 244 |
operands[4], operands[5], operands[6], CONST0_RTX (Pmode))); |
| 245 |
DONE; |
| 246 |
} |
| 247 |
[(set_attr "type" "vector")]) |
| 248 |
|
| 249 |
;; Combine sign_extend/zero_extend(vf8) and vcond_mask_len |
| 250 |
(define_insn_and_split "*cond_len_<optab><v_oct_trunc><mode>" |
| 251 |
[(set (match_operand:VOEXTI 0 "register_operand") |
| 252 |
(if_then_else:VOEXTI |
| 253 |
(unspec:<VM> |
| 254 |
[(match_operand 4 "vector_length_operand") |
| 255 |
(match_operand 5 "const_int_operand") |
| 256 |
(match_operand 6 "const_int_operand") |
| 257 |
(reg:SI VL_REGNUM) |
| 258 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) |
| 259 |
(vec_merge:VOEXTI |
| 260 |
(any_extend:VOEXTI (match_operand:<V_OCT_TRUNC> 2 "register_operand")) |
| 261 |
(match_operand:VOEXTI 1 "vector_merge_operand") |
| 262 |
(match_operand:<VM> 3 "register_operand")) |
| 263 |
(match_dup 1)))] |
| 264 |
"TARGET_VECTOR" |
| 265 |
"#" |
| 266 |
"&& 1" |
| 267 |
[(const_int 0)] |
| 268 |
{ |
| 269 |
emit_insn (gen_pred_<optab><mode>_vf8 (operands[0], operands[3], operands[1], operands[2], |
| 270 |
operands[4], operands[5], operands[6], CONST0_RTX (Pmode))); |
| 271 |
DONE; |
| 272 |
} |
| 273 |
[(set_attr "type" "vector")]) |
| 274 |
|
| 275 |
;; Combine trunc(vf2) + vcond_mask |
| 276 |
(define_insn_and_split "*cond_trunc<mode><v_double_trunc>" |
| 277 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand") |
| 278 |
(if_then_else:<V_DOUBLE_TRUNC> |
| 279 |
(match_operand:<VM> 1 "register_operand") |
| 280 |
(truncate:<V_DOUBLE_TRUNC> |
| 281 |
(match_operand:VWEXTI 2 "register_operand")) |
| 282 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand")))] |
| 283 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 284 |
"#" |
| 285 |
"&& 1" |
| 286 |
[(const_int 0)] |
| 287 |
{ |
| 288 |
insn_code icode = code_for_pred_trunc (<MODE>mode); |
| 289 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 290 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 291 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 292 |
DONE; |
| 293 |
} |
| 294 |
[(set_attr "type" "vector")]) |
| 295 |
|
| 296 |
;; Combine FP extend(vf2) and vcond_mask |
| 297 |
(define_insn_and_split "*cond_extend<v_double_trunc><mode>" |
| 298 |
[(set (match_operand:VWEXTF_ZVFHMIN 0 "register_operand") |
| 299 |
(if_then_else:VWEXTF_ZVFHMIN |
| 300 |
(match_operand:<VM> 1 "register_operand") |
| 301 |
(float_extend:VWEXTF_ZVFHMIN (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 302 |
(match_operand:VWEXTF_ZVFHMIN 3 "register_operand")))] |
| 303 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 304 |
"#" |
| 305 |
"&& 1" |
| 306 |
[(const_int 0)] |
| 307 |
{ |
| 308 |
insn_code icode = code_for_pred_extend (<MODE>mode); |
| 309 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 310 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 311 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 312 |
DONE; |
| 313 |
} |
| 314 |
[(set_attr "type" "vector")]) |
| 315 |
|
| 316 |
;; Combine FP extend(vf2) and vcond_mask_len |
| 317 |
(define_insn_and_split "*cond_len_extend<v_double_trunc><mode>" |
| 318 |
[(set (match_operand:VWEXTF_ZVFHMIN 0 "register_operand") |
| 319 |
(if_then_else:VWEXTF_ZVFHMIN |
| 320 |
(unspec:<VM> |
| 321 |
[(match_operand 4 "vector_length_operand") |
| 322 |
(match_operand 5 "const_int_operand") |
| 323 |
(match_operand 6 "const_int_operand") |
| 324 |
(reg:SI VL_REGNUM) |
| 325 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE) |
| 326 |
(vec_merge:VWEXTF_ZVFHMIN |
| 327 |
(float_extend:VWEXTF_ZVFHMIN (match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 328 |
(match_operand:VWEXTF_ZVFHMIN 1 "vector_merge_operand") |
| 329 |
(match_operand:<VM> 3 "register_operand")) |
| 330 |
(match_dup 1)))] |
| 331 |
"TARGET_VECTOR" |
| 332 |
"#" |
| 333 |
"&& 1" |
| 334 |
[(const_int 0)] |
| 335 |
{ |
| 336 |
emit_insn (gen_pred_extend<mode> (operands[0], operands[3], operands[1], operands[2], |
| 337 |
operands[4], operands[5], operands[6], CONST0_RTX (Pmode))); |
| 338 |
DONE; |
| 339 |
} |
| 340 |
[(set_attr "type" "vector")]) |
| 341 |
|
| 342 |
;; Combine FP trunc(vf2) + vcond_mask |
| 343 |
(define_insn_and_split "*cond_trunc<mode><v_double_trunc>" |
| 344 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand") |
| 345 |
(if_then_else:<V_DOUBLE_TRUNC> |
| 346 |
(match_operand:<VM> 1 "register_operand") |
| 347 |
(float_truncate:<V_DOUBLE_TRUNC> |
| 348 |
(match_operand:VWEXTF_ZVFHMIN 2 "register_operand")) |
| 349 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand")))] |
| 350 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 351 |
"#" |
| 352 |
"&& 1" |
| 353 |
[(const_int 0)] |
| 354 |
{ |
| 355 |
insn_code icode = code_for_pred_trunc (<MODE>mode); |
| 356 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 357 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 358 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 359 |
DONE; |
| 360 |
} |
| 361 |
[(set_attr "type" "vector")]) |
| 362 |
|
| 363 |
;; Combine convert(FP->INT) + vcond_mask |
| 364 |
(define_insn_and_split "*cond_<optab><mode><vconvert>" |
| 365 |
[(set (match_operand:<VCONVERT> 0 "register_operand") |
| 366 |
(if_then_else:<VCONVERT> |
| 367 |
(match_operand:<VM> 1 "register_operand") |
| 368 |
(any_fix:<VCONVERT> |
| 369 |
(match_operand:V_VLSF 2 "register_operand")) |
| 370 |
(match_operand:<VCONVERT> 3 "register_operand")))] |
| 371 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 372 |
"#" |
| 373 |
"&& 1" |
| 374 |
[(const_int 0)] |
| 375 |
{ |
| 376 |
insn_code icode = code_for_pred (<CODE>, <MODE>mode); |
| 377 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 378 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 379 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 380 |
DONE; |
| 381 |
} |
| 382 |
[(set_attr "type" "vector")]) |
| 383 |
|
| 384 |
;; Combine convert(INT->FP) + vcond_mask |
| 385 |
(define_insn_and_split "*cond_<float_cvt><vconvert><mode>" |
| 386 |
[(set (match_operand:V_VLSF 0 "register_operand") |
| 387 |
(if_then_else:V_VLSF |
| 388 |
(match_operand:<VM> 1 "register_operand") |
| 389 |
(any_float:V_VLSF |
| 390 |
(match_operand:<VCONVERT> 2 "register_operand")) |
| 391 |
(match_operand:V_VLSF 3 "register_operand")))] |
| 392 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 393 |
"#" |
| 394 |
"&& 1" |
| 395 |
[(const_int 0)] |
| 396 |
{ |
| 397 |
insn_code icode = code_for_pred (<CODE>, <MODE>mode); |
| 398 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 399 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 400 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 401 |
DONE; |
| 402 |
} |
| 403 |
[(set_attr "type" "vector")]) |
| 404 |
|
| 405 |
;; Combine convert(FP->2xINT) + vcond_mask |
| 406 |
(define_insn_and_split "*cond_<optab><vnconvert><mode>" |
| 407 |
[(set (match_operand:VWCONVERTI 0 "register_operand") |
| 408 |
(if_then_else:VWCONVERTI |
| 409 |
(match_operand:<VM> 1 "register_operand") |
| 410 |
(any_fix:VWCONVERTI |
| 411 |
(match_operand:<VNCONVERT> 2 "register_operand")) |
| 412 |
(match_operand:VWCONVERTI 3 "register_operand")))] |
| 413 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 414 |
"#" |
| 415 |
"&& 1" |
| 416 |
[(const_int 0)] |
| 417 |
{ |
| 418 |
insn_code icode = code_for_pred_widen (<CODE>, <MODE>mode); |
| 419 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 420 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 421 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 422 |
DONE; |
| 423 |
} |
| 424 |
[(set_attr "type" "vector")]) |
| 425 |
|
| 426 |
;; Combine convert(INT->2xFP) + vcond_mask |
| 427 |
(define_insn_and_split "*cond_<float_cvt><vnconvert><mode>" |
| 428 |
[(set (match_operand:V_VLSF 0 "register_operand") |
| 429 |
(if_then_else:V_VLSF |
| 430 |
(match_operand:<VM> 1 "register_operand") |
| 431 |
(any_float:V_VLSF |
| 432 |
(match_operand:<VNCONVERT> 2 "register_operand")) |
| 433 |
(match_operand:V_VLSF 3 "register_operand")))] |
| 434 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 435 |
"#" |
| 436 |
"&& 1" |
| 437 |
[(const_int 0)] |
| 438 |
{ |
| 439 |
insn_code icode = code_for_pred_widen (<CODE>, <MODE>mode); |
| 440 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 441 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 442 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 443 |
DONE; |
| 444 |
} |
| 445 |
[(set_attr "type" "vector")]) |
| 446 |
|
| 447 |
;; Combine convert(2xFP->INT) + vcond_mask |
| 448 |
(define_insn_and_split "*cond_<optab><mode><vnconvert>" |
| 449 |
[(set (match_operand:<VNCONVERT> 0 "register_operand") |
| 450 |
(if_then_else:<VNCONVERT> |
| 451 |
(match_operand:<VM> 1 "register_operand") |
| 452 |
(any_fix:<VNCONVERT> |
| 453 |
(match_operand:V_VLSF 2 "register_operand")) |
| 454 |
(match_operand:<VNCONVERT> 3 "register_operand")))] |
| 455 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 456 |
"#" |
| 457 |
"&& 1" |
| 458 |
[(const_int 0)] |
| 459 |
{ |
| 460 |
insn_code icode = code_for_pred_narrow (<CODE>, <MODE>mode); |
| 461 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 462 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 463 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 464 |
DONE; |
| 465 |
} |
| 466 |
[(set_attr "type" "vector")]) |
| 467 |
|
| 468 |
;; Combine convert(2xINT->FP) + vcond_mask |
| 469 |
(define_insn_and_split "*cond_<float_cvt><mode><vnconvert>2" |
| 470 |
[(set (match_operand:<VNCONVERT> 0 "register_operand") |
| 471 |
(if_then_else:<VNCONVERT> |
| 472 |
(match_operand:<VM> 1 "register_operand") |
| 473 |
(any_float:<VNCONVERT> |
| 474 |
(match_operand:VWCONVERTI 2 "register_operand")) |
| 475 |
(match_operand:<VNCONVERT> 3 "register_operand")))] |
| 476 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 477 |
"#" |
| 478 |
"&& 1" |
| 479 |
[(const_int 0)] |
| 480 |
{ |
| 481 |
insn_code icode = code_for_pred_narrow (<CODE>, <MODE>mode); |
| 482 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], |
| 483 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 484 |
riscv_vector::expand_cond_len_unop (icode, ops); |
| 485 |
DONE; |
| 486 |
} |
| 487 |
[(set_attr "type" "vector")]) |
| 488 |
|
| 489 |
;; Combine vnsra + vcond_mask |
| 490 |
(define_insn_and_split "*cond_v<any_shiftrt:optab><any_extend:optab>trunc<mode>" |
| 491 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand") |
| 492 |
(if_then_else:<V_DOUBLE_TRUNC> |
| 493 |
(match_operand:<VM> 1 "register_operand") |
| 494 |
(truncate:<V_DOUBLE_TRUNC> |
| 495 |
(any_shiftrt:VWEXTI |
| 496 |
(match_operand:VWEXTI 2 "register_operand") |
| 497 |
(any_extend:VWEXTI |
| 498 |
(match_operand:<V_DOUBLE_TRUNC> 3 "vector_shift_operand")))) |
| 499 |
(match_operand:<V_DOUBLE_TRUNC> 4 "register_operand")))] |
| 500 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 501 |
"#" |
| 502 |
"&& 1" |
| 503 |
[(const_int 0)] |
| 504 |
{ |
| 505 |
insn_code icode = code_for_pred_narrow (<any_shiftrt:CODE>, <MODE>mode); |
| 506 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], operands[4], |
| 507 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 508 |
riscv_vector::expand_cond_len_binop (icode, ops); |
| 509 |
DONE; |
| 510 |
} |
| 511 |
[(set_attr "type" "vnshift")]) |
| 512 |
|
| 513 |
(define_insn_and_split "*cond_<any_shiftrt:optab>trunc<mode>" |
| 514 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand") |
| 515 |
(if_then_else:<V_DOUBLE_TRUNC> |
| 516 |
(match_operand:<VM> 1 "register_operand") |
| 517 |
(truncate:<V_DOUBLE_TRUNC> |
| 518 |
(any_shiftrt:VWEXTI |
| 519 |
(match_operand:VWEXTI 2 "register_operand") |
| 520 |
(match_operand:<VEL> 3 "csr_operand"))) |
| 521 |
(match_operand:<V_DOUBLE_TRUNC> 4 "register_operand")))] |
| 522 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 523 |
"#" |
| 524 |
"&& 1" |
| 525 |
[(const_int 0)] |
| 526 |
{ |
| 527 |
insn_code icode = code_for_pred_narrow_scalar (<any_shiftrt:CODE>, <MODE>mode); |
| 528 |
rtx ops[] = {operands[0], operands[1], operands[2], gen_lowpart (Pmode, operands[3]), |
| 529 |
operands[4], gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 530 |
riscv_vector::expand_cond_len_binop (icode, ops); |
| 531 |
DONE; |
| 532 |
} |
| 533 |
[(set_attr "type" "vnshift")]) |
| 534 |
|
| 535 |
;; Combine vmulh.vv/vmulhu.vv + vcond_mask |
| 536 |
(define_insn_and_split "*cond_<mulh_table><mode>3_highpart" |
| 537 |
[(set (match_operand:VFULLI 0 "register_operand") |
| 538 |
(if_then_else:VFULLI |
| 539 |
(match_operand:<VM> 1 "register_operand") |
| 540 |
(mulh:VFULLI |
| 541 |
(match_operand:VFULLI 2 "register_operand") |
| 542 |
(match_operand:VFULLI 3 "register_operand")) |
| 543 |
(match_operand:VFULLI 4 "register_operand")))] |
| 544 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 545 |
"#" |
| 546 |
"&& 1" |
| 547 |
[(const_int 0)] |
| 548 |
{ |
| 549 |
insn_code icode = code_for_pred_mulh (<MULH_UNSPEC>, <MODE>mode); |
| 550 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3], operands[4], |
| 551 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 552 |
riscv_vector::expand_cond_len_binop (icode, ops); |
| 553 |
DONE; |
| 554 |
} |
| 555 |
[(set_attr "type" "vector")]) |
| 556 |
|
| 557 |
;; ============================================================================= |
| 558 |
;; Combine binop + trunc to narrow_binop |
| 559 |
;; ============================================================================= |
| 560 |
|
| 561 |
;; Combine vsr[la].vv + trunc to vnsr[la].wv |
| 562 |
(define_insn_and_split "*narrow_<any_shiftrt:optab><any_extend:optab><mode>" |
| 563 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vr,vr") |
| 564 |
(truncate:<V_DOUBLE_TRUNC> |
| 565 |
(any_shiftrt:VWEXTI |
| 566 |
(match_operand:VWEXTI 1 "register_operand" " vr,vr") |
| 567 |
(any_extend:VWEXTI |
| 568 |
(match_operand:<V_DOUBLE_TRUNC> 2 "vector_shift_operand" " vr,vk")))))] |
| 569 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 570 |
"#" |
| 571 |
"&& 1" |
| 572 |
[(const_int 0)] |
| 573 |
{ |
| 574 |
insn_code icode = code_for_pred_narrow (<any_shiftrt:CODE>, <MODE>mode); |
| 575 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 576 |
DONE; |
| 577 |
} |
| 578 |
[(set_attr "type" "vnshift")]) |
| 579 |
|
| 580 |
;; Combine vsr[la].w[xi] + trunc to vnsr[la].w[xi] |
| 581 |
(define_insn_and_split "*narrow_<any_shiftrt:optab><mode>_scalar" |
| 582 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vr") |
| 583 |
(truncate:<V_DOUBLE_TRUNC> |
| 584 |
(any_shiftrt:VWEXTI |
| 585 |
(match_operand:VWEXTI 1 "register_operand" " vr") |
| 586 |
(match_operand:<VEL> 2 "csr_operand" " rK"))))] |
| 587 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 588 |
"#" |
| 589 |
"&& 1" |
| 590 |
[(const_int 0)] |
| 591 |
{ |
| 592 |
operands[2] = gen_lowpart (Pmode, operands[2]); |
| 593 |
insn_code icode = code_for_pred_narrow_scalar (<any_shiftrt:CODE>, <MODE>mode); |
| 594 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 595 |
DONE; |
| 596 |
} |
| 597 |
[(set_attr "type" "vnshift")]) |
| 598 |
|
| 599 |
;; ============================================================================= |
| 600 |
;; Combine extend + binop to widen_binop |
| 601 |
;; ============================================================================= |
| 602 |
|
| 603 |
(define_insn_and_split "*dual_widen_<any_widen_binop:optab><any_extend:su><mode>" |
| 604 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 605 |
(any_widen_binop:VWEXTI |
| 606 |
(any_extend:VWEXTI |
| 607 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand")) |
| 608 |
(any_extend:VWEXTI |
| 609 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))))] |
| 610 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 611 |
"#" |
| 612 |
"&& 1" |
| 613 |
[(const_int 0)] |
| 614 |
{ |
| 615 |
insn_code icode = code_for_pred_dual_widen (<any_widen_binop:CODE>, |
| 616 |
<any_extend:CODE>, |
| 617 |
<MODE>mode); |
| 618 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 619 |
DONE; |
| 620 |
} |
| 621 |
[(set_attr "type" "vector")]) |
| 622 |
|
| 623 |
(define_insn_and_split "*single_widen_sub<any_extend:su><mode>" |
| 624 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 625 |
(minus:VWEXTI |
| 626 |
(match_operand:VWEXTI 1 "register_operand") |
| 627 |
(any_extend:VWEXTI |
| 628 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))))] |
| 629 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 630 |
"#" |
| 631 |
"&& 1" |
| 632 |
[(const_int 0)] |
| 633 |
{ |
| 634 |
insn_code icode = code_for_pred_single_widen_sub (<any_extend:CODE>, |
| 635 |
<MODE>mode); |
| 636 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 637 |
DONE; |
| 638 |
} |
| 639 |
[(set_attr "type" "viwalu")]) |
| 640 |
|
| 641 |
; This is a bridge pattern for combine. Although we do not have a |
| 642 |
; pattern that extends just the first operand it helps combine bridge |
| 643 |
; the gap to the pred_dual_widen insns. |
| 644 |
; If combination fails it will just expand two a separate extend and |
| 645 |
; a binop again. |
| 646 |
(define_insn_and_split "*single_widen_first_sub<any_extend:su><mode>" |
| 647 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 648 |
(minus:VWEXTI |
| 649 |
(any_extend:VWEXTI |
| 650 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand")) |
| 651 |
(match_operand:VWEXTI 2 "register_operand")))] |
| 652 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 653 |
"#" |
| 654 |
"&& 1" |
| 655 |
[(const_int 0)] |
| 656 |
{ |
| 657 |
insn_code extend_icode = code_for_pred_vf2 (<any_extend:CODE>, <MODE>mode); |
| 658 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 659 |
rtx extend_ops[] = {tmp, operands[1]}; |
| 660 |
riscv_vector::emit_vlmax_insn (extend_icode, riscv_vector::UNARY_OP, extend_ops); |
| 661 |
|
| 662 |
rtx ops[] = {operands[0], tmp, operands[2]}; |
| 663 |
insn_code icode = code_for_pred (MINUS, <MODE>mode); |
| 664 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, ops); |
| 665 |
DONE; |
| 666 |
} |
| 667 |
[(set_attr "type" "vector")]) |
| 668 |
|
| 669 |
(define_insn_and_split "*single_widen_add<any_extend:su><mode>" |
| 670 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 671 |
(plus:VWEXTI |
| 672 |
(any_extend:VWEXTI |
| 673 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 674 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 675 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 676 |
"#" |
| 677 |
"&& 1" |
| 678 |
[(const_int 0)] |
| 679 |
{ |
| 680 |
insn_code icode = code_for_pred_single_widen_add (<any_extend:CODE>, |
| 681 |
<MODE>mode); |
| 682 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 683 |
DONE; |
| 684 |
} |
| 685 |
[(set_attr "type" "viwalu")]) |
| 686 |
|
| 687 |
;; This combine pattern does not correspond to an single instruction, |
| 688 |
;; i.e. there is no vwmul.wv instruction. This is a temporary pattern |
| 689 |
;; produced by a combine pass and if there is no further combine into |
| 690 |
;; vwmul.vv pattern, then fall back to extend pattern and vmul.vv pattern. |
| 691 |
(define_insn_and_split "*single_widen_mul<any_extend:su><mode>" |
| 692 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 693 |
(mult:VWEXTI |
| 694 |
(any_extend:VWEXTI |
| 695 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 696 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 697 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 698 |
"#" |
| 699 |
"&& 1" |
| 700 |
[(const_int 0)] |
| 701 |
{ |
| 702 |
insn_code extend_icode = code_for_pred_vf2 (<any_extend:CODE>, <MODE>mode); |
| 703 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 704 |
rtx extend_ops[] = {tmp, operands[2]}; |
| 705 |
riscv_vector::emit_vlmax_insn (extend_icode, riscv_vector::UNARY_OP, |
| 706 |
extend_ops); |
| 707 |
|
| 708 |
rtx ops[] = {operands[0], operands[1], tmp}; |
| 709 |
insn_code icode = code_for_pred (MULT, <MODE>mode); |
| 710 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, ops); |
| 711 |
DONE; |
| 712 |
} |
| 713 |
[(set_attr "type" "viwmul")]) |
| 714 |
|
| 715 |
(define_insn_and_split "*dual_widen_mulsu<mode>" |
| 716 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 717 |
(mult:VWEXTI |
| 718 |
(sign_extend:VWEXTI |
| 719 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand")) |
| 720 |
(zero_extend:VWEXTI |
| 721 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))))] |
| 722 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 723 |
"#" |
| 724 |
"&& 1" |
| 725 |
[(const_int 0)] |
| 726 |
{ |
| 727 |
insn_code icode = code_for_pred_widen_mulsu (<MODE>mode); |
| 728 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 729 |
DONE; |
| 730 |
} |
| 731 |
[(set_attr "type" "vector")]) |
| 732 |
|
| 733 |
(define_insn_and_split "*dual_widen_mulus<mode>" |
| 734 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 735 |
(mult:VWEXTI |
| 736 |
(zero_extend:VWEXTI |
| 737 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 738 |
(sign_extend:VWEXTI |
| 739 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand"))))] |
| 740 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 741 |
"#" |
| 742 |
"&& 1" |
| 743 |
[(const_int 0)] |
| 744 |
{ |
| 745 |
insn_code icode = code_for_pred_widen_mulsu (<MODE>mode); |
| 746 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 747 |
DONE; |
| 748 |
} |
| 749 |
[(set_attr "type" "vector")]) |
| 750 |
|
| 751 |
(define_insn_and_split "*dual_widen_<optab><mode>" |
| 752 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 753 |
(any_widen_binop:VWEXTF |
| 754 |
(float_extend:VWEXTF |
| 755 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand")) |
| 756 |
(float_extend:VWEXTF |
| 757 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))))] |
| 758 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 759 |
"#" |
| 760 |
"&& 1" |
| 761 |
[(const_int 0)] |
| 762 |
{ |
| 763 |
insn_code icode = code_for_pred_dual_widen (<CODE>, <MODE>mode); |
| 764 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP_FRM_DYN, operands); |
| 765 |
DONE; |
| 766 |
} |
| 767 |
[(set_attr "type" "vector")]) |
| 768 |
|
| 769 |
(define_insn_and_split "*single_widen_add<mode>" |
| 770 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 771 |
(plus:VWEXTF |
| 772 |
(float_extend:VWEXTF |
| 773 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 774 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 775 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 776 |
"#" |
| 777 |
"&& 1" |
| 778 |
[(const_int 0)] |
| 779 |
{ |
| 780 |
insn_code icode = code_for_pred_single_widen_add (<MODE>mode); |
| 781 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP_FRM_DYN, operands); |
| 782 |
DONE; |
| 783 |
} |
| 784 |
[(set_attr "type" "vfwalu")]) |
| 785 |
|
| 786 |
(define_insn_and_split "*single_widen_sub<mode>" |
| 787 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 788 |
(minus:VWEXTF |
| 789 |
(match_operand:VWEXTF 1 "register_operand") |
| 790 |
(float_extend:VWEXTF |
| 791 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))))] |
| 792 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 793 |
"#" |
| 794 |
"&& 1" |
| 795 |
[(const_int 0)] |
| 796 |
{ |
| 797 |
insn_code icode = code_for_pred_single_widen_sub (<MODE>mode); |
| 798 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP_FRM_DYN, operands); |
| 799 |
DONE; |
| 800 |
} |
| 801 |
[(set_attr "type" "vfwalu")]) |
| 802 |
|
| 803 |
; This is a bridge pattern for combine (see above). |
| 804 |
(define_insn_and_split "*single_widen_first_sub<mode>" |
| 805 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 806 |
(minus:VWEXTF |
| 807 |
(float_extend:VWEXTF |
| 808 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand")) |
| 809 |
(match_operand:VWEXTF 2 "register_operand")))] |
| 810 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 811 |
"#" |
| 812 |
"&& 1" |
| 813 |
[(const_int 0)] |
| 814 |
{ |
| 815 |
insn_code extend_icode = code_for_pred_extend (<MODE>mode); |
| 816 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 817 |
rtx extend_ops[] = {tmp, operands[1]}; |
| 818 |
riscv_vector::emit_vlmax_insn (extend_icode, riscv_vector::UNARY_OP, |
| 819 |
extend_ops); |
| 820 |
|
| 821 |
rtx ops[] = {operands[0], tmp, operands[2]}; |
| 822 |
insn_code icode = code_for_pred (MINUS, <MODE>mode); |
| 823 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP_FRM_DYN, ops); |
| 824 |
DONE; |
| 825 |
} |
| 826 |
[(set_attr "type" "vector")]) |
| 827 |
|
| 828 |
;; This combine pattern does not correspond to an single instruction, |
| 829 |
;; i.e. there is no vfwmul.wv instruction. This is a temporary pattern |
| 830 |
;; produced by a combine pass and if there is no further combine into |
| 831 |
;; vfwmul.vv pattern, then fall back to extend pattern and vfmul.vv pattern. |
| 832 |
(define_insn_and_split "*single_widen_mul<mode>" |
| 833 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 834 |
(mult:VWEXTF |
| 835 |
(float_extend:VWEXTF |
| 836 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 837 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 838 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 839 |
"#" |
| 840 |
"&& 1" |
| 841 |
[(const_int 0)] |
| 842 |
{ |
| 843 |
insn_code extend_icode = code_for_pred_extend (<MODE>mode); |
| 844 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 845 |
rtx extend_ops[] = {tmp, operands[2]}; |
| 846 |
riscv_vector::emit_vlmax_insn (extend_icode, riscv_vector::UNARY_OP, extend_ops); |
| 847 |
|
| 848 |
rtx ops[] = {operands[0], operands[1], tmp}; |
| 849 |
riscv_vector::emit_vlmax_insn (code_for_pred (MULT, <MODE>mode), |
| 850 |
riscv_vector::BINARY_OP_FRM_DYN, ops); |
| 851 |
DONE; |
| 852 |
} |
| 853 |
[(set_attr "type" "vfwmul")]) |
| 854 |
|
| 855 |
;; Combine extend + vredsum to vwredsum[u] |
| 856 |
(define_insn_and_split "*widen_reduc_plus_scal_<mode>" |
| 857 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 858 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 859 |
(any_extend:<V_DOUBLE_EXTEND> |
| 860 |
(match_operand:VI_QHS_NO_M8 1 "register_operand")) |
| 861 |
] UNSPEC_REDUC_SUM))] |
| 862 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 863 |
"#" |
| 864 |
"&& 1" |
| 865 |
[(const_int 0)] |
| 866 |
{ |
| 867 |
riscv_vector::expand_reduction (<WREDUC_UNSPEC>, <WREDUC_UNSPEC_VL0_SAFE>, |
| 868 |
riscv_vector::REDUCE_OP, |
| 869 |
operands, |
| 870 |
CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 871 |
DONE; |
| 872 |
} |
| 873 |
[(set_attr "type" "vector")]) |
| 874 |
|
| 875 |
;; Combine extend + vfredusum to vfwredusum |
| 876 |
(define_insn_and_split "*widen_reduc_plus_scal_<mode>" |
| 877 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 878 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 879 |
(float_extend:<V_DOUBLE_EXTEND> |
| 880 |
(match_operand:VF_HS_NO_M8 1 "register_operand")) |
| 881 |
] UNSPEC_REDUC_SUM_UNORDERED))] |
| 882 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 883 |
"#" |
| 884 |
"&& 1" |
| 885 |
[(const_int 0)] |
| 886 |
{ |
| 887 |
riscv_vector::expand_reduction (UNSPEC_WREDUC_SUM_UNORDERED, |
| 888 |
UNSPEC_WREDUC_SUM_UNORDERED_VL0_SAFE, |
| 889 |
riscv_vector::REDUCE_OP_FRM_DYN, |
| 890 |
operands, |
| 891 |
CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 892 |
DONE; |
| 893 |
} |
| 894 |
[(set_attr "type" "vector")]) |
| 895 |
|
| 896 |
;; Combine extend + vfredosum to vfwredosum |
| 897 |
(define_insn_and_split "*fold_left_widen_plus_<mode>" |
| 898 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 899 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 900 |
(float_extend:<V_DOUBLE_EXTEND> |
| 901 |
(match_operand:VF_HS_NO_M8 1 "register_operand")) |
| 902 |
(match_operand:<V_DOUBLE_EXTEND_VEL> 2 "register_operand") |
| 903 |
] UNSPEC_REDUC_SUM_ORDERED))] |
| 904 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 905 |
"#" |
| 906 |
"&& 1" |
| 907 |
[(const_int 0)] |
| 908 |
{ |
| 909 |
riscv_vector::expand_reduction (UNSPEC_WREDUC_SUM_ORDERED, |
| 910 |
UNSPEC_WREDUC_SUM_ORDERED_VL0_SAFE, |
| 911 |
riscv_vector::REDUCE_OP_FRM_DYN, |
| 912 |
operands, operands[2]); |
| 913 |
DONE; |
| 914 |
} |
| 915 |
[(set_attr "type" "vector")]) |
| 916 |
|
| 917 |
;; Combine extend + mask vfredosum to mask vfwredosum |
| 918 |
(define_insn_and_split "*mask_len_fold_left_widen_plus_<mode>" |
| 919 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 920 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 921 |
(float_extend:<V_DOUBLE_EXTEND> |
| 922 |
(match_operand:VF_HS_NO_M8 2 "register_operand")) |
| 923 |
(match_operand:<V_DOUBLE_EXTEND_VEL> 1 "register_operand") |
| 924 |
(match_operand:<VM> 3 "vector_mask_operand") |
| 925 |
(match_operand 4 "autovec_length_operand") |
| 926 |
(match_operand 5 "const_0_operand") |
| 927 |
] UNSPEC_REDUC_SUM_ORDERED))] |
| 928 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 929 |
"#" |
| 930 |
"&& 1" |
| 931 |
[(const_int 0)] |
| 932 |
{ |
| 933 |
if (rtx_equal_p (operands[4], const0_rtx)) |
| 934 |
emit_move_insn (operands[0], operands[1]); |
| 935 |
else |
| 936 |
{ |
| 937 |
rtx ops[] = {operands[0], operands[2], operands[3], operands[4]}; |
| 938 |
riscv_vector::expand_reduction (UNSPEC_WREDUC_SUM_ORDERED, |
| 939 |
UNSPEC_WREDUC_SUM_ORDERED_VL0_SAFE, |
| 940 |
riscv_vector::REDUCE_OP_M_FRM_DYN, |
| 941 |
ops, operands[1]); |
| 942 |
} |
| 943 |
DONE; |
| 944 |
} |
| 945 |
[(set_attr "type" "vector")]) |
| 946 |
|
| 947 |
;; ============================================================================= |
| 948 |
;; Combine extend + ternop to widen_ternop |
| 949 |
;; ============================================================================= |
| 950 |
|
| 951 |
;; Combine ext + fma(vmacc,vmadd) to widen_fma (vwmacc[u]) |
| 952 |
(define_insn_and_split "*dual_widen_fma<su><mode>" |
| 953 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 954 |
(plus:VWEXTI |
| 955 |
(mult:VWEXTI |
| 956 |
(any_extend:VWEXTI |
| 957 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 958 |
(any_extend:VWEXTI |
| 959 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))) |
| 960 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 961 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 962 |
"#" |
| 963 |
"&& 1" |
| 964 |
[(const_int 0)] |
| 965 |
{ |
| 966 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 967 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul_plus (<CODE>, <MODE>mode), |
| 968 |
riscv_vector::WIDEN_TERNARY_OP, ops); |
| 969 |
DONE; |
| 970 |
} |
| 971 |
[(set_attr "type" "viwmuladd")]) |
| 972 |
|
| 973 |
;; Combine sign_extend + zero_extend + fma to widen_fma (vwmaccsu) |
| 974 |
(define_insn_and_split "*dual_widen_fmasu<mode>" |
| 975 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 976 |
(plus:VWEXTI |
| 977 |
(mult:VWEXTI |
| 978 |
(sign_extend:VWEXTI |
| 979 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 980 |
(zero_extend:VWEXTI |
| 981 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))) |
| 982 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 983 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 984 |
"#" |
| 985 |
"&& 1" |
| 986 |
[(const_int 0)] |
| 987 |
{ |
| 988 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 989 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul_plussu (<MODE>mode), |
| 990 |
riscv_vector::WIDEN_TERNARY_OP, ops); |
| 991 |
DONE; |
| 992 |
} |
| 993 |
[(set_attr "type" "viwmuladd")]) |
| 994 |
|
| 995 |
;; Combine zero_extend + sign_extend + fma to widen_fma (vwmaccsu) |
| 996 |
(define_insn_and_split "*dual_widen_fmaus<mode>" |
| 997 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 998 |
(plus:VWEXTI |
| 999 |
(mult:VWEXTI |
| 1000 |
(zero_extend:VWEXTI |
| 1001 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand")) |
| 1002 |
(sign_extend:VWEXTI |
| 1003 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))) |
| 1004 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 1005 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1006 |
"#" |
| 1007 |
"&& 1" |
| 1008 |
[(const_int 0)] |
| 1009 |
{ |
| 1010 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 1011 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul_plussu (<MODE>mode), |
| 1012 |
riscv_vector::WIDEN_TERNARY_OP, ops); |
| 1013 |
DONE; |
| 1014 |
} |
| 1015 |
[(set_attr "type" "viwmuladd")]) |
| 1016 |
|
| 1017 |
;; This combine pattern does not correspond to an single instruction. |
| 1018 |
;; This is a temporary pattern produced by a combine pass and if there |
| 1019 |
;; is no further combine into widen pattern, then fall back to extend |
| 1020 |
;; pattern and non-widen fma pattern. |
| 1021 |
(define_insn_and_split "*single_widen_fma<su><mode>" |
| 1022 |
[(set (match_operand:VWEXTI 0 "register_operand") |
| 1023 |
(plus:VWEXTI |
| 1024 |
(mult:VWEXTI |
| 1025 |
(any_extend:VWEXTI |
| 1026 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1027 |
(match_operand:VWEXTI 3 "register_operand")) |
| 1028 |
(match_operand:VWEXTI 1 "register_operand")))] |
| 1029 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1030 |
"#" |
| 1031 |
"&& 1" |
| 1032 |
[(const_int 0)] |
| 1033 |
{ |
| 1034 |
insn_code extend_icode = code_for_pred_vf2 (<CODE>, <MODE>mode); |
| 1035 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 1036 |
rtx extend_ops[] = {tmp, operands[2]}; |
| 1037 |
riscv_vector::emit_vlmax_insn (extend_icode, riscv_vector::UNARY_OP, |
| 1038 |
extend_ops); |
| 1039 |
|
| 1040 |
rtx ops[] = {operands[0], tmp, operands[3], operands[1], |
| 1041 |
RVV_VUNDEF(<MODE>mode)}; |
| 1042 |
riscv_vector::emit_vlmax_insn (code_for_pred_mul_plus (<MODE>mode), |
| 1043 |
riscv_vector::TERNARY_OP, ops); |
| 1044 |
DONE; |
| 1045 |
} |
| 1046 |
[(set_attr "type" "viwmuladd")]) |
| 1047 |
|
| 1048 |
;; Combine extend + fma to widen_fma (vfwmacc) |
| 1049 |
(define_insn_and_split "*dual_widen_fma<mode>" |
| 1050 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1051 |
(plus:VWEXTF |
| 1052 |
(mult:VWEXTF |
| 1053 |
(float_extend:VWEXTF |
| 1054 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1055 |
(float_extend:VWEXTF |
| 1056 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))) |
| 1057 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1058 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1059 |
"#" |
| 1060 |
"&& 1" |
| 1061 |
[(const_int 0)] |
| 1062 |
{ |
| 1063 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 1064 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul (PLUS, <MODE>mode), |
| 1065 |
riscv_vector::WIDEN_TERNARY_OP_FRM_DYN, ops); |
| 1066 |
DONE; |
| 1067 |
} |
| 1068 |
[(set_attr "type" "vfwmuladd")]) |
| 1069 |
|
| 1070 |
;; This combine pattern does not correspond to an single instruction. |
| 1071 |
;; This is a temporary pattern produced by a combine pass and if there |
| 1072 |
;; is no further combine into widen pattern, then fall back to extend |
| 1073 |
;; pattern and non-widen fma pattern. |
| 1074 |
(define_insn_and_split "*single_widen_fma<mode>" |
| 1075 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1076 |
(plus:VWEXTF |
| 1077 |
(mult:VWEXTF |
| 1078 |
(float_extend:VWEXTF |
| 1079 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1080 |
(match_operand:VWEXTF 3 "register_operand")) |
| 1081 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1082 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1083 |
"#" |
| 1084 |
"&& 1" |
| 1085 |
[(const_int 0)] |
| 1086 |
{ |
| 1087 |
insn_code icode = code_for_pred_extend (<MODE>mode); |
| 1088 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 1089 |
rtx ext_ops[] = {tmp, operands[2]}; |
| 1090 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::UNARY_OP, ext_ops); |
| 1091 |
|
| 1092 |
rtx ops[] = {operands[0], tmp, operands[3], operands[1], |
| 1093 |
RVV_VUNDEF(<MODE>mode)}; |
| 1094 |
riscv_vector::emit_vlmax_insn (code_for_pred_mul (PLUS, <MODE>mode), |
| 1095 |
riscv_vector::TERNARY_OP_FRM_DYN, ops); |
| 1096 |
DONE; |
| 1097 |
} |
| 1098 |
[(set_attr "type" "vfwmuladd")]) |
| 1099 |
|
| 1100 |
;; Combine extend + fnma to widen_fnma (vfwnmsac) |
| 1101 |
(define_insn_and_split "*dual_widen_fnma<mode>" |
| 1102 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1103 |
(minus:VWEXTF |
| 1104 |
(match_operand:VWEXTF 1 "register_operand") |
| 1105 |
(mult:VWEXTF |
| 1106 |
(float_extend:VWEXTF |
| 1107 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1108 |
(float_extend:VWEXTF |
| 1109 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand")))))] |
| 1110 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1111 |
"#" |
| 1112 |
"&& 1" |
| 1113 |
[(const_int 0)] |
| 1114 |
{ |
| 1115 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 1116 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul_neg (PLUS, <MODE>mode), |
| 1117 |
riscv_vector::WIDEN_TERNARY_OP_FRM_DYN, ops); |
| 1118 |
DONE; |
| 1119 |
} |
| 1120 |
[(set_attr "type" "vfwmuladd")]) |
| 1121 |
|
| 1122 |
;; This combine pattern does not correspond to an single instruction. |
| 1123 |
;; This is a temporary pattern produced by a combine pass and if there |
| 1124 |
;; is no further combine into widen pattern, then fall back to extend |
| 1125 |
;; pattern and non-widen fnma pattern. |
| 1126 |
(define_insn_and_split "*single_widen_fnma<mode>" |
| 1127 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1128 |
(minus:VWEXTF |
| 1129 |
(match_operand:VWEXTF 1 "register_operand") |
| 1130 |
(mult:VWEXTF |
| 1131 |
(float_extend:VWEXTF |
| 1132 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1133 |
(match_operand:VWEXTF 3 "register_operand"))))] |
| 1134 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1135 |
"#" |
| 1136 |
"&& 1" |
| 1137 |
[(const_int 0)] |
| 1138 |
{ |
| 1139 |
insn_code icode = code_for_pred_extend (<MODE>mode); |
| 1140 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 1141 |
rtx ext_ops[] = {tmp, operands[2]}; |
| 1142 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::UNARY_OP, ext_ops); |
| 1143 |
|
| 1144 |
rtx ops[] = {operands[0], tmp, operands[3], operands[1], |
| 1145 |
RVV_VUNDEF(<MODE>mode)}; |
| 1146 |
riscv_vector::emit_vlmax_insn (code_for_pred_mul_neg (PLUS, <MODE>mode), |
| 1147 |
riscv_vector::TERNARY_OP_FRM_DYN, ops); |
| 1148 |
DONE; |
| 1149 |
} |
| 1150 |
[(set_attr "type" "vfwmuladd")]) |
| 1151 |
|
| 1152 |
;; Combine extend + fms to widen_fms (vfwmsac) |
| 1153 |
(define_insn_and_split "*dual_widen_fms<mode>" |
| 1154 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1155 |
(minus:VWEXTF |
| 1156 |
(mult:VWEXTF |
| 1157 |
(float_extend:VWEXTF |
| 1158 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1159 |
(float_extend:VWEXTF |
| 1160 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))) |
| 1161 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1162 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1163 |
"#" |
| 1164 |
"&& 1" |
| 1165 |
[(const_int 0)] |
| 1166 |
{ |
| 1167 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 1168 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul (MINUS, <MODE>mode), |
| 1169 |
riscv_vector::WIDEN_TERNARY_OP_FRM_DYN, ops); |
| 1170 |
DONE; |
| 1171 |
} |
| 1172 |
[(set_attr "type" "vfwmuladd")]) |
| 1173 |
|
| 1174 |
;; This combine pattern does not correspond to an single instruction. |
| 1175 |
;; This is a temporary pattern produced by a combine pass and if there |
| 1176 |
;; is no further combine into widen pattern, then fall back to extend |
| 1177 |
;; pattern and non-widen fms pattern. |
| 1178 |
(define_insn_and_split "*single_widen_fms<mode>" |
| 1179 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1180 |
(minus:VWEXTF |
| 1181 |
(mult:VWEXTF |
| 1182 |
(float_extend:VWEXTF |
| 1183 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand")) |
| 1184 |
(match_operand:VWEXTF 3 "register_operand")) |
| 1185 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1186 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1187 |
"#" |
| 1188 |
"&& 1" |
| 1189 |
[(const_int 0)] |
| 1190 |
{ |
| 1191 |
insn_code icode = code_for_pred_extend (<MODE>mode); |
| 1192 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 1193 |
rtx ext_ops[] = {tmp, operands[2]}; |
| 1194 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::UNARY_OP, ext_ops); |
| 1195 |
|
| 1196 |
rtx ops[] = {operands[0], tmp, operands[3], operands[1], |
| 1197 |
RVV_VUNDEF(<MODE>mode)}; |
| 1198 |
riscv_vector::emit_vlmax_insn (code_for_pred_mul (MINUS, <MODE>mode), |
| 1199 |
riscv_vector::TERNARY_OP_FRM_DYN, ops); |
| 1200 |
DONE; |
| 1201 |
} |
| 1202 |
[(set_attr "type" "vfwmuladd")]) |
| 1203 |
|
| 1204 |
;; Combine extend + fnms to widen_fnms (vfwnmacc) |
| 1205 |
(define_insn_and_split "*dual_widen_fnms<mode>" |
| 1206 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1207 |
(minus:VWEXTF |
| 1208 |
(mult:VWEXTF |
| 1209 |
(neg:VWEXTF |
| 1210 |
(float_extend:VWEXTF |
| 1211 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))) |
| 1212 |
(float_extend:VWEXTF |
| 1213 |
(match_operand:<V_DOUBLE_TRUNC> 3 "register_operand"))) |
| 1214 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1215 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1216 |
"#" |
| 1217 |
"&& 1" |
| 1218 |
[(const_int 0)] |
| 1219 |
{ |
| 1220 |
rtx ops[] = {operands[0], operands[1], operands[2], operands[3]}; |
| 1221 |
riscv_vector::emit_vlmax_insn (code_for_pred_widen_mul_neg (MINUS, <MODE>mode), |
| 1222 |
riscv_vector::WIDEN_TERNARY_OP_FRM_DYN, ops); |
| 1223 |
DONE; |
| 1224 |
} |
| 1225 |
[(set_attr "type" "vfwmuladd")]) |
| 1226 |
|
| 1227 |
;; This combine pattern does not correspond to an single instruction. |
| 1228 |
;; This is a temporary pattern produced by a combine pass and if there |
| 1229 |
;; is no further combine into widen pattern, then fall back to extend |
| 1230 |
;; pattern and non-widen fnms pattern. |
| 1231 |
(define_insn_and_split "*single_widen_fnms<mode>" |
| 1232 |
[(set (match_operand:VWEXTF 0 "register_operand") |
| 1233 |
(minus:VWEXTF |
| 1234 |
(mult:VWEXTF |
| 1235 |
(neg:VWEXTF |
| 1236 |
(match_operand:VWEXTF 3 "register_operand")) |
| 1237 |
(float_extend:VWEXTF |
| 1238 |
(match_operand:<V_DOUBLE_TRUNC> 2 "register_operand"))) |
| 1239 |
(match_operand:VWEXTF 1 "register_operand")))] |
| 1240 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1241 |
"#" |
| 1242 |
"&& 1" |
| 1243 |
[(const_int 0)] |
| 1244 |
{ |
| 1245 |
insn_code icode = code_for_pred_extend (<MODE>mode); |
| 1246 |
rtx tmp = gen_reg_rtx (<MODE>mode); |
| 1247 |
rtx ext_ops[] = {tmp, operands[2]}; |
| 1248 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::UNARY_OP, ext_ops); |
| 1249 |
|
| 1250 |
rtx ops[] = {operands[0], tmp, operands[3], operands[1], |
| 1251 |
RVV_VUNDEF(<MODE>mode)}; |
| 1252 |
riscv_vector::emit_vlmax_insn (code_for_pred_mul_neg (MINUS, <MODE>mode), |
| 1253 |
riscv_vector::TERNARY_OP_FRM_DYN, ops); |
| 1254 |
DONE; |
| 1255 |
} |
| 1256 |
[(set_attr "type" "vfwmuladd")]) |
| 1257 |
|
| 1258 |
;; Combine mask_extend + vredsum to mask_vwredsum[u] |
| 1259 |
;; where the mrege of mask_extend is vector const 0 |
| 1260 |
(define_insn_and_split "*cond_widen_reduc_plus_scal_<mode>" |
| 1261 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 1262 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 1263 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1264 |
(match_operand:<VM> 1 "register_operand") |
| 1265 |
(any_extend:<V_DOUBLE_EXTEND> |
| 1266 |
(match_operand:VI_QHS_NO_M8 2 "register_operand")) |
| 1267 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1268 |
(unspec:<VM> [ |
| 1269 |
(match_operand:<VM> 3 "vector_all_trues_mask_operand") |
| 1270 |
(match_operand 6 "vector_length_operand") |
| 1271 |
(match_operand 7 "const_int_operand") |
| 1272 |
(match_operand 8 "const_int_operand") |
| 1273 |
(match_operand 9 "const_1_or_2_operand") |
| 1274 |
(reg:SI VL_REGNUM) |
| 1275 |
(reg:SI VTYPE_REGNUM) |
| 1276 |
] UNSPEC_VPREDICATE) |
| 1277 |
(match_operand:<V_DOUBLE_EXTEND> 5 "vector_const_0_operand") |
| 1278 |
(match_operand:<V_DOUBLE_EXTEND> 4 "vector_merge_operand"))) |
| 1279 |
] UNSPEC_REDUC_SUM))] |
| 1280 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1281 |
"#" |
| 1282 |
"&& 1" |
| 1283 |
[(const_int 0)] |
| 1284 |
{ |
| 1285 |
rtx ops[] = {operands[0], operands[2], operands[1], |
| 1286 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 1287 |
riscv_vector::expand_reduction (<WREDUC_UNSPEC>, |
| 1288 |
<WREDUC_UNSPEC_VL0_SAFE>, |
| 1289 |
riscv_vector::REDUCE_OP_M, |
| 1290 |
ops, CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 1291 |
DONE; |
| 1292 |
} |
| 1293 |
[(set_attr "type" "vector")]) |
| 1294 |
|
| 1295 |
;; Combine mask_len_extend + vredsum to mask_vwredsum[u] |
| 1296 |
;; where the mrege of mask_len_extend is vector const 0 |
| 1297 |
(define_insn_and_split "*cond_len_widen_reduc_plus_scal_<mode>" |
| 1298 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 1299 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 1300 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1301 |
(unspec:<VM> [ |
| 1302 |
(match_operand 2 "vector_length_operand") |
| 1303 |
(const_int 0) |
| 1304 |
(const_int 0) |
| 1305 |
(reg:SI VL_REGNUM) |
| 1306 |
(reg:SI VTYPE_REGNUM) |
| 1307 |
] UNSPEC_VPREDICATE) |
| 1308 |
(vec_merge:<V_DOUBLE_EXTEND> |
| 1309 |
(any_extend:<V_DOUBLE_EXTEND> |
| 1310 |
(match_operand:VI_QHS_NO_M8 3 "register_operand")) |
| 1311 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1312 |
(unspec:<VM> [ |
| 1313 |
(match_operand:<VM> 4 "vector_all_trues_mask_operand") |
| 1314 |
(match_operand 5 "vector_length_operand") |
| 1315 |
(match_operand 6 "const_int_operand") |
| 1316 |
(match_operand 7 "const_int_operand") |
| 1317 |
(match_operand 8 "const_1_or_2_operand") |
| 1318 |
(reg:SI VL_REGNUM) |
| 1319 |
(reg:SI VTYPE_REGNUM) |
| 1320 |
] UNSPEC_VPREDICATE) |
| 1321 |
(match_operand:<V_DOUBLE_EXTEND> 9 "vector_const_0_operand") |
| 1322 |
(match_operand:<V_DOUBLE_EXTEND> 10 "vector_merge_operand")) |
| 1323 |
(match_operand:<VM> 1 "register_operand")) |
| 1324 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1325 |
(unspec:<VM> [ |
| 1326 |
(match_dup 4) |
| 1327 |
(match_dup 5) |
| 1328 |
(match_dup 6) |
| 1329 |
(match_dup 7) |
| 1330 |
(match_dup 8) |
| 1331 |
(reg:SI VL_REGNUM) |
| 1332 |
(reg:SI VTYPE_REGNUM) |
| 1333 |
] UNSPEC_VPREDICATE) |
| 1334 |
(match_dup 9) |
| 1335 |
(match_dup 10))) |
| 1336 |
] UNSPEC_REDUC_SUM))] |
| 1337 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1338 |
"#" |
| 1339 |
"&& 1" |
| 1340 |
[(const_int 0)] |
| 1341 |
{ |
| 1342 |
rtx ops[] = {operands[0], operands[3], operands[1], operands[2]}; |
| 1343 |
riscv_vector::expand_reduction (<WREDUC_UNSPEC>, |
| 1344 |
<WREDUC_UNSPEC_VL0_SAFE>, |
| 1345 |
riscv_vector::REDUCE_OP_M, |
| 1346 |
ops, CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 1347 |
DONE; |
| 1348 |
} |
| 1349 |
[(set_attr "type" "vector")]) |
| 1350 |
|
| 1351 |
;; Combine mask_extend + vfredsum to mask_vfwredusum |
| 1352 |
;; where the mrege of mask_extend is vector const 0 |
| 1353 |
(define_insn_and_split "*cond_widen_reduc_plus_scal_<mode>" |
| 1354 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 1355 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 1356 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1357 |
(match_operand:<VM> 1 "register_operand") |
| 1358 |
(float_extend:<V_DOUBLE_EXTEND> |
| 1359 |
(match_operand:VF_HS_NO_M8 2 "register_operand")) |
| 1360 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1361 |
(unspec:<VM> [ |
| 1362 |
(match_operand:<VM> 3 "vector_all_trues_mask_operand") |
| 1363 |
(match_operand 6 "vector_length_operand") |
| 1364 |
(match_operand 7 "const_int_operand") |
| 1365 |
(match_operand 8 "const_int_operand") |
| 1366 |
(match_operand 9 "const_1_or_2_operand") |
| 1367 |
(reg:SI VL_REGNUM) |
| 1368 |
(reg:SI VTYPE_REGNUM) |
| 1369 |
] UNSPEC_VPREDICATE) |
| 1370 |
(match_operand:<V_DOUBLE_EXTEND> 5 "vector_const_0_operand") |
| 1371 |
(match_operand:<V_DOUBLE_EXTEND> 4 "vector_merge_operand"))) |
| 1372 |
] UNSPEC_REDUC_SUM_UNORDERED))] |
| 1373 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1374 |
"#" |
| 1375 |
"&& 1" |
| 1376 |
[(const_int 0)] |
| 1377 |
{ |
| 1378 |
rtx ops[] = {operands[0], operands[2], operands[1], |
| 1379 |
gen_int_mode (GET_MODE_NUNITS (<MODE>mode), Pmode)}; |
| 1380 |
riscv_vector::expand_reduction (UNSPEC_WREDUC_SUM_UNORDERED, |
| 1381 |
UNSPEC_WREDUC_SUM_UNORDERED_VL0_SAFE, |
| 1382 |
riscv_vector::REDUCE_OP_M_FRM_DYN, |
| 1383 |
ops, CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 1384 |
DONE; |
| 1385 |
} |
| 1386 |
[(set_attr "type" "vector")]) |
| 1387 |
|
| 1388 |
;; Combine mask_len_extend + vredsum to mask_vwredsum[u] |
| 1389 |
;; where the mrege of mask_len_extend is vector const 0 |
| 1390 |
(define_insn_and_split "*cond_len_widen_reduc_plus_scal_<mode>" |
| 1391 |
[(set (match_operand:<V_DOUBLE_EXTEND_VEL> 0 "register_operand") |
| 1392 |
(unspec:<V_DOUBLE_EXTEND_VEL> [ |
| 1393 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1394 |
(unspec:<VM> [ |
| 1395 |
(match_operand 2 "vector_length_operand") |
| 1396 |
(const_int 0) |
| 1397 |
(const_int 0) |
| 1398 |
(reg:SI VL_REGNUM) |
| 1399 |
(reg:SI VTYPE_REGNUM) |
| 1400 |
] UNSPEC_VPREDICATE) |
| 1401 |
(vec_merge:<V_DOUBLE_EXTEND> |
| 1402 |
(float_extend:<V_DOUBLE_EXTEND> |
| 1403 |
(match_operand:VF_HS_NO_M8 3 "register_operand")) |
| 1404 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1405 |
(unspec:<VM> [ |
| 1406 |
(match_operand:<VM> 4 "vector_all_trues_mask_operand") |
| 1407 |
(match_operand 5 "vector_length_operand") |
| 1408 |
(match_operand 6 "const_int_operand") |
| 1409 |
(match_operand 7 "const_int_operand") |
| 1410 |
(match_operand 8 "const_1_or_2_operand") |
| 1411 |
(reg:SI VL_REGNUM) |
| 1412 |
(reg:SI VTYPE_REGNUM) |
| 1413 |
] UNSPEC_VPREDICATE) |
| 1414 |
(match_operand:<V_DOUBLE_EXTEND> 9 "vector_const_0_operand") |
| 1415 |
(match_operand:<V_DOUBLE_EXTEND> 10 "vector_merge_operand")) |
| 1416 |
(match_operand:<VM> 1 "register_operand")) |
| 1417 |
(if_then_else:<V_DOUBLE_EXTEND> |
| 1418 |
(unspec:<VM> [ |
| 1419 |
(match_dup 4) |
| 1420 |
(match_dup 5) |
| 1421 |
(match_dup 6) |
| 1422 |
(match_dup 7) |
| 1423 |
(match_dup 8) |
| 1424 |
(reg:SI VL_REGNUM) |
| 1425 |
(reg:SI VTYPE_REGNUM) |
| 1426 |
] UNSPEC_VPREDICATE) |
| 1427 |
(match_dup 9) |
| 1428 |
(match_dup 10))) |
| 1429 |
] UNSPEC_REDUC_SUM_UNORDERED))] |
| 1430 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1431 |
"#" |
| 1432 |
"&& 1" |
| 1433 |
[(const_int 0)] |
| 1434 |
{ |
| 1435 |
rtx ops[] = {operands[0], operands[3], operands[1], operands[2]}; |
| 1436 |
riscv_vector::expand_reduction (UNSPEC_WREDUC_SUM_UNORDERED, |
| 1437 |
UNSPEC_WREDUC_SUM_UNORDERED_VL0_SAFE, |
| 1438 |
riscv_vector::REDUCE_OP_M_FRM_DYN, |
| 1439 |
ops, CONST0_RTX (<V_DOUBLE_EXTEND_VEL>mode)); |
| 1440 |
DONE; |
| 1441 |
} |
| 1442 |
[(set_attr "type" "vector")]) |
| 1443 |
|
| 1444 |
;; ============================================================================= |
| 1445 |
;; Misc combine patterns |
| 1446 |
;; ============================================================================= |
| 1447 |
|
| 1448 |
;; Combine neg + vfsgnj to vfsgnjn |
| 1449 |
(define_insn_and_split "*copysign<mode>_neg" |
| 1450 |
[(set (match_operand:VF 0 "register_operand") |
| 1451 |
(neg:VF |
| 1452 |
(unspec:VF [ |
| 1453 |
(match_operand:VF 1 "register_operand") |
| 1454 |
(match_operand:VF 2 "register_operand") |
| 1455 |
] UNSPEC_VCOPYSIGN)))] |
| 1456 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1457 |
"#" |
| 1458 |
"&& 1" |
| 1459 |
[(const_int 0)] |
| 1460 |
{ |
| 1461 |
riscv_vector::emit_vlmax_insn (code_for_pred_ncopysign (<MODE>mode), |
| 1462 |
riscv_vector::BINARY_OP, operands); |
| 1463 |
DONE; |
| 1464 |
} |
| 1465 |
[(set_attr "type" "vector")]) |
| 1466 |
|
| 1467 |
;; Combine vmand/vmor + vmnot to vmandnot/vmornot |
| 1468 |
(define_insn_and_split "*<optab>not<mode>" |
| 1469 |
[(set (match_operand:VB_VLS 0 "register_operand" "=vr") |
| 1470 |
(bitmanip_bitwise:VB_VLS |
| 1471 |
(not:VB_VLS (match_operand:VB_VLS 2 "register_operand" " vr")) |
| 1472 |
(match_operand:VB_VLS 1 "register_operand" " vr")))] |
| 1473 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1474 |
"#" |
| 1475 |
"&& 1" |
| 1476 |
[(const_int 0)] |
| 1477 |
{ |
| 1478 |
insn_code icode = code_for_pred_not (<CODE>, <MODE>mode); |
| 1479 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_MASK_OP, operands); |
| 1480 |
DONE; |
| 1481 |
} |
| 1482 |
[(set_attr "type" "vmalu")]) |
| 1483 |
|
| 1484 |
;; Combine vmnot + vmand/vmor/vmxor to vmnand/vmnor/vmxnor |
| 1485 |
(define_insn_and_split "*n<optab><mode>" |
| 1486 |
[(set (match_operand:VB_VLS 0 "register_operand" "=vr") |
| 1487 |
(not:VB_VLS |
| 1488 |
(any_bitwise:VB_VLS |
| 1489 |
(match_operand:VB_VLS 1 "register_operand" " vr") |
| 1490 |
(match_operand:VB_VLS 2 "register_operand" " vr"))))] |
| 1491 |
"TARGET_VECTOR && can_create_pseudo_p ()" |
| 1492 |
"#" |
| 1493 |
"&& 1" |
| 1494 |
[(const_int 0)] |
| 1495 |
{ |
| 1496 |
insn_code icode = code_for_pred_n (<CODE>, <MODE>mode); |
| 1497 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_MASK_OP, operands); |
| 1498 |
DONE; |
| 1499 |
} |
| 1500 |
[(set_attr "type" "vmalu")]) |
| 1501 |
|
| 1502 |
;; Optimization pattern for early break auto-vectorization |
| 1503 |
;; vcond_mask_len (mask, ones, zeros, len, bias) + vlmax popcount |
| 1504 |
;; -> non vlmax popcount (mask, len) |
| 1505 |
(define_insn_and_split "*vcond_mask_len_popcount_<VB_VLS:mode><P:mode>" |
| 1506 |
[(set (match_operand:P 0 "register_operand") |
| 1507 |
(popcount:P |
| 1508 |
(unspec:VB_VLS [ |
| 1509 |
(unspec:VB_VLS [ |
| 1510 |
(match_operand:VB_VLS 1 "register_operand") |
| 1511 |
(match_operand:VB_VLS 2 "const_1_operand") |
| 1512 |
(match_operand:VB_VLS 3 "const_0_operand") |
| 1513 |
(match_operand 4 "autovec_length_operand") |
| 1514 |
(match_operand 5 "const_0_operand")] UNSPEC_SELECT_MASK) |
| 1515 |
(match_operand 6 "autovec_length_operand") |
| 1516 |
(const_int 1) |
| 1517 |
(reg:SI VL_REGNUM) |
| 1518 |
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)))] |
| 1519 |
"TARGET_VECTOR |
| 1520 |
&& can_create_pseudo_p () |
| 1521 |
&& riscv_vector::get_vector_mode (Pmode, GET_MODE_NUNITS (<VB_VLS:MODE>mode)).exists ()" |
| 1522 |
"#" |
| 1523 |
"&& 1" |
| 1524 |
[(const_int 0)] |
| 1525 |
{ |
| 1526 |
riscv_vector::emit_nonvlmax_insn ( |
| 1527 |
code_for_pred_popcount (<VB_VLS:MODE>mode, Pmode), |
| 1528 |
riscv_vector::CPOP_OP, |
| 1529 |
operands, operands[4]); |
| 1530 |
DONE; |
| 1531 |
} |
| 1532 |
[(set_attr "type" "vector")]) |
| 1533 |
|
| 1534 |
;; vzext.vf2 + vsll = vwsll. |
| 1535 |
(define_insn_and_split "*vwsll_zext1_<mode>" |
| 1536 |
[(set (match_operand:VWEXTI 0 "register_operand" "=vr ") |
| 1537 |
(ashift:VWEXTI |
| 1538 |
(zero_extend:VWEXTI |
| 1539 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand" " vr ")) |
| 1540 |
(match_operand:<V_DOUBLE_TRUNC> 2 "vector_shift_operand" "vrvk")))] |
| 1541 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1542 |
"#" |
| 1543 |
"&& 1" |
| 1544 |
[(const_int 0)] |
| 1545 |
{ |
| 1546 |
insn_code icode = code_for_pred_vwsll (<MODE>mode); |
| 1547 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1548 |
DONE; |
| 1549 |
} |
| 1550 |
[(set_attr "type" "vwsll")]) |
| 1551 |
|
| 1552 |
(define_insn_and_split "*vwsll_zext2_<mode>" |
| 1553 |
[(set (match_operand:VWEXTI 0 "register_operand" "=vr ") |
| 1554 |
(ashift:VWEXTI |
| 1555 |
(zero_extend:VWEXTI |
| 1556 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand" " vr ")) |
| 1557 |
(zero_extend:VWEXTI |
| 1558 |
(match_operand:<V_DOUBLE_TRUNC> 2 "vector_shift_operand" "vrvk"))))] |
| 1559 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1560 |
"#" |
| 1561 |
"&& 1" |
| 1562 |
[(const_int 0)] |
| 1563 |
{ |
| 1564 |
insn_code icode = code_for_pred_vwsll (<MODE>mode); |
| 1565 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1566 |
DONE; |
| 1567 |
} |
| 1568 |
[(set_attr "type" "vwsll")]) |
| 1569 |
|
| 1570 |
|
| 1571 |
(define_insn_and_split "*vwsll_zext1_scalar_<mode>" |
| 1572 |
[(set (match_operand:VWEXTI 0 "register_operand" "=vr") |
| 1573 |
(ashift:VWEXTI |
| 1574 |
(zero_extend:VWEXTI |
| 1575 |
(match_operand:<V_DOUBLE_TRUNC> 1 "register_operand" " vr")) |
| 1576 |
(match_operand:<VEL> 2 "vector_scalar_shift_operand" " rK")))] |
| 1577 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1578 |
"#" |
| 1579 |
"&& 1" |
| 1580 |
[(const_int 0)] |
| 1581 |
{ |
| 1582 |
operands[2] = gen_lowpart (Pmode, operands[2]); |
| 1583 |
insn_code icode = code_for_pred_vwsll_scalar (<MODE>mode); |
| 1584 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1585 |
DONE; |
| 1586 |
} |
| 1587 |
[(set_attr "type" "vwsll")]) |
| 1588 |
|
| 1589 |
;; For |
| 1590 |
;; uint16_t dst; |
| 1591 |
;; uint8_t a, b; |
| 1592 |
;; dst = vwsll (a, b) |
| 1593 |
;; we seem to create |
| 1594 |
;; aa = (int) a; |
| 1595 |
;; bb = (int) b; |
| 1596 |
;; dst = (short) vwsll (aa, bb); |
| 1597 |
;; The following patterns help to combine this idiom into one vwsll. |
| 1598 |
|
| 1599 |
(define_insn_and_split "*vwsll_zext1_trunc_<mode>" |
| 1600 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vr ") |
| 1601 |
(truncate:<V_DOUBLE_TRUNC> |
| 1602 |
(ashift:VQEXTI |
| 1603 |
(zero_extend:VQEXTI |
| 1604 |
(match_operand:<V_QUAD_TRUNC> 1 "register_operand" " vr ")) |
| 1605 |
(match_operand:VQEXTI 2 "vector_shift_operand" "vrvk"))))] |
| 1606 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1607 |
"#" |
| 1608 |
"&& 1" |
| 1609 |
[(const_int 0)] |
| 1610 |
{ |
| 1611 |
rtx truncated = gen_reg_rtx (<V_QUAD_TRUNC>mode); |
| 1612 |
emit_insn (gen_trunc<mode><v_quad_trunc>2 (truncated, operands[2])); |
| 1613 |
operands[2] = truncated; |
| 1614 |
|
| 1615 |
insn_code icode = code_for_pred_vwsll (<V_DOUBLE_TRUNC>mode); |
| 1616 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1617 |
DONE; |
| 1618 |
} |
| 1619 |
[(set_attr "type" "vwsll")]) |
| 1620 |
|
| 1621 |
(define_insn_and_split "*vwsll_zext2_trunc_<mode>" |
| 1622 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vr ") |
| 1623 |
(truncate:<V_DOUBLE_TRUNC> |
| 1624 |
(ashift:VQEXTI |
| 1625 |
(zero_extend:VQEXTI |
| 1626 |
(match_operand:<V_QUAD_TRUNC> 1 "register_operand" " vr ")) |
| 1627 |
(zero_extend:VQEXTI |
| 1628 |
(match_operand:<V_QUAD_TRUNC> 2 "vector_shift_operand" "vrvk")))))] |
| 1629 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1630 |
"#" |
| 1631 |
"&& 1" |
| 1632 |
[(const_int 0)] |
| 1633 |
{ |
| 1634 |
insn_code icode = code_for_pred_vwsll (<V_DOUBLE_TRUNC>mode); |
| 1635 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1636 |
DONE; |
| 1637 |
} |
| 1638 |
[(set_attr "type" "vwsll")]) |
| 1639 |
|
| 1640 |
(define_insn_and_split "*vwsll_zext1_trunc_scalar_<mode>" |
| 1641 |
[(set (match_operand:<V_DOUBLE_TRUNC> 0 "register_operand" "=vr ") |
| 1642 |
(truncate:<V_DOUBLE_TRUNC> |
| 1643 |
(ashift:VQEXTI |
| 1644 |
(zero_extend:VQEXTI |
| 1645 |
(match_operand:<V_QUAD_TRUNC> 1 "register_operand" " vr ")) |
| 1646 |
(match_operand:<VEL> 2 "vector_scalar_shift_operand" " rK"))))] |
| 1647 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1648 |
"#" |
| 1649 |
"&& 1" |
| 1650 |
[(const_int 0)] |
| 1651 |
{ |
| 1652 |
operands[2] = gen_lowpart (Pmode, operands[2]); |
| 1653 |
insn_code icode = code_for_pred_vwsll_scalar (<V_DOUBLE_TRUNC>mode); |
| 1654 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1655 |
DONE; |
| 1656 |
} |
| 1657 |
[(set_attr "type" "vwsll")]) |
| 1658 |
|
| 1659 |
;; vnot + vand = vandn. |
| 1660 |
(define_insn_and_split "*vandn_<mode>" |
| 1661 |
[(set (match_operand:V_VLSI 0 "register_operand" "=vr") |
| 1662 |
(and:V_VLSI |
| 1663 |
(not:V_VLSI |
| 1664 |
(match_operand:V_VLSI 2 "register_operand" "vr")) |
| 1665 |
(match_operand:V_VLSI 1 "register_operand" "vr")))] |
| 1666 |
"TARGET_ZVBB && can_create_pseudo_p ()" |
| 1667 |
"#" |
| 1668 |
"&& 1" |
| 1669 |
[(const_int 0)] |
| 1670 |
{ |
| 1671 |
insn_code icode = code_for_pred_vandn (<MODE>mode); |
| 1672 |
riscv_vector::emit_vlmax_insn (icode, riscv_vector::BINARY_OP, operands); |
| 1673 |
DONE; |
| 1674 |
} |
| 1675 |
[(set_attr "type" "vandn")]) |