1 ;;- Instruction patterns for the System z vector facility builtins.
2 ;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
3 ;; Contributed by Andreas Krebbel (Andreas.Krebbel@de.ibm.com)
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it under
8 ;; the terms of the GNU General Public License as published by the Free
9 ;; Software Foundation; either version 3, or (at your option) any later
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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/>.
21 ; The patterns in this file are enabled with -mzvector
23 (define_mode_iterator V_HW_32_64 [V4SI V2DI V2DF (V4SF "TARGET_VXE")])
24 (define_mode_iterator VI_HW_SD [V4SI V2DI])
25 (define_mode_iterator V_HW_HSD [V8HI V4SI V2DI V2DF])
26 (define_mode_iterator V_HW_4 [V4SI V4SF])
27 ; Full size vector modes with more than one element which are directly supported in vector registers by the hardware.
28 (define_mode_iterator VEC_HW [V16QI V8HI V4SI V2DI V2DF (V4SF "TARGET_VXE")])
29 (define_mode_iterator VECF_HW [(V4SF "TARGET_VXE") V2DF])
31 ; The element type of the vector with floating point modes translated
32 ; to int modes of the same size.
33 (define_mode_attr non_vec_int[(V1QI "QI") (V2QI "QI") (V4QI "QI") (V8QI "QI") (V16QI "QI")
34 (V1HI "HI") (V2HI "HI") (V4HI "HI") (V8HI "HI")
35 (V1SI "SI") (V2SI "SI") (V4SI "SI")
36 (V1DI "DI") (V2DI "DI")
37 (V1SF "SI") (V2SF "SI") (V4SF "SI")
38 (V1DF "DI") (V2DF "DI")])
40 ; Condition code modes generated by int comparisons
41 (define_mode_iterator VICMP [CCVEQ CCVIH CCVIHU])
43 ; Comparisons supported by the vec_cmp* builtins
44 (define_code_iterator intcmp [eq gt gtu ge geu lt ltu le leu])
45 (define_code_iterator fpcmp [eq gt ge lt le])
47 ; Comparisons supported by the vec_all/any* builtins
48 (define_code_iterator intcmpcc [eq ne gt ge lt le gtu geu ltu leu])
49 (define_code_iterator fpcmpcc [eq ne gt ge unle unlt lt le])
51 ; Flags for vector string instructions (vfae all 4, vfee only ZS and CS, vstrc all 4)
53 [(VSTRING_FLAG_IN 8) ; invert result
54 (VSTRING_FLAG_RT 4) ; result type
55 (VSTRING_FLAG_ZS 2) ; zero search
56 (VSTRING_FLAG_CS 1)]) ; condition code set
58 ; Rounding modes as being used for e.g. VFI
61 (VEC_RND_NEAREST_AWAY_FROM_ZERO 1)
62 (VEC_RND_SHORT_PREC 3)
63 (VEC_RND_NEAREST_TO_EVEN 4)
68 ; Inexact suppression facility flag as being used for e.g. VFI
74 ; Vector gather element
77 (define_insn "vec_gather_element<mode>"
78 [(set (match_operand:V_HW_32_64 0 "register_operand" "=v")
79 (unspec:V_HW_32_64 [(match_operand:V_HW_32_64 1 "register_operand" "0")
80 (match_operand:<tointvec> 2 "register_operand" "v")
81 (match_operand:BLK 3 "memory_operand" "R")
82 (match_operand:QI 4 "const_mask_operand" "C")]
84 "TARGET_VX && UINTVAL (operands[4]) < GET_MODE_NUNITS (<V_HW_32_64:MODE>mode)"
85 "vge<bhfgq>\t%0,%O3(%v2,%R3),%b4"
86 [(set_attr "op_type" "VRV")])
88 (define_expand "vec_genmask<mode>"
89 [(match_operand:VI_HW 0 "register_operand" "=v")
90 (match_operand:QI 1 "const_int_operand" "C")
91 (match_operand:QI 2 "const_int_operand" "C")]
94 int nunits = GET_MODE_NUNITS (<VI_HW:MODE>mode);
95 int bitlen = GET_MODE_UNIT_BITSIZE (<VI_HW:MODE>mode);
96 /* To bit little endian style. */
97 int end = bitlen - 1 - INTVAL (operands[1]);
98 int start = bitlen - 1 - INTVAL (operands[2]);
101 unsigned HOST_WIDE_INT mask;
102 bool swapped_p = false;
106 i = start - 1; start = end + 1; end = i;
110 mask = HOST_WIDE_INT_M1U;
112 mask = (HOST_WIDE_INT_1U << (end + 1)) - 1;
114 mask &= ~((HOST_WIDE_INT_1U << start) - 1);
119 for (i = 0; i < nunits; i++)
120 const_vec[i] = GEN_INT (trunc_int_for_mode (mask,
121 GET_MODE_INNER (<VI_HW:MODE>mode)));
123 emit_insn (gen_rtx_SET (operands[0],
124 gen_rtx_CONST_VECTOR (<VI_HW:MODE>mode,
125 gen_rtvec_v (nunits, const_vec))));
129 (define_expand "vec_genbytemaskv16qi"
130 [(match_operand:V16QI 0 "register_operand" "")
131 (match_operand:HI 1 "const_int_operand" "")]
135 unsigned mask = 0x8000;
137 unsigned HOST_WIDE_INT byte_mask = UINTVAL (operands[1]);
139 for (i = 0; i < 16; i++)
141 if (mask & byte_mask)
142 const_vec[i] = constm1_rtx;
144 const_vec[i] = const0_rtx;
147 emit_insn (gen_rtx_SET (operands[0],
148 gen_rtx_CONST_VECTOR (V16QImode,
149 gen_rtvec_v (16, const_vec))));
153 (define_expand "vec_splats<mode>"
154 [(set (match_operand:VEC_HW 0 "register_operand" "")
155 (vec_duplicate:VEC_HW (match_operand:<non_vec> 1 "general_operand" "")))]
158 (define_expand "vec_insert<mode>"
159 [(set (match_operand:VEC_HW 0 "register_operand" "")
160 (unspec:VEC_HW [(match_operand:<non_vec> 2 "register_operand" "")
161 (match_operand:SI 3 "nonmemory_operand" "")
162 (match_operand:VEC_HW 1 "register_operand" "")]
167 ; This is vec_set + modulo arithmetic on the element selector (op 2)
168 (define_expand "vec_promote<mode>"
169 [(set (match_operand:VEC_HW 0 "register_operand" "")
170 (unspec:VEC_HW [(match_operand:<non_vec> 1 "register_operand" "")
171 (match_operand:SI 2 "nonmemory_operand" "")
177 ; vec_extract is also an RTL standard name -> vector.md
179 ; vllezb, vllezh, vllezf, vllezg
180 (define_insn "vec_insert_and_zero<mode>"
181 [(set (match_operand:VEC_HW 0 "register_operand" "=v")
182 (unspec:VEC_HW [(match_operand:<non_vec> 1 "memory_operand" "R")]
183 UNSPEC_VEC_INSERT_AND_ZERO))]
185 "vllez<bhfgq>\t%v0,%1"
186 [(set_attr "op_type" "VRX")])
189 [(set (match_operand:V16QI 0 "register_operand" "=v")
190 (unspec:V16QI [(match_operand:BLK 1 "memory_operand" "R")
191 (match_operand:QI 2 "const_mask_operand" "C")]
192 UNSPEC_VEC_LOAD_BNDRY))]
193 "TARGET_VX && UINTVAL (operands[2]) < 7"
195 [(set_attr "op_type" "VRX")])
197 (define_insn "vlrlrv16qi"
198 [(set (match_operand:V16QI 0 "register_operand" "=v,v")
199 (unspec:V16QI [(match_operand:BLK 2 "memory_operand" "Q,Q")
200 (match_operand:SI 1 "nonmemory_operand" "d,C")]
201 UNSPEC_VEC_LOAD_LEN_R))]
206 [(set_attr "op_type" "VRS,VSI")])
209 ; FIXME: The following two patterns might using vec_merge. But what is
210 ; the canonical form: (vec_select (vec_merge op0 op1)) or (vec_merge
211 ; (vec_select op0) (vec_select op1)
212 ; vmrhb, vmrhh, vmrhf, vmrhg
213 (define_insn "vec_mergeh<mode>"
214 [(set (match_operand:VEC_HW 0 "register_operand" "=v")
215 (unspec:VEC_HW [(match_operand:VEC_HW 1 "register_operand" "v")
216 (match_operand:VEC_HW 2 "register_operand" "v")]
219 "vmrh<bhfgq>\t%v0,%1,%2"
220 [(set_attr "op_type" "VRR")])
222 ; vmrlb, vmrlh, vmrlf, vmrlg
223 (define_insn "vec_mergel<mode>"
224 [(set (match_operand:VEC_HW 0 "register_operand" "=v")
225 (unspec:VEC_HW [(match_operand:VEC_HW 1 "register_operand" "v")
226 (match_operand:VEC_HW 2 "register_operand" "v")]
229 "vmrl<bhfgq>\t%v0,%1,%2"
230 [(set_attr "op_type" "VRR")])
236 (define_insn "vec_pack<mode>"
237 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
238 (unspec:<vec_half> [(match_operand:VI_HW_HSD 1 "register_operand" "v")
239 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
242 "vpk<bhfgq>\t%v0,%v1,%v2"
243 [(set_attr "op_type" "VRR")])
246 ; Vector pack saturate
248 ; vpksh, vpksf, vpksg
249 (define_insn "vec_packs<mode>"
250 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
251 (unspec:<vec_half> [(match_operand:VI_HW_HSD 1 "register_operand" "v")
252 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
253 UNSPEC_VEC_PACK_SATURATE))]
255 "vpks<bhfgq>\t%v0,%v1,%v2"
256 [(set_attr "op_type" "VRR")])
259 ; This is vec_packs_cc + loading cc into a caller specified memory location.
260 (define_expand "vec_packs_cc<mode>"
262 [(set (reg:CCRAW CC_REGNUM)
263 (unspec:CCRAW [(match_operand:VI_HW_HSD 1 "register_operand" "")
264 (match_operand:VI_HW_HSD 2 "register_operand" "")]
265 UNSPEC_VEC_PACK_SATURATE_GENCC))
266 (set (match_operand:<vec_half> 0 "register_operand" "")
267 (unspec:<vec_half> [(match_dup 1) (match_dup 2)]
268 UNSPEC_VEC_PACK_SATURATE_CC))])
270 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
271 (set (match_operand:SI 3 "memory_operand" "")
275 operands[4] = gen_reg_rtx (SImode);
278 ; vpksh, vpksf, vpksg
279 (define_insn "*vec_packs_cc<mode>"
280 [(set (reg:CCRAW CC_REGNUM)
281 (unspec:CCRAW [(match_operand:VI_HW_HSD 1 "register_operand" "v")
282 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
283 UNSPEC_VEC_PACK_SATURATE_GENCC))
284 (set (match_operand:<vec_half> 0 "register_operand" "=v")
285 (unspec:<vec_half> [(match_dup 1) (match_dup 2)]
286 UNSPEC_VEC_PACK_SATURATE_CC))]
288 "vpks<bhfgq>s\t%v0,%v1,%v2"
289 [(set_attr "op_type" "VRR")])
292 ; Vector pack logical saturate
294 ; vpklsh, vpklsf, vpklsg
295 (define_insn "vec_packsu<mode>"
296 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
297 (unspec:<vec_half> [(match_operand:VI_HW_HSD 1 "register_operand" "v")
298 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
299 UNSPEC_VEC_PACK_UNSIGNED_SATURATE))]
301 "vpkls<bhfgq>\t%v0,%v1,%v2"
302 [(set_attr "op_type" "VRR")])
304 ; Emulate saturate unsigned pack on signed operands.
305 ; Zero out negative elements and continue with the unsigned saturating pack.
306 (define_expand "vec_packsu_u<mode>"
307 [(set (match_operand:<vec_half> 0 "register_operand" "=v")
308 (unspec:<vec_half> [(match_operand:VI_HW_HSD 1 "register_operand" "v")
309 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
310 UNSPEC_VEC_PACK_UNSIGNED_SATURATE))]
313 rtx null_vec = CONST0_RTX(<MODE>mode);
314 machine_mode half_mode;
317 case V8HImode: half_mode = V16QImode; break;
318 case V4SImode: half_mode = V8HImode; break;
319 case V2DImode: half_mode = V4SImode; break;
320 default: gcc_unreachable ();
322 s390_expand_vcond (operands[1], operands[1], null_vec,
323 GE, operands[1], null_vec);
324 s390_expand_vcond (operands[2], operands[2], null_vec,
325 GE, operands[2], null_vec);
326 emit_insn (gen_rtx_SET (operands[0],
327 gen_rtx_UNSPEC (half_mode,
328 gen_rtvec (2, operands[1], operands[2]),
329 UNSPEC_VEC_PACK_UNSIGNED_SATURATE)));
333 ; This is vec_packsu_cc + loading cc into a caller specified memory location.
334 ; FIXME: The reg to target mem copy should be issued by reload?!
335 (define_expand "vec_packsu_cc<mode>"
337 [(set (reg:CCRAW CC_REGNUM)
338 (unspec:CCRAW [(match_operand:VI_HW_HSD 1 "register_operand" "")
339 (match_operand:VI_HW_HSD 2 "register_operand" "")]
340 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC))
341 (set (match_operand:<vec_half> 0 "register_operand" "")
342 (unspec:<vec_half> [(match_dup 1) (match_dup 2)]
343 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC))])
345 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))
346 (set (match_operand:SI 3 "memory_operand" "")
350 operands[4] = gen_reg_rtx (SImode);
353 ; vpklsh, vpklsf, vpklsg
354 (define_insn "*vec_packsu_cc<mode>"
355 [(set (reg:CCRAW CC_REGNUM)
356 (unspec:CCRAW [(match_operand:VI_HW_HSD 1 "register_operand" "v")
357 (match_operand:VI_HW_HSD 2 "register_operand" "v")]
358 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_GENCC))
359 (set (match_operand:<vec_half> 0 "register_operand" "=v")
360 (unspec:<vec_half> [(match_dup 1) (match_dup 2)]
361 UNSPEC_VEC_PACK_UNSIGNED_SATURATE_CC))]
363 "vpkls<bhfgq>s\t%v0,%v1,%v2"
364 [(set_attr "op_type" "VRR")])
369 ; vec_perm is also RTL standard name, but we can only use it for V16QI
371 (define_insn "vec_zperm<mode>"
372 [(set (match_operand:V_HW_HSD 0 "register_operand" "=v")
373 (unspec:V_HW_HSD [(match_operand:V_HW_HSD 1 "register_operand" "v")
374 (match_operand:V_HW_HSD 2 "register_operand" "v")
375 (match_operand:V16QI 3 "register_operand" "v")]
378 "vperm\t%v0,%v1,%v2,%v3"
379 [(set_attr "op_type" "VRR")])
381 (define_expand "vec_permi<mode>"
382 [(set (match_operand:V_HW_64 0 "register_operand" "")
383 (unspec:V_HW_64 [(match_operand:V_HW_64 1 "register_operand" "")
384 (match_operand:V_HW_64 2 "register_operand" "")
385 (match_operand:QI 3 "const_mask_operand" "")]
389 HOST_WIDE_INT val = INTVAL (operands[3]);
390 operands[3] = GEN_INT ((val & 1) | (val & 2) << 1);
393 (define_insn "*vec_permi<mode>"
394 [(set (match_operand:V_HW_64 0 "register_operand" "=v")
395 (unspec:V_HW_64 [(match_operand:V_HW_64 1 "register_operand" "v")
396 (match_operand:V_HW_64 2 "register_operand" "v")
397 (match_operand:QI 3 "const_mask_operand" "C")]
399 "TARGET_VX && (UINTVAL (operands[3]) & 10) == 0"
400 "vpdi\t%v0,%v1,%v2,%b3"
401 [(set_attr "op_type" "VRR")])
407 ; Replicate from vector element
408 (define_expand "vec_splat<mode>"
409 [(set (match_operand:V_HW 0 "register_operand" "")
410 (vec_duplicate:V_HW (vec_select:<non_vec>
411 (match_operand:V_HW 1 "register_operand" "")
413 [(match_operand:QI 2 "const_mask_operand" "")]))))]
416 ; Vector scatter element
420 ; A 64 bit target address generated from 32 bit elements
421 (define_insn "vec_scatter_element<V_HW_4:mode>_DI"
423 (plus:DI (zero_extend:DI
424 (unspec:SI [(match_operand:V4SI 1 "register_operand" "v")
425 (match_operand:QI 3 "const_mask_operand" "C")]
427 (match_operand:SI 2 "address_operand" "ZQ")))
428 (unspec:<non_vec> [(match_operand:V_HW_4 0 "register_operand" "v")
429 (match_dup 3)] UNSPEC_VEC_EXTRACT))]
430 "TARGET_VX && TARGET_64BIT && UINTVAL (operands[3]) < 4"
431 "vscef\t%v0,%O2(%v1,%R2),%3"
432 [(set_attr "op_type" "VRV")])
434 ; A 31 bit target address is generated from 64 bit elements
436 (define_insn "vec_scatter_element<V_HW_64:mode>_SI"
439 (unspec:<non_vec_int> [(match_operand:V_HW_64 1 "register_operand" "v")
440 (match_operand:QI 3 "const_mask_operand" "C")]
441 UNSPEC_VEC_EXTRACT) 4)
442 (match_operand:SI 2 "address_operand" "ZQ")))
443 (unspec:<non_vec> [(match_operand:V_HW_64 0 "register_operand" "v")
444 (match_dup 3)] UNSPEC_VEC_EXTRACT))]
445 "TARGET_VX && !TARGET_64BIT && UINTVAL (operands[3]) < GET_MODE_NUNITS (<V_HW_64:MODE>mode)"
446 "vsce<V_HW_64:bhfgq>\t%v0,%O2(%v1,%R2),%3"
447 [(set_attr "op_type" "VRV")])
449 ; Element size and target address size is the same
451 (define_insn "vec_scatter_element<mode>_<non_vec_int>"
453 (plus:<non_vec_int> (unspec:<non_vec_int>
454 [(match_operand:<tointvec> 1 "register_operand" "v")
455 (match_operand:QI 3 "const_mask_operand" "C")]
457 (match_operand:DI 2 "address_operand" "ZQ")))
458 (unspec:<non_vec> [(match_operand:V_HW_32_64 0 "register_operand" "v")
459 (match_dup 3)] UNSPEC_VEC_EXTRACT))]
460 "TARGET_VX && UINTVAL (operands[3]) < GET_MODE_NUNITS (<V_HW_32_64:MODE>mode)"
461 "vsce<bhfgq>\t%v0,%O2(%v1,%R2),%3"
462 [(set_attr "op_type" "VRV")])
464 ; Depending on the address size we have to expand a different pattern.
465 ; This however cannot be represented in s390-builtins.def so we do the
466 ; multiplexing here in the expander.
467 (define_expand "vec_scatter_element<V_HW_32_64:mode>"
468 [(match_operand:V_HW_32_64 0 "register_operand" "")
469 (match_operand:<tointvec> 1 "register_operand" "")
470 (match_operand 2 "address_operand" "")
471 (match_operand:QI 3 "const_mask_operand" "")]
476 PUT_MODE (operands[2], DImode);
478 gen_vec_scatter_element<V_HW_32_64:mode>_DI (operands[0], operands[1],
479 operands[2], operands[3]));
483 PUT_MODE (operands[2], SImode);
485 gen_vec_scatter_element<V_HW_32_64:mode>_SI (operands[0], operands[1],
486 operands[2], operands[3]));
494 ; Operand 3 selects bits from either OP1 (0) or OP2 (1)
496 ; Comparison operator should not matter as long as we always use the same ?!
498 ; Operands 1 and 2 are swapped in order to match the altivec builtin.
499 ; If operand 3 is a const_int bitmask this would be vec_merge
500 (define_expand "vec_sel<mode>"
501 [(set (match_operand:V_HW 0 "register_operand" "")
503 (eq (match_operand:<tointvec> 3 "register_operand" "")
505 (match_operand:V_HW 2 "register_operand" "")
506 (match_operand:V_HW 1 "register_operand" "")))]
509 operands[4] = CONST0_RTX (<tointvec>mode);
513 ; Vector sign extend to doubleword
515 ; Sign extend of right most vector element to respective double-word
516 ; vsegb, vsegh, vsegf
517 (define_insn "vec_extend<mode>"
518 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
519 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
522 "vseg<bhfgq>\t%v0,%1"
523 [(set_attr "op_type" "VRR")])
526 ; Vector store with length
528 ; Store bytes in OP1 from OP0 with the highest indexed byte to be
529 ; stored from OP0 given by OP2
530 (define_insn "vstl<mode>"
531 [(set (match_operand:BLK 2 "memory_operand" "=Q")
532 (unspec:BLK [(match_operand:V 0 "register_operand" "v")
533 (match_operand:SI 1 "register_operand" "d")]
534 UNSPEC_VEC_STORE_LEN))]
537 [(set_attr "op_type" "VRS")])
539 ; Vector store rightmost with length
541 (define_insn "vstrlrv16qi"
542 [(set (match_operand:BLK 2 "memory_operand" "=Q,Q")
543 (unspec:BLK [(match_operand:V16QI 0 "register_operand" "v,v")
544 (match_operand:SI 1 "nonmemory_operand" "d,C")]
545 UNSPEC_VEC_STORE_LEN_R))]
550 [(set_attr "op_type" "VRS,VSI")])
556 (define_insn "vbpermv16qi"
557 [(set (match_operand:V2DI 0 "register_operand" "=v")
558 (unspec:V2DI [(match_operand:V16QI 1 "register_operand" "v")
559 (match_operand:V16QI 2 "register_operand" "v")]
562 "vbperm\t%v0,%v1,%v2"
563 [(set_attr "op_type" "VRR")])
567 ; vuphb, vuphh, vuphf
568 (define_insn "vec_unpackh<mode>"
569 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
570 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
571 UNSPEC_VEC_UNPACKH))]
573 "vuph<bhfgq>\t%v0,%v1"
574 [(set_attr "op_type" "VRR")])
576 ; vuplhb, vuplhh, vuplhf
577 (define_insn "vec_unpackh_l<mode>"
578 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
579 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
580 UNSPEC_VEC_UNPACKH_L))]
582 "vuplh<bhfgq>\t%v0,%v1"
583 [(set_attr "op_type" "VRR")])
588 ; vuplb, vuplhw, vuplf
589 (define_insn "vec_unpackl<mode>"
590 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
591 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
592 UNSPEC_VEC_UNPACKL))]
594 "vupl<bhfgq><w>\t%v0,%v1"
595 [(set_attr "op_type" "VRR")])
597 ; vupllb, vupllh, vupllf
598 (define_insn "vec_unpackl_l<mode>"
599 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
600 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
601 UNSPEC_VEC_UNPACKL_L))]
603 "vupll<bhfgq>\t%v0,%v1"
604 [(set_attr "op_type" "VRR")])
609 ; Vector add compute carry
611 ; vaccb, vacch, vaccf, vaccg, vaccq
612 (define_insn "vacc<bhfgq>_<mode>"
613 [(set (match_operand:VIT_HW 0 "register_operand" "=v")
614 (unspec:VIT_HW [(match_operand:VIT_HW 1 "register_operand" "%v")
615 (match_operand:VIT_HW 2 "register_operand" "v")]
618 "vacc<bhfgq>\t%v0,%v1,%v2"
619 [(set_attr "op_type" "VRR")])
621 ; Vector add with carry
624 [(set (match_operand:TI 0 "register_operand" "=v")
625 (unspec:TI [(match_operand:TI 1 "register_operand" "%v")
626 (match_operand:TI 2 "register_operand" "v")
627 (match_operand:TI 3 "register_operand" "v")]
628 UNSPEC_VEC_ADDE_U128))]
630 "vacq\t%v0,%v1,%v2,%v3"
631 [(set_attr "op_type" "VRR")])
634 ; Vector add with carry compute carry
636 (define_insn "vacccq"
637 [(set (match_operand:TI 0 "register_operand" "=v")
638 (unspec:TI [(match_operand:TI 1 "register_operand" "%v")
639 (match_operand:TI 2 "register_operand" "v")
640 (match_operand:TI 3 "register_operand" "v")]
641 UNSPEC_VEC_ADDEC_U128))]
643 "vacccq\t%v0,%v1,%v2,%v3"
644 [(set_attr "op_type" "VRR")])
649 ; Vector and with complement
652 (define_insn "vec_andc<mode>3"
653 [(set (match_operand:VT_HW 0 "register_operand" "=v")
654 (and:VT_HW (not:VT_HW (match_operand:VT_HW 2 "register_operand" "v"))
655 (match_operand:VT_HW 1 "register_operand" "v")))]
658 [(set_attr "op_type" "VRR")])
663 ; vavgb, vavgh, vavgf, vavgg
664 (define_insn "vec_avg<mode>"
665 [(set (match_operand:VI_HW 0 "register_operand" "=v")
666 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "%v")
667 (match_operand:VI_HW 2 "register_operand" "v")]
670 "vavg<bhfgq>\t%v0,%v1,%v2"
671 [(set_attr "op_type" "VRR")])
673 ; Vector average logical
675 ; vavglb, vavglh, vavglf, vavglg
676 (define_insn "vec_avgu<mode>"
677 [(set (match_operand:VI_HW 0 "register_operand" "=v")
678 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "%v")
679 (match_operand:VI_HW 2 "register_operand" "v")]
682 "vavgl<bhfgq>\t%v0,%v1,%v2"
683 [(set_attr "op_type" "VRR")])
688 (define_insn "vec_checksum"
689 [(set (match_operand:V4SI 0 "register_operand" "=v")
690 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
691 (match_operand:V4SI 2 "register_operand" "v")]
692 UNSPEC_VEC_CHECKSUM))]
695 [(set_attr "op_type" "VRR")])
701 ; vec_all/any int compares
703 (define_expand "vec_all_<intcmpcc:code><VI_HW:mode>"
704 [(match_operand:SI 0 "register_operand" "")
705 (intcmpcc (match_operand:VI_HW 1 "register_operand" "")
706 (match_operand:VI_HW 2 "register_operand" ""))]
709 s390_expand_vec_compare_cc (operands[0],
717 (define_expand "vec_any_<intcmpcc:code><VI_HW:mode>"
718 [(match_operand:SI 0 "register_operand" "")
719 (intcmpcc (match_operand:VI_HW 1 "register_operand" "")
720 (match_operand:VI_HW 2 "register_operand" ""))]
723 s390_expand_vec_compare_cc (operands[0],
731 ; vec_all/any fp compares
733 (define_expand "vec_all_<fpcmpcc:code><mode>"
734 [(match_operand:SI 0 "register_operand" "")
735 (fpcmpcc (match_operand:VECF_HW 1 "register_operand" "")
736 (match_operand:VECF_HW 2 "register_operand" ""))]
739 s390_expand_vec_compare_cc (operands[0],
747 (define_expand "vec_any_<fpcmpcc:code><mode>"
748 [(match_operand:SI 0 "register_operand" "")
749 (fpcmpcc (match_operand:VECF_HW 1 "register_operand" "")
750 (match_operand:VECF_HW 2 "register_operand" ""))]
753 s390_expand_vec_compare_cc (operands[0],
762 ; Compare without generating CC
764 (define_expand "vec_cmp<intcmp:code><VI_HW:mode>"
765 [(set (match_operand:VI_HW 0 "register_operand" "=v")
766 (intcmp:VI_HW (match_operand:VI_HW 1 "register_operand" "v")
767 (match_operand:VI_HW 2 "register_operand" "v")))]
770 s390_expand_vec_compare (operands[0], <intcmp:CODE>, operands[1], operands[2]);
774 (define_expand "vec_cmp<fpcmp:code><mode>"
775 [(set (match_operand:<tointvec> 0 "register_operand" "=v")
776 (fpcmp:<tointvec> (match_operand:VF_HW 1 "register_operand" "v")
777 (match_operand:VF_HW 2 "register_operand" "v")))]
780 s390_expand_vec_compare (operands[0], <fpcmp:CODE>, operands[1], operands[2]);
785 ; Vector count leading zeros
794 ; Vector Galois field multiply sum
796 ; vgfmb, vgfmh, vgfmf
797 (define_insn "vec_gfmsum<mode>"
798 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
799 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
800 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
803 "vgfm<bhfgq>\t%v0,%v1,%v2"
804 [(set_attr "op_type" "VRR")])
806 (define_insn "vec_gfmsum_128"
807 [(set (match_operand:V16QI 0 "register_operand" "=v")
808 (unspec:V16QI [(match_operand:V2DI 1 "register_operand" "v")
809 (match_operand:V2DI 2 "register_operand" "v")]
810 UNSPEC_VEC_GFMSUM_128))]
813 [(set_attr "op_type" "VRR")])
815 ; vgfmab, vgfmah, vgfmaf
816 (define_insn "vec_gfmsum_accum<mode>"
817 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
818 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")
819 (match_operand:VI_HW_QHS 2 "register_operand" "v")
820 (match_operand:<vec_double> 3 "register_operand" "v")]
821 UNSPEC_VEC_GFMSUM_ACCUM))]
823 "vgfma<bhfgq>\t%v0,%v1,%v2,%v3"
824 [(set_attr "op_type" "VRR")])
826 (define_insn "vec_gfmsum_accum_128"
827 [(set (match_operand:V16QI 0 "register_operand" "=v")
828 (unspec:V16QI [(match_operand:V2DI 1 "register_operand" "v")
829 (match_operand:V2DI 2 "register_operand" "v")
830 (match_operand:V16QI 3 "register_operand" "v")]
831 UNSPEC_VEC_GFMSUM_ACCUM_128))]
833 "vgfmag\t%v0,%v1,%v2,%v3"
834 [(set_attr "op_type" "VRR")])
839 ; Vector load positive: vec_abs -> abs
840 ; Vector maximum vec_max -> smax, logical vec_max -> umax
841 ; Vector maximum vec_min -> smin, logical vec_min -> umin
844 ; Vector multiply and add high
846 ; vec_mladd -> vec_vmal
847 ; vmalb, vmalh, vmalf, vmalg
848 (define_insn "vec_vmal<mode>"
849 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
850 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
851 (match_operand:VI_HW_QHS 2 "register_operand" "v")
852 (match_operand:VI_HW_QHS 3 "register_operand" "v")]
855 "vmal<bhfgq><w>\t%v0,%v1,%v2,%v3"
856 [(set_attr "op_type" "VRR")])
858 ; vec_mhadd -> vec_vmah/vec_vmalh
860 ; vmahb; vmahh, vmahf, vmahg
861 (define_insn "vec_vmah<mode>"
862 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
863 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
864 (match_operand:VI_HW_QHS 2 "register_operand" "v")
865 (match_operand:VI_HW_QHS 3 "register_operand" "v")]
868 "vmah<bhfgq>\t%v0,%v1,%v2,%v3"
869 [(set_attr "op_type" "VRR")])
871 ; vmalhb; vmalhh, vmalhf, vmalhg
872 (define_insn "vec_vmalh<mode>"
873 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
874 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
875 (match_operand:VI_HW_QHS 2 "register_operand" "v")
876 (match_operand:VI_HW_QHS 3 "register_operand" "v")]
879 "vmalh<bhfgq>\t%v0,%v1,%v2,%v3"
880 [(set_attr "op_type" "VRR")])
882 ; vec_meadd -> vec_vmae/vec_vmale
884 ; vmaeb; vmaeh, vmaef, vmaeg
885 (define_insn "vec_vmae<mode>"
886 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
887 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
888 (match_operand:VI_HW_QHS 2 "register_operand" "v")
889 (match_operand:<vec_double> 3 "register_operand" "v")]
892 "vmae<bhfgq>\t%v0,%v1,%v2,%v3"
893 [(set_attr "op_type" "VRR")])
895 ; vmaleb; vmaleh, vmalef, vmaleg
896 (define_insn "vec_vmale<mode>"
897 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
898 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
899 (match_operand:VI_HW_QHS 2 "register_operand" "v")
900 (match_operand:<vec_double> 3 "register_operand" "v")]
903 "vmale<bhfgq>\t%v0,%v1,%v2,%v3"
904 [(set_attr "op_type" "VRR")])
906 ; vec_moadd -> vec_vmao/vec_vmalo
908 ; vmaob; vmaoh, vmaof, vmaog
909 (define_insn "vec_vmao<mode>"
910 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
911 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
912 (match_operand:VI_HW_QHS 2 "register_operand" "v")
913 (match_operand:<vec_double> 3 "register_operand" "v")]
916 "vmao<bhfgq>\t%v0,%v1,%v2,%v3"
917 [(set_attr "op_type" "VRR")])
919 ; vmalob; vmaloh, vmalof, vmalog
920 (define_insn "vec_vmalo<mode>"
921 [(set (match_operand:<vec_double> 0 "register_operand" "=v")
922 (unspec:<vec_double> [(match_operand:VI_HW_QHS 1 "register_operand" "v")
923 (match_operand:VI_HW_QHS 2 "register_operand" "v")
924 (match_operand:<vec_double> 3 "register_operand" "v")]
927 "vmalo<bhfgq>\t%v0,%v1,%v2,%v3"
928 [(set_attr "op_type" "VRR")])
931 ; Vector multiply high
933 ; vec_mulh -> vec_smulh/vec_umulh
936 (define_insn "vec_smulh<mode>"
937 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
938 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
939 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
940 UNSPEC_VEC_SMULT_HI))]
942 "vmh<bhfgq>\t%v0,%v1,%v2"
943 [(set_attr "op_type" "VRR")])
945 ; vmlhb, vmlhh, vmlhf
946 (define_insn "vec_umulh<mode>"
947 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
948 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "%v")
949 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
950 UNSPEC_VEC_UMULT_HI))]
952 "vmlh<bhfgq>\t%v0,%v1,%v2"
953 [(set_attr "op_type" "VRR")])
956 ; Vector multiply low
958 ; vec_mule -> vec_widen_umult_even/vec_widen_smult_even
959 ; vec_mulo -> vec_widen_umult_odd/vec_widen_smult_odd
964 (define_insn "vec_nor<mode>3"
965 [(set (match_operand:VT_HW 0 "register_operand" "=v")
967 (ior:VT_HW (match_operand:VT_HW 1 "register_operand" "%v")
968 (match_operand:VT_HW 2 "register_operand" "v"))))]
971 [(set_attr "op_type" "VRR")])
976 ; Vector population count vec_popcnt -> popcount
977 ; Vector element rotate left logical vec_rl -> vrotl, vec_rli -> rot
979 ; Vector element rotate and insert under mask
981 ; verimb, verimh, verimf, verimg
982 (define_insn "verim<mode>"
983 [(set (match_operand:VI_HW 0 "register_operand" "=v")
984 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "0")
985 (match_operand:VI_HW 2 "register_operand" "v")
986 (match_operand:VI_HW 3 "register_operand" "v")
987 (match_operand:QI 4 "const_int_operand" "C")]
988 UNSPEC_VEC_RL_MASK))]
990 "verim<bhfgq>\t%v0,%v2,%v3,%b4"
991 [(set_attr "op_type" "VRI")])
996 (define_insn "vec_sll<VI_HW:mode><VI_HW_QHS:mode>"
997 [(set (match_operand:VI_HW 0 "register_operand" "=v")
998 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "v")
999 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
1003 [(set_attr "op_type" "VRR")])
1006 ; Vector shift left by byte
1008 (define_insn "vec_slb<mode>"
1009 [(set (match_operand:V_HW 0 "register_operand" "=v")
1010 (unspec:V_HW [(match_operand:V_HW 1 "register_operand" "v")
1011 (match_operand:<tointvec> 2 "register_operand" "v")]
1015 [(set_attr "op_type" "VRR")])
1018 ; Vector shift left double by byte
1020 (define_insn "vec_sld<mode>"
1021 [(set (match_operand:V_HW 0 "register_operand" "=v")
1022 (unspec:V_HW [(match_operand:V_HW 1 "register_operand" "v")
1023 (match_operand:V_HW 2 "register_operand" "v")
1024 (match_operand:QI 3 "const_int_operand" "C")]
1027 "vsldb\t%v0,%v1,%v2,%b3"
1028 [(set_attr "op_type" "VRI")])
1030 (define_expand "vec_sldw<mode>"
1031 [(set (match_operand:V_HW 0 "register_operand" "")
1032 (unspec:V_HW [(match_operand:V_HW 1 "register_operand" "")
1033 (match_operand:V_HW 2 "register_operand" "")
1034 (match_operand:QI 3 "const_int_operand" "")]
1038 operands[3] = GEN_INT (INTVAL (operands[3]) << 2);
1041 ; Vector shift right arithmetic
1043 (define_insn "vec_sral<VI_HW:mode><VI_HW_QHS:mode>"
1044 [(set (match_operand:VI_HW 0 "register_operand" "=v")
1045 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "v")
1046 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
1050 [(set_attr "op_type" "VRR")])
1053 ; Vector shift right arithmetic by byte
1055 (define_insn "vec_srab<mode>"
1056 [(set (match_operand:V_HW 0 "register_operand" "=v")
1057 (unspec:V_HW [(match_operand:V_HW 1 "register_operand" "v")
1058 (match_operand:<tointvec> 2 "register_operand" "v")]
1061 "vsrab\t%v0,%v1,%v2"
1062 [(set_attr "op_type" "VRR")])
1065 ; Vector shift right logical
1067 (define_insn "vec_srl<VI_HW:mode><VI_HW_QHS:mode>"
1068 [(set (match_operand:VI_HW 0 "register_operand" "=v")
1069 (unspec:VI_HW [(match_operand:VI_HW 1 "register_operand" "v")
1070 (match_operand:VI_HW_QHS 2 "register_operand" "v")]
1074 [(set_attr "op_type" "VRR")])
1077 ; Vector shift right logical by byte
1079 ; Pattern definition in vector.md
1080 (define_expand "vec_srb<mode>"
1081 [(set (match_operand:V_HW 0 "register_operand" "")
1082 (unspec:V_HW [(match_operand:V_HW 1 "register_operand" "")
1083 (match_operand:<tointvec> 2 "register_operand" "")]
1090 ; Vector subtract compute borrow indication
1092 ; vscbib, vscbih, vscbif, vscbig, vscbiq
1093 (define_insn "vscbi<bhfgq>_<mode>"
1094 [(set (match_operand:VIT_HW 0 "register_operand" "=v")
1095 (unspec:VIT_HW [(match_operand:VIT_HW 1 "register_operand" "v")
1096 (match_operand:VIT_HW 2 "register_operand" "v")]
1099 "vscbi<bhfgq>\t%v0,%v1,%v2"
1100 [(set_attr "op_type" "VRR")])
1102 ; Vector subtract with borrow indication
1104 (define_insn "vsbiq"
1105 [(set (match_operand:TI 0 "register_operand" "=v")
1106 (unspec:TI [(match_operand:TI 1 "register_operand" "v")
1107 (match_operand:TI 2 "register_operand" "v")
1108 (match_operand:TI 3 "register_operand" "v")]
1109 UNSPEC_VEC_SUBE_U128))]
1111 "vsbiq\t%v0,%v1,%v2,%v3"
1112 [(set_attr "op_type" "VRR")])
1115 ; Vector subtract with borrow compute and borrow indication
1117 (define_insn "vsbcbiq"
1118 [(set (match_operand:TI 0 "register_operand" "=v")
1119 (unspec:TI [(match_operand:TI 1 "register_operand" "v")
1120 (match_operand:TI 2 "register_operand" "v")
1121 (match_operand:TI 3 "register_operand" "v")]
1122 UNSPEC_VEC_SUBEC_U128))]
1124 "vsbcbiq\t%v0,%v1,%v2,%v3"
1125 [(set_attr "op_type" "VRR")])
1130 ; Sum across DImode parts of the 1st operand and add the rightmost
1131 ; element of 2nd operand
1133 (define_expand "vec_sum2<mode>"
1134 [(set (match_operand:V2DI 0 "register_operand" "")
1135 (unspec:V2DI [(match_operand:VI_HW_HS 1 "register_operand" "")
1136 (match_operand:VI_HW_HS 2 "register_operand" "")]
1141 (define_insn "vec_sum_u128<mode>"
1142 [(set (match_operand:V2DI 0 "register_operand" "=v")
1143 (unspec:V2DI [(match_operand:VI_HW_SD 1 "register_operand" "v")
1144 (match_operand:VI_HW_SD 2 "register_operand" "v")]
1147 "vsumq<bhfgq>\t%v0,%v1,%v2"
1148 [(set_attr "op_type" "VRR")])
1151 (define_expand "vec_sum4<mode>"
1152 [(set (match_operand:V4SI 0 "register_operand" "")
1153 (unspec:V4SI [(match_operand:VI_HW_QH 1 "register_operand" "")
1154 (match_operand:VI_HW_QH 2 "register_operand" "")]
1159 ; Vector test under mask
1161 (define_expand "vec_test_mask_int<mode>"
1162 [(set (reg:CCRAW CC_REGNUM)
1163 (unspec:CCRAW [(match_operand:V_HW 1 "register_operand" "")
1164 (match_operand:<tointvec> 2 "register_operand" "")]
1165 UNSPEC_VEC_TEST_MASK))
1166 (set (match_operand:SI 0 "register_operand" "")
1167 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1170 (define_insn "*vec_test_mask<mode>"
1171 [(set (reg:CCRAW CC_REGNUM)
1172 (unspec:CCRAW [(match_operand:V_HW 0 "register_operand" "v")
1173 (match_operand:<tointvec> 1 "register_operand" "v")]
1174 UNSPEC_VEC_TEST_MASK))]
1177 [(set_attr "op_type" "VRR")])
1180 ; Vector multiply sum logical
1182 (define_insn "vec_msumv2di"
1183 [(set (match_operand:V16QI 0 "register_operand" "=v")
1184 (unspec:V16QI [(match_operand:V2DI 1 "register_operand" "v")
1185 (match_operand:V2DI 2 "register_operand" "v")
1186 (match_operand:V16QI 3 "register_operand" "v")
1187 (match_operand:QI 4 "const_mask_operand" "C")]
1190 "vmslg\t%v0,%v1,%v2,%v3"
1191 [(set_attr "op_type" "VRR")])
1193 (define_insn "vmslg"
1194 [(set (match_operand:TI 0 "register_operand" "=v")
1195 (unspec:TI [(match_operand:V2DI 1 "register_operand" "v")
1196 (match_operand:V2DI 2 "register_operand" "v")
1197 (match_operand:TI 3 "register_operand" "v")
1198 (match_operand:QI 4 "const_mask_operand" "C")]
1201 "vmslg\t%v0,%v1,%v2,%v3"
1202 [(set_attr "op_type" "VRR")])
1205 ; Vector find any element equal
1207 ; vfaeb, vfaeh, vfaef
1208 ; vfaezb, vfaezh, vfaezf
1209 (define_insn "vfae<mode>"
1210 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1211 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1212 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1213 (match_operand:QI 3 "const_mask_operand" "C")]
1217 unsigned HOST_WIDE_INT flags = UINTVAL (operands[3]);
1219 if (flags & VSTRING_FLAG_ZS)
1221 flags &= ~VSTRING_FLAG_ZS;
1222 operands[3] = GEN_INT (flags);
1223 return "vfaez<bhfgq>\t%v0,%v1,%v2,%b3";
1225 return "vfae<bhfgq>\t%v0,%v1,%v2,%b3";
1227 [(set_attr "op_type" "VRR")])
1229 ; vfaebs, vfaehs, vfaefs
1230 ; vfaezbs, vfaezhs, vfaezfs
1231 (define_insn "*vfaes<mode>"
1232 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1233 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1234 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1235 (match_operand:QI 3 "const_mask_operand" "C")]
1237 (set (reg:CCRAW CC_REGNUM)
1238 (unspec:CCRAW [(match_dup 1)
1241 UNSPEC_VEC_VFAECC))]
1244 unsigned HOST_WIDE_INT flags = UINTVAL (operands[3]);
1246 if (flags & VSTRING_FLAG_ZS)
1248 flags &= ~VSTRING_FLAG_ZS;
1249 operands[3] = GEN_INT (flags);
1250 return "vfaez<bhfgq>s\t%v0,%v1,%v2,%b3";
1252 return "vfae<bhfgq>s\t%v0,%v1,%v2,%b3";
1254 [(set_attr "op_type" "VRR")])
1256 (define_expand "vfaez<mode>"
1257 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1258 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1259 (match_operand:VI_HW_QHS 2 "register_operand" "")
1260 (match_operand:QI 3 "const_mask_operand" "")]
1264 operands[3] = GEN_INT (INTVAL (operands[3]) | VSTRING_FLAG_ZS);
1267 (define_expand "vfaes<mode>"
1269 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1270 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1271 (match_operand:VI_HW_QHS 2 "register_operand" "")
1272 (match_operand:QI 3 "const_mask_operand" "")]
1274 (set (reg:CCRAW CC_REGNUM)
1275 (unspec:CCRAW [(match_dup 1)
1278 UNSPEC_VEC_VFAECC))])
1279 (set (match_operand:SI 4 "memory_operand" "")
1280 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1283 operands[3] = GEN_INT (INTVAL (operands[3]) | VSTRING_FLAG_CS);
1286 (define_expand "vfaezs<mode>"
1288 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1289 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1290 (match_operand:VI_HW_QHS 2 "register_operand" "")
1291 (match_operand:SI 3 "const_mask_operand" "")]
1293 (set (reg:CCRAW CC_REGNUM)
1294 (unspec:CCRAW [(match_dup 1)
1297 UNSPEC_VEC_VFAECC))])
1298 (set (match_operand:SI 4 "memory_operand" "")
1299 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1302 operands[3] = GEN_INT (INTVAL (operands[3]) | VSTRING_FLAG_CS | VSTRING_FLAG_ZS);
1306 ; Vector find element equal
1308 ; vfeebs, vfeehs, vfeefs
1309 ; vfeezbs, vfeezhs, vfeezfs
1310 (define_insn "*vfees<mode>"
1311 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1312 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1313 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1314 (match_operand:QI 3 "const_mask_operand" "C")]
1316 (set (reg:CCRAW CC_REGNUM)
1317 (unspec:CCRAW [(match_dup 1)
1320 UNSPEC_VEC_VFEECC))]
1323 unsigned HOST_WIDE_INT flags = UINTVAL (operands[3]);
1325 gcc_assert (!(flags & ~(VSTRING_FLAG_ZS | VSTRING_FLAG_CS)));
1326 flags &= ~VSTRING_FLAG_CS;
1328 if (flags == VSTRING_FLAG_ZS)
1329 return "vfeez<bhfgq>s\t%v0,%v1,%v2";
1330 return "vfee<bhfgq>s\t%v0,%v1,%v2,%b3";
1332 [(set_attr "op_type" "VRR")])
1334 ; vfeeb, vfeeh, vfeef
1335 (define_insn "vfee<mode>"
1336 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1337 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1338 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1342 "vfee<bhfgq>\t%v0,%v1,%v2,0"
1343 [(set_attr "op_type" "VRR")])
1345 ; vfeezb, vfeezh, vfeezf
1346 (define_insn "vfeez<mode>"
1347 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1348 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1349 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1350 (const_int VSTRING_FLAG_ZS)]
1353 "vfeez<bhfgq>s\t%v0,%v1,%v2,2"
1354 [(set_attr "op_type" "VRR")])
1356 (define_expand "vfees<mode>"
1358 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1359 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1360 (match_operand:VI_HW_QHS 2 "register_operand" "")
1361 (const_int VSTRING_FLAG_CS)]
1363 (set (reg:CCRAW CC_REGNUM)
1364 (unspec:CCRAW [(match_dup 1)
1366 (const_int VSTRING_FLAG_CS)]
1367 UNSPEC_VEC_VFEECC))])
1368 (set (match_operand:SI 3 "memory_operand" "")
1369 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1372 (define_expand "vfeezs<mode>"
1374 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1375 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1376 (match_operand:VI_HW_QHS 2 "register_operand" "")
1379 (set (reg:CCRAW CC_REGNUM)
1380 (unspec:CCRAW [(match_dup 1)
1383 UNSPEC_VEC_VFEECC))])
1384 (set (match_operand:SI 3 "memory_operand" "")
1385 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1388 operands[4] = GEN_INT (VSTRING_FLAG_ZS | VSTRING_FLAG_CS);
1391 ; Vector find element not equal
1393 ; vfeneb, vfeneh, vfenef
1394 (define_insn "vfene<mode>"
1395 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1396 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1397 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1401 "vfene<bhfgq>\t%v0,%v1,%v2,0"
1402 [(set_attr "op_type" "VRR")])
1404 ; vec_vfenes can be found in vector.md since it is used for strlen
1406 ; vfenezb, vfenezh, vfenezf
1407 (define_insn "vfenez<mode>"
1408 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1409 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1410 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1411 (const_int VSTRING_FLAG_ZS)]
1414 "vfenez<bhfgq>\t%v0,%v1,%v2"
1415 [(set_attr "op_type" "VRR")])
1417 (define_expand "vfenes<mode>"
1419 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1420 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1421 (match_operand:VI_HW_QHS 2 "register_operand" "")
1422 (const_int VSTRING_FLAG_CS)]
1424 (set (reg:CCRAW CC_REGNUM)
1425 (unspec:CCRAW [(match_dup 1)
1427 (const_int VSTRING_FLAG_CS)]
1428 UNSPEC_VEC_VFENECC))])
1429 (set (match_operand:SI 3 "memory_operand" "")
1430 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1433 (define_expand "vfenezs<mode>"
1435 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1436 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1437 (match_operand:VI_HW_QHS 2 "register_operand" "")
1440 (set (reg:CCRAW CC_REGNUM)
1441 (unspec:CCRAW [(match_dup 1)
1444 UNSPEC_VEC_VFENECC))])
1445 (set (match_operand:SI 3 "memory_operand" "")
1446 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1449 operands[4] = GEN_INT (VSTRING_FLAG_ZS | VSTRING_FLAG_CS);
1452 ; Vector isolate string
1454 ; vistrb, vistrh, vistrf
1455 (define_insn "vistr<mode>"
1456 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1457 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
1460 "vistr<bhfgq>\t%v0,%v1"
1461 [(set_attr "op_type" "VRR")])
1463 ; vistrbs, vistrhs, vistrfs
1464 (define_insn "*vistrs<mode>"
1465 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1466 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")]
1468 (set (reg:CCRAW CC_REGNUM)
1469 (unspec:CCRAW [(match_dup 1)] UNSPEC_VEC_VISTRCC))]
1471 "vistr<bhfgq>s\t%v0,%v1"
1472 [(set_attr "op_type" "VRR")])
1474 (define_expand "vistrs<mode>"
1476 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1477 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")]
1479 (set (reg:CCRAW CC_REGNUM)
1480 (unspec:CCRAW [(match_dup 1)]
1481 UNSPEC_VEC_VISTRCC))])
1482 (set (match_operand:SI 2 "memory_operand" "")
1483 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1487 ; Vector compare range
1489 ; vstrcb, vstrch, vstrcf
1490 ; vstrczb, vstrczh, vstrczf
1491 (define_insn "vstrc<mode>"
1492 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1493 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1494 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1495 (match_operand:VI_HW_QHS 3 "register_operand" "v")
1496 (match_operand:QI 4 "const_mask_operand" "C")]
1500 unsigned HOST_WIDE_INT flags = UINTVAL (operands[4]);
1502 if (flags & VSTRING_FLAG_ZS)
1504 flags &= ~VSTRING_FLAG_ZS;
1505 operands[4] = GEN_INT (flags);
1506 return "vstrcz<bhfgq>\t%v0,%v1,%v2,%v3,%b4";
1508 return "vstrc<bhfgq>\t%v0,%v1,%v2,%v3,%b4";
1510 [(set_attr "op_type" "VRR")])
1512 ; vstrcbs, vstrchs, vstrcfs
1513 ; vstrczbs, vstrczhs, vstrczfs
1514 (define_insn "*vstrcs<mode>"
1515 [(set (match_operand:VI_HW_QHS 0 "register_operand" "=v")
1516 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "v")
1517 (match_operand:VI_HW_QHS 2 "register_operand" "v")
1518 (match_operand:VI_HW_QHS 3 "register_operand" "v")
1519 (match_operand:QI 4 "const_mask_operand" "C")]
1521 (set (reg:CCRAW CC_REGNUM)
1522 (unspec:CCRAW [(match_dup 1)
1526 UNSPEC_VEC_VSTRCCC))]
1529 unsigned HOST_WIDE_INT flags = UINTVAL (operands[4]);
1531 if (flags & VSTRING_FLAG_ZS)
1533 flags &= ~VSTRING_FLAG_ZS;
1534 operands[4] = GEN_INT (flags);
1535 return "vstrcz<bhfgq>s\t%v0,%v1,%v2,%v3,%b4";
1537 return "vstrc<bhfgq>s\t%v0,%v1,%v2,%v3,%b4";
1539 [(set_attr "op_type" "VRR")])
1541 (define_expand "vstrcz<mode>"
1542 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1543 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1544 (match_operand:VI_HW_QHS 2 "register_operand" "")
1545 (match_operand:VI_HW_QHS 3 "register_operand" "")
1546 (match_operand:QI 4 "const_mask_operand" "")]
1550 operands[4] = GEN_INT (INTVAL (operands[4]) | VSTRING_FLAG_ZS);
1553 (define_expand "vstrcs<mode>"
1555 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1556 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1557 (match_operand:VI_HW_QHS 2 "register_operand" "")
1558 (match_operand:VI_HW_QHS 3 "register_operand" "")
1559 (match_operand:QI 4 "const_mask_operand" "")]
1561 (set (reg:CCRAW CC_REGNUM)
1562 (unspec:CCRAW [(match_dup 1)
1566 UNSPEC_VEC_VSTRCCC))])
1567 (set (match_operand:SI 5 "memory_operand" "")
1568 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1571 operands[4] = GEN_INT (INTVAL (operands[4]) | VSTRING_FLAG_CS);
1574 (define_expand "vstrczs<mode>"
1576 [(set (match_operand:VI_HW_QHS 0 "register_operand" "")
1577 (unspec:VI_HW_QHS [(match_operand:VI_HW_QHS 1 "register_operand" "")
1578 (match_operand:VI_HW_QHS 2 "register_operand" "")
1579 (match_operand:VI_HW_QHS 3 "register_operand" "")
1580 (match_operand:QI 4 "const_mask_operand" "")]
1582 (set (reg:CCRAW CC_REGNUM)
1583 (unspec:CCRAW [(match_dup 1)
1587 UNSPEC_VEC_VSTRCCC))])
1588 (set (match_operand:SI 5 "memory_operand" "")
1589 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1592 operands[4] = GEN_INT (INTVAL (operands[4]) | VSTRING_FLAG_CS | VSTRING_FLAG_ZS);
1595 (define_insn "vcdgb"
1596 [(set (match_operand:V2DF 0 "register_operand" "=v")
1597 (unspec:V2DF [(match_operand:V2DI 1 "register_operand" "v")
1598 (match_operand:QI 2 "const_mask_operand" "C") ; inexact suppression
1599 (match_operand:QI 3 "const_mask_operand" "C")] ; rounding mode
1601 "TARGET_VX && UINTVAL (operands[3]) != 2 && UINTVAL (operands[3]) <= 7"
1602 "vcdgb\t%v0,%v1,%b2,%b3"
1603 [(set_attr "op_type" "VRR")])
1606 ; The result needs to be multiplied with 2**-op2
1607 (define_expand "vec_ctd_s64"
1608 [(set (match_operand:V2DF 0 "register_operand" "")
1609 (unspec:V2DF [(match_operand:V2DI 1 "register_operand" "")
1610 (const_int 4) ; inexact suppressed
1611 (const_int VEC_RND_CURRENT)]
1613 (use (match_operand:QI 2 "const_int_operand" ""))
1614 (set (match_dup 0) (mult:V2DF (match_dup 0) (match_dup 3)))]
1620 real_2expN (&f, -INTVAL (operands[2]), DFmode);
1621 c = const_double_from_real_value (f, DFmode);
1623 operands[3] = gen_rtx_CONST_VECTOR (V2DFmode, gen_rtvec (2, c, c));
1624 operands[3] = force_reg (V2DFmode, operands[3]);
1627 (define_insn "vcdlgb"
1628 [(set (match_operand:V2DF 0 "register_operand" "=v")
1629 (unspec:V2DF [(match_operand:V2DI 1 "register_operand" "v")
1630 (match_operand:QI 2 "const_mask_operand" "C") ; inexact suppression
1631 (match_operand:QI 3 "const_mask_operand" "C")] ; rounding mode
1632 UNSPEC_VEC_VCDLGB))]
1633 "TARGET_VX && UINTVAL (operands[3]) != 2 && UINTVAL (operands[3]) <= 7"
1634 "vcdlgb\t%v0,%v1,%b2,%b3"
1635 [(set_attr "op_type" "VRR")])
1637 ; The result needs to be multiplied with 2**-op2
1638 (define_expand "vec_ctd_u64"
1639 [(set (match_operand:V2DF 0 "register_operand" "")
1640 (unspec:V2DF [(match_operand:V2DI 1 "register_operand" "")
1641 (const_int 4) ; inexact suppressed
1642 (const_int VEC_RND_CURRENT)]
1644 (use (match_operand:QI 2 "const_int_operand" ""))
1645 (set (match_dup 0) (mult:V2DF (match_dup 0) (match_dup 3)))]
1651 real_2expN (&f, -INTVAL (operands[2]), DFmode);
1652 c = const_double_from_real_value (f, DFmode);
1654 operands[3] = gen_rtx_CONST_VECTOR (V2DFmode, gen_rtvec (2, c, c));
1655 operands[3] = force_reg (V2DFmode, operands[3]);
1658 (define_insn "vcgdb"
1659 [(set (match_operand:V2DI 0 "register_operand" "=v")
1660 (unspec:V2DI [(match_operand:V2DF 1 "register_operand" "v")
1661 (match_operand:QI 2 "const_mask_operand" "C")
1662 (match_operand:QI 3 "const_mask_operand" "C")]
1664 "TARGET_VX && UINTVAL (operands[3]) != 2 && UINTVAL (operands[3]) <= 7"
1665 "vcgdb\t%v0,%v1,%b2,%b3"
1666 [(set_attr "op_type" "VRR")])
1668 ; The input needs to be multiplied with 2**op2
1669 (define_expand "vec_ctsl"
1670 [(use (match_operand:QI 2 "const_int_operand" ""))
1671 (set (match_dup 4) (mult:V2DF (match_operand:V2DF 1 "register_operand" "")
1673 (set (match_operand:V2DI 0 "register_operand" "")
1674 (unspec:V2DI [(match_dup 4)
1675 (const_int 4) ; inexact suppressed
1676 (const_int VEC_RND_CURRENT)]
1683 real_2expN (&f, INTVAL (operands[2]), DFmode);
1684 c = const_double_from_real_value (f, DFmode);
1686 operands[3] = gen_rtx_CONST_VECTOR (V2DFmode, gen_rtvec (2, c, c));
1687 operands[3] = force_reg (V2DFmode, operands[3]);
1688 operands[4] = gen_reg_rtx (V2DFmode);
1691 (define_insn "vclgdb"
1692 [(set (match_operand:V2DI 0 "register_operand" "=v")
1693 (unspec:V2DI [(match_operand:V2DF 1 "register_operand" "v")
1694 (match_operand:QI 2 "const_mask_operand" "C")
1695 (match_operand:QI 3 "const_mask_operand" "C")]
1696 UNSPEC_VEC_VCLGDB))]
1697 "TARGET_VX && UINTVAL (operands[3]) != 2 && UINTVAL (operands[3]) <= 7"
1698 "vclgdb\t%v0,%v1,%b2,%b3"
1699 [(set_attr "op_type" "VRR")])
1701 ; The input needs to be multiplied with 2**op2
1702 (define_expand "vec_ctul"
1703 [(use (match_operand:QI 2 "const_int_operand" ""))
1704 (set (match_dup 4) (mult:V2DF (match_operand:V2DF 1 "register_operand" "")
1706 (set (match_operand:V2DI 0 "register_operand" "")
1707 (unspec:V2DI [(match_dup 4)
1708 (const_int 4) ; inexact suppressed
1709 (const_int VEC_RND_CURRENT)]
1710 UNSPEC_VEC_VCLGDB))]
1716 real_2expN (&f, INTVAL (operands[2]), DFmode);
1717 c = const_double_from_real_value (f, DFmode);
1719 operands[3] = gen_rtx_CONST_VECTOR (V2DFmode, gen_rtvec (2, c, c));
1720 operands[3] = force_reg (V2DFmode, operands[3]);
1721 operands[4] = gen_reg_rtx (V2DFmode);
1724 ; Vector load fp integer - IEEE inexact exception is suppressed
1725 ; vfisb, vfidb, wfisb, wfidb, wfixb
1726 (define_insn "vec_fpint<mode>"
1727 [(set (match_operand:VFT 0 "register_operand" "=v")
1728 (unspec:VFT [(match_operand:VFT 1 "register_operand" "v")
1729 (match_operand:QI 2 "const_mask_operand" "C") ; inexact suppression control
1730 (match_operand:QI 3 "const_mask_operand" "C")] ; rounding mode
1733 "<vw>fi<sdx>b\t%v0,%v1,%b2,%b3"
1734 [(set_attr "op_type" "VRR")])
1737 ; Vector load lengthened - V4SF -> V2DF
1739 (define_insn "vflls"
1740 [(set (match_operand:V2DF 0 "register_operand" "=v")
1741 (unspec:V2DF [(match_operand:V4SF 1 "register_operand" "v")]
1745 [(set_attr "op_type" "VRR")])
1747 (define_expand "vec_ld2f"
1748 [; Initialize a vector to all zeroes. FIXME: This should not be
1749 ; necessary since all elements of the vector will be set anyway.
1750 ; This is just to make it explicit to the data flow framework.
1751 (set (match_dup 2) (match_dup 3))
1752 (set (match_dup 2) (unspec:V4SF [(match_operand:SF 1 "memory_operand" "")
1756 (set (match_dup 2) (unspec:V4SF [(match_dup 4)
1760 (set (match_operand:V2DF 0 "register_operand" "")
1761 (unspec:V2DF [(match_dup 2)] UNSPEC_VEC_VFLL))]
1764 operands[2] = gen_reg_rtx (V4SFmode);
1765 operands[3] = CONST0_RTX (V4SFmode);
1766 operands[4] = adjust_address (operands[1], SFmode, 4);
1770 ; Vector load rounded - V2DF -> V4SF
1772 (define_insn "vflrd"
1773 [(set (match_operand:V4SF 0 "register_operand" "=v")
1774 (unspec:V4SF [(match_operand:V2DF 1 "register_operand" "v")
1775 (match_operand:QI 2 "const_mask_operand" "C")
1776 (match_operand:QI 3 "const_mask_operand" "C")]
1779 "vledb\t%v0,%v1,%b2,%b3"
1780 [(set_attr "op_type" "VRR")])
1782 (define_expand "vec_st2f"
1784 (unspec:V4SF [(match_operand:V2DF 0 "register_operand" "")
1785 (const_int VEC_INEXACT)
1786 (const_int VEC_RND_CURRENT)]
1788 (set (match_operand:SF 1 "memory_operand" "")
1789 (unspec:SF [(match_dup 2) (const_int 0)] UNSPEC_VEC_EXTRACT))
1791 (unspec:SF [(match_dup 2) (const_int 2)] UNSPEC_VEC_EXTRACT))]
1794 operands[2] = gen_reg_rtx (V4SFmode);
1795 operands[3] = adjust_address (operands[1], SFmode, 4);
1799 ; Vector square root fp vec_sqrt -> sqrt rtx standard name
1801 ;; Vector FP test data class immediate
1803 ; vec_all_nan, vec_all_numeric, vec_any_nan, vec_any_numeric
1804 ; These ignore the vector result and only want CC stored to an int
1808 (define_insn "*vftci<mode>_cconly"
1809 [(set (reg:CCRAW CC_REGNUM)
1810 (unspec:CCRAW [(match_operand:VECF_HW 1 "register_operand")
1811 (match_operand:HI 2 "const_int_operand")]
1812 UNSPEC_VEC_VFTCICC))
1813 (clobber (match_scratch:<tointvec> 0))]
1814 "TARGET_VX && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'J', \"J\")"
1815 "vftci<sdx>b\t%v0,%v1,%x2"
1816 [(set_attr "op_type" "VRR")])
1818 (define_expand "vftci<mode>_intcconly"
1820 [(set (reg:CCRAW CC_REGNUM)
1821 (unspec:CCRAW [(match_operand:VECF_HW 0 "register_operand")
1822 (match_operand:HI 1 "const_int_operand")]
1823 UNSPEC_VEC_VFTCICC))
1824 (clobber (scratch:<tointvec>))])
1825 (set (match_operand:SI 2 "register_operand" "")
1826 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1827 "TARGET_VX && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'J', \"J\")")
1829 ; vec_fp_test_data_class wants the result vector and the CC stored to
1833 (define_insn "*vftci<mode>"
1834 [(set (match_operand:VECF_HW 0 "register_operand" "=v")
1835 (unspec:VECF_HW [(match_operand:VECF_HW 1 "register_operand" "v")
1836 (match_operand:HI 2 "const_int_operand" "J")]
1838 (set (reg:CCRAW CC_REGNUM)
1839 (unspec:CCRAW [(match_dup 1) (match_dup 2)] UNSPEC_VEC_VFTCICC))]
1840 "TARGET_VX && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'J', \"J\")"
1841 "vftci<sdx>b\t%v0,%v1,%x2"
1842 [(set_attr "op_type" "VRR")])
1844 (define_expand "vftci<mode>_intcc"
1846 [(set (match_operand:VECF_HW 0 "register_operand")
1847 (unspec:VECF_HW [(match_operand:VECF_HW 1 "register_operand")
1848 (match_operand:HI 2 "const_int_operand")]
1850 (set (reg:CCRAW CC_REGNUM)
1851 (unspec:CCRAW [(match_dup 1) (match_dup 2)] UNSPEC_VEC_VFTCICC))])
1852 (set (match_operand:SI 3 "memory_operand" "")
1853 (unspec:SI [(reg:CCRAW CC_REGNUM)] UNSPEC_CC_TO_INT))]
1854 "TARGET_VX && CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[2]), 'J', \"J\")")
1860 ; All comparisons which produce a CC need fully populated (VI_HW)
1861 ; vector arguments. Otherwise the any/all CCs would be just bogus.
1863 (define_insn "*vec_cmp<VICMP:insn_cmp><VI_HW:mode>_cconly"
1864 [(set (reg:VICMP CC_REGNUM)
1865 (compare:VICMP (match_operand:VI_HW 0 "register_operand" "v")
1866 (match_operand:VI_HW 1 "register_operand" "v")))
1867 (clobber (match_scratch:VI_HW 2 "=v"))]
1869 "vc<VICMP:insn_cmp><VI_HW:bhfgq>s\t%v2,%v0,%v1"
1870 [(set_attr "op_type" "VRR")])
1872 ; FIXME: The following 2x3 definitions should be merged into 2 with
1873 ; VICMP like above but I could not find a way to set the comparison
1874 ; operator (eq) depending on the mode CCVEQ (mode_iterator). Or the
1875 ; other way around - setting the mode depending on the code
1877 (define_expand "vec_cmpeq<VI_HW:mode>_cc"
1879 [(set (reg:CCVEQ CC_REGNUM)
1880 (compare:CCVEQ (match_operand:VI_HW 1 "register_operand" "v")
1881 (match_operand:VI_HW 2 "register_operand" "v")))
1882 (set (match_operand:VI_HW 0 "register_operand" "=v")
1883 (eq:VI_HW (match_dup 1) (match_dup 2)))])
1884 (set (match_operand:SI 3 "memory_operand" "")
1885 (unspec:SI [(reg:CCVEQ CC_REGNUM)] UNSPEC_CC_TO_INT))]
1888 (define_expand "vec_cmph<VI_HW:mode>_cc"
1890 [(set (reg:CCVIH CC_REGNUM)
1891 (compare:CCVIH (match_operand:VI_HW 1 "register_operand" "v")
1892 (match_operand:VI_HW 2 "register_operand" "v")))
1893 (set (match_operand:VI_HW 0 "register_operand" "=v")
1894 (gt:VI_HW (match_dup 1) (match_dup 2)))])
1895 (set (match_operand:SI 3 "memory_operand" "")
1896 (unspec:SI [(reg:CCVIH CC_REGNUM)] UNSPEC_CC_TO_INT))]
1899 (define_expand "vec_cmphl<VI_HW:mode>_cc"
1901 [(set (reg:CCVIHU CC_REGNUM)
1902 (compare:CCVIHU (match_operand:VI_HW 1 "register_operand" "v")
1903 (match_operand:VI_HW 2 "register_operand" "v")))
1904 (set (match_operand:VI_HW 0 "register_operand" "=v")
1905 (gtu:VI_HW (match_dup 1) (match_dup 2)))])
1906 (set (match_operand:SI 3 "memory_operand" "")
1907 (unspec:SI [(reg:CCVIHU CC_REGNUM)] UNSPEC_CC_TO_INT))]
1911 (define_insn "*vec_cmpeq<VI_HW:mode>_cc"
1912 [(set (reg:CCVEQ CC_REGNUM)
1913 (compare:CCVEQ (match_operand:VI_HW 0 "register_operand" "v")
1914 (match_operand:VI_HW 1 "register_operand" "v")))
1915 (set (match_operand:VI_HW 2 "register_operand" "=v")
1916 (eq:VI_HW (match_dup 0) (match_dup 1)))]
1918 "vceq<VI_HW:bhfgq>s\t%v2,%v0,%v1"
1919 [(set_attr "op_type" "VRR")])
1921 (define_insn "*vec_cmph<VI_HW:mode>_cc"
1922 [(set (reg:CCVIH CC_REGNUM)
1923 (compare:CCVIH (match_operand:VI_HW 0 "register_operand" "v")
1924 (match_operand:VI_HW 1 "register_operand" "v")))
1925 (set (match_operand:VI_HW 2 "register_operand" "=v")
1926 (gt:VI_HW (match_dup 0) (match_dup 1)))]
1928 "vch<VI_HW:bhfgq>s\t%v2,%v0,%v1"
1929 [(set_attr "op_type" "VRR")])
1931 (define_insn "*vec_cmphl<VI_HW:mode>_cc"
1932 [(set (reg:CCVIHU CC_REGNUM)
1933 (compare:CCVIHU (match_operand:VI_HW 0 "register_operand" "v")
1934 (match_operand:VI_HW 1 "register_operand" "v")))
1935 (set (match_operand:VI_HW 2 "register_operand" "=v")
1936 (gtu:VI_HW (match_dup 0) (match_dup 1)))]
1938 "vchl<VI_HW:bhfgq>s\t%v2,%v0,%v1"
1939 [(set_attr "op_type" "VRR")])
1942 ;; Floating point compares
1945 ; vfcesbs, vfcedbs, wfcexbs, vfchsbs, vfchdbs, wfchxbs, vfchesbs, vfchedbs, wfchexbs
1946 (define_insn "*vec_cmp<insn_cmp><mode>_cconly"
1947 [(set (reg:VFCMP CC_REGNUM)
1948 (compare:VFCMP (match_operand:VF_HW 0 "register_operand" "v")
1949 (match_operand:VF_HW 1 "register_operand" "v")))
1950 (clobber (match_scratch:<tointvec> 2 "=v"))]
1952 "<vw>fc<asm_fcmp><sdx>bs\t%v2,%v0,%v1"
1953 [(set_attr "op_type" "VRR")])
1955 ; FIXME: Merge the following 2x3 patterns with VFCMP
1956 (define_expand "vec_cmpeq<mode>_cc"
1958 [(set (reg:CCVEQ CC_REGNUM)
1959 (compare:CCVEQ (match_operand:VF_HW 1 "register_operand" "v")
1960 (match_operand:VF_HW 2 "register_operand" "v")))
1961 (set (match_operand:<tointvec> 0 "register_operand" "=v")
1962 (eq:<tointvec> (match_dup 1) (match_dup 2)))])
1963 (set (match_operand:SI 3 "memory_operand" "")
1964 (unspec:SI [(reg:CCVEQ CC_REGNUM)] UNSPEC_CC_TO_INT))]
1967 (define_expand "vec_cmph<mode>_cc"
1969 [(set (reg:CCVFH CC_REGNUM)
1970 (compare:CCVFH (match_operand:VF_HW 1 "register_operand" "v")
1971 (match_operand:VF_HW 2 "register_operand" "v")))
1972 (set (match_operand:<tointvec> 0 "register_operand" "=v")
1973 (gt:<tointvec> (match_dup 1) (match_dup 2)))])
1974 (set (match_operand:SI 3 "memory_operand" "")
1975 (unspec:SI [(reg:CCVIH CC_REGNUM)] UNSPEC_CC_TO_INT))]
1978 (define_expand "vec_cmphe<mode>_cc"
1980 [(set (reg:CCVFHE CC_REGNUM)
1981 (compare:CCVFHE (match_operand:VF_HW 1 "register_operand" "v")
1982 (match_operand:VF_HW 2 "register_operand" "v")))
1983 (set (match_operand:<tointvec> 0 "register_operand" "=v")
1984 (ge:<tointvec> (match_dup 1) (match_dup 2)))])
1985 (set (match_operand:SI 3 "memory_operand" "")
1986 (unspec:SI [(reg:CCVFHE CC_REGNUM)] UNSPEC_CC_TO_INT))]
1989 ; These 3 cannot be merged as the insn defintion above since it also
1990 ; requires to rewrite the RTL equality operator that the same time as
1993 ; vfcesbs, vfcedbs, wfcexbs
1994 (define_insn "*vec_cmpeq<mode>_cc"
1995 [(set (reg:CCVEQ CC_REGNUM)
1996 (compare:CCVEQ (match_operand:VF_HW 0 "register_operand" "v")
1997 (match_operand:VF_HW 1 "register_operand" "v")))
1998 (set (match_operand:<tointvec> 2 "register_operand" "=v")
1999 (eq:<tointvec> (match_dup 0) (match_dup 1)))]
2001 "<vw>fce<sdx>bs\t%v2,%v0,%v1"
2002 [(set_attr "op_type" "VRR")])
2004 ; vfchsbs, vfchdbs, wfchxbs
2005 (define_insn "*vec_cmph<mode>_cc"
2006 [(set (reg:CCVFH CC_REGNUM)
2007 (compare:CCVFH (match_operand:VF_HW 0 "register_operand" "v")
2008 (match_operand:VF_HW 1 "register_operand" "v")))
2009 (set (match_operand:<tointvec> 2 "register_operand" "=v")
2010 (gt:<tointvec> (match_dup 0) (match_dup 1)))]
2012 "<vw>fch<sdx>bs\t%v2,%v0,%v1"
2013 [(set_attr "op_type" "VRR")])
2015 ; vfchesbs, vfchedbs, wfchexbs
2016 (define_insn "*vec_cmphe<mode>_cc"
2017 [(set (reg:CCVFHE CC_REGNUM)
2018 (compare:CCVFHE (match_operand:VF_HW 0 "register_operand" "v")
2019 (match_operand:VF_HW 1 "register_operand" "v")))
2020 (set (match_operand:<tointvec> 2 "register_operand" "=v")
2021 (ge:<tointvec> (match_dup 0) (match_dup 1)))]
2023 "<vw>fche<sdx>bs\t%v2,%v0,%v1"
2024 [(set_attr "op_type" "VRR")])
2026 (define_expand "vec_double_s64"
2027 [(set (match_operand:V2DF 0 "register_operand")
2028 (unspec:V2DF [(match_operand:V2DI 1 "register_operand")
2029 (const_int 0) ; inexact suppression disabled
2030 (const_int VEC_RND_CURRENT)]
2034 (define_expand "vec_double_u64"
2035 [(set (match_operand:V2DF 0 "register_operand")
2036 (unspec:V2DF [(match_operand:V2DI 1 "register_operand")
2037 (const_int 0) ; inexact suppression disabled
2038 (const_int VEC_RND_CURRENT)]
2039 UNSPEC_VEC_VCDLGB))]
2043 (define_insn "vfmin<mode>"
2044 [(set (match_operand:VF_HW 0 "register_operand" "=v")
2045 (unspec:VF_HW [(match_operand:VF_HW 1 "register_operand" "%v")
2046 (match_operand:VF_HW 2 "register_operand" "v")
2047 (match_operand:QI 3 "const_mask_operand" "C")]
2050 "<vw>fmin<sdx>b\t%v0,%v1,%v2,%b3"
2051 [(set_attr "op_type" "VRR")])
2053 (define_insn "vfmax<mode>"
2054 [(set (match_operand:VF_HW 0 "register_operand" "=v")
2055 (unspec:VF_HW [(match_operand:VF_HW 1 "register_operand" "%v")
2056 (match_operand:VF_HW 2 "register_operand" "v")
2057 (match_operand:QI 3 "const_mask_operand" "C")]
2060 "<vw>fmax<sdx>b\t%v0,%v1,%v2,%b3"
2061 [(set_attr "op_type" "VRR")])