1 ;; Expander definitions for vector support between altivec & vsx. No
2 ;; instructions are in this file, this file provides the generic vector
3 ;; expander, and the actual vector instructions will be in altivec.md and
6 ;; Copyright (C) 2009-2018 Free Software Foundation, Inc.
7 ;; Contributed by Michael Meissner <meissner@linux.vnet.ibm.com>
9 ;; This file is part of GCC.
11 ;; GCC is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published
13 ;; by the Free Software Foundation; either version 3, or (at your
14 ;; option) any later version.
16 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
19 ;; License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GCC; see the file COPYING3. If not see
23 ;; <http://www.gnu.org/licenses/>.
27 (define_mode_iterator VEC_I [V16QI V8HI V4SI V2DI])
29 ;; Vector int modes for parity
30 (define_mode_iterator VEC_IP [V8HI
34 (TI "TARGET_VSX_TIMODE")])
37 (define_mode_iterator VEC_F [V4SF V2DF])
39 ;; Vector arithmetic modes
40 (define_mode_iterator VEC_A [V16QI V8HI V4SI V2DI V4SF V2DF])
42 ;; Vector modes that need alginment via permutes
43 (define_mode_iterator VEC_K [V16QI V8HI V4SI V4SF])
45 ;; Vector logical modes
46 (define_mode_iterator VEC_L [V16QI V8HI V4SI V2DI V4SF V2DF V1TI TI KF TF])
48 ;; Vector modes for moves. Don't do TImode or TFmode here, since their
49 ;; moves are handled elsewhere.
50 (define_mode_iterator VEC_M [V16QI V8HI V4SI V2DI V4SF V2DF V1TI KF])
52 ;; Vector modes for types that don't need a realignment under VSX
53 (define_mode_iterator VEC_N [V4SI V4SF V2DI V2DF V1TI KF TF])
55 ;; Vector comparison modes
56 (define_mode_iterator VEC_C [V16QI V8HI V4SI V2DI V4SF V2DF])
58 ;; Vector init/extract modes
59 (define_mode_iterator VEC_E [V16QI V8HI V4SI V2DI V4SF V2DF])
61 ;; Vector modes for 64-bit base types
62 (define_mode_iterator VEC_64 [V2DI V2DF])
64 ;; Vector integer modes
65 (define_mode_iterator VI [V4SI V8HI V16QI])
67 ;; Base type from vector mode
68 (define_mode_attr VEC_base [(V16QI "QI")
77 ;; As above, but in lower case
78 (define_mode_attr VEC_base_l [(V16QI "qi")
87 ;; Same size integer type for floating point data
88 (define_mode_attr VEC_int [(V4SF "v4si")
91 (define_mode_attr VEC_INT [(V4SF "V4SI")
94 ;; constants for unspec
95 (define_c_enum "unspec" [UNSPEC_PREDICATE
99 ;; Vector reduction code iterators
100 (define_code_iterator VEC_reduc [plus smin smax])
102 (define_code_attr VEC_reduc_name [(plus "plus")
106 (define_code_attr VEC_reduc_rtx [(plus "add")
111 ;; Vector move instructions. Little-endian VSX loads and stores require
112 ;; special handling to circumvent "element endianness."
113 (define_expand "mov<mode>"
114 [(set (match_operand:VEC_M 0 "nonimmediate_operand" "")
115 (match_operand:VEC_M 1 "any_operand" ""))]
116 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
118 if (can_create_pseudo_p ())
120 if (CONSTANT_P (operands[1]))
122 if (FLOAT128_VECTOR_P (<MODE>mode))
124 if (!easy_fp_constant (operands[1], <MODE>mode))
125 operands[1] = force_const_mem (<MODE>mode, operands[1]);
127 else if (!easy_vector_constant (operands[1], <MODE>mode))
128 operands[1] = force_const_mem (<MODE>mode, operands[1]);
131 if (!vlogical_operand (operands[0], <MODE>mode)
132 && !vlogical_operand (operands[1], <MODE>mode))
133 operands[1] = force_reg (<MODE>mode, operands[1]);
135 if (!BYTES_BIG_ENDIAN
136 && VECTOR_MEM_VSX_P (<MODE>mode)
138 && !gpr_or_gpr_p (operands[0], operands[1])
139 && (memory_operand (operands[0], <MODE>mode)
140 ^ memory_operand (operands[1], <MODE>mode)))
142 rs6000_emit_le_vsx_move (operands[0], operands[1], <MODE>mode);
147 ;; Generic vector floating point load/store instructions. These will match
148 ;; insns defined in vsx.md or altivec.md depending on the switches.
149 (define_expand "vector_load_<mode>"
150 [(set (match_operand:VEC_M 0 "vfloat_operand" "")
151 (match_operand:VEC_M 1 "memory_operand" ""))]
152 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
155 (define_expand "vector_store_<mode>"
156 [(set (match_operand:VEC_M 0 "memory_operand" "")
157 (match_operand:VEC_M 1 "vfloat_operand" ""))]
158 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
161 ;; Splits if a GPR register was chosen for the move
163 [(set (match_operand:VEC_L 0 "nonimmediate_operand" "")
164 (match_operand:VEC_L 1 "input_operand" ""))]
165 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)
167 && gpr_or_gpr_p (operands[0], operands[1])
168 && !direct_move_p (operands[0], operands[1])
169 && !quad_load_store_p (operands[0], operands[1])"
172 rs6000_split_multireg_move (operands[0], operands[1]);
176 ;; Vector floating point load/store instructions that uses the Altivec
177 ;; instructions even if we are compiling for VSX, since the Altivec
178 ;; instructions silently ignore the bottom 3 bits of the address, and VSX does
180 (define_expand "vector_altivec_load_<mode>"
181 [(set (match_operand:VEC_M 0 "vfloat_operand" "")
182 (match_operand:VEC_M 1 "memory_operand" ""))]
183 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
186 gcc_assert (VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode));
188 if (VECTOR_MEM_VSX_P (<MODE>mode))
190 operands[1] = rs6000_address_for_altivec (operands[1]);
191 rtx and_op = XEXP (operands[1], 0);
192 gcc_assert (GET_CODE (and_op) == AND);
193 rtx addr = XEXP (and_op, 0);
194 if (GET_CODE (addr) == PLUS)
195 emit_insn (gen_altivec_lvx_<mode>_2op (operands[0], XEXP (addr, 0),
198 emit_insn (gen_altivec_lvx_<mode>_1op (operands[0], operands[1]));
203 (define_expand "vector_altivec_store_<mode>"
204 [(set (match_operand:VEC_M 0 "memory_operand" "")
205 (match_operand:VEC_M 1 "vfloat_operand" ""))]
206 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
209 gcc_assert (VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode));
211 if (VECTOR_MEM_VSX_P (<MODE>mode))
213 operands[0] = rs6000_address_for_altivec (operands[0]);
214 rtx and_op = XEXP (operands[0], 0);
215 gcc_assert (GET_CODE (and_op) == AND);
216 rtx addr = XEXP (and_op, 0);
217 if (GET_CODE (addr) == PLUS)
218 emit_insn (gen_altivec_stvx_<mode>_2op (operands[1], XEXP (addr, 0),
221 emit_insn (gen_altivec_stvx_<mode>_1op (operands[1], operands[0]));
228 ;; Generic floating point vector arithmetic support
229 (define_expand "add<mode>3"
230 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
231 (plus:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
232 (match_operand:VEC_F 2 "vfloat_operand" "")))]
233 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
236 (define_expand "sub<mode>3"
237 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
238 (minus:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
239 (match_operand:VEC_F 2 "vfloat_operand" "")))]
240 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
243 (define_expand "mul<mode>3"
244 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
245 (mult:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
246 (match_operand:VEC_F 2 "vfloat_operand" "")))]
247 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
249 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
251 emit_insn (gen_altivec_mulv4sf3 (operands[0], operands[1], operands[2]));
256 (define_expand "div<mode>3"
257 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
258 (div:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
259 (match_operand:VEC_F 2 "vfloat_operand" "")))]
260 "VECTOR_UNIT_VSX_P (<MODE>mode)"
262 if (RS6000_RECIP_AUTO_RE_P (<MODE>mode)
263 && can_create_pseudo_p () && flag_finite_math_only
264 && !flag_trapping_math && flag_reciprocal_math)
266 rs6000_emit_swdiv (operands[0], operands[1], operands[2], true);
271 (define_expand "neg<mode>2"
272 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
273 (neg:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
274 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
277 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
279 emit_insn (gen_altivec_negv4sf2 (operands[0], operands[1]));
284 (define_expand "abs<mode>2"
285 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
286 (abs:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
287 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
290 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
292 emit_insn (gen_altivec_absv4sf2 (operands[0], operands[1]));
297 (define_expand "smin<mode>3"
298 [(set (match_operand:VEC_F 0 "register_operand" "")
299 (smin:VEC_F (match_operand:VEC_F 1 "register_operand" "")
300 (match_operand:VEC_F 2 "register_operand" "")))]
301 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
304 (define_expand "smax<mode>3"
305 [(set (match_operand:VEC_F 0 "register_operand" "")
306 (smax:VEC_F (match_operand:VEC_F 1 "register_operand" "")
307 (match_operand:VEC_F 2 "register_operand" "")))]
308 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
312 (define_expand "sqrt<mode>2"
313 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
314 (sqrt:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
315 "VECTOR_UNIT_VSX_P (<MODE>mode)"
317 if (<MODE>mode == V4SFmode
318 && !optimize_function_for_size_p (cfun)
319 && flag_finite_math_only && !flag_trapping_math
320 && flag_unsafe_math_optimizations)
322 rs6000_emit_swsqrt (operands[0], operands[1], 0);
327 (define_expand "rsqrte<mode>2"
328 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
329 (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
331 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
334 (define_expand "re<mode>2"
335 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
336 (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "f")]
338 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
341 (define_expand "ftrunc<mode>2"
342 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
343 (fix:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
344 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
347 (define_expand "vector_ceil<mode>2"
348 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
349 (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
351 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
354 (define_expand "vector_floor<mode>2"
355 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
356 (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
358 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
361 (define_expand "vector_btrunc<mode>2"
362 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
363 (fix:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
364 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
367 (define_expand "vector_copysign<mode>3"
368 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
369 (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")
370 (match_operand:VEC_F 2 "vfloat_operand" "")] UNSPEC_COPYSIGN))]
371 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
374 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
376 emit_insn (gen_altivec_copysign_v4sf3 (operands[0], operands[1],
383 ;; Vector comparisons
384 (define_expand "vcond<mode><mode>"
385 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
387 (match_operator 3 "comparison_operator"
388 [(match_operand:VEC_F 4 "vfloat_operand" "")
389 (match_operand:VEC_F 5 "vfloat_operand" "")])
390 (match_operand:VEC_F 1 "vfloat_operand" "")
391 (match_operand:VEC_F 2 "vfloat_operand" "")))]
392 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
395 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
396 operands[3], operands[4], operands[5]))
402 (define_expand "vcond<mode><mode>"
403 [(set (match_operand:VEC_I 0 "vint_operand")
405 (match_operator 3 "comparison_operator"
406 [(match_operand:VEC_I 4 "vint_operand")
407 (match_operand:VEC_I 5 "vint_operand")])
408 (match_operand:VEC_I 1 "vector_int_reg_or_same_bit")
409 (match_operand:VEC_I 2 "vector_int_reg_or_same_bit")))]
410 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
413 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
414 operands[3], operands[4], operands[5]))
420 (define_expand "vcondv4sfv4si"
421 [(set (match_operand:V4SF 0 "vfloat_operand" "")
423 (match_operator 3 "comparison_operator"
424 [(match_operand:V4SI 4 "vint_operand" "")
425 (match_operand:V4SI 5 "vint_operand" "")])
426 (match_operand:V4SF 1 "vfloat_operand" "")
427 (match_operand:V4SF 2 "vfloat_operand" "")))]
428 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)
429 && VECTOR_UNIT_ALTIVEC_P (V4SImode)"
432 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
433 operands[3], operands[4], operands[5]))
439 (define_expand "vcondv4siv4sf"
440 [(set (match_operand:V4SI 0 "vint_operand" "")
442 (match_operator 3 "comparison_operator"
443 [(match_operand:V4SF 4 "vfloat_operand" "")
444 (match_operand:V4SF 5 "vfloat_operand" "")])
445 (match_operand:V4SI 1 "vint_operand" "")
446 (match_operand:V4SI 2 "vint_operand" "")))]
447 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)
448 && VECTOR_UNIT_ALTIVEC_P (V4SImode)"
451 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
452 operands[3], operands[4], operands[5]))
458 (define_expand "vcondu<mode><mode>"
459 [(set (match_operand:VEC_I 0 "vint_operand")
461 (match_operator 3 "comparison_operator"
462 [(match_operand:VEC_I 4 "vint_operand")
463 (match_operand:VEC_I 5 "vint_operand")])
464 (match_operand:VEC_I 1 "vector_int_reg_or_same_bit")
465 (match_operand:VEC_I 2 "vector_int_reg_or_same_bit")))]
466 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
469 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
470 operands[3], operands[4], operands[5]))
476 (define_expand "vconduv4sfv4si"
477 [(set (match_operand:V4SF 0 "vfloat_operand" "")
479 (match_operator 3 "comparison_operator"
480 [(match_operand:V4SI 4 "vint_operand" "")
481 (match_operand:V4SI 5 "vint_operand" "")])
482 (match_operand:V4SF 1 "vfloat_operand" "")
483 (match_operand:V4SF 2 "vfloat_operand" "")))]
484 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)
485 && VECTOR_UNIT_ALTIVEC_P (V4SImode)"
488 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
489 operands[3], operands[4], operands[5]))
495 (define_expand "vector_eq<mode>"
496 [(set (match_operand:VEC_C 0 "vlogical_operand" "")
497 (eq:VEC_C (match_operand:VEC_C 1 "vlogical_operand" "")
498 (match_operand:VEC_C 2 "vlogical_operand" "")))]
499 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
502 (define_expand "vector_gt<mode>"
503 [(set (match_operand:VEC_C 0 "vlogical_operand" "")
504 (gt:VEC_C (match_operand:VEC_C 1 "vlogical_operand" "")
505 (match_operand:VEC_C 2 "vlogical_operand" "")))]
506 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
509 (define_expand "vector_ge<mode>"
510 [(set (match_operand:VEC_F 0 "vlogical_operand" "")
511 (ge:VEC_F (match_operand:VEC_F 1 "vlogical_operand" "")
512 (match_operand:VEC_F 2 "vlogical_operand" "")))]
513 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
516 ; >= for integer vectors: swap operands and apply not-greater-than
517 (define_expand "vector_nlt<mode>"
518 [(set (match_operand:VEC_I 3 "vlogical_operand" "")
519 (gt:VEC_I (match_operand:VEC_I 2 "vlogical_operand" "")
520 (match_operand:VEC_I 1 "vlogical_operand" "")))
521 (set (match_operand:VEC_I 0 "vlogical_operand" "")
522 (not:VEC_I (match_dup 3)))]
523 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
526 operands[3] = gen_reg_rtx_and_attrs (operands[0]);
529 (define_expand "vector_gtu<mode>"
530 [(set (match_operand:VEC_I 0 "vint_operand" "")
531 (gtu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
532 (match_operand:VEC_I 2 "vint_operand" "")))]
533 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
536 ; >= for integer vectors: swap operands and apply not-greater-than
537 (define_expand "vector_nltu<mode>"
538 [(set (match_operand:VEC_I 3 "vlogical_operand" "")
539 (gtu:VEC_I (match_operand:VEC_I 2 "vlogical_operand" "")
540 (match_operand:VEC_I 1 "vlogical_operand" "")))
541 (set (match_operand:VEC_I 0 "vlogical_operand" "")
542 (not:VEC_I (match_dup 3)))]
543 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
546 operands[3] = gen_reg_rtx_and_attrs (operands[0]);
549 (define_expand "vector_geu<mode>"
550 [(set (match_operand:VEC_I 0 "vint_operand" "")
551 (geu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
552 (match_operand:VEC_I 2 "vint_operand" "")))]
553 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
556 ; <= for integer vectors: apply not-greater-than
557 (define_expand "vector_ngt<mode>"
558 [(set (match_operand:VEC_I 3 "vlogical_operand" "")
559 (gt:VEC_I (match_operand:VEC_I 1 "vlogical_operand" "")
560 (match_operand:VEC_I 2 "vlogical_operand" "")))
561 (set (match_operand:VEC_I 0 "vlogical_operand" "")
562 (not:VEC_I (match_dup 3)))]
563 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
566 operands[3] = gen_reg_rtx_and_attrs (operands[0]);
569 (define_expand "vector_ngtu<mode>"
570 [(set (match_operand:VEC_I 3 "vlogical_operand" "")
571 (gtu:VEC_I (match_operand:VEC_I 1 "vlogical_operand" "")
572 (match_operand:VEC_I 2 "vlogical_operand" "")))
573 (set (match_operand:VEC_I 0 "vlogical_operand" "")
574 (not:VEC_I (match_dup 3)))]
575 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
578 operands[3] = gen_reg_rtx_and_attrs (operands[0]);
581 (define_insn_and_split "*vector_uneq<mode>"
582 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
583 (uneq:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
584 (match_operand:VEC_F 2 "vfloat_operand" "")))]
585 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
589 (gt:VEC_F (match_dup 1)
592 (gt:VEC_F (match_dup 2)
595 (not:VEC_F (ior:VEC_F (match_dup 3)
599 operands[3] = gen_reg_rtx (<MODE>mode);
600 operands[4] = gen_reg_rtx (<MODE>mode);
603 (define_insn_and_split "*vector_ltgt<mode>"
604 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
605 (ltgt:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
606 (match_operand:VEC_F 2 "vfloat_operand" "")))]
607 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
611 (gt:VEC_F (match_dup 1)
614 (gt:VEC_F (match_dup 2)
617 (ior:VEC_F (match_dup 3)
621 operands[3] = gen_reg_rtx (<MODE>mode);
622 operands[4] = gen_reg_rtx (<MODE>mode);
625 (define_insn_and_split "*vector_ordered<mode>"
626 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
627 (ordered:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
628 (match_operand:VEC_F 2 "vfloat_operand" "")))]
629 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
633 (ge:VEC_F (match_dup 1)
636 (ge:VEC_F (match_dup 2)
639 (ior:VEC_F (match_dup 3)
643 operands[3] = gen_reg_rtx (<MODE>mode);
644 operands[4] = gen_reg_rtx (<MODE>mode);
647 (define_insn_and_split "*vector_unordered<mode>"
648 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
649 (unordered:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
650 (match_operand:VEC_F 2 "vfloat_operand" "")))]
651 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
655 (ge:VEC_F (match_dup 1)
658 (ge:VEC_F (match_dup 2)
661 (and:VEC_F (not:VEC_F (match_dup 3))
662 (not:VEC_F (match_dup 4))))]
665 operands[3] = gen_reg_rtx (<MODE>mode);
666 operands[4] = gen_reg_rtx (<MODE>mode);
669 ;; Note the arguments for __builtin_altivec_vsel are op2, op1, mask
670 ;; which is in the reverse order that we want
671 (define_expand "vector_select_<mode>"
672 [(set (match_operand:VEC_L 0 "vlogical_operand" "")
674 (ne:CC (match_operand:VEC_L 3 "vlogical_operand" "")
676 (match_operand:VEC_L 2 "vlogical_operand" "")
677 (match_operand:VEC_L 1 "vlogical_operand" "")))]
678 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
679 "operands[4] = CONST0_RTX (<MODE>mode);")
681 (define_expand "vector_select_<mode>_uns"
682 [(set (match_operand:VEC_L 0 "vlogical_operand" "")
684 (ne:CCUNS (match_operand:VEC_L 3 "vlogical_operand" "")
686 (match_operand:VEC_L 2 "vlogical_operand" "")
687 (match_operand:VEC_L 1 "vlogical_operand" "")))]
688 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
689 "operands[4] = CONST0_RTX (<MODE>mode);")
691 ;; Expansions that compare vectors producing a vector result and a predicate,
692 ;; setting CR6 to indicate a combined status
693 (define_expand "vector_eq_<mode>_p"
695 [(set (reg:CC CR6_REGNO)
696 (unspec:CC [(eq:CC (match_operand:VEC_A 1 "vlogical_operand" "")
697 (match_operand:VEC_A 2 "vlogical_operand" ""))]
699 (set (match_operand:VEC_A 0 "vlogical_operand" "")
700 (eq:VEC_A (match_dup 1)
702 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
705 ;; This expansion handles the V16QI, V8HI, and V4SI modes in the
706 ;; implementation of the vec_all_ne built-in functions on Power9.
707 (define_expand "vector_ne_<mode>_p"
709 [(set (reg:CC CR6_REGNO)
710 (unspec:CC [(ne:CC (match_operand:VI 1 "vlogical_operand")
711 (match_operand:VI 2 "vlogical_operand"))]
716 (set (match_operand:SI 0 "register_operand" "=r")
717 (lt:SI (reg:CC CR6_REGNO)
721 operands[3] = gen_reg_rtx (<MODE>mode);
724 ;; This expansion handles the V16QI, V8HI, and V4SI modes in the
725 ;; implementation of the vec_any_eq built-in functions on Power9.
726 (define_expand "vector_ae_<mode>_p"
728 [(set (reg:CC CR6_REGNO)
729 (unspec:CC [(ne:CC (match_operand:VI 1 "vlogical_operand")
730 (match_operand:VI 2 "vlogical_operand"))]
735 (set (match_operand:SI 0 "register_operand" "=r")
736 (lt:SI (reg:CC CR6_REGNO)
739 (xor:SI (match_dup 0)
743 operands[3] = gen_reg_rtx (<MODE>mode);
746 ;; This expansion handles the V16QI, V8HI, and V4SI modes in the
747 ;; implementation of the vec_all_nez and vec_any_eqz built-in
748 ;; functions on Power9.
749 (define_expand "vector_nez_<mode>_p"
751 [(set (reg:CC CR6_REGNO)
752 (unspec:CC [(unspec:VI
753 [(match_operand:VI 1 "vlogical_operand")
754 (match_operand:VI 2 "vlogical_operand")]
757 (set (match_operand:VI 0 "vlogical_operand")
758 (unspec:VI [(match_dup 1)
764 ;; This expansion handles the V2DI mode in the implementation of the
765 ;; vec_all_ne built-in function on Power9.
767 ;; Since the Power9 "xvcmpne<mode>." instruction does not support DImode,
768 ;; this expands into the same rtl that would be used for the Power8
770 (define_expand "vector_ne_v2di_p"
772 [(set (reg:CC CR6_REGNO)
773 (unspec:CC [(eq:CC (match_operand:V2DI 1 "vlogical_operand")
774 (match_operand:V2DI 2 "vlogical_operand"))]
777 (eq:V2DI (match_dup 1)
779 (set (match_operand:SI 0 "register_operand" "=r")
780 (eq:SI (reg:CC CR6_REGNO)
784 operands[3] = gen_reg_rtx (V2DImode);
787 ;; This expansion handles the V2DI mode in the implementation of the
788 ;; vec_any_eq built-in function on Power9.
790 ;; Since the Power9 "xvcmpne<mode>." instruction does not support DImode,
791 ;; this expands into the same rtl that would be used for the Power8
793 (define_expand "vector_ae_v2di_p"
795 [(set (reg:CC CR6_REGNO)
796 (unspec:CC [(eq:CC (match_operand:V2DI 1 "vlogical_operand")
797 (match_operand:V2DI 2 "vlogical_operand"))]
800 (eq:V2DI (match_dup 1)
802 (set (match_operand:SI 0 "register_operand" "=r")
803 (eq:SI (reg:CC CR6_REGNO)
806 (xor:SI (match_dup 0)
810 operands[3] = gen_reg_rtx (V2DImode);
813 ;; This expansion handles the V4SF and V2DF modes in the Power9
814 ;; implementation of the vec_all_ne built-in functions. Note that the
815 ;; expansions for this pattern with these modes makes no use of power9-
816 ;; specific instructions since there are no new power9 instructions
817 ;; for vector compare not equal with floating point arguments.
818 (define_expand "vector_ne_<mode>_p"
820 [(set (reg:CC CR6_REGNO)
821 (unspec:CC [(eq:CC (match_operand:VEC_F 1 "vlogical_operand")
822 (match_operand:VEC_F 2 "vlogical_operand"))]
825 (eq:VEC_F (match_dup 1)
827 (set (match_operand:SI 0 "register_operand" "=r")
828 (eq:SI (reg:CC CR6_REGNO)
832 operands[3] = gen_reg_rtx (<MODE>mode);
835 ;; This expansion handles the V4SF and V2DF modes in the Power9
836 ;; implementation of the vec_any_eq built-in functions. Note that the
837 ;; expansions for this pattern with these modes makes no use of power9-
838 ;; specific instructions since there are no new power9 instructions
839 ;; for vector compare not equal with floating point arguments.
840 (define_expand "vector_ae_<mode>_p"
842 [(set (reg:CC CR6_REGNO)
843 (unspec:CC [(eq:CC (match_operand:VEC_F 1 "vlogical_operand")
844 (match_operand:VEC_F 2 "vlogical_operand"))]
847 (eq:VEC_F (match_dup 1)
849 (set (match_operand:SI 0 "register_operand" "=r")
850 (eq:SI (reg:CC CR6_REGNO)
853 (xor:SI (match_dup 0)
857 operands[3] = gen_reg_rtx (<MODE>mode);
860 (define_expand "vector_gt_<mode>_p"
862 [(set (reg:CC CR6_REGNO)
863 (unspec:CC [(gt:CC (match_operand:VEC_A 1 "vlogical_operand" "")
864 (match_operand:VEC_A 2 "vlogical_operand" ""))]
866 (set (match_operand:VEC_A 0 "vlogical_operand" "")
867 (gt:VEC_A (match_dup 1)
869 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
872 (define_expand "vector_ge_<mode>_p"
874 [(set (reg:CC CR6_REGNO)
875 (unspec:CC [(ge:CC (match_operand:VEC_F 1 "vfloat_operand" "")
876 (match_operand:VEC_F 2 "vfloat_operand" ""))]
878 (set (match_operand:VEC_F 0 "vfloat_operand" "")
879 (ge:VEC_F (match_dup 1)
881 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
884 (define_expand "vector_gtu_<mode>_p"
886 [(set (reg:CC CR6_REGNO)
887 (unspec:CC [(gtu:CC (match_operand:VEC_I 1 "vint_operand" "")
888 (match_operand:VEC_I 2 "vint_operand" ""))]
890 (set (match_operand:VEC_I 0 "vlogical_operand" "")
891 (gtu:VEC_I (match_dup 1)
893 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
896 ;; AltiVec/VSX predicates.
898 ;; This expansion is triggered during expansion of predicate built-in
899 ;; functions (built-ins defined with the RS6000_BUILTIN_P macro) by the
900 ;; altivec_expand_predicate_builtin() function when the value of the
901 ;; integer constant first argument equals zero (aka __CR6_EQ in altivec.h).
902 (define_expand "cr6_test_for_zero"
903 [(set (match_operand:SI 0 "register_operand" "=r")
904 (eq:SI (reg:CC CR6_REGNO)
906 "TARGET_ALTIVEC || TARGET_VSX"
909 ;; This expansion is triggered during expansion of predicate built-in
910 ;; functions (built-ins defined with the RS6000_BUILTIN_P macro) by the
911 ;; altivec_expand_predicate_builtin() function when the value of the
912 ;; integer constant first argument equals one (aka __CR6_EQ_REV in altivec.h).
913 (define_expand "cr6_test_for_zero_reverse"
914 [(set (match_operand:SI 0 "register_operand" "=r")
915 (eq:SI (reg:CC CR6_REGNO)
918 (xor:SI (match_dup 0)
920 "TARGET_ALTIVEC || TARGET_VSX"
923 ;; This expansion is triggered during expansion of predicate built-in
924 ;; functions (built-ins defined with the RS6000_BUILTIN_P macro) by the
925 ;; altivec_expand_predicate_builtin() function when the value of the
926 ;; integer constant first argument equals two (aka __CR6_LT in altivec.h).
927 (define_expand "cr6_test_for_lt"
928 [(set (match_operand:SI 0 "register_operand" "=r")
929 (lt:SI (reg:CC CR6_REGNO)
931 "TARGET_ALTIVEC || TARGET_VSX"
934 ;; This expansion is triggered during expansion of predicate built-in
935 ;; functions (built-ins defined with the RS6000_BUILTIN_P macro) by the
936 ;; altivec_expand_predicate_builtin() function when the value of the
937 ;; integer constant first argument equals three
938 ;; (aka __CR6_LT_REV in altivec.h).
939 (define_expand "cr6_test_for_lt_reverse"
940 [(set (match_operand:SI 0 "register_operand" "=r")
941 (lt:SI (reg:CC CR6_REGNO)
944 (xor:SI (match_dup 0)
946 "TARGET_ALTIVEC || TARGET_VSX"
950 ;; Vector count leading zeros
951 (define_expand "clz<mode>2"
952 [(set (match_operand:VEC_I 0 "register_operand" "")
953 (clz:VEC_I (match_operand:VEC_I 1 "register_operand" "")))]
956 ;; Vector count trailing zeros
957 (define_expand "ctz<mode>2"
958 [(set (match_operand:VEC_I 0 "register_operand" "")
959 (ctz:VEC_I (match_operand:VEC_I 1 "register_operand" "")))]
962 ;; Vector population count
963 (define_expand "popcount<mode>2"
964 [(set (match_operand:VEC_I 0 "register_operand" "")
965 (popcount:VEC_I (match_operand:VEC_I 1 "register_operand" "")))]
969 (define_expand "parity<mode>2"
970 [(set (match_operand:VEC_IP 0 "register_operand" "")
971 (parity:VEC_IP (match_operand:VEC_IP 1 "register_operand" "")))]
975 ;; Same size conversions
976 (define_expand "float<VEC_int><mode>2"
977 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
978 (float:VEC_F (match_operand:<VEC_INT> 1 "vint_operand" "")))]
979 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
982 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
984 emit_insn (gen_altivec_vcfsx (operands[0], operands[1], const0_rtx));
989 (define_expand "floatuns<VEC_int><mode>2"
990 [(set (match_operand:VEC_F 0 "vfloat_operand" "")
991 (unsigned_float:VEC_F (match_operand:<VEC_INT> 1 "vint_operand" "")))]
992 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
995 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
997 emit_insn (gen_altivec_vcfux (operands[0], operands[1], const0_rtx));
1002 (define_expand "fix_trunc<mode><VEC_int>2"
1003 [(set (match_operand:<VEC_INT> 0 "vint_operand" "")
1004 (fix:<VEC_INT> (match_operand:VEC_F 1 "vfloat_operand" "")))]
1005 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1008 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
1010 emit_insn (gen_altivec_vctsxs (operands[0], operands[1], const0_rtx));
1015 (define_expand "fixuns_trunc<mode><VEC_int>2"
1016 [(set (match_operand:<VEC_INT> 0 "vint_operand" "")
1017 (unsigned_fix:<VEC_INT> (match_operand:VEC_F 1 "vfloat_operand" "")))]
1018 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1021 if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
1023 emit_insn (gen_altivec_vctuxs (operands[0], operands[1], const0_rtx));
1029 ;; Vector initialization, set, extract
1030 (define_expand "vec_init<mode><VEC_base_l>"
1031 [(match_operand:VEC_E 0 "vlogical_operand" "")
1032 (match_operand:VEC_E 1 "" "")]
1033 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
1035 rs6000_expand_vector_init (operands[0], operands[1]);
1039 (define_expand "vec_set<mode>"
1040 [(match_operand:VEC_E 0 "vlogical_operand" "")
1041 (match_operand:<VEC_base> 1 "register_operand" "")
1042 (match_operand 2 "const_int_operand" "")]
1043 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
1045 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1049 (define_expand "vec_extract<mode><VEC_base_l>"
1050 [(match_operand:<VEC_base> 0 "register_operand" "")
1051 (match_operand:VEC_E 1 "vlogical_operand" "")
1052 (match_operand 2 "const_int_operand" "")]
1053 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
1055 rs6000_expand_vector_extract (operands[0], operands[1], operands[2]);
1059 ;; Convert double word types to single word types
1060 (define_expand "vec_pack_trunc_v2df"
1061 [(match_operand:V4SF 0 "vfloat_operand" "")
1062 (match_operand:V2DF 1 "vfloat_operand" "")
1063 (match_operand:V2DF 2 "vfloat_operand" "")]
1064 "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
1066 rtx r1 = gen_reg_rtx (V4SFmode);
1067 rtx r2 = gen_reg_rtx (V4SFmode);
1069 emit_insn (gen_vsx_xvcvdpsp (r1, operands[1]));
1070 emit_insn (gen_vsx_xvcvdpsp (r2, operands[2]));
1071 rs6000_expand_extract_even (operands[0], r1, r2);
1075 (define_expand "vec_pack_sfix_trunc_v2df"
1076 [(match_operand:V4SI 0 "vint_operand" "")
1077 (match_operand:V2DF 1 "vfloat_operand" "")
1078 (match_operand:V2DF 2 "vfloat_operand" "")]
1079 "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
1081 rtx r1 = gen_reg_rtx (V4SImode);
1082 rtx r2 = gen_reg_rtx (V4SImode);
1084 emit_insn (gen_vsx_xvcvdpsxws (r1, operands[1]));
1085 emit_insn (gen_vsx_xvcvdpsxws (r2, operands[2]));
1086 rs6000_expand_extract_even (operands[0], r1, r2);
1090 (define_expand "vec_pack_ufix_trunc_v2df"
1091 [(match_operand:V4SI 0 "vint_operand" "")
1092 (match_operand:V2DF 1 "vfloat_operand" "")
1093 (match_operand:V2DF 2 "vfloat_operand" "")]
1094 "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
1096 rtx r1 = gen_reg_rtx (V4SImode);
1097 rtx r2 = gen_reg_rtx (V4SImode);
1099 emit_insn (gen_vsx_xvcvdpuxws (r1, operands[1]));
1100 emit_insn (gen_vsx_xvcvdpuxws (r2, operands[2]));
1101 rs6000_expand_extract_even (operands[0], r1, r2);
1105 ;; Convert single word types to double word
1106 (define_expand "vec_unpacks_hi_v4sf"
1107 [(match_operand:V2DF 0 "vfloat_operand" "")
1108 (match_operand:V4SF 1 "vfloat_operand" "")]
1109 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
1111 rtx reg = gen_reg_rtx (V4SFmode);
1113 rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
1114 emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
1118 (define_expand "vec_unpacks_lo_v4sf"
1119 [(match_operand:V2DF 0 "vfloat_operand" "")
1120 (match_operand:V4SF 1 "vfloat_operand" "")]
1121 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
1123 rtx reg = gen_reg_rtx (V4SFmode);
1125 rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
1126 emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
1130 (define_expand "vec_unpacks_float_hi_v4si"
1131 [(match_operand:V2DF 0 "vfloat_operand" "")
1132 (match_operand:V4SI 1 "vint_operand" "")]
1133 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
1135 rtx reg = gen_reg_rtx (V4SImode);
1137 rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
1138 emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
1142 (define_expand "vec_unpacks_float_lo_v4si"
1143 [(match_operand:V2DF 0 "vfloat_operand" "")
1144 (match_operand:V4SI 1 "vint_operand" "")]
1145 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
1147 rtx reg = gen_reg_rtx (V4SImode);
1149 rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
1150 emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
1154 (define_expand "vec_unpacku_float_hi_v4si"
1155 [(match_operand:V2DF 0 "vfloat_operand" "")
1156 (match_operand:V4SI 1 "vint_operand" "")]
1157 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
1159 rtx reg = gen_reg_rtx (V4SImode);
1161 rs6000_expand_interleave (reg, operands[1], operands[1], BYTES_BIG_ENDIAN);
1162 emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
1166 (define_expand "vec_unpacku_float_lo_v4si"
1167 [(match_operand:V2DF 0 "vfloat_operand" "")
1168 (match_operand:V4SI 1 "vint_operand" "")]
1169 "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
1171 rtx reg = gen_reg_rtx (V4SImode);
1173 rs6000_expand_interleave (reg, operands[1], operands[1], !BYTES_BIG_ENDIAN);
1174 emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
1179 ;; Align vector loads with a permute.
1180 (define_expand "vec_realign_load_<mode>"
1181 [(match_operand:VEC_K 0 "vlogical_operand" "")
1182 (match_operand:VEC_K 1 "vlogical_operand" "")
1183 (match_operand:VEC_K 2 "vlogical_operand" "")
1184 (match_operand:V16QI 3 "vlogical_operand" "")]
1185 "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
1187 if (BYTES_BIG_ENDIAN)
1188 emit_insn (gen_altivec_vperm_<mode> (operands[0], operands[1],
1189 operands[2], operands[3]));
1192 /* We have changed lvsr to lvsl, so to complete the transformation
1193 of vperm for LE, we must swap the inputs. */
1194 rtx unspec = gen_rtx_UNSPEC (<MODE>mode,
1195 gen_rtvec (3, operands[2],
1196 operands[1], operands[3]),
1198 emit_move_insn (operands[0], unspec);
1203 ;; Under VSX, vectors of 4/8 byte alignments do not need to be aligned
1204 ;; since the load already handles it.
1205 (define_expand "movmisalign<mode>"
1206 [(set (match_operand:VEC_N 0 "nonimmediate_operand" "")
1207 (match_operand:VEC_N 1 "any_operand" ""))]
1208 "VECTOR_MEM_VSX_P (<MODE>mode) && TARGET_ALLOW_MOVMISALIGN"
1211 ;; Vector shift right in bits. Currently supported ony for shift
1212 ;; amounts that can be expressed as byte shifts (divisible by 8).
1213 ;; General shift amounts can be supported using vsro + vsr. We're
1214 ;; not expecting to see these yet (the vectorizer currently
1215 ;; generates only shifts by a whole number of vector elements).
1216 ;; Note that the vec_shr operation is actually defined as
1217 ;; 'shift toward element 0' so is a shr for LE and shl for BE.
1218 (define_expand "vec_shr_<mode>"
1219 [(match_operand:VEC_L 0 "vlogical_operand" "")
1220 (match_operand:VEC_L 1 "vlogical_operand" "")
1221 (match_operand:QI 2 "reg_or_short_operand" "")]
1225 rtx bitshift = operands[2];
1228 rtx zero_reg, op1, op2;
1229 HOST_WIDE_INT bitshift_val;
1230 HOST_WIDE_INT byteshift_val;
1232 if (! CONSTANT_P (bitshift))
1234 bitshift_val = INTVAL (bitshift);
1235 if (bitshift_val & 0x7)
1237 byteshift_val = (bitshift_val >> 3);
1238 zero_reg = gen_reg_rtx (<MODE>mode);
1239 emit_move_insn (zero_reg, CONST0_RTX (<MODE>mode));
1240 if (!BYTES_BIG_ENDIAN)
1242 byteshift_val = 16 - byteshift_val;
1252 if (TARGET_VSX && (byteshift_val & 0x3) == 0)
1254 shift = gen_rtx_CONST_INT (QImode, byteshift_val >> 2);
1255 insn = gen_vsx_xxsldwi_<mode> (operands[0], op1, op2, shift);
1259 shift = gen_rtx_CONST_INT (QImode, byteshift_val);
1260 insn = gen_altivec_vsldoi_<mode> (operands[0], op1, op2, shift);
1267 ;; Expanders for rotate each element in a vector
1268 (define_expand "vrotl<mode>3"
1269 [(set (match_operand:VEC_I 0 "vint_operand" "")
1270 (rotate:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
1271 (match_operand:VEC_I 2 "vint_operand" "")))]
1272 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1275 ;; Expanders for arithmetic shift left on each vector element
1276 (define_expand "vashl<mode>3"
1277 [(set (match_operand:VEC_I 0 "vint_operand" "")
1278 (ashift:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
1279 (match_operand:VEC_I 2 "vint_operand" "")))]
1280 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1283 ;; Expanders for logical shift right on each vector element
1284 (define_expand "vlshr<mode>3"
1285 [(set (match_operand:VEC_I 0 "vint_operand" "")
1286 (lshiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
1287 (match_operand:VEC_I 2 "vint_operand" "")))]
1288 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1291 ;; Expanders for arithmetic shift right on each vector element
1292 (define_expand "vashr<mode>3"
1293 [(set (match_operand:VEC_I 0 "vint_operand" "")
1294 (ashiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
1295 (match_operand:VEC_I 2 "vint_operand" "")))]
1296 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
1299 ;; Vector reduction expanders for VSX
1300 ; The (VEC_reduc:...
1302 ; (unspec:... [(const_int 0)] UNSPEC_REDUC))
1304 ; is to allow us to use a code iterator, but not completely list all of the
1305 ; vector rotates, etc. to prevent canonicalization
1308 (define_expand "reduc_<VEC_reduc:VEC_reduc_name>_scal_<VEC_F:mode>"
1309 [(match_operand:<VEC_base> 0 "register_operand" "")
1310 (VEC_reduc:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
1311 (unspec:VEC_F [(const_int 0)] UNSPEC_REDUC))]
1312 "VECTOR_UNIT_VSX_P (<VEC_F:MODE>mode)"
1314 rtx vec = gen_reg_rtx (<VEC_F:MODE>mode);
1315 rtx elt = BYTES_BIG_ENDIAN
1316 ? gen_int_mode (GET_MODE_NUNITS (<VEC_F:MODE>mode) - 1, QImode)
1318 emit_insn (gen_vsx_reduc_<VEC_reduc:VEC_reduc_name>_<VEC_F:mode> (vec,
1320 emit_insn (gen_vsx_extract_<VEC_F:mode> (operand0, vec, elt));
1325 ;;; Expanders for vector insn patterns shared between the SPE and TARGET_PAIRED systems.
1327 (define_expand "absv2sf2"
1328 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1329 (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")))]
1330 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1333 (define_expand "negv2sf2"
1334 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1335 (neg:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")))]
1336 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1339 (define_expand "addv2sf3"
1340 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1341 (plus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1342 (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1343 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1348 /* We need to make a note that we clobber SPEFSCR. */
1349 rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1351 XVECEXP (par, 0, 0) = gen_rtx_SET (operands[0],
1352 gen_rtx_PLUS (V2SFmode, operands[1], operands[2]));
1353 XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1359 (define_expand "subv2sf3"
1360 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1361 (minus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1362 (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1363 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1368 /* We need to make a note that we clobber SPEFSCR. */
1369 rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1371 XVECEXP (par, 0, 0) = gen_rtx_SET (operands[0],
1372 gen_rtx_MINUS (V2SFmode, operands[1], operands[2]));
1373 XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1379 (define_expand "mulv2sf3"
1380 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1381 (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1382 (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1383 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1388 /* We need to make a note that we clobber SPEFSCR. */
1389 rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1391 XVECEXP (par, 0, 0) = gen_rtx_SET (operands[0],
1392 gen_rtx_MULT (V2SFmode, operands[1], operands[2]));
1393 XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1399 (define_expand "divv2sf3"
1400 [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1401 (div:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1402 (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1403 "TARGET_PAIRED_FLOAT || TARGET_SPE"
1408 /* We need to make a note that we clobber SPEFSCR. */
1409 rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1411 XVECEXP (par, 0, 0) = gen_rtx_SET (operands[0],
1412 gen_rtx_DIV (V2SFmode, operands[1], operands[2]));
1413 XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));