2 ;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
3 ;; Contributed by Aldy Hernandez (aldy@quesejoda.com)
5 ;; This file is part of GCC.
7 ;; GCC is free software; you can redistribute it and/or modify it
8 ;; under the terms of the GNU General Public License as published
9 ;; by the Free Software Foundation; either version 3, or (at your
10 ;; option) any later version.
12 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
13 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 ;; License for more details.
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 (define_c_enum "unspec"
139 (define_c_enum "unspecv"
148 (define_mode_iterator VI [V4SI V8HI V16QI])
149 ;; Short vec in modes
150 (define_mode_iterator VIshort [V8HI V16QI])
152 (define_mode_iterator VF [V4SF])
153 ;; Vec modes, pity mode iterators are not composable
154 (define_mode_iterator V [V4SI V8HI V16QI V4SF])
155 ;; Vec modes for move/logical/permute ops, include vector types for move not
156 ;; otherwise handled by altivec (v2df, v2di, ti)
157 (define_mode_iterator VM [V4SI V8HI V16QI V4SF V2DF V2DI TI])
159 ;; Like VM, except don't do TImode
160 (define_mode_iterator VM2 [V4SI V8HI V16QI V4SF V2DF V2DI])
162 (define_mode_attr VI_char [(V4SI "w") (V8HI "h") (V16QI "b")])
163 (define_mode_attr VI_scalar [(V4SI "SI") (V8HI "HI") (V16QI "QI")])
165 ;; Vector move instructions.
166 (define_insn "*altivec_mov<mode>"
167 [(set (match_operand:VM2 0 "nonimmediate_operand" "=Z,v,v,*Y,*r,*r,v,v")
168 (match_operand:VM2 1 "input_operand" "v,Z,v,r,Y,r,j,W"))]
169 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)
170 && (register_operand (operands[0], <MODE>mode)
171 || register_operand (operands[1], <MODE>mode))"
173 switch (which_alternative)
175 case 0: return "stvx %1,%y0";
176 case 1: return "lvx %0,%y1";
177 case 2: return "vor %0,%1,%1";
181 case 6: return "vxor %0,%0,%0";
182 case 7: return output_vec_const_move (operands);
183 default: gcc_unreachable ();
186 [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,vecsimple,*")])
188 ;; Unlike other altivec moves, allow the GPRs, since a normal use of TImode
189 ;; is for unions. However for plain data movement, slightly favor the vector
191 (define_insn "*altivec_movti"
192 [(set (match_operand:TI 0 "nonimmediate_operand" "=Z,v,v,?Y,?r,?r,v,v")
193 (match_operand:TI 1 "input_operand" "v,Z,v,r,Y,r,j,W"))]
194 "VECTOR_MEM_ALTIVEC_P (TImode)
195 && (register_operand (operands[0], TImode)
196 || register_operand (operands[1], TImode))"
198 switch (which_alternative)
200 case 0: return "stvx %1,%y0";
201 case 1: return "lvx %0,%y1";
202 case 2: return "vor %0,%1,%1";
206 case 6: return "vxor %0,%0,%0";
207 case 7: return output_vec_const_move (operands);
208 default: gcc_unreachable ();
211 [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,vecsimple,*")])
213 ;; Load up a vector with the most significant bit set by loading up -1 and
214 ;; doing a shift left
216 [(set (match_operand:VM 0 "altivec_register_operand" "")
217 (match_operand:VM 1 "easy_vector_constant_msb" ""))]
218 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && reload_completed"
221 rtx dest = operands[0];
222 enum machine_mode mode = GET_MODE (operands[0]);
226 if (mode == V4SFmode)
229 dest = gen_lowpart (V4SImode, dest);
232 num_elements = GET_MODE_NUNITS (mode);
233 v = rtvec_alloc (num_elements);
234 for (i = 0; i < num_elements; i++)
235 RTVEC_ELT (v, i) = constm1_rtx;
237 emit_insn (gen_vec_initv4si (dest, gen_rtx_PARALLEL (mode, v)));
238 emit_insn (gen_rtx_SET (VOIDmode, dest, gen_rtx_ASHIFT (mode, dest, dest)));
243 [(set (match_operand:VM 0 "altivec_register_operand" "")
244 (match_operand:VM 1 "easy_vector_constant_add_self" ""))]
245 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode) && reload_completed"
246 [(set (match_dup 0) (match_dup 3))
247 (set (match_dup 0) (match_dup 4))]
249 rtx dup = gen_easy_altivec_constant (operands[1]);
251 enum machine_mode op_mode = <MODE>mode;
253 /* Divide the operand of the resulting VEC_DUPLICATE, and use
254 simplify_rtx to make a CONST_VECTOR. */
255 XEXP (dup, 0) = simplify_const_binary_operation (ASHIFTRT, QImode,
256 XEXP (dup, 0), const1_rtx);
257 const_vec = simplify_rtx (dup);
259 if (op_mode == V4SFmode)
262 operands[0] = gen_lowpart (op_mode, operands[0]);
264 if (GET_MODE (const_vec) == op_mode)
265 operands[3] = const_vec;
267 operands[3] = gen_lowpart (op_mode, const_vec);
268 operands[4] = gen_rtx_PLUS (op_mode, operands[0], operands[0]);
271 (define_insn "get_vrsave_internal"
272 [(set (match_operand:SI 0 "register_operand" "=r")
273 (unspec:SI [(reg:SI 109)] UNSPEC_GET_VRSAVE))]
277 return "mfspr %0,256";
279 return "mfvrsave %0";
281 [(set_attr "type" "*")])
283 (define_insn "*set_vrsave_internal"
284 [(match_parallel 0 "vrsave_operation"
286 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
287 (reg:SI 109)] UNSPECV_SET_VRSAVE))])]
291 return "mtspr 256,%1";
293 return "mtvrsave %1";
295 [(set_attr "type" "*")])
297 (define_insn "*save_world"
298 [(match_parallel 0 "save_world_operation"
299 [(clobber (reg:SI 65))
300 (use (match_operand:SI 1 "call_operand" "s"))])]
301 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
303 [(set_attr "type" "branch")
304 (set_attr "length" "4")])
306 (define_insn "*restore_world"
307 [(match_parallel 0 "restore_world_operation"
310 (use (match_operand:SI 1 "call_operand" "s"))
311 (clobber (match_operand:SI 2 "gpc_reg_operand" "=r"))])]
312 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
315 ;; The save_vregs and restore_vregs patterns don't use memory_operand
316 ;; because (plus (reg) (const_int)) is not a valid vector address.
317 ;; This way is more compact than describing exactly what happens in
318 ;; the out-of-line functions, ie. loading the constant into r11/r12
319 ;; then using indexed addressing, and requires less editing of rtl
320 ;; to describe the operation to dwarf2out_frame_debug_expr.
321 (define_insn "*save_vregs_<mode>_r11"
322 [(match_parallel 0 "any_parallel_operand"
323 [(clobber (reg:P 65))
324 (use (match_operand:P 1 "symbol_ref_operand" "s"))
327 (set (mem:V4SI (plus:P (match_operand:P 2 "gpc_reg_operand" "b")
328 (match_operand:P 3 "short_cint_operand" "I")))
329 (match_operand:V4SI 4 "gpc_reg_operand" "v"))])]
332 [(set_attr "type" "branch")
333 (set_attr "length" "4")])
335 (define_insn "*save_vregs_<mode>_r12"
336 [(match_parallel 0 "any_parallel_operand"
337 [(clobber (reg:P 65))
338 (use (match_operand:P 1 "symbol_ref_operand" "s"))
341 (set (mem:V4SI (plus:P (match_operand:P 2 "gpc_reg_operand" "b")
342 (match_operand:P 3 "short_cint_operand" "I")))
343 (match_operand:V4SI 4 "gpc_reg_operand" "v"))])]
346 [(set_attr "type" "branch")
347 (set_attr "length" "4")])
349 (define_insn "*restore_vregs_<mode>_r11"
350 [(match_parallel 0 "any_parallel_operand"
351 [(clobber (reg:P 65))
352 (use (match_operand:P 1 "symbol_ref_operand" "s"))
355 (set (match_operand:V4SI 2 "gpc_reg_operand" "=v")
356 (mem:V4SI (plus:P (match_operand:P 3 "gpc_reg_operand" "b")
357 (match_operand:P 4 "short_cint_operand" "I"))))])]
360 [(set_attr "type" "branch")
361 (set_attr "length" "4")])
363 (define_insn "*restore_vregs_<mode>_r12"
364 [(match_parallel 0 "any_parallel_operand"
365 [(clobber (reg:P 65))
366 (use (match_operand:P 1 "symbol_ref_operand" "s"))
369 (set (match_operand:V4SI 2 "gpc_reg_operand" "=v")
370 (mem:V4SI (plus:P (match_operand:P 3 "gpc_reg_operand" "b")
371 (match_operand:P 4 "short_cint_operand" "I"))))])]
374 [(set_attr "type" "branch")
375 (set_attr "length" "4")])
377 ;; Simple binary operations.
380 (define_insn "add<mode>3"
381 [(set (match_operand:VI 0 "register_operand" "=v")
382 (plus:VI (match_operand:VI 1 "register_operand" "v")
383 (match_operand:VI 2 "register_operand" "v")))]
385 "vaddu<VI_char>m %0,%1,%2"
386 [(set_attr "type" "vecsimple")])
388 (define_insn "*altivec_addv4sf3"
389 [(set (match_operand:V4SF 0 "register_operand" "=v")
390 (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
391 (match_operand:V4SF 2 "register_operand" "v")))]
392 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
394 [(set_attr "type" "vecfloat")])
396 (define_insn "altivec_vaddcuw"
397 [(set (match_operand:V4SI 0 "register_operand" "=v")
398 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
399 (match_operand:V4SI 2 "register_operand" "v")]
403 [(set_attr "type" "vecsimple")])
405 (define_insn "altivec_vaddu<VI_char>s"
406 [(set (match_operand:VI 0 "register_operand" "=v")
407 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
408 (match_operand:VI 2 "register_operand" "v")]
410 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
412 "vaddu<VI_char>s %0,%1,%2"
413 [(set_attr "type" "vecsimple")])
415 (define_insn "altivec_vadds<VI_char>s"
416 [(set (match_operand:VI 0 "register_operand" "=v")
417 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
418 (match_operand:VI 2 "register_operand" "v")]
420 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
422 "vadds<VI_char>s %0,%1,%2"
423 [(set_attr "type" "vecsimple")])
426 (define_insn "sub<mode>3"
427 [(set (match_operand:VI 0 "register_operand" "=v")
428 (minus:VI (match_operand:VI 1 "register_operand" "v")
429 (match_operand:VI 2 "register_operand" "v")))]
431 "vsubu<VI_char>m %0,%1,%2"
432 [(set_attr "type" "vecsimple")])
434 (define_insn "*altivec_subv4sf3"
435 [(set (match_operand:V4SF 0 "register_operand" "=v")
436 (minus:V4SF (match_operand:V4SF 1 "register_operand" "v")
437 (match_operand:V4SF 2 "register_operand" "v")))]
438 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
440 [(set_attr "type" "vecfloat")])
442 (define_insn "altivec_vsubcuw"
443 [(set (match_operand:V4SI 0 "register_operand" "=v")
444 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
445 (match_operand:V4SI 2 "register_operand" "v")]
449 [(set_attr "type" "vecsimple")])
451 (define_insn "altivec_vsubu<VI_char>s"
452 [(set (match_operand:VI 0 "register_operand" "=v")
453 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
454 (match_operand:VI 2 "register_operand" "v")]
456 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
458 "vsubu<VI_char>s %0,%1,%2"
459 [(set_attr "type" "vecsimple")])
461 (define_insn "altivec_vsubs<VI_char>s"
462 [(set (match_operand:VI 0 "register_operand" "=v")
463 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
464 (match_operand:VI 2 "register_operand" "v")]
466 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
468 "vsubs<VI_char>s %0,%1,%2"
469 [(set_attr "type" "vecsimple")])
472 (define_insn "altivec_vavgu<VI_char>"
473 [(set (match_operand:VI 0 "register_operand" "=v")
474 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
475 (match_operand:VI 2 "register_operand" "v")]
478 "vavgu<VI_char> %0,%1,%2"
479 [(set_attr "type" "vecsimple")])
481 (define_insn "altivec_vavgs<VI_char>"
482 [(set (match_operand:VI 0 "register_operand" "=v")
483 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
484 (match_operand:VI 2 "register_operand" "v")]
487 "vavgs<VI_char> %0,%1,%2"
488 [(set_attr "type" "vecsimple")])
490 (define_insn "altivec_vcmpbfp"
491 [(set (match_operand:V4SI 0 "register_operand" "=v")
492 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
493 (match_operand:V4SF 2 "register_operand" "v")]
497 [(set_attr "type" "veccmp")])
499 (define_insn "*altivec_eq<mode>"
500 [(set (match_operand:VI 0 "altivec_register_operand" "=v")
501 (eq:VI (match_operand:VI 1 "altivec_register_operand" "v")
502 (match_operand:VI 2 "altivec_register_operand" "v")))]
504 "vcmpequ<VI_char> %0,%1,%2"
505 [(set_attr "type" "veccmp")])
507 (define_insn "*altivec_gt<mode>"
508 [(set (match_operand:VI 0 "altivec_register_operand" "=v")
509 (gt:VI (match_operand:VI 1 "altivec_register_operand" "v")
510 (match_operand:VI 2 "altivec_register_operand" "v")))]
512 "vcmpgts<VI_char> %0,%1,%2"
513 [(set_attr "type" "veccmp")])
515 (define_insn "*altivec_gtu<mode>"
516 [(set (match_operand:VI 0 "altivec_register_operand" "=v")
517 (gtu:VI (match_operand:VI 1 "altivec_register_operand" "v")
518 (match_operand:VI 2 "altivec_register_operand" "v")))]
520 "vcmpgtu<VI_char> %0,%1,%2"
521 [(set_attr "type" "veccmp")])
523 (define_insn "*altivec_eqv4sf"
524 [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
525 (eq:V4SF (match_operand:V4SF 1 "altivec_register_operand" "v")
526 (match_operand:V4SF 2 "altivec_register_operand" "v")))]
527 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
529 [(set_attr "type" "veccmp")])
531 (define_insn "*altivec_gtv4sf"
532 [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
533 (gt:V4SF (match_operand:V4SF 1 "altivec_register_operand" "v")
534 (match_operand:V4SF 2 "altivec_register_operand" "v")))]
535 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
537 [(set_attr "type" "veccmp")])
539 (define_insn "*altivec_gev4sf"
540 [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
541 (ge:V4SF (match_operand:V4SF 1 "altivec_register_operand" "v")
542 (match_operand:V4SF 2 "altivec_register_operand" "v")))]
543 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
545 [(set_attr "type" "veccmp")])
547 (define_insn "*altivec_vsel<mode>"
548 [(set (match_operand:VM 0 "altivec_register_operand" "=v")
550 (ne:CC (match_operand:VM 1 "altivec_register_operand" "v")
551 (match_operand:VM 4 "zero_constant" ""))
552 (match_operand:VM 2 "altivec_register_operand" "v")
553 (match_operand:VM 3 "altivec_register_operand" "v")))]
554 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
556 [(set_attr "type" "vecperm")])
558 (define_insn "*altivec_vsel<mode>_uns"
559 [(set (match_operand:VM 0 "altivec_register_operand" "=v")
561 (ne:CCUNS (match_operand:VM 1 "altivec_register_operand" "v")
562 (match_operand:VM 4 "zero_constant" ""))
563 (match_operand:VM 2 "altivec_register_operand" "v")
564 (match_operand:VM 3 "altivec_register_operand" "v")))]
565 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
567 [(set_attr "type" "vecperm")])
569 ;; Fused multiply add.
571 (define_insn "*altivec_fmav4sf4"
572 [(set (match_operand:V4SF 0 "register_operand" "=v")
573 (fma:V4SF (match_operand:V4SF 1 "register_operand" "v")
574 (match_operand:V4SF 2 "register_operand" "v")
575 (match_operand:V4SF 3 "register_operand" "v")))]
576 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
577 "vmaddfp %0,%1,%2,%3"
578 [(set_attr "type" "vecfloat")])
580 ;; We do multiply as a fused multiply-add with an add of a -0.0 vector.
582 (define_expand "altivec_mulv4sf3"
583 [(set (match_operand:V4SF 0 "register_operand" "")
584 (fma:V4SF (match_operand:V4SF 1 "register_operand" "")
585 (match_operand:V4SF 2 "register_operand" "")
587 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
591 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
592 neg0 = gen_reg_rtx (V4SImode);
593 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
594 emit_insn (gen_vashlv4si3 (neg0, neg0, neg0));
596 operands[3] = gen_lowpart (V4SFmode, neg0);
599 ;; 32-bit integer multiplication
600 ;; A_high = Operand_0 & 0xFFFF0000 >> 16
601 ;; A_low = Operand_0 & 0xFFFF
602 ;; B_high = Operand_1 & 0xFFFF0000 >> 16
603 ;; B_low = Operand_1 & 0xFFFF
604 ;; result = A_low * B_low + (A_high * B_low + B_high * A_low) << 16
606 ;; (define_insn "mulv4si3"
607 ;; [(set (match_operand:V4SI 0 "register_operand" "=v")
608 ;; (mult:V4SI (match_operand:V4SI 1 "register_operand" "v")
609 ;; (match_operand:V4SI 2 "register_operand" "v")))]
610 (define_expand "mulv4si3"
611 [(use (match_operand:V4SI 0 "register_operand" ""))
612 (use (match_operand:V4SI 1 "register_operand" ""))
613 (use (match_operand:V4SI 2 "register_operand" ""))]
626 zero = gen_reg_rtx (V4SImode);
627 emit_insn (gen_altivec_vspltisw (zero, const0_rtx));
629 sixteen = gen_reg_rtx (V4SImode);
630 emit_insn (gen_altivec_vspltisw (sixteen, gen_rtx_CONST_INT (V4SImode, -16)));
632 swap = gen_reg_rtx (V4SImode);
633 emit_insn (gen_vrotlv4si3 (swap, operands[2], sixteen));
635 one = gen_reg_rtx (V8HImode);
636 convert_move (one, operands[1], 0);
638 two = gen_reg_rtx (V8HImode);
639 convert_move (two, operands[2], 0);
641 small_swap = gen_reg_rtx (V8HImode);
642 convert_move (small_swap, swap, 0);
644 low_product = gen_reg_rtx (V4SImode);
645 emit_insn (gen_vec_widen_umult_odd_v8hi (low_product, one, two));
647 high_product = gen_reg_rtx (V4SImode);
648 emit_insn (gen_altivec_vmsumuhm (high_product, one, small_swap, zero));
650 emit_insn (gen_vashlv4si3 (high_product, high_product, sixteen));
652 emit_insn (gen_addv4si3 (operands[0], high_product, low_product));
657 (define_expand "mulv8hi3"
658 [(use (match_operand:V8HI 0 "register_operand" ""))
659 (use (match_operand:V8HI 1 "register_operand" ""))
660 (use (match_operand:V8HI 2 "register_operand" ""))]
664 rtx odd = gen_reg_rtx (V4SImode);
665 rtx even = gen_reg_rtx (V4SImode);
666 rtx high = gen_reg_rtx (V4SImode);
667 rtx low = gen_reg_rtx (V4SImode);
669 emit_insn (gen_vec_widen_smult_even_v8hi (even, operands[1], operands[2]));
670 emit_insn (gen_vec_widen_smult_odd_v8hi (odd, operands[1], operands[2]));
672 emit_insn (gen_altivec_vmrghw (high, even, odd));
673 emit_insn (gen_altivec_vmrglw (low, even, odd));
675 emit_insn (gen_altivec_vpkuwum (operands[0], high, low));
680 ;; Fused multiply subtract
681 (define_insn "*altivec_vnmsubfp"
682 [(set (match_operand:V4SF 0 "register_operand" "=v")
684 (fma:V4SF (match_operand:V4SF 1 "register_operand" "v")
685 (match_operand:V4SF 2 "register_operand" "v")
687 (match_operand:V4SF 3 "register_operand" "v")))))]
688 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
689 "vnmsubfp %0,%1,%2,%3"
690 [(set_attr "type" "vecfloat")])
692 (define_insn "altivec_vmsumu<VI_char>m"
693 [(set (match_operand:V4SI 0 "register_operand" "=v")
694 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
695 (match_operand:VIshort 2 "register_operand" "v")
696 (match_operand:V4SI 3 "register_operand" "v")]
699 "vmsumu<VI_char>m %0,%1,%2,%3"
700 [(set_attr "type" "veccomplex")])
702 (define_insn "altivec_vmsumm<VI_char>m"
703 [(set (match_operand:V4SI 0 "register_operand" "=v")
704 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
705 (match_operand:VIshort 2 "register_operand" "v")
706 (match_operand:V4SI 3 "register_operand" "v")]
709 "vmsumm<VI_char>m %0,%1,%2,%3"
710 [(set_attr "type" "veccomplex")])
712 (define_insn "altivec_vmsumshm"
713 [(set (match_operand:V4SI 0 "register_operand" "=v")
714 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
715 (match_operand:V8HI 2 "register_operand" "v")
716 (match_operand:V4SI 3 "register_operand" "v")]
719 "vmsumshm %0,%1,%2,%3"
720 [(set_attr "type" "veccomplex")])
722 (define_insn "altivec_vmsumuhs"
723 [(set (match_operand:V4SI 0 "register_operand" "=v")
724 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
725 (match_operand:V8HI 2 "register_operand" "v")
726 (match_operand:V4SI 3 "register_operand" "v")]
728 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
730 "vmsumuhs %0,%1,%2,%3"
731 [(set_attr "type" "veccomplex")])
733 (define_insn "altivec_vmsumshs"
734 [(set (match_operand:V4SI 0 "register_operand" "=v")
735 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
736 (match_operand:V8HI 2 "register_operand" "v")
737 (match_operand:V4SI 3 "register_operand" "v")]
739 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
741 "vmsumshs %0,%1,%2,%3"
742 [(set_attr "type" "veccomplex")])
746 (define_insn "umax<mode>3"
747 [(set (match_operand:VI 0 "register_operand" "=v")
748 (umax:VI (match_operand:VI 1 "register_operand" "v")
749 (match_operand:VI 2 "register_operand" "v")))]
751 "vmaxu<VI_char> %0,%1,%2"
752 [(set_attr "type" "vecsimple")])
754 (define_insn "smax<mode>3"
755 [(set (match_operand:VI 0 "register_operand" "=v")
756 (smax:VI (match_operand:VI 1 "register_operand" "v")
757 (match_operand:VI 2 "register_operand" "v")))]
759 "vmaxs<VI_char> %0,%1,%2"
760 [(set_attr "type" "vecsimple")])
762 (define_insn "*altivec_smaxv4sf3"
763 [(set (match_operand:V4SF 0 "register_operand" "=v")
764 (smax:V4SF (match_operand:V4SF 1 "register_operand" "v")
765 (match_operand:V4SF 2 "register_operand" "v")))]
766 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
768 [(set_attr "type" "veccmp")])
770 (define_insn "umin<mode>3"
771 [(set (match_operand:VI 0 "register_operand" "=v")
772 (umin:VI (match_operand:VI 1 "register_operand" "v")
773 (match_operand:VI 2 "register_operand" "v")))]
775 "vminu<VI_char> %0,%1,%2"
776 [(set_attr "type" "vecsimple")])
778 (define_insn "smin<mode>3"
779 [(set (match_operand:VI 0 "register_operand" "=v")
780 (smin:VI (match_operand:VI 1 "register_operand" "v")
781 (match_operand:VI 2 "register_operand" "v")))]
783 "vmins<VI_char> %0,%1,%2"
784 [(set_attr "type" "vecsimple")])
786 (define_insn "*altivec_sminv4sf3"
787 [(set (match_operand:V4SF 0 "register_operand" "=v")
788 (smin:V4SF (match_operand:V4SF 1 "register_operand" "v")
789 (match_operand:V4SF 2 "register_operand" "v")))]
790 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
792 [(set_attr "type" "veccmp")])
794 (define_insn "altivec_vmhaddshs"
795 [(set (match_operand:V8HI 0 "register_operand" "=v")
796 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
797 (match_operand:V8HI 2 "register_operand" "v")
798 (match_operand:V8HI 3 "register_operand" "v")]
800 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
802 "vmhaddshs %0,%1,%2,%3"
803 [(set_attr "type" "veccomplex")])
805 (define_insn "altivec_vmhraddshs"
806 [(set (match_operand:V8HI 0 "register_operand" "=v")
807 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
808 (match_operand:V8HI 2 "register_operand" "v")
809 (match_operand:V8HI 3 "register_operand" "v")]
811 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
813 "vmhraddshs %0,%1,%2,%3"
814 [(set_attr "type" "veccomplex")])
816 (define_insn "altivec_vmladduhm"
817 [(set (match_operand:V8HI 0 "register_operand" "=v")
818 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
819 (match_operand:V8HI 2 "register_operand" "v")
820 (match_operand:V8HI 3 "register_operand" "v")]
823 "vmladduhm %0,%1,%2,%3"
824 [(set_attr "type" "veccomplex")])
826 (define_insn "altivec_vmrghb"
827 [(set (match_operand:V16QI 0 "register_operand" "=v")
830 (match_operand:V16QI 1 "register_operand" "v")
831 (match_operand:V16QI 2 "register_operand" "v"))
832 (parallel [(const_int 0) (const_int 16)
833 (const_int 1) (const_int 17)
834 (const_int 2) (const_int 18)
835 (const_int 3) (const_int 19)
836 (const_int 4) (const_int 20)
837 (const_int 5) (const_int 21)
838 (const_int 6) (const_int 22)
839 (const_int 7) (const_int 23)])))]
842 [(set_attr "type" "vecperm")])
844 (define_insn "altivec_vmrghh"
845 [(set (match_operand:V8HI 0 "register_operand" "=v")
848 (match_operand:V8HI 1 "register_operand" "v")
849 (match_operand:V8HI 2 "register_operand" "v"))
850 (parallel [(const_int 0) (const_int 8)
851 (const_int 1) (const_int 9)
852 (const_int 2) (const_int 10)
853 (const_int 3) (const_int 11)])))]
856 [(set_attr "type" "vecperm")])
858 (define_insn "altivec_vmrghw"
859 [(set (match_operand:V4SI 0 "register_operand" "=v")
862 (match_operand:V4SI 1 "register_operand" "v")
863 (match_operand:V4SI 2 "register_operand" "v"))
864 (parallel [(const_int 0) (const_int 4)
865 (const_int 1) (const_int 5)])))]
866 "VECTOR_MEM_ALTIVEC_P (V4SImode)"
868 [(set_attr "type" "vecperm")])
870 (define_insn "*altivec_vmrghsf"
871 [(set (match_operand:V4SF 0 "register_operand" "=v")
874 (match_operand:V4SF 1 "register_operand" "v")
875 (match_operand:V4SF 2 "register_operand" "v"))
876 (parallel [(const_int 0) (const_int 4)
877 (const_int 1) (const_int 5)])))]
878 "VECTOR_MEM_ALTIVEC_P (V4SFmode)"
880 [(set_attr "type" "vecperm")])
882 (define_insn "altivec_vmrglb"
883 [(set (match_operand:V16QI 0 "register_operand" "=v")
886 (match_operand:V16QI 1 "register_operand" "v")
887 (match_operand:V16QI 2 "register_operand" "v"))
888 (parallel [(const_int 8) (const_int 24)
889 (const_int 9) (const_int 25)
890 (const_int 10) (const_int 26)
891 (const_int 11) (const_int 27)
892 (const_int 12) (const_int 28)
893 (const_int 13) (const_int 29)
894 (const_int 14) (const_int 30)
895 (const_int 15) (const_int 31)])))]
898 [(set_attr "type" "vecperm")])
900 (define_insn "altivec_vmrglh"
901 [(set (match_operand:V8HI 0 "register_operand" "=v")
904 (match_operand:V8HI 1 "register_operand" "v")
905 (match_operand:V8HI 2 "register_operand" "v"))
906 (parallel [(const_int 4) (const_int 12)
907 (const_int 5) (const_int 13)
908 (const_int 6) (const_int 14)
909 (const_int 7) (const_int 15)])))]
912 [(set_attr "type" "vecperm")])
914 (define_insn "altivec_vmrglw"
915 [(set (match_operand:V4SI 0 "register_operand" "=v")
918 (match_operand:V4SI 1 "register_operand" "v")
919 (match_operand:V4SI 2 "register_operand" "v"))
920 (parallel [(const_int 2) (const_int 6)
921 (const_int 3) (const_int 7)])))]
922 "VECTOR_MEM_ALTIVEC_P (V4SImode)"
924 [(set_attr "type" "vecperm")])
926 (define_insn "*altivec_vmrglsf"
927 [(set (match_operand:V4SF 0 "register_operand" "=v")
930 (match_operand:V4SF 1 "register_operand" "v")
931 (match_operand:V4SF 2 "register_operand" "v"))
932 (parallel [(const_int 2) (const_int 6)
933 (const_int 3) (const_int 7)])))]
934 "VECTOR_MEM_ALTIVEC_P (V4SFmode)"
936 [(set_attr "type" "vecperm")])
938 (define_insn "vec_widen_umult_even_v16qi"
939 [(set (match_operand:V8HI 0 "register_operand" "=v")
940 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
941 (match_operand:V16QI 2 "register_operand" "v")]
945 [(set_attr "type" "veccomplex")])
947 (define_insn "vec_widen_smult_even_v16qi"
948 [(set (match_operand:V8HI 0 "register_operand" "=v")
949 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
950 (match_operand:V16QI 2 "register_operand" "v")]
954 [(set_attr "type" "veccomplex")])
956 (define_insn "vec_widen_umult_even_v8hi"
957 [(set (match_operand:V4SI 0 "register_operand" "=v")
958 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
959 (match_operand:V8HI 2 "register_operand" "v")]
963 [(set_attr "type" "veccomplex")])
965 (define_insn "vec_widen_smult_even_v8hi"
966 [(set (match_operand:V4SI 0 "register_operand" "=v")
967 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
968 (match_operand:V8HI 2 "register_operand" "v")]
972 [(set_attr "type" "veccomplex")])
974 (define_insn "vec_widen_umult_odd_v16qi"
975 [(set (match_operand:V8HI 0 "register_operand" "=v")
976 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
977 (match_operand:V16QI 2 "register_operand" "v")]
981 [(set_attr "type" "veccomplex")])
983 (define_insn "vec_widen_smult_odd_v16qi"
984 [(set (match_operand:V8HI 0 "register_operand" "=v")
985 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
986 (match_operand:V16QI 2 "register_operand" "v")]
990 [(set_attr "type" "veccomplex")])
992 (define_insn "vec_widen_umult_odd_v8hi"
993 [(set (match_operand:V4SI 0 "register_operand" "=v")
994 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
995 (match_operand:V8HI 2 "register_operand" "v")]
999 [(set_attr "type" "veccomplex")])
1001 (define_insn "vec_widen_smult_odd_v8hi"
1002 [(set (match_operand:V4SI 0 "register_operand" "=v")
1003 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
1004 (match_operand:V8HI 2 "register_operand" "v")]
1008 [(set_attr "type" "veccomplex")])
1011 ;; logical ops. Have the logical ops follow the memory ops in
1012 ;; terms of whether to prefer VSX or Altivec
1014 (define_insn "*altivec_and<mode>3"
1015 [(set (match_operand:VM 0 "register_operand" "=v")
1016 (and:VM (match_operand:VM 1 "register_operand" "v")
1017 (match_operand:VM 2 "register_operand" "v")))]
1018 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1020 [(set_attr "type" "vecsimple")])
1022 (define_insn "*altivec_ior<mode>3"
1023 [(set (match_operand:VM 0 "register_operand" "=v")
1024 (ior:VM (match_operand:VM 1 "register_operand" "v")
1025 (match_operand:VM 2 "register_operand" "v")))]
1026 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1028 [(set_attr "type" "vecsimple")])
1030 (define_insn "*altivec_xor<mode>3"
1031 [(set (match_operand:VM 0 "register_operand" "=v")
1032 (xor:VM (match_operand:VM 1 "register_operand" "v")
1033 (match_operand:VM 2 "register_operand" "v")))]
1034 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1036 [(set_attr "type" "vecsimple")])
1038 (define_insn "*altivec_one_cmpl<mode>2"
1039 [(set (match_operand:VM 0 "register_operand" "=v")
1040 (not:VM (match_operand:VM 1 "register_operand" "v")))]
1041 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1043 [(set_attr "type" "vecsimple")])
1045 (define_insn "*altivec_nor<mode>3"
1046 [(set (match_operand:VM 0 "register_operand" "=v")
1047 (not:VM (ior:VM (match_operand:VM 1 "register_operand" "v")
1048 (match_operand:VM 2 "register_operand" "v"))))]
1049 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1051 [(set_attr "type" "vecsimple")])
1053 (define_insn "*altivec_andc<mode>3"
1054 [(set (match_operand:VM 0 "register_operand" "=v")
1055 (and:VM (not:VM (match_operand:VM 2 "register_operand" "v"))
1056 (match_operand:VM 1 "register_operand" "v")))]
1057 "VECTOR_MEM_ALTIVEC_P (<MODE>mode)"
1059 [(set_attr "type" "vecsimple")])
1061 (define_insn "altivec_vpkuhum"
1062 [(set (match_operand:V16QI 0 "register_operand" "=v")
1063 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1064 (match_operand:V8HI 2 "register_operand" "v")]
1068 [(set_attr "type" "vecperm")])
1070 (define_insn "altivec_vpkuwum"
1071 [(set (match_operand:V8HI 0 "register_operand" "=v")
1072 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1073 (match_operand:V4SI 2 "register_operand" "v")]
1077 [(set_attr "type" "vecperm")])
1079 (define_insn "altivec_vpkpx"
1080 [(set (match_operand:V8HI 0 "register_operand" "=v")
1081 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1082 (match_operand:V4SI 2 "register_operand" "v")]
1086 [(set_attr "type" "vecperm")])
1088 (define_insn "altivec_vpkshss"
1089 [(set (match_operand:V16QI 0 "register_operand" "=v")
1090 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1091 (match_operand:V8HI 2 "register_operand" "v")]
1093 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1096 [(set_attr "type" "vecperm")])
1098 (define_insn "altivec_vpkswss"
1099 [(set (match_operand:V8HI 0 "register_operand" "=v")
1100 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1101 (match_operand:V4SI 2 "register_operand" "v")]
1103 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1106 [(set_attr "type" "vecperm")])
1108 (define_insn "altivec_vpkuhus"
1109 [(set (match_operand:V16QI 0 "register_operand" "=v")
1110 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1111 (match_operand:V8HI 2 "register_operand" "v")]
1113 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1116 [(set_attr "type" "vecperm")])
1118 (define_insn "altivec_vpkshus"
1119 [(set (match_operand:V16QI 0 "register_operand" "=v")
1120 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1121 (match_operand:V8HI 2 "register_operand" "v")]
1123 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1126 [(set_attr "type" "vecperm")])
1128 (define_insn "altivec_vpkuwus"
1129 [(set (match_operand:V8HI 0 "register_operand" "=v")
1130 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1131 (match_operand:V4SI 2 "register_operand" "v")]
1133 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1136 [(set_attr "type" "vecperm")])
1138 (define_insn "altivec_vpkswus"
1139 [(set (match_operand:V8HI 0 "register_operand" "=v")
1140 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1141 (match_operand:V4SI 2 "register_operand" "v")]
1143 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1146 [(set_attr "type" "vecperm")])
1148 (define_insn "*altivec_vrl<VI_char>"
1149 [(set (match_operand:VI 0 "register_operand" "=v")
1150 (rotate:VI (match_operand:VI 1 "register_operand" "v")
1151 (match_operand:VI 2 "register_operand" "v")))]
1153 "vrl<VI_char> %0,%1,%2"
1154 [(set_attr "type" "vecsimple")])
1156 (define_insn "altivec_vsl"
1157 [(set (match_operand:V4SI 0 "register_operand" "=v")
1158 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1159 (match_operand:V4SI 2 "register_operand" "v")]
1163 [(set_attr "type" "vecperm")])
1165 (define_insn "altivec_vslo"
1166 [(set (match_operand:V4SI 0 "register_operand" "=v")
1167 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1168 (match_operand:V4SI 2 "register_operand" "v")]
1172 [(set_attr "type" "vecperm")])
1174 (define_insn "*altivec_vsl<VI_char>"
1175 [(set (match_operand:VI 0 "register_operand" "=v")
1176 (ashift:VI (match_operand:VI 1 "register_operand" "v")
1177 (match_operand:VI 2 "register_operand" "v")))]
1179 "vsl<VI_char> %0,%1,%2"
1180 [(set_attr "type" "vecsimple")])
1182 (define_insn "*altivec_vsr<VI_char>"
1183 [(set (match_operand:VI 0 "register_operand" "=v")
1184 (lshiftrt:VI (match_operand:VI 1 "register_operand" "v")
1185 (match_operand:VI 2 "register_operand" "v")))]
1187 "vsr<VI_char> %0,%1,%2"
1188 [(set_attr "type" "vecsimple")])
1190 (define_insn "*altivec_vsra<VI_char>"
1191 [(set (match_operand:VI 0 "register_operand" "=v")
1192 (ashiftrt:VI (match_operand:VI 1 "register_operand" "v")
1193 (match_operand:VI 2 "register_operand" "v")))]
1195 "vsra<VI_char> %0,%1,%2"
1196 [(set_attr "type" "vecsimple")])
1198 (define_insn "altivec_vsr"
1199 [(set (match_operand:V4SI 0 "register_operand" "=v")
1200 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1201 (match_operand:V4SI 2 "register_operand" "v")]
1205 [(set_attr "type" "vecperm")])
1207 (define_insn "altivec_vsro"
1208 [(set (match_operand:V4SI 0 "register_operand" "=v")
1209 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1210 (match_operand:V4SI 2 "register_operand" "v")]
1214 [(set_attr "type" "vecperm")])
1216 (define_insn "altivec_vsum4ubs"
1217 [(set (match_operand:V4SI 0 "register_operand" "=v")
1218 (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
1219 (match_operand:V4SI 2 "register_operand" "v")]
1221 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1224 [(set_attr "type" "veccomplex")])
1226 (define_insn "altivec_vsum4s<VI_char>s"
1227 [(set (match_operand:V4SI 0 "register_operand" "=v")
1228 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
1229 (match_operand:V4SI 2 "register_operand" "v")]
1231 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1233 "vsum4s<VI_char>s %0,%1,%2"
1234 [(set_attr "type" "veccomplex")])
1236 (define_insn "altivec_vsum2sws"
1237 [(set (match_operand:V4SI 0 "register_operand" "=v")
1238 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1239 (match_operand:V4SI 2 "register_operand" "v")]
1241 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1244 [(set_attr "type" "veccomplex")])
1246 (define_insn "altivec_vsumsws"
1247 [(set (match_operand:V4SI 0 "register_operand" "=v")
1248 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1249 (match_operand:V4SI 2 "register_operand" "v")]
1251 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1254 [(set_attr "type" "veccomplex")])
1256 (define_insn "altivec_vspltb"
1257 [(set (match_operand:V16QI 0 "register_operand" "=v")
1258 (vec_duplicate:V16QI
1259 (vec_select:QI (match_operand:V16QI 1 "register_operand" "v")
1261 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1264 [(set_attr "type" "vecperm")])
1266 (define_insn "altivec_vsplth"
1267 [(set (match_operand:V8HI 0 "register_operand" "=v")
1269 (vec_select:HI (match_operand:V8HI 1 "register_operand" "v")
1271 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1274 [(set_attr "type" "vecperm")])
1276 (define_insn "altivec_vspltw"
1277 [(set (match_operand:V4SI 0 "register_operand" "=v")
1279 (vec_select:SI (match_operand:V4SI 1 "register_operand" "v")
1281 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1284 [(set_attr "type" "vecperm")])
1286 (define_insn "altivec_vspltsf"
1287 [(set (match_operand:V4SF 0 "register_operand" "=v")
1289 (vec_select:SF (match_operand:V4SF 1 "register_operand" "v")
1291 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1292 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1294 [(set_attr "type" "vecperm")])
1296 (define_insn "altivec_vspltis<VI_char>"
1297 [(set (match_operand:VI 0 "register_operand" "=v")
1299 (match_operand:QI 1 "s5bit_cint_operand" "i")))]
1301 "vspltis<VI_char> %0,%1"
1302 [(set_attr "type" "vecperm")])
1304 (define_insn "*altivec_vrfiz"
1305 [(set (match_operand:V4SF 0 "register_operand" "=v")
1306 (fix:V4SF (match_operand:V4SF 1 "register_operand" "v")))]
1307 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1309 [(set_attr "type" "vecfloat")])
1311 (define_insn "altivec_vperm_<mode>"
1312 [(set (match_operand:VM 0 "register_operand" "=v")
1313 (unspec:VM [(match_operand:VM 1 "register_operand" "v")
1314 (match_operand:VM 2 "register_operand" "v")
1315 (match_operand:V16QI 3 "register_operand" "v")]
1319 [(set_attr "type" "vecperm")])
1321 (define_insn "altivec_vperm_<mode>_uns"
1322 [(set (match_operand:VM 0 "register_operand" "=v")
1323 (unspec:VM [(match_operand:VM 1 "register_operand" "v")
1324 (match_operand:VM 2 "register_operand" "v")
1325 (match_operand:V16QI 3 "register_operand" "v")]
1329 [(set_attr "type" "vecperm")])
1331 (define_expand "vec_permv16qi"
1332 [(set (match_operand:V16QI 0 "register_operand" "")
1333 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "")
1334 (match_operand:V16QI 2 "register_operand" "")
1335 (match_operand:V16QI 3 "register_operand" "")]
1340 (define_expand "vec_perm_constv16qi"
1341 [(match_operand:V16QI 0 "register_operand" "")
1342 (match_operand:V16QI 1 "register_operand" "")
1343 (match_operand:V16QI 2 "register_operand" "")
1344 (match_operand:V16QI 3 "" "")]
1347 if (altivec_expand_vec_perm_const (operands))
1353 (define_insn "altivec_vrfip" ; ceil
1354 [(set (match_operand:V4SF 0 "register_operand" "=v")
1355 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1359 [(set_attr "type" "vecfloat")])
1361 (define_insn "altivec_vrfin"
1362 [(set (match_operand:V4SF 0 "register_operand" "=v")
1363 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1367 [(set_attr "type" "vecfloat")])
1369 (define_insn "*altivec_vrfim" ; floor
1370 [(set (match_operand:V4SF 0 "register_operand" "=v")
1371 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1375 [(set_attr "type" "vecfloat")])
1377 (define_insn "altivec_vcfux"
1378 [(set (match_operand:V4SF 0 "register_operand" "=v")
1379 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1380 (match_operand:QI 2 "immediate_operand" "i")]
1384 [(set_attr "type" "vecfloat")])
1386 (define_insn "altivec_vcfsx"
1387 [(set (match_operand:V4SF 0 "register_operand" "=v")
1388 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1389 (match_operand:QI 2 "immediate_operand" "i")]
1393 [(set_attr "type" "vecfloat")])
1395 (define_insn "altivec_vctuxs"
1396 [(set (match_operand:V4SI 0 "register_operand" "=v")
1397 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1398 (match_operand:QI 2 "immediate_operand" "i")]
1400 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1403 [(set_attr "type" "vecfloat")])
1405 (define_insn "altivec_vctsxs"
1406 [(set (match_operand:V4SI 0 "register_operand" "=v")
1407 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1408 (match_operand:QI 2 "immediate_operand" "i")]
1410 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1413 [(set_attr "type" "vecfloat")])
1415 (define_insn "altivec_vlogefp"
1416 [(set (match_operand:V4SF 0 "register_operand" "=v")
1417 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1421 [(set_attr "type" "vecfloat")])
1423 (define_insn "altivec_vexptefp"
1424 [(set (match_operand:V4SF 0 "register_operand" "=v")
1425 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1429 [(set_attr "type" "vecfloat")])
1431 (define_insn "*altivec_vrsqrtefp"
1432 [(set (match_operand:V4SF 0 "register_operand" "=v")
1433 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1435 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1437 [(set_attr "type" "vecfloat")])
1439 (define_insn "altivec_vrefp"
1440 [(set (match_operand:V4SF 0 "register_operand" "=v")
1441 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1443 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1445 [(set_attr "type" "vecfloat")])
1447 (define_expand "altivec_copysign_v4sf3"
1448 [(use (match_operand:V4SF 0 "register_operand" ""))
1449 (use (match_operand:V4SF 1 "register_operand" ""))
1450 (use (match_operand:V4SF 2 "register_operand" ""))]
1451 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1454 rtx mask = gen_reg_rtx (V4SImode);
1455 rtvec v = rtvec_alloc (4);
1456 unsigned HOST_WIDE_INT mask_val = ((unsigned HOST_WIDE_INT)1) << 31;
1458 RTVEC_ELT (v, 0) = GEN_INT (mask_val);
1459 RTVEC_ELT (v, 1) = GEN_INT (mask_val);
1460 RTVEC_ELT (v, 2) = GEN_INT (mask_val);
1461 RTVEC_ELT (v, 3) = GEN_INT (mask_val);
1463 emit_insn (gen_vec_initv4si (mask, gen_rtx_PARALLEL (V4SImode, v)));
1464 emit_insn (gen_vector_select_v4sf (operands[0], operands[1], operands[2],
1465 gen_lowpart (V4SFmode, mask)));
1469 (define_insn "altivec_vsldoi_<mode>"
1470 [(set (match_operand:VM 0 "register_operand" "=v")
1471 (unspec:VM [(match_operand:VM 1 "register_operand" "v")
1472 (match_operand:VM 2 "register_operand" "v")
1473 (match_operand:QI 3 "immediate_operand" "i")]
1476 "vsldoi %0,%1,%2,%3"
1477 [(set_attr "type" "vecperm")])
1479 (define_insn "altivec_vupkhsb"
1480 [(set (match_operand:V8HI 0 "register_operand" "=v")
1481 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1485 [(set_attr "type" "vecperm")])
1487 (define_insn "altivec_vupkhpx"
1488 [(set (match_operand:V4SI 0 "register_operand" "=v")
1489 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1493 [(set_attr "type" "vecperm")])
1495 (define_insn "altivec_vupkhsh"
1496 [(set (match_operand:V4SI 0 "register_operand" "=v")
1497 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1501 [(set_attr "type" "vecperm")])
1503 (define_insn "altivec_vupklsb"
1504 [(set (match_operand:V8HI 0 "register_operand" "=v")
1505 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1509 [(set_attr "type" "vecperm")])
1511 (define_insn "altivec_vupklpx"
1512 [(set (match_operand:V4SI 0 "register_operand" "=v")
1513 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1517 [(set_attr "type" "vecperm")])
1519 (define_insn "altivec_vupklsh"
1520 [(set (match_operand:V4SI 0 "register_operand" "=v")
1521 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1525 [(set_attr "type" "vecperm")])
1527 ;; Compare vectors producing a vector result and a predicate, setting CR6 to
1528 ;; indicate a combined status
1529 (define_insn "*altivec_vcmpequ<VI_char>_p"
1531 (unspec:CC [(eq:CC (match_operand:VI 1 "register_operand" "v")
1532 (match_operand:VI 2 "register_operand" "v"))]
1534 (set (match_operand:VI 0 "register_operand" "=v")
1535 (eq:VI (match_dup 1)
1537 "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
1538 "vcmpequ<VI_char>. %0,%1,%2"
1539 [(set_attr "type" "veccmp")])
1541 (define_insn "*altivec_vcmpgts<VI_char>_p"
1543 (unspec:CC [(gt:CC (match_operand:VI 1 "register_operand" "v")
1544 (match_operand:VI 2 "register_operand" "v"))]
1546 (set (match_operand:VI 0 "register_operand" "=v")
1547 (gt:VI (match_dup 1)
1549 "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
1550 "vcmpgts<VI_char>. %0,%1,%2"
1551 [(set_attr "type" "veccmp")])
1553 (define_insn "*altivec_vcmpgtu<VI_char>_p"
1555 (unspec:CC [(gtu:CC (match_operand:VI 1 "register_operand" "v")
1556 (match_operand:VI 2 "register_operand" "v"))]
1558 (set (match_operand:VI 0 "register_operand" "=v")
1559 (gtu:VI (match_dup 1)
1561 "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
1562 "vcmpgtu<VI_char>. %0,%1,%2"
1563 [(set_attr "type" "veccmp")])
1565 (define_insn "*altivec_vcmpeqfp_p"
1567 (unspec:CC [(eq:CC (match_operand:V4SF 1 "register_operand" "v")
1568 (match_operand:V4SF 2 "register_operand" "v"))]
1570 (set (match_operand:V4SF 0 "register_operand" "=v")
1571 (eq:V4SF (match_dup 1)
1573 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1574 "vcmpeqfp. %0,%1,%2"
1575 [(set_attr "type" "veccmp")])
1577 (define_insn "*altivec_vcmpgtfp_p"
1579 (unspec:CC [(gt:CC (match_operand:V4SF 1 "register_operand" "v")
1580 (match_operand:V4SF 2 "register_operand" "v"))]
1582 (set (match_operand:V4SF 0 "register_operand" "=v")
1583 (gt:V4SF (match_dup 1)
1585 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1586 "vcmpgtfp. %0,%1,%2"
1587 [(set_attr "type" "veccmp")])
1589 (define_insn "*altivec_vcmpgefp_p"
1591 (unspec:CC [(ge:CC (match_operand:V4SF 1 "register_operand" "v")
1592 (match_operand:V4SF 2 "register_operand" "v"))]
1594 (set (match_operand:V4SF 0 "register_operand" "=v")
1595 (ge:V4SF (match_dup 1)
1597 "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
1598 "vcmpgefp. %0,%1,%2"
1599 [(set_attr "type" "veccmp")])
1601 (define_insn "altivec_vcmpbfp_p"
1603 (unspec:CC [(match_operand:V4SF 1 "register_operand" "v")
1604 (match_operand:V4SF 2 "register_operand" "v")]
1606 (set (match_operand:V4SF 0 "register_operand" "=v")
1607 (unspec:V4SF [(match_dup 1)
1610 "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
1612 [(set_attr "type" "veccmp")])
1614 (define_insn "altivec_mtvscr"
1617 [(match_operand:V4SI 0 "register_operand" "v")] UNSPECV_MTVSCR))]
1620 [(set_attr "type" "vecsimple")])
1622 (define_insn "altivec_mfvscr"
1623 [(set (match_operand:V8HI 0 "register_operand" "=v")
1624 (unspec_volatile:V8HI [(reg:SI 110)] UNSPECV_MFVSCR))]
1627 [(set_attr "type" "vecsimple")])
1629 (define_insn "altivec_dssall"
1630 [(unspec_volatile [(const_int 0)] UNSPECV_DSSALL)]
1633 [(set_attr "type" "vecsimple")])
1635 (define_insn "altivec_dss"
1636 [(unspec_volatile [(match_operand:QI 0 "immediate_operand" "i")]
1640 [(set_attr "type" "vecsimple")])
1642 (define_insn "altivec_dst"
1643 [(unspec [(match_operand 0 "register_operand" "b")
1644 (match_operand:SI 1 "register_operand" "r")
1645 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DST)]
1646 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1648 [(set_attr "type" "vecsimple")])
1650 (define_insn "altivec_dstt"
1651 [(unspec [(match_operand 0 "register_operand" "b")
1652 (match_operand:SI 1 "register_operand" "r")
1653 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTT)]
1654 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1656 [(set_attr "type" "vecsimple")])
1658 (define_insn "altivec_dstst"
1659 [(unspec [(match_operand 0 "register_operand" "b")
1660 (match_operand:SI 1 "register_operand" "r")
1661 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTST)]
1662 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1664 [(set_attr "type" "vecsimple")])
1666 (define_insn "altivec_dststt"
1667 [(unspec [(match_operand 0 "register_operand" "b")
1668 (match_operand:SI 1 "register_operand" "r")
1669 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTSTT)]
1670 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1672 [(set_attr "type" "vecsimple")])
1674 (define_insn "altivec_lvsl"
1675 [(set (match_operand:V16QI 0 "register_operand" "=v")
1676 (unspec:V16QI [(match_operand:V16QI 1 "memory_operand" "Z")]
1680 [(set_attr "type" "vecload")])
1682 (define_insn "altivec_lvsr"
1683 [(set (match_operand:V16QI 0 "register_operand" "=v")
1684 (unspec:V16QI [(match_operand:V16QI 1 "memory_operand" "Z")]
1688 [(set_attr "type" "vecload")])
1690 (define_expand "build_vector_mask_for_load"
1691 [(set (match_operand:V16QI 0 "register_operand" "")
1692 (unspec:V16QI [(match_operand 1 "memory_operand" "")] UNSPEC_LVSR))]
1699 gcc_assert (GET_CODE (operands[1]) == MEM);
1701 addr = XEXP (operands[1], 0);
1702 temp = gen_reg_rtx (GET_MODE (addr));
1703 emit_insn (gen_rtx_SET (VOIDmode, temp,
1704 gen_rtx_NEG (GET_MODE (addr), addr)));
1705 emit_insn (gen_altivec_lvsr (operands[0],
1706 replace_equiv_address (operands[1], temp)));
1710 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
1711 ;; identical rtl but different instructions-- and gcc gets confused.
1713 (define_insn "altivec_lve<VI_char>x"
1715 [(set (match_operand:VI 0 "register_operand" "=v")
1716 (match_operand:VI 1 "memory_operand" "Z"))
1717 (unspec [(const_int 0)] UNSPEC_LVE)])]
1719 "lve<VI_char>x %0,%y1"
1720 [(set_attr "type" "vecload")])
1722 (define_insn "*altivec_lvesfx"
1724 [(set (match_operand:V4SF 0 "register_operand" "=v")
1725 (match_operand:V4SF 1 "memory_operand" "Z"))
1726 (unspec [(const_int 0)] UNSPEC_LVE)])]
1729 [(set_attr "type" "vecload")])
1731 (define_insn "altivec_lvxl"
1733 [(set (match_operand:V4SI 0 "register_operand" "=v")
1734 (match_operand:V4SI 1 "memory_operand" "Z"))
1735 (unspec [(const_int 0)] UNSPEC_SET_VSCR)])]
1738 [(set_attr "type" "vecload")])
1740 (define_insn "altivec_lvx_<mode>"
1742 [(set (match_operand:VM2 0 "register_operand" "=v")
1743 (match_operand:VM2 1 "memory_operand" "Z"))
1744 (unspec [(const_int 0)] UNSPEC_LVX)])]
1747 [(set_attr "type" "vecload")])
1749 (define_insn "altivec_stvx_<mode>"
1751 [(set (match_operand:VM2 0 "memory_operand" "=Z")
1752 (match_operand:VM2 1 "register_operand" "v"))
1753 (unspec [(const_int 0)] UNSPEC_STVX)])]
1756 [(set_attr "type" "vecstore")])
1758 (define_insn "altivec_stvxl"
1760 [(set (match_operand:V4SI 0 "memory_operand" "=Z")
1761 (match_operand:V4SI 1 "register_operand" "v"))
1762 (unspec [(const_int 0)] UNSPEC_STVXL)])]
1765 [(set_attr "type" "vecstore")])
1767 (define_insn "altivec_stve<VI_char>x"
1768 [(set (match_operand:<VI_scalar> 0 "memory_operand" "=Z")
1769 (unspec:<VI_scalar> [(match_operand:VI 1 "register_operand" "v")] UNSPEC_STVE))]
1771 "stve<VI_char>x %1,%y0"
1772 [(set_attr "type" "vecstore")])
1774 (define_insn "*altivec_stvesfx"
1775 [(set (match_operand:SF 0 "memory_operand" "=Z")
1776 (unspec:SF [(match_operand:V4SF 1 "register_operand" "v")] UNSPEC_STVE))]
1779 [(set_attr "type" "vecstore")])
1782 ;; vspltis? SCRATCH0,0
1783 ;; vsubu?m SCRATCH2,SCRATCH1,%1
1784 ;; vmaxs? %0,%1,SCRATCH2"
1785 (define_expand "abs<mode>2"
1786 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
1788 (minus:VI (match_dup 2)
1789 (match_operand:VI 1 "register_operand" "v")))
1790 (set (match_operand:VI 0 "register_operand" "=v")
1791 (smax:VI (match_dup 1) (match_dup 3)))]
1794 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
1795 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
1799 ;; vspltisw SCRATCH1,-1
1800 ;; vslw SCRATCH2,SCRATCH1,SCRATCH1
1801 ;; vandc %0,%1,SCRATCH2
1802 (define_expand "altivec_absv4sf2"
1804 (vec_duplicate:V4SI (const_int -1)))
1806 (ashift:V4SI (match_dup 2) (match_dup 2)))
1807 (set (match_operand:V4SF 0 "register_operand" "=v")
1808 (and:V4SF (not:V4SF (subreg:V4SF (match_dup 3) 0))
1809 (match_operand:V4SF 1 "register_operand" "v")))]
1812 operands[2] = gen_reg_rtx (V4SImode);
1813 operands[3] = gen_reg_rtx (V4SImode);
1817 ;; vspltis? SCRATCH0,0
1818 ;; vsubs?s SCRATCH2,SCRATCH1,%1
1819 ;; vmaxs? %0,%1,SCRATCH2"
1820 (define_expand "altivec_abss_<mode>"
1821 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
1822 (parallel [(set (match_dup 3)
1823 (unspec:VI [(match_dup 2)
1824 (match_operand:VI 1 "register_operand" "v")]
1826 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))])
1827 (set (match_operand:VI 0 "register_operand" "=v")
1828 (smax:VI (match_dup 1) (match_dup 3)))]
1831 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
1832 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
1835 (define_expand "reduc_splus_<mode>"
1836 [(set (match_operand:VIshort 0 "register_operand" "=v")
1837 (unspec:VIshort [(match_operand:VIshort 1 "register_operand" "v")]
1838 UNSPEC_REDUC_PLUS))]
1841 rtx vzero = gen_reg_rtx (V4SImode);
1842 rtx vtmp1 = gen_reg_rtx (V4SImode);
1843 rtx dest = gen_lowpart (V4SImode, operands[0]);
1845 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
1846 emit_insn (gen_altivec_vsum4s<VI_char>s (vtmp1, operands[1], vzero));
1847 emit_insn (gen_altivec_vsumsws (dest, vtmp1, vzero));
1851 (define_expand "reduc_uplus_v16qi"
1852 [(set (match_operand:V16QI 0 "register_operand" "=v")
1853 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
1854 UNSPEC_REDUC_PLUS))]
1857 rtx vzero = gen_reg_rtx (V4SImode);
1858 rtx vtmp1 = gen_reg_rtx (V4SImode);
1859 rtx dest = gen_lowpart (V4SImode, operands[0]);
1861 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
1862 emit_insn (gen_altivec_vsum4ubs (vtmp1, operands[1], vzero));
1863 emit_insn (gen_altivec_vsumsws (dest, vtmp1, vzero));
1867 (define_expand "neg<mode>2"
1868 [(use (match_operand:VI 0 "register_operand" ""))
1869 (use (match_operand:VI 1 "register_operand" ""))]
1875 vzero = gen_reg_rtx (GET_MODE (operands[0]));
1876 emit_insn (gen_altivec_vspltis<VI_char> (vzero, const0_rtx));
1877 emit_insn (gen_sub<mode>3 (operands[0], vzero, operands[1]));
1882 (define_expand "udot_prod<mode>"
1883 [(set (match_operand:V4SI 0 "register_operand" "=v")
1884 (plus:V4SI (match_operand:V4SI 3 "register_operand" "v")
1885 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
1886 (match_operand:VIshort 2 "register_operand" "v")]
1891 emit_insn (gen_altivec_vmsumu<VI_char>m (operands[0], operands[1], operands[2], operands[3]));
1895 (define_expand "sdot_prodv8hi"
1896 [(set (match_operand:V4SI 0 "register_operand" "=v")
1897 (plus:V4SI (match_operand:V4SI 3 "register_operand" "v")
1898 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
1899 (match_operand:V8HI 2 "register_operand" "v")]
1904 emit_insn (gen_altivec_vmsumshm (operands[0], operands[1], operands[2], operands[3]));
1908 (define_expand "widen_usum<mode>3"
1909 [(set (match_operand:V4SI 0 "register_operand" "=v")
1910 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
1911 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")]
1916 rtx vones = gen_reg_rtx (GET_MODE (operands[1]));
1918 emit_insn (gen_altivec_vspltis<VI_char> (vones, const1_rtx));
1919 emit_insn (gen_altivec_vmsumu<VI_char>m (operands[0], operands[1], vones, operands[2]));
1923 (define_expand "widen_ssumv16qi3"
1924 [(set (match_operand:V4SI 0 "register_operand" "=v")
1925 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
1926 (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")]
1931 rtx vones = gen_reg_rtx (V16QImode);
1933 emit_insn (gen_altivec_vspltisb (vones, const1_rtx));
1934 emit_insn (gen_altivec_vmsummbm (operands[0], operands[1], vones, operands[2]));
1938 (define_expand "widen_ssumv8hi3"
1939 [(set (match_operand:V4SI 0 "register_operand" "=v")
1940 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
1941 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1946 rtx vones = gen_reg_rtx (V8HImode);
1948 emit_insn (gen_altivec_vspltish (vones, const1_rtx));
1949 emit_insn (gen_altivec_vmsumshm (operands[0], operands[1], vones, operands[2]));
1953 (define_expand "vec_unpacks_hi_v16qi"
1954 [(set (match_operand:V8HI 0 "register_operand" "=v")
1955 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1960 emit_insn (gen_altivec_vupkhsb (operands[0], operands[1]));
1964 (define_expand "vec_unpacks_hi_v8hi"
1965 [(set (match_operand:V4SI 0 "register_operand" "=v")
1966 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1971 emit_insn (gen_altivec_vupkhsh (operands[0], operands[1]));
1975 (define_expand "vec_unpacks_lo_v16qi"
1976 [(set (match_operand:V8HI 0 "register_operand" "=v")
1977 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1982 emit_insn (gen_altivec_vupklsb (operands[0], operands[1]));
1986 (define_expand "vec_unpacks_lo_v8hi"
1987 [(set (match_operand:V4SI 0 "register_operand" "=v")
1988 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1993 emit_insn (gen_altivec_vupklsh (operands[0], operands[1]));
1997 (define_insn "vperm_v8hiv4si"
1998 [(set (match_operand:V4SI 0 "register_operand" "=v")
1999 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2000 (match_operand:V4SI 2 "register_operand" "v")
2001 (match_operand:V16QI 3 "register_operand" "v")]
2005 [(set_attr "type" "vecperm")])
2007 (define_insn "vperm_v16qiv8hi"
2008 [(set (match_operand:V8HI 0 "register_operand" "=v")
2009 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2010 (match_operand:V8HI 2 "register_operand" "v")
2011 (match_operand:V16QI 3 "register_operand" "v")]
2015 [(set_attr "type" "vecperm")])
2018 (define_expand "vec_unpacku_hi_v16qi"
2019 [(set (match_operand:V8HI 0 "register_operand" "=v")
2020 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2025 rtx vzero = gen_reg_rtx (V8HImode);
2026 rtx mask = gen_reg_rtx (V16QImode);
2027 rtvec v = rtvec_alloc (16);
2029 emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
2031 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2032 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 0);
2033 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
2034 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
2035 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2036 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 2);
2037 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
2038 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
2039 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2040 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 4);
2041 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
2042 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
2043 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2044 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 6);
2045 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
2046 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
2048 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2049 emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
2053 (define_expand "vec_unpacku_hi_v8hi"
2054 [(set (match_operand:V4SI 0 "register_operand" "=v")
2055 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2060 rtx vzero = gen_reg_rtx (V4SImode);
2061 rtx mask = gen_reg_rtx (V16QImode);
2062 rtvec v = rtvec_alloc (16);
2064 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2066 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2067 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
2068 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 0);
2069 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
2070 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2071 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
2072 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 2);
2073 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
2074 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2075 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
2076 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 4);
2077 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
2078 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2079 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
2080 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 6);
2081 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
2083 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2084 emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
2088 (define_expand "vec_unpacku_lo_v16qi"
2089 [(set (match_operand:V8HI 0 "register_operand" "=v")
2090 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2095 rtx vzero = gen_reg_rtx (V8HImode);
2096 rtx mask = gen_reg_rtx (V16QImode);
2097 rtvec v = rtvec_alloc (16);
2099 emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
2101 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2102 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 8);
2103 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
2104 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
2105 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2106 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 10);
2107 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
2108 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
2109 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2110 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 12);
2111 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
2112 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
2113 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2114 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 14);
2115 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
2116 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
2118 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2119 emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
2123 (define_expand "vec_unpacku_lo_v8hi"
2124 [(set (match_operand:V4SI 0 "register_operand" "=v")
2125 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2130 rtx vzero = gen_reg_rtx (V4SImode);
2131 rtx mask = gen_reg_rtx (V16QImode);
2132 rtvec v = rtvec_alloc (16);
2134 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2136 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2137 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
2138 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 8);
2139 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
2140 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2141 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
2142 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 10);
2143 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
2144 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2145 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
2146 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 12);
2147 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
2148 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2149 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
2150 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 14);
2151 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
2153 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2154 emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
2158 (define_expand "vec_widen_umult_hi_v16qi"
2159 [(set (match_operand:V8HI 0 "register_operand" "=v")
2160 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2161 (match_operand:V16QI 2 "register_operand" "v")]
2166 rtx ve = gen_reg_rtx (V8HImode);
2167 rtx vo = gen_reg_rtx (V8HImode);
2169 emit_insn (gen_vec_widen_umult_even_v16qi (ve, operands[1], operands[2]));
2170 emit_insn (gen_vec_widen_umult_odd_v16qi (vo, operands[1], operands[2]));
2171 emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
2175 (define_expand "vec_widen_umult_lo_v16qi"
2176 [(set (match_operand:V8HI 0 "register_operand" "=v")
2177 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2178 (match_operand:V16QI 2 "register_operand" "v")]
2183 rtx ve = gen_reg_rtx (V8HImode);
2184 rtx vo = gen_reg_rtx (V8HImode);
2186 emit_insn (gen_vec_widen_umult_even_v16qi (ve, operands[1], operands[2]));
2187 emit_insn (gen_vec_widen_umult_odd_v16qi (vo, operands[1], operands[2]));
2188 emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
2192 (define_expand "vec_widen_smult_hi_v16qi"
2193 [(set (match_operand:V8HI 0 "register_operand" "=v")
2194 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2195 (match_operand:V16QI 2 "register_operand" "v")]
2200 rtx ve = gen_reg_rtx (V8HImode);
2201 rtx vo = gen_reg_rtx (V8HImode);
2203 emit_insn (gen_vec_widen_smult_even_v16qi (ve, operands[1], operands[2]));
2204 emit_insn (gen_vec_widen_smult_odd_v16qi (vo, operands[1], operands[2]));
2205 emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
2209 (define_expand "vec_widen_smult_lo_v16qi"
2210 [(set (match_operand:V8HI 0 "register_operand" "=v")
2211 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2212 (match_operand:V16QI 2 "register_operand" "v")]
2217 rtx ve = gen_reg_rtx (V8HImode);
2218 rtx vo = gen_reg_rtx (V8HImode);
2220 emit_insn (gen_vec_widen_smult_even_v16qi (ve, operands[1], operands[2]));
2221 emit_insn (gen_vec_widen_smult_odd_v16qi (vo, operands[1], operands[2]));
2222 emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
2226 (define_expand "vec_widen_umult_hi_v8hi"
2227 [(set (match_operand:V4SI 0 "register_operand" "=v")
2228 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2229 (match_operand:V8HI 2 "register_operand" "v")]
2234 rtx ve = gen_reg_rtx (V4SImode);
2235 rtx vo = gen_reg_rtx (V4SImode);
2237 emit_insn (gen_vec_widen_umult_even_v8hi (ve, operands[1], operands[2]));
2238 emit_insn (gen_vec_widen_umult_odd_v8hi (vo, operands[1], operands[2]));
2239 emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
2243 (define_expand "vec_widen_umult_lo_v8hi"
2244 [(set (match_operand:V4SI 0 "register_operand" "=v")
2245 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2246 (match_operand:V8HI 2 "register_operand" "v")]
2251 rtx ve = gen_reg_rtx (V4SImode);
2252 rtx vo = gen_reg_rtx (V4SImode);
2254 emit_insn (gen_vec_widen_umult_even_v8hi (ve, operands[1], operands[2]));
2255 emit_insn (gen_vec_widen_umult_odd_v8hi (vo, operands[1], operands[2]));
2256 emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
2260 (define_expand "vec_widen_smult_hi_v8hi"
2261 [(set (match_operand:V4SI 0 "register_operand" "=v")
2262 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2263 (match_operand:V8HI 2 "register_operand" "v")]
2268 rtx ve = gen_reg_rtx (V4SImode);
2269 rtx vo = gen_reg_rtx (V4SImode);
2271 emit_insn (gen_vec_widen_smult_even_v8hi (ve, operands[1], operands[2]));
2272 emit_insn (gen_vec_widen_smult_odd_v8hi (vo, operands[1], operands[2]));
2273 emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
2277 (define_expand "vec_widen_smult_lo_v8hi"
2278 [(set (match_operand:V4SI 0 "register_operand" "=v")
2279 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2280 (match_operand:V8HI 2 "register_operand" "v")]
2285 rtx ve = gen_reg_rtx (V4SImode);
2286 rtx vo = gen_reg_rtx (V4SImode);
2288 emit_insn (gen_vec_widen_smult_even_v8hi (ve, operands[1], operands[2]));
2289 emit_insn (gen_vec_widen_smult_odd_v8hi (vo, operands[1], operands[2]));
2290 emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
2294 (define_expand "vec_pack_trunc_v8hi"
2295 [(set (match_operand:V16QI 0 "register_operand" "=v")
2296 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
2297 (match_operand:V8HI 2 "register_operand" "v")]
2302 emit_insn (gen_altivec_vpkuhum (operands[0], operands[1], operands[2]));
2306 (define_expand "vec_pack_trunc_v4si"
2307 [(set (match_operand:V8HI 0 "register_operand" "=v")
2308 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
2309 (match_operand:V4SI 2 "register_operand" "v")]
2314 emit_insn (gen_altivec_vpkuwum (operands[0], operands[1], operands[2]));
2318 (define_expand "altivec_negv4sf2"
2319 [(use (match_operand:V4SF 0 "register_operand" ""))
2320 (use (match_operand:V4SF 1 "register_operand" ""))]
2326 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
2327 neg0 = gen_reg_rtx (V4SImode);
2328 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
2329 emit_insn (gen_vashlv4si3 (neg0, neg0, neg0));
2332 emit_insn (gen_xorv4sf3 (operands[0],
2333 gen_lowpart (V4SFmode, neg0), operands[1]));
2338 ;; Vector SIMD PEM v2.06c defines LVLX, LVLXL, LVRX, LVRXL,
2339 ;; STVLX, STVLXL, STVVRX, STVRXL are available only on Cell.
2340 (define_insn "altivec_lvlx"
2341 [(set (match_operand:V16QI 0 "register_operand" "=v")
2342 (unspec:V16QI [(match_operand:BLK 1 "memory_operand" "Z")]
2344 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2346 [(set_attr "type" "vecload")])
2348 (define_insn "altivec_lvlxl"
2349 [(set (match_operand:V16QI 0 "register_operand" "=v")
2350 (unspec:V16QI [(match_operand:BLK 1 "memory_operand" "Z")]
2352 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2354 [(set_attr "type" "vecload")])
2356 (define_insn "altivec_lvrx"
2357 [(set (match_operand:V16QI 0 "register_operand" "=v")
2358 (unspec:V16QI [(match_operand:BLK 1 "memory_operand" "Z")]
2360 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2362 [(set_attr "type" "vecload")])
2364 (define_insn "altivec_lvrxl"
2365 [(set (match_operand:V16QI 0 "register_operand" "=v")
2366 (unspec:V16QI [(match_operand:BLK 1 "memory_operand" "Z")]
2368 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2370 [(set_attr "type" "vecload")])
2372 (define_insn "altivec_stvlx"
2374 [(set (match_operand:V16QI 0 "memory_operand" "=Z")
2375 (match_operand:V16QI 1 "register_operand" "v"))
2376 (unspec [(const_int 0)] UNSPEC_STVLX)])]
2377 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2379 [(set_attr "type" "vecstore")])
2381 (define_insn "altivec_stvlxl"
2383 [(set (match_operand:V16QI 0 "memory_operand" "=Z")
2384 (match_operand:V16QI 1 "register_operand" "v"))
2385 (unspec [(const_int 0)] UNSPEC_STVLXL)])]
2386 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2388 [(set_attr "type" "vecstore")])
2390 (define_insn "altivec_stvrx"
2392 [(set (match_operand:V16QI 0 "memory_operand" "=Z")
2393 (match_operand:V16QI 1 "register_operand" "v"))
2394 (unspec [(const_int 0)] UNSPEC_STVRX)])]
2395 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2397 [(set_attr "type" "vecstore")])
2399 (define_insn "altivec_stvrxl"
2401 [(set (match_operand:V16QI 0 "memory_operand" "=Z")
2402 (match_operand:V16QI 1 "register_operand" "v"))
2403 (unspec [(const_int 0)] UNSPEC_STVRXL)])]
2404 "TARGET_ALTIVEC && rs6000_cpu == PROCESSOR_CELL"
2406 [(set_attr "type" "vecstore")])
2408 (define_expand "vec_unpacks_float_hi_v8hi"
2409 [(set (match_operand:V4SF 0 "register_operand" "")
2410 (unspec:V4SF [(match_operand:V8HI 1 "register_operand" "")]
2411 UNSPEC_VUPKHS_V4SF))]
2415 rtx tmp = gen_reg_rtx (V4SImode);
2417 emit_insn (gen_vec_unpacks_hi_v8hi (tmp, operands[1]));
2418 emit_insn (gen_altivec_vcfsx (operands[0], tmp, const0_rtx));
2422 (define_expand "vec_unpacks_float_lo_v8hi"
2423 [(set (match_operand:V4SF 0 "register_operand" "")
2424 (unspec:V4SF [(match_operand:V8HI 1 "register_operand" "")]
2425 UNSPEC_VUPKLS_V4SF))]
2429 rtx tmp = gen_reg_rtx (V4SImode);
2431 emit_insn (gen_vec_unpacks_lo_v8hi (tmp, operands[1]));
2432 emit_insn (gen_altivec_vcfsx (operands[0], tmp, const0_rtx));
2436 (define_expand "vec_unpacku_float_hi_v8hi"
2437 [(set (match_operand:V4SF 0 "register_operand" "")
2438 (unspec:V4SF [(match_operand:V8HI 1 "register_operand" "")]
2439 UNSPEC_VUPKHU_V4SF))]
2443 rtx tmp = gen_reg_rtx (V4SImode);
2445 emit_insn (gen_vec_unpacku_hi_v8hi (tmp, operands[1]));
2446 emit_insn (gen_altivec_vcfux (operands[0], tmp, const0_rtx));
2450 (define_expand "vec_unpacku_float_lo_v8hi"
2451 [(set (match_operand:V4SF 0 "register_operand" "")
2452 (unspec:V4SF [(match_operand:V8HI 1 "register_operand" "")]
2453 UNSPEC_VUPKLU_V4SF))]
2457 rtx tmp = gen_reg_rtx (V4SImode);
2459 emit_insn (gen_vec_unpacku_lo_v8hi (tmp, operands[1]));
2460 emit_insn (gen_altivec_vcfux (operands[0], tmp, const0_rtx));