2 ;; Copyright (C) 2002, 2003, 2004, 2005, 2006 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 2, 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 COPYING. If not, write to the
19 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
20 ;; MA 02110-1301, USA.
42 (UNSPEC_VMHRADDSHS 72)
89 (UNSPEC_VRSQRTEFP 157)
102 (UNSPEC_PREDICATE 173)
113 (UNSPEC_SET_VSCR 213)
114 (UNSPEC_GET_VRSAVE 214)
115 (UNSPEC_REALIGN_LOAD 215)
116 (UNSPEC_REDUC_PLUS 217)
118 (UNSPEC_VCOND_V4SI 301)
119 (UNSPEC_VCOND_V4SF 302)
120 (UNSPEC_VCOND_V8HI 303)
121 (UNSPEC_VCOND_V16QI 304)
122 (UNSPEC_VCONDU_V4SI 305)
123 (UNSPEC_VCONDU_V8HI 306)
124 (UNSPEC_VCONDU_V16QI 307)
125 (UNSPEC_VMULWHUB 308)
126 (UNSPEC_VMULWLUB 309)
127 (UNSPEC_VMULWHSB 310)
128 (UNSPEC_VMULWLSB 311)
129 (UNSPEC_VMULWHUH 312)
130 (UNSPEC_VMULWLUH 313)
131 (UNSPEC_VMULWHSH 314)
132 (UNSPEC_VMULWLSH 315)
142 [(UNSPECV_SET_VRSAVE 30)
150 (define_mode_macro VI [V4SI V8HI V16QI])
151 ;; Short vec in modes
152 (define_mode_macro VIshort [V8HI V16QI])
154 (define_mode_macro VF [V4SF])
155 ;; Vec modes, pity mode macros are not composable
156 (define_mode_macro V [V4SI V8HI V16QI V4SF])
158 (define_mode_attr VI_char [(V4SI "w") (V8HI "h") (V16QI "b")])
160 ;; Generic LVX load instruction.
161 (define_insn "altivec_lvx_<mode>"
162 [(set (match_operand:V 0 "altivec_register_operand" "=v")
163 (match_operand:V 1 "memory_operand" "Z"))]
166 [(set_attr "type" "vecload")])
168 ;; Generic STVX store instruction.
169 (define_insn "altivec_stvx_<mode>"
170 [(set (match_operand:V 0 "memory_operand" "=Z")
171 (match_operand:V 1 "altivec_register_operand" "v"))]
174 [(set_attr "type" "vecstore")])
176 ;; Vector move instructions.
177 (define_expand "mov<mode>"
178 [(set (match_operand:V 0 "nonimmediate_operand" "")
179 (match_operand:V 1 "any_operand" ""))]
182 rs6000_emit_move (operands[0], operands[1], <MODE>mode);
186 (define_insn "*mov<mode>_internal"
187 [(set (match_operand:V 0 "nonimmediate_operand" "=Z,v,v,o,r,r,v")
188 (match_operand:V 1 "input_operand" "v,Z,v,r,o,r,W"))]
190 && (register_operand (operands[0], <MODE>mode)
191 || register_operand (operands[1], <MODE>mode))"
193 switch (which_alternative)
195 case 0: return "stvx %1,%y0";
196 case 1: return "lvx %0,%y1";
197 case 2: return "vor %0,%1,%1";
201 case 6: return output_vec_const_move (operands);
202 default: gcc_unreachable ();
205 [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,*")])
208 [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
209 (match_operand:V4SI 1 "input_operand" ""))]
210 "TARGET_ALTIVEC && reload_completed
211 && gpr_or_gpr_p (operands[0], operands[1])"
214 rs6000_split_multireg_move (operands[0], operands[1]); DONE;
218 [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
219 (match_operand:V8HI 1 "input_operand" ""))]
220 "TARGET_ALTIVEC && reload_completed
221 && gpr_or_gpr_p (operands[0], operands[1])"
223 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
226 [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
227 (match_operand:V16QI 1 "input_operand" ""))]
228 "TARGET_ALTIVEC && reload_completed
229 && gpr_or_gpr_p (operands[0], operands[1])"
231 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
234 [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
235 (match_operand:V4SF 1 "input_operand" ""))]
236 "TARGET_ALTIVEC && reload_completed
237 && gpr_or_gpr_p (operands[0], operands[1])"
240 rs6000_split_multireg_move (operands[0], operands[1]); DONE;
244 [(set (match_operand:VI 0 "altivec_register_operand" "")
245 (match_operand:VI 1 "easy_vector_constant_add_self" ""))]
246 "TARGET_ALTIVEC && reload_completed"
247 [(set (match_dup 0) (match_dup 3))
248 (set (match_dup 0) (plus:VI (match_dup 0)
251 rtx dup = gen_easy_altivec_constant (operands[1]);
254 /* Divide the operand of the resulting VEC_DUPLICATE, and use
255 simplify_rtx to make a CONST_VECTOR. */
256 XEXP (dup, 0) = simplify_const_binary_operation (ASHIFTRT, QImode,
257 XEXP (dup, 0), const1_rtx);
258 const_vec = simplify_rtx (dup);
260 if (GET_MODE (const_vec) == <MODE>mode)
261 operands[3] = const_vec;
263 operands[3] = gen_lowpart (<MODE>mode, const_vec);
266 (define_insn "get_vrsave_internal"
267 [(set (match_operand:SI 0 "register_operand" "=r")
268 (unspec:SI [(reg:SI 109)] UNSPEC_GET_VRSAVE))]
272 return "mfspr %0,256";
274 return "mfvrsave %0";
276 [(set_attr "type" "*")])
278 (define_insn "*set_vrsave_internal"
279 [(match_parallel 0 "vrsave_operation"
281 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
282 (reg:SI 109)] UNSPECV_SET_VRSAVE))])]
286 return "mtspr 256,%1";
288 return "mtvrsave %1";
290 [(set_attr "type" "*")])
292 (define_insn "*save_world"
293 [(match_parallel 0 "save_world_operation"
294 [(clobber (match_operand:SI 1 "register_operand" "=l"))
295 (use (match_operand:SI 2 "call_operand" "s"))])]
296 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
298 [(set_attr "type" "branch")
299 (set_attr "length" "4")])
301 (define_insn "*restore_world"
302 [(match_parallel 0 "restore_world_operation"
304 (use (match_operand:SI 1 "register_operand" "l"))
305 (use (match_operand:SI 2 "call_operand" "s"))
306 (clobber (match_operand:SI 3 "gpc_reg_operand" "=r"))])]
307 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
310 ;; Simple binary operations.
313 (define_insn "add<mode>3"
314 [(set (match_operand:VI 0 "register_operand" "=v")
315 (plus:VI (match_operand:VI 1 "register_operand" "v")
316 (match_operand:VI 2 "register_operand" "v")))]
318 "vaddu<VI_char>m %0,%1,%2"
319 [(set_attr "type" "vecsimple")])
321 (define_insn "addv4sf3"
322 [(set (match_operand:V4SF 0 "register_operand" "=v")
323 (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
324 (match_operand:V4SF 2 "register_operand" "v")))]
327 [(set_attr "type" "vecfloat")])
329 (define_insn "altivec_vaddcuw"
330 [(set (match_operand:V4SI 0 "register_operand" "=v")
331 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
332 (match_operand:V4SI 2 "register_operand" "v")]
336 [(set_attr "type" "vecsimple")])
338 (define_insn "altivec_vaddu<VI_char>s"
339 [(set (match_operand:VI 0 "register_operand" "=v")
340 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
341 (match_operand:VI 2 "register_operand" "v")]
343 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
345 "vaddu<VI_char>s %0,%1,%2"
346 [(set_attr "type" "vecsimple")])
348 (define_insn "altivec_vadds<VI_char>s"
349 [(set (match_operand:VI 0 "register_operand" "=v")
350 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
351 (match_operand:VI 2 "register_operand" "v")]
353 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
355 "vadds<VI_char>s %0,%1,%2"
356 [(set_attr "type" "vecsimple")])
359 (define_insn "sub<mode>3"
360 [(set (match_operand:VI 0 "register_operand" "=v")
361 (minus:VI (match_operand:VI 1 "register_operand" "v")
362 (match_operand:VI 2 "register_operand" "v")))]
364 "vsubu<VI_char>m %0,%1,%2"
365 [(set_attr "type" "vecsimple")])
367 (define_insn "subv4sf3"
368 [(set (match_operand:V4SF 0 "register_operand" "=v")
369 (minus:V4SF (match_operand:V4SF 1 "register_operand" "v")
370 (match_operand:V4SF 2 "register_operand" "v")))]
373 [(set_attr "type" "vecfloat")])
375 (define_insn "altivec_vsubcuw"
376 [(set (match_operand:V4SI 0 "register_operand" "=v")
377 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
378 (match_operand:V4SI 2 "register_operand" "v")]
382 [(set_attr "type" "vecsimple")])
384 (define_insn "altivec_vsubu<VI_char>s"
385 [(set (match_operand:VI 0 "register_operand" "=v")
386 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
387 (match_operand:VI 2 "register_operand" "v")]
389 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
391 "vsubu<VI_char>s %0,%1,%2"
392 [(set_attr "type" "vecsimple")])
394 (define_insn "altivec_vsubs<VI_char>s"
395 [(set (match_operand:VI 0 "register_operand" "=v")
396 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
397 (match_operand:VI 2 "register_operand" "v")]
399 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
401 "vsubs<VI_char>s %0,%1,%2"
402 [(set_attr "type" "vecsimple")])
405 (define_insn "altivec_vavgu<VI_char>"
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")]
411 "vavgu<VI_char> %0,%1,%2"
412 [(set_attr "type" "vecsimple")])
414 (define_insn "altivec_vavgs<VI_char>"
415 [(set (match_operand:VI 0 "register_operand" "=v")
416 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
417 (match_operand:VI 2 "register_operand" "v")]
420 "vavgs<VI_char> %0,%1,%2"
421 [(set_attr "type" "vecsimple")])
423 (define_insn "altivec_vcmpbfp"
424 [(set (match_operand:V4SI 0 "register_operand" "=v")
425 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
426 (match_operand:V4SF 2 "register_operand" "v")]
430 [(set_attr "type" "veccmp")])
432 (define_insn "altivec_vcmpequb"
433 [(set (match_operand:V16QI 0 "register_operand" "=v")
434 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
435 (match_operand:V16QI 2 "register_operand" "v")]
439 [(set_attr "type" "vecsimple")])
441 (define_insn "altivec_vcmpequh"
442 [(set (match_operand:V8HI 0 "register_operand" "=v")
443 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
444 (match_operand:V8HI 2 "register_operand" "v")]
448 [(set_attr "type" "vecsimple")])
450 (define_insn "altivec_vcmpequw"
451 [(set (match_operand:V4SI 0 "register_operand" "=v")
452 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
453 (match_operand:V4SI 2 "register_operand" "v")]
457 [(set_attr "type" "vecsimple")])
459 (define_insn "altivec_vcmpeqfp"
460 [(set (match_operand:V4SI 0 "register_operand" "=v")
461 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
462 (match_operand:V4SF 2 "register_operand" "v")]
466 [(set_attr "type" "veccmp")])
468 (define_insn "altivec_vcmpgefp"
469 [(set (match_operand:V4SI 0 "register_operand" "=v")
470 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
471 (match_operand:V4SF 2 "register_operand" "v")]
475 [(set_attr "type" "veccmp")])
477 (define_insn "altivec_vcmpgtub"
478 [(set (match_operand:V16QI 0 "register_operand" "=v")
479 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
480 (match_operand:V16QI 2 "register_operand" "v")]
484 [(set_attr "type" "vecsimple")])
486 (define_insn "altivec_vcmpgtsb"
487 [(set (match_operand:V16QI 0 "register_operand" "=v")
488 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
489 (match_operand:V16QI 2 "register_operand" "v")]
493 [(set_attr "type" "vecsimple")])
495 (define_insn "altivec_vcmpgtuh"
496 [(set (match_operand:V8HI 0 "register_operand" "=v")
497 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
498 (match_operand:V8HI 2 "register_operand" "v")]
502 [(set_attr "type" "vecsimple")])
504 (define_insn "altivec_vcmpgtsh"
505 [(set (match_operand:V8HI 0 "register_operand" "=v")
506 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
507 (match_operand:V8HI 2 "register_operand" "v")]
511 [(set_attr "type" "vecsimple")])
513 (define_insn "altivec_vcmpgtuw"
514 [(set (match_operand:V4SI 0 "register_operand" "=v")
515 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
516 (match_operand:V4SI 2 "register_operand" "v")]
520 [(set_attr "type" "vecsimple")])
522 (define_insn "altivec_vcmpgtsw"
523 [(set (match_operand:V4SI 0 "register_operand" "=v")
524 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
525 (match_operand:V4SI 2 "register_operand" "v")]
529 [(set_attr "type" "vecsimple")])
531 (define_insn "altivec_vcmpgtfp"
532 [(set (match_operand:V4SI 0 "register_operand" "=v")
533 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
534 (match_operand:V4SF 2 "register_operand" "v")]
538 [(set_attr "type" "veccmp")])
540 ;; Fused multiply add
541 (define_insn "altivec_vmaddfp"
542 [(set (match_operand:V4SF 0 "register_operand" "=v")
543 (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
544 (match_operand:V4SF 2 "register_operand" "v"))
545 (match_operand:V4SF 3 "register_operand" "v")))]
547 "vmaddfp %0,%1,%2,%3"
548 [(set_attr "type" "vecfloat")])
550 ;; We do multiply as a fused multiply-add with an add of a -0.0 vector.
552 (define_expand "mulv4sf3"
553 [(use (match_operand:V4SF 0 "register_operand" ""))
554 (use (match_operand:V4SF 1 "register_operand" ""))
555 (use (match_operand:V4SF 2 "register_operand" ""))]
556 "TARGET_ALTIVEC && TARGET_FUSED_MADD"
561 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
562 neg0 = gen_reg_rtx (V4SImode);
563 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
564 emit_insn (gen_altivec_vslw (neg0, neg0, neg0));
566 /* Use the multiply-add. */
567 emit_insn (gen_altivec_vmaddfp (operands[0], operands[1], operands[2],
568 gen_lowpart (V4SFmode, neg0)));
572 ;; 32 bit integer multiplication
573 ;; A_high = Operand_0 & 0xFFFF0000 >> 16
574 ;; A_low = Operand_0 & 0xFFFF
575 ;; B_high = Operand_1 & 0xFFFF0000 >> 16
576 ;; B_low = Operand_1 & 0xFFFF
577 ;; result = A_low * B_low + (A_high * B_low + B_high * A_low) << 16
579 ;; (define_insn "mulv4si3"
580 ;; [(set (match_operand:V4SI 0 "register_operand" "=v")
581 ;; (mult:V4SI (match_operand:V4SI 1 "register_operand" "v")
582 ;; (match_operand:V4SI 2 "register_operand" "v")))]
583 (define_expand "mulv4si3"
584 [(use (match_operand:V4SI 0 "register_operand" ""))
585 (use (match_operand:V4SI 1 "register_operand" ""))
586 (use (match_operand:V4SI 2 "register_operand" ""))]
599 zero = gen_reg_rtx (V4SImode);
600 emit_insn (gen_altivec_vspltisw (zero, const0_rtx));
602 sixteen = gen_reg_rtx (V4SImode);
603 emit_insn (gen_altivec_vspltisw (sixteen, gen_rtx_CONST_INT (V4SImode, -16)));
605 swap = gen_reg_rtx (V4SImode);
606 emit_insn (gen_altivec_vrlw (swap, operands[2], sixteen));
608 one = gen_reg_rtx (V8HImode);
609 convert_move (one, operands[1], 0);
611 two = gen_reg_rtx (V8HImode);
612 convert_move (two, operands[2], 0);
614 small_swap = gen_reg_rtx (V8HImode);
615 convert_move (small_swap, swap, 0);
617 low_product = gen_reg_rtx (V4SImode);
618 emit_insn (gen_altivec_vmulouh (low_product, one, two));
620 high_product = gen_reg_rtx (V4SImode);
621 emit_insn (gen_altivec_vmsumuhm (high_product, one, small_swap, zero));
623 emit_insn (gen_altivec_vslw (high_product, high_product, sixteen));
625 emit_insn (gen_addv4si3 (operands[0], high_product, low_product));
631 ;; Fused multiply subtract
632 (define_insn "altivec_vnmsubfp"
633 [(set (match_operand:V4SF 0 "register_operand" "=v")
634 (neg:V4SF (minus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
635 (match_operand:V4SF 2 "register_operand" "v"))
636 (match_operand:V4SF 3 "register_operand" "v"))))]
638 "vnmsubfp %0,%1,%2,%3"
639 [(set_attr "type" "vecfloat")])
641 (define_insn "altivec_vmsumu<VI_char>m"
642 [(set (match_operand:V4SI 0 "register_operand" "=v")
643 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
644 (match_operand:VIshort 2 "register_operand" "v")
645 (match_operand:V4SI 3 "register_operand" "v")]
648 "vmsumu<VI_char>m %0,%1,%2,%3"
649 [(set_attr "type" "veccomplex")])
651 (define_insn "altivec_vmsumm<VI_char>m"
652 [(set (match_operand:V4SI 0 "register_operand" "=v")
653 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
654 (match_operand:VIshort 2 "register_operand" "v")
655 (match_operand:V4SI 3 "register_operand" "v")]
658 "vmsumm<VI_char>m %0,%1,%2,%3"
659 [(set_attr "type" "veccomplex")])
661 (define_insn "altivec_vmsumshm"
662 [(set (match_operand:V4SI 0 "register_operand" "=v")
663 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
664 (match_operand:V8HI 2 "register_operand" "v")
665 (match_operand:V4SI 3 "register_operand" "v")]
668 "vmsumshm %0,%1,%2,%3"
669 [(set_attr "type" "veccomplex")])
671 (define_insn "altivec_vmsumuhs"
672 [(set (match_operand:V4SI 0 "register_operand" "=v")
673 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
674 (match_operand:V8HI 2 "register_operand" "v")
675 (match_operand:V4SI 3 "register_operand" "v")]
677 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
679 "vmsumuhs %0,%1,%2,%3"
680 [(set_attr "type" "veccomplex")])
682 (define_insn "altivec_vmsumshs"
683 [(set (match_operand:V4SI 0 "register_operand" "=v")
684 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
685 (match_operand:V8HI 2 "register_operand" "v")
686 (match_operand:V4SI 3 "register_operand" "v")]
688 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
690 "vmsumshs %0,%1,%2,%3"
691 [(set_attr "type" "veccomplex")])
695 (define_insn "umax<mode>3"
696 [(set (match_operand:VI 0 "register_operand" "=v")
697 (umax:VI (match_operand:VI 1 "register_operand" "v")
698 (match_operand:VI 2 "register_operand" "v")))]
700 "vmaxu<VI_char> %0,%1,%2"
701 [(set_attr "type" "vecsimple")])
703 (define_insn "smax<mode>3"
704 [(set (match_operand:VI 0 "register_operand" "=v")
705 (smax:VI (match_operand:VI 1 "register_operand" "v")
706 (match_operand:VI 2 "register_operand" "v")))]
708 "vmaxs<VI_char> %0,%1,%2"
709 [(set_attr "type" "vecsimple")])
711 (define_insn "smaxv4sf3"
712 [(set (match_operand:V4SF 0 "register_operand" "=v")
713 (smax:V4SF (match_operand:V4SF 1 "register_operand" "v")
714 (match_operand:V4SF 2 "register_operand" "v")))]
717 [(set_attr "type" "veccmp")])
719 (define_insn "umin<mode>3"
720 [(set (match_operand:VI 0 "register_operand" "=v")
721 (umin:VI (match_operand:VI 1 "register_operand" "v")
722 (match_operand:VI 2 "register_operand" "v")))]
724 "vminu<VI_char> %0,%1,%2"
725 [(set_attr "type" "vecsimple")])
727 (define_insn "smin<mode>3"
728 [(set (match_operand:VI 0 "register_operand" "=v")
729 (smin:VI (match_operand:VI 1 "register_operand" "v")
730 (match_operand:VI 2 "register_operand" "v")))]
732 "vmins<VI_char> %0,%1,%2"
733 [(set_attr "type" "vecsimple")])
735 (define_insn "sminv4sf3"
736 [(set (match_operand:V4SF 0 "register_operand" "=v")
737 (smin:V4SF (match_operand:V4SF 1 "register_operand" "v")
738 (match_operand:V4SF 2 "register_operand" "v")))]
741 [(set_attr "type" "veccmp")])
743 (define_insn "altivec_vmhaddshs"
744 [(set (match_operand:V8HI 0 "register_operand" "=v")
745 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
746 (match_operand:V8HI 2 "register_operand" "v")
747 (match_operand:V8HI 3 "register_operand" "v")]
749 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
751 "vmhaddshs %0,%1,%2,%3"
752 [(set_attr "type" "veccomplex")])
754 (define_insn "altivec_vmhraddshs"
755 [(set (match_operand:V8HI 0 "register_operand" "=v")
756 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
757 (match_operand:V8HI 2 "register_operand" "v")
758 (match_operand:V8HI 3 "register_operand" "v")]
760 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
762 "vmhraddshs %0,%1,%2,%3"
763 [(set_attr "type" "veccomplex")])
765 (define_insn "altivec_vmladduhm"
766 [(set (match_operand:V8HI 0 "register_operand" "=v")
767 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
768 (match_operand:V8HI 2 "register_operand" "v")
769 (match_operand:V8HI 3 "register_operand" "v")]
772 "vmladduhm %0,%1,%2,%3"
773 [(set_attr "type" "veccomplex")])
775 (define_insn "altivec_vmrghb"
776 [(set (match_operand:V16QI 0 "register_operand" "=v")
777 (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
778 (parallel [(const_int 0)
794 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
795 (parallel [(const_int 8)
814 [(set_attr "type" "vecperm")])
816 (define_insn "altivec_vmrghh"
817 [(set (match_operand:V8HI 0 "register_operand" "=v")
818 (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
819 (parallel [(const_int 0)
827 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
828 (parallel [(const_int 4)
839 [(set_attr "type" "vecperm")])
841 (define_insn "altivec_vmrghw"
842 [(set (match_operand:V4SI 0 "register_operand" "=v")
843 (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
844 (parallel [(const_int 0)
848 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
849 (parallel [(const_int 2)
856 [(set_attr "type" "vecperm")])
858 (define_insn "altivec_vmrglb"
859 [(set (match_operand:V16QI 0 "register_operand" "=v")
860 (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
861 (parallel [(const_int 8)
877 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
878 (parallel [(const_int 0)
897 [(set_attr "type" "vecperm")])
899 (define_insn "altivec_vmrglh"
900 [(set (match_operand:V8HI 0 "register_operand" "=v")
901 (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
902 (parallel [(const_int 4)
910 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
911 (parallel [(const_int 0)
922 [(set_attr "type" "vecperm")])
924 (define_insn "altivec_vmrglw"
925 [(set (match_operand:V4SI 0 "register_operand" "=v")
926 (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
927 (parallel [(const_int 2)
931 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
932 (parallel [(const_int 0)
939 [(set_attr "type" "vecperm")])
941 (define_insn "altivec_vmuleub"
942 [(set (match_operand:V8HI 0 "register_operand" "=v")
943 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
944 (match_operand:V16QI 2 "register_operand" "v")]
948 [(set_attr "type" "veccomplex")])
950 (define_insn "altivec_vmulesb"
951 [(set (match_operand:V8HI 0 "register_operand" "=v")
952 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
953 (match_operand:V16QI 2 "register_operand" "v")]
957 [(set_attr "type" "veccomplex")])
959 (define_insn "altivec_vmuleuh"
960 [(set (match_operand:V4SI 0 "register_operand" "=v")
961 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
962 (match_operand:V8HI 2 "register_operand" "v")]
966 [(set_attr "type" "veccomplex")])
968 (define_insn "altivec_vmulesh"
969 [(set (match_operand:V4SI 0 "register_operand" "=v")
970 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
971 (match_operand:V8HI 2 "register_operand" "v")]
975 [(set_attr "type" "veccomplex")])
977 (define_insn "altivec_vmuloub"
978 [(set (match_operand:V8HI 0 "register_operand" "=v")
979 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
980 (match_operand:V16QI 2 "register_operand" "v")]
984 [(set_attr "type" "veccomplex")])
986 (define_insn "altivec_vmulosb"
987 [(set (match_operand:V8HI 0 "register_operand" "=v")
988 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
989 (match_operand:V16QI 2 "register_operand" "v")]
993 [(set_attr "type" "veccomplex")])
995 (define_insn "altivec_vmulouh"
996 [(set (match_operand:V4SI 0 "register_operand" "=v")
997 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
998 (match_operand:V8HI 2 "register_operand" "v")]
1002 [(set_attr "type" "veccomplex")])
1004 (define_insn "altivec_vmulosh"
1005 [(set (match_operand:V4SI 0 "register_operand" "=v")
1006 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
1007 (match_operand:V8HI 2 "register_operand" "v")]
1011 [(set_attr "type" "veccomplex")])
1016 (define_insn "and<mode>3"
1017 [(set (match_operand:VI 0 "register_operand" "=v")
1018 (and:VI (match_operand:VI 1 "register_operand" "v")
1019 (match_operand:VI 2 "register_operand" "v")))]
1022 [(set_attr "type" "vecsimple")])
1024 (define_insn "ior<mode>3"
1025 [(set (match_operand:VI 0 "register_operand" "=v")
1026 (ior:VI (match_operand:VI 1 "register_operand" "v")
1027 (match_operand:VI 2 "register_operand" "v")))]
1030 [(set_attr "type" "vecsimple")])
1032 (define_insn "xor<mode>3"
1033 [(set (match_operand:VI 0 "register_operand" "=v")
1034 (xor:VI (match_operand:VI 1 "register_operand" "v")
1035 (match_operand:VI 2 "register_operand" "v")))]
1038 [(set_attr "type" "vecsimple")])
1040 (define_insn "xorv4sf3"
1041 [(set (match_operand:V4SF 0 "register_operand" "=v")
1042 (xor:V4SF (match_operand:V4SF 1 "register_operand" "v")
1043 (match_operand:V4SF 2 "register_operand" "v")))]
1046 [(set_attr "type" "vecsimple")])
1048 (define_insn "one_cmpl<mode>2"
1049 [(set (match_operand:VI 0 "register_operand" "=v")
1050 (not:VI (match_operand:VI 1 "register_operand" "v")))]
1053 [(set_attr "type" "vecsimple")])
1055 (define_insn "altivec_nor<mode>3"
1056 [(set (match_operand:VI 0 "register_operand" "=v")
1057 (not:VI (ior:VI (match_operand:VI 1 "register_operand" "v")
1058 (match_operand:VI 2 "register_operand" "v"))))]
1061 [(set_attr "type" "vecsimple")])
1063 (define_insn "andc<mode>3"
1064 [(set (match_operand:VI 0 "register_operand" "=v")
1065 (and:VI (not:VI (match_operand:VI 2 "register_operand" "v"))
1066 (match_operand:VI 1 "register_operand" "v")))]
1069 [(set_attr "type" "vecsimple")])
1071 (define_insn "*andc3_v4sf"
1072 [(set (match_operand:V4SF 0 "register_operand" "=v")
1073 (and:V4SF (not:V4SF (match_operand:V4SF 2 "register_operand" "v"))
1074 (match_operand:V4SF 1 "register_operand" "v")))]
1077 [(set_attr "type" "vecsimple")])
1079 (define_insn "altivec_vpkuhum"
1080 [(set (match_operand:V16QI 0 "register_operand" "=v")
1081 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1082 (match_operand:V8HI 2 "register_operand" "v")]
1086 [(set_attr "type" "vecperm")])
1088 (define_insn "altivec_vpkuwum"
1089 [(set (match_operand:V8HI 0 "register_operand" "=v")
1090 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1091 (match_operand:V4SI 2 "register_operand" "v")]
1095 [(set_attr "type" "vecperm")])
1097 (define_insn "altivec_vpkpx"
1098 [(set (match_operand:V8HI 0 "register_operand" "=v")
1099 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1100 (match_operand:V4SI 2 "register_operand" "v")]
1104 [(set_attr "type" "vecperm")])
1106 (define_insn "altivec_vpkshss"
1107 [(set (match_operand:V16QI 0 "register_operand" "=v")
1108 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1109 (match_operand:V8HI 2 "register_operand" "v")]
1111 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1114 [(set_attr "type" "vecperm")])
1116 (define_insn "altivec_vpkswss"
1117 [(set (match_operand:V8HI 0 "register_operand" "=v")
1118 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1119 (match_operand:V4SI 2 "register_operand" "v")]
1121 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1124 [(set_attr "type" "vecperm")])
1126 (define_insn "altivec_vpkuhus"
1127 [(set (match_operand:V16QI 0 "register_operand" "=v")
1128 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1129 (match_operand:V8HI 2 "register_operand" "v")]
1131 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1134 [(set_attr "type" "vecperm")])
1136 (define_insn "altivec_vpkshus"
1137 [(set (match_operand:V16QI 0 "register_operand" "=v")
1138 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1139 (match_operand:V8HI 2 "register_operand" "v")]
1141 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1144 [(set_attr "type" "vecperm")])
1146 (define_insn "altivec_vpkuwus"
1147 [(set (match_operand:V8HI 0 "register_operand" "=v")
1148 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1149 (match_operand:V4SI 2 "register_operand" "v")]
1151 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1154 [(set_attr "type" "vecperm")])
1156 (define_insn "altivec_vpkswus"
1157 [(set (match_operand:V8HI 0 "register_operand" "=v")
1158 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1159 (match_operand:V4SI 2 "register_operand" "v")]
1161 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1164 [(set_attr "type" "vecperm")])
1166 (define_insn "altivec_vrl<VI_char>"
1167 [(set (match_operand:VI 0 "register_operand" "=v")
1168 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
1169 (match_operand:VI 2 "register_operand" "v")]
1172 "vrl<VI_char> %0,%1,%2"
1173 [(set_attr "type" "vecsimple")])
1175 (define_insn "altivec_vsl<VI_char>"
1176 [(set (match_operand:VI 0 "register_operand" "=v")
1177 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
1178 (match_operand:VI 2 "register_operand" "v")]
1181 "vsl<VI_char> %0,%1,%2"
1182 [(set_attr "type" "vecsimple")])
1184 (define_insn "altivec_vsl"
1185 [(set (match_operand:V4SI 0 "register_operand" "=v")
1186 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1187 (match_operand:V4SI 2 "register_operand" "v")]
1191 [(set_attr "type" "vecperm")])
1193 (define_insn "altivec_vslo"
1194 [(set (match_operand:V4SI 0 "register_operand" "=v")
1195 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1196 (match_operand:V4SI 2 "register_operand" "v")]
1200 [(set_attr "type" "vecperm")])
1202 (define_insn "lshr<mode>3"
1203 [(set (match_operand:VI 0 "register_operand" "=v")
1204 (lshiftrt:VI (match_operand:VI 1 "register_operand" "v")
1205 (match_operand:VI 2 "register_operand" "v") ))]
1207 "vsr<VI_char> %0,%1,%2"
1208 [(set_attr "type" "vecsimple")])
1210 (define_insn "ashr<mode>3"
1211 [(set (match_operand:VI 0 "register_operand" "=v")
1212 (ashiftrt:VI (match_operand:VI 1 "register_operand" "v")
1213 (match_operand:VI 2 "register_operand" "v") ))]
1215 "vsra<VI_char> %0,%1,%2"
1216 [(set_attr "type" "vecsimple")])
1218 (define_insn "altivec_vsr"
1219 [(set (match_operand:V4SI 0 "register_operand" "=v")
1220 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1221 (match_operand:V4SI 2 "register_operand" "v")]
1225 [(set_attr "type" "vecperm")])
1227 (define_insn "altivec_vsro"
1228 [(set (match_operand:V4SI 0 "register_operand" "=v")
1229 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1230 (match_operand:V4SI 2 "register_operand" "v")]
1234 [(set_attr "type" "vecperm")])
1236 (define_insn "altivec_vsum4ubs"
1237 [(set (match_operand:V4SI 0 "register_operand" "=v")
1238 (unspec:V4SI [(match_operand:V16QI 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_vsum4s<VI_char>s"
1247 [(set (match_operand:V4SI 0 "register_operand" "=v")
1248 (unspec:V4SI [(match_operand:VIshort 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))]
1253 "vsum4s<VI_char>s %0,%1,%2"
1254 [(set_attr "type" "veccomplex")])
1256 (define_insn "altivec_vsum2sws"
1257 [(set (match_operand:V4SI 0 "register_operand" "=v")
1258 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1259 (match_operand:V4SI 2 "register_operand" "v")]
1261 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1264 [(set_attr "type" "veccomplex")])
1266 (define_insn "altivec_vsumsws"
1267 [(set (match_operand:V4SI 0 "register_operand" "=v")
1268 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1269 (match_operand:V4SI 2 "register_operand" "v")]
1271 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1274 [(set_attr "type" "veccomplex")])
1276 (define_insn "altivec_vspltb"
1277 [(set (match_operand:V16QI 0 "register_operand" "=v")
1278 (vec_duplicate:V16QI
1279 (vec_select:QI (match_operand:V16QI 1 "register_operand" "v")
1281 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1284 [(set_attr "type" "vecperm")])
1286 (define_insn "altivec_vsplth"
1287 [(set (match_operand:V8HI 0 "register_operand" "=v")
1289 (vec_select:HI (match_operand:V8HI 1 "register_operand" "v")
1291 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1294 [(set_attr "type" "vecperm")])
1296 (define_insn "altivec_vspltw"
1297 [(set (match_operand:V4SI 0 "register_operand" "=v")
1299 (vec_select:SI (match_operand:V4SI 1 "register_operand" "v")
1301 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1304 [(set_attr "type" "vecperm")])
1306 (define_insn "*altivec_vspltsf"
1307 [(set (match_operand:V4SF 0 "register_operand" "=v")
1309 (vec_select:SF (match_operand:V4SF 1 "register_operand" "v")
1311 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1314 [(set_attr "type" "vecperm")])
1316 (define_insn "altivec_vspltis<VI_char>"
1317 [(set (match_operand:VI 0 "register_operand" "=v")
1319 (match_operand:QI 1 "s5bit_cint_operand" "i")))]
1321 "vspltis<VI_char> %0,%1"
1322 [(set_attr "type" "vecperm")])
1324 (define_insn "ftruncv4sf2"
1325 [(set (match_operand:V4SF 0 "register_operand" "=v")
1326 (fix:V4SF (match_operand:V4SF 1 "register_operand" "v")))]
1329 [(set_attr "type" "vecfloat")])
1331 (define_insn "altivec_vperm_<mode>"
1332 [(set (match_operand:V 0 "register_operand" "=v")
1333 (unspec:V [(match_operand:V 1 "register_operand" "v")
1334 (match_operand:V 2 "register_operand" "v")
1335 (match_operand:V16QI 3 "register_operand" "v")]
1339 [(set_attr "type" "vecperm")])
1341 (define_insn "altivec_vrfip"
1342 [(set (match_operand:V4SF 0 "register_operand" "=v")
1343 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1347 [(set_attr "type" "vecfloat")])
1349 (define_insn "altivec_vrfin"
1350 [(set (match_operand:V4SF 0 "register_operand" "=v")
1351 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1355 [(set_attr "type" "vecfloat")])
1357 (define_insn "altivec_vrfim"
1358 [(set (match_operand:V4SF 0 "register_operand" "=v")
1359 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1363 [(set_attr "type" "vecfloat")])
1365 (define_insn "altivec_vcfux"
1366 [(set (match_operand:V4SF 0 "register_operand" "=v")
1367 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1368 (match_operand:QI 2 "immediate_operand" "i")]
1372 [(set_attr "type" "vecfloat")])
1374 (define_insn "altivec_vcfsx"
1375 [(set (match_operand:V4SF 0 "register_operand" "=v")
1376 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1377 (match_operand:QI 2 "immediate_operand" "i")]
1381 [(set_attr "type" "vecfloat")])
1383 (define_insn "altivec_vctuxs"
1384 [(set (match_operand:V4SI 0 "register_operand" "=v")
1385 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1386 (match_operand:QI 2 "immediate_operand" "i")]
1388 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1391 [(set_attr "type" "vecfloat")])
1393 (define_insn "altivec_vctsxs"
1394 [(set (match_operand:V4SI 0 "register_operand" "=v")
1395 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1396 (match_operand:QI 2 "immediate_operand" "i")]
1398 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1401 [(set_attr "type" "vecfloat")])
1403 (define_insn "altivec_vlogefp"
1404 [(set (match_operand:V4SF 0 "register_operand" "=v")
1405 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1409 [(set_attr "type" "vecfloat")])
1411 (define_insn "altivec_vexptefp"
1412 [(set (match_operand:V4SF 0 "register_operand" "=v")
1413 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1417 [(set_attr "type" "vecfloat")])
1419 (define_insn "altivec_vrsqrtefp"
1420 [(set (match_operand:V4SF 0 "register_operand" "=v")
1421 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1425 [(set_attr "type" "vecfloat")])
1427 (define_insn "altivec_vrefp"
1428 [(set (match_operand:V4SF 0 "register_operand" "=v")
1429 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1433 [(set_attr "type" "vecfloat")])
1435 (define_expand "vcondv4si"
1436 [(set (match_operand:V4SI 0 "register_operand" "=v")
1437 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1438 (match_operand:V4SI 2 "register_operand" "v")
1439 (match_operand:V4SI 3 "comparison_operator" "")
1440 (match_operand:V4SI 4 "register_operand" "v")
1441 (match_operand:V4SI 5 "register_operand" "v")
1442 ] UNSPEC_VCOND_V4SI))]
1446 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1447 operands[3], operands[4], operands[5]))
1454 (define_expand "vconduv4si"
1455 [(set (match_operand:V4SI 0 "register_operand" "=v")
1456 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1457 (match_operand:V4SI 2 "register_operand" "v")
1458 (match_operand:V4SI 3 "comparison_operator" "")
1459 (match_operand:V4SI 4 "register_operand" "v")
1460 (match_operand:V4SI 5 "register_operand" "v")
1461 ] UNSPEC_VCONDU_V4SI))]
1465 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1466 operands[3], operands[4], operands[5]))
1473 (define_expand "vcondv4sf"
1474 [(set (match_operand:V4SF 0 "register_operand" "=v")
1475 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1476 (match_operand:V4SF 2 "register_operand" "v")
1477 (match_operand:V4SF 3 "comparison_operator" "")
1478 (match_operand:V4SF 4 "register_operand" "v")
1479 (match_operand:V4SF 5 "register_operand" "v")
1480 ] UNSPEC_VCOND_V4SF))]
1484 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1485 operands[3], operands[4], operands[5]))
1492 (define_expand "vcondv8hi"
1493 [(set (match_operand:V4SF 0 "register_operand" "=v")
1494 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1495 (match_operand:V8HI 2 "register_operand" "v")
1496 (match_operand:V8HI 3 "comparison_operator" "")
1497 (match_operand:V8HI 4 "register_operand" "v")
1498 (match_operand:V8HI 5 "register_operand" "v")
1499 ] UNSPEC_VCOND_V8HI))]
1503 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1504 operands[3], operands[4], operands[5]))
1511 (define_expand "vconduv8hi"
1512 [(set (match_operand:V4SF 0 "register_operand" "=v")
1513 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1514 (match_operand:V8HI 2 "register_operand" "v")
1515 (match_operand:V8HI 3 "comparison_operator" "")
1516 (match_operand:V8HI 4 "register_operand" "v")
1517 (match_operand:V8HI 5 "register_operand" "v")
1518 ] UNSPEC_VCONDU_V8HI))]
1522 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1523 operands[3], operands[4], operands[5]))
1530 (define_expand "vcondv16qi"
1531 [(set (match_operand:V4SF 0 "register_operand" "=v")
1532 (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")
1533 (match_operand:V16QI 2 "register_operand" "v")
1534 (match_operand:V16QI 3 "comparison_operator" "")
1535 (match_operand:V16QI 4 "register_operand" "v")
1536 (match_operand:V16QI 5 "register_operand" "v")
1537 ] UNSPEC_VCOND_V16QI))]
1541 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1542 operands[3], operands[4], operands[5]))
1549 (define_expand "vconduv16qi"
1550 [(set (match_operand:V4SF 0 "register_operand" "=v")
1551 (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")
1552 (match_operand:V16QI 2 "register_operand" "v")
1553 (match_operand:V16QI 3 "comparison_operator" "")
1554 (match_operand:V16QI 4 "register_operand" "v")
1555 (match_operand:V16QI 5 "register_operand" "v")
1556 ] UNSPEC_VCONDU_V16QI))]
1560 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1561 operands[3], operands[4], operands[5]))
1569 (define_insn "altivec_vsel_v4si"
1570 [(set (match_operand:V4SI 0 "register_operand" "=v")
1571 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1572 (match_operand:V4SI 2 "register_operand" "v")
1573 (match_operand:V4SI 3 "register_operand" "v")]
1577 [(set_attr "type" "vecperm")])
1579 (define_insn "altivec_vsel_v4sf"
1580 [(set (match_operand:V4SF 0 "register_operand" "=v")
1581 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
1582 (match_operand:V4SF 2 "register_operand" "v")
1583 (match_operand:V4SI 3 "register_operand" "v")]
1587 [(set_attr "type" "vecperm")])
1589 (define_insn "altivec_vsel_v8hi"
1590 [(set (match_operand:V8HI 0 "register_operand" "=v")
1591 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
1592 (match_operand:V8HI 2 "register_operand" "v")
1593 (match_operand:V8HI 3 "register_operand" "v")]
1597 [(set_attr "type" "vecperm")])
1599 (define_insn "altivec_vsel_v16qi"
1600 [(set (match_operand:V16QI 0 "register_operand" "=v")
1601 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
1602 (match_operand:V16QI 2 "register_operand" "v")
1603 (match_operand:V16QI 3 "register_operand" "v")]
1607 [(set_attr "type" "vecperm")])
1609 (define_insn "altivec_vsldoi_<mode>"
1610 [(set (match_operand:V 0 "register_operand" "=v")
1611 (unspec:V [(match_operand:V 1 "register_operand" "v")
1612 (match_operand:V 2 "register_operand" "v")
1613 (match_operand:QI 3 "immediate_operand" "i")]
1616 "vsldoi %0,%1,%2,%3"
1617 [(set_attr "type" "vecperm")])
1619 (define_insn "altivec_vupkhsb"
1620 [(set (match_operand:V8HI 0 "register_operand" "=v")
1621 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1625 [(set_attr "type" "vecperm")])
1627 (define_insn "altivec_vupkhpx"
1628 [(set (match_operand:V4SI 0 "register_operand" "=v")
1629 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1633 [(set_attr "type" "vecperm")])
1635 (define_insn "altivec_vupkhsh"
1636 [(set (match_operand:V4SI 0 "register_operand" "=v")
1637 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1641 [(set_attr "type" "vecperm")])
1643 (define_insn "altivec_vupklsb"
1644 [(set (match_operand:V8HI 0 "register_operand" "=v")
1645 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1649 [(set_attr "type" "vecperm")])
1651 (define_insn "altivec_vupklpx"
1652 [(set (match_operand:V4SI 0 "register_operand" "=v")
1653 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1657 [(set_attr "type" "vecperm")])
1659 (define_insn "altivec_vupklsh"
1660 [(set (match_operand:V4SI 0 "register_operand" "=v")
1661 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1665 [(set_attr "type" "vecperm")])
1667 ;; AltiVec predicates.
1669 (define_expand "cr6_test_for_zero"
1670 [(set (match_operand:SI 0 "register_operand" "=r")
1676 (define_expand "cr6_test_for_zero_reverse"
1677 [(set (match_operand:SI 0 "register_operand" "=r")
1680 (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
1684 (define_expand "cr6_test_for_lt"
1685 [(set (match_operand:SI 0 "register_operand" "=r")
1691 (define_expand "cr6_test_for_lt_reverse"
1692 [(set (match_operand:SI 0 "register_operand" "=r")
1695 (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
1699 ;; We can get away with generating the opcode on the fly (%3 below)
1700 ;; because all the predicates have the same scheduling parameters.
1702 (define_insn "altivec_predicate_<mode>"
1704 (unspec:CC [(match_operand:V 1 "register_operand" "v")
1705 (match_operand:V 2 "register_operand" "v")
1706 (match_operand 3 "any_operand" "")] UNSPEC_PREDICATE))
1707 (clobber (match_scratch:V 0 "=v"))]
1710 [(set_attr "type" "veccmp")])
1712 (define_insn "altivec_mtvscr"
1715 [(match_operand:V4SI 0 "register_operand" "v")] UNSPECV_MTVSCR))]
1718 [(set_attr "type" "vecsimple")])
1720 (define_insn "altivec_mfvscr"
1721 [(set (match_operand:V8HI 0 "register_operand" "=v")
1722 (unspec_volatile:V8HI [(reg:SI 110)] UNSPECV_MFVSCR))]
1725 [(set_attr "type" "vecsimple")])
1727 (define_insn "altivec_dssall"
1728 [(unspec_volatile [(const_int 0)] UNSPECV_DSSALL)]
1731 [(set_attr "type" "vecsimple")])
1733 (define_insn "altivec_dss"
1734 [(unspec_volatile [(match_operand:QI 0 "immediate_operand" "i")]
1738 [(set_attr "type" "vecsimple")])
1740 (define_insn "altivec_dst"
1741 [(unspec [(match_operand 0 "register_operand" "b")
1742 (match_operand:SI 1 "register_operand" "r")
1743 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DST)]
1744 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1746 [(set_attr "type" "vecsimple")])
1748 (define_insn "altivec_dstt"
1749 [(unspec [(match_operand 0 "register_operand" "b")
1750 (match_operand:SI 1 "register_operand" "r")
1751 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTT)]
1752 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1754 [(set_attr "type" "vecsimple")])
1756 (define_insn "altivec_dstst"
1757 [(unspec [(match_operand 0 "register_operand" "b")
1758 (match_operand:SI 1 "register_operand" "r")
1759 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTST)]
1760 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1762 [(set_attr "type" "vecsimple")])
1764 (define_insn "altivec_dststt"
1765 [(unspec [(match_operand 0 "register_operand" "b")
1766 (match_operand:SI 1 "register_operand" "r")
1767 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTSTT)]
1768 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1770 [(set_attr "type" "vecsimple")])
1772 (define_insn "altivec_lvsl"
1773 [(set (match_operand:V16QI 0 "register_operand" "=v")
1774 (unspec:V16QI [(match_operand 1 "memory_operand" "Z")] UNSPEC_LVSL))]
1777 [(set_attr "type" "vecload")])
1779 (define_insn "altivec_lvsr"
1780 [(set (match_operand:V16QI 0 "register_operand" "=v")
1781 (unspec:V16QI [(match_operand 1 "memory_operand" "Z")] UNSPEC_LVSR))]
1784 [(set_attr "type" "vecload")])
1786 (define_expand "build_vector_mask_for_load"
1787 [(set (match_operand:V16QI 0 "register_operand" "")
1788 (unspec:V16QI [(match_operand 1 "memory_operand" "")] UNSPEC_LVSR))]
1795 gcc_assert (GET_CODE (operands[1]) == MEM);
1797 addr = XEXP (operands[1], 0);
1798 temp = gen_reg_rtx (GET_MODE (addr));
1799 emit_insn (gen_rtx_SET (VOIDmode, temp,
1800 gen_rtx_NEG (GET_MODE (addr), addr)));
1801 emit_insn (gen_altivec_lvsr (operands[0],
1802 replace_equiv_address (operands[1], temp)));
1806 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
1807 ;; identical rtl but different instructions-- and gcc gets confused.
1809 (define_insn "altivec_lve<VI_char>x"
1811 [(set (match_operand:VI 0 "register_operand" "=v")
1812 (match_operand:VI 1 "memory_operand" "Z"))
1813 (unspec [(const_int 0)] UNSPEC_LVE)])]
1815 "lve<VI_char>x %0,%y1"
1816 [(set_attr "type" "vecload")])
1818 (define_insn "*altivec_lvesfx"
1820 [(set (match_operand:V4SF 0 "register_operand" "=v")
1821 (match_operand:V4SF 1 "memory_operand" "Z"))
1822 (unspec [(const_int 0)] UNSPEC_LVE)])]
1825 [(set_attr "type" "vecload")])
1827 (define_insn "altivec_lvxl"
1829 [(set (match_operand:V4SI 0 "register_operand" "=v")
1830 (match_operand:V4SI 1 "memory_operand" "Z"))
1831 (unspec [(const_int 0)] UNSPEC_SET_VSCR)])]
1834 [(set_attr "type" "vecload")])
1836 (define_insn "altivec_lvx"
1837 [(set (match_operand:V4SI 0 "register_operand" "=v")
1838 (match_operand:V4SI 1 "memory_operand" "Z"))]
1841 [(set_attr "type" "vecload")])
1843 (define_insn "altivec_stvx"
1845 [(set (match_operand:V4SI 0 "memory_operand" "=Z")
1846 (match_operand:V4SI 1 "register_operand" "v"))
1847 (unspec [(const_int 0)] UNSPEC_STVX)])]
1850 [(set_attr "type" "vecstore")])
1852 (define_insn "altivec_stvxl"
1854 [(set (match_operand:V4SI 0 "memory_operand" "=Z")
1855 (match_operand:V4SI 1 "register_operand" "v"))
1856 (unspec [(const_int 0)] UNSPEC_STVXL)])]
1859 [(set_attr "type" "vecstore")])
1861 (define_insn "altivec_stve<VI_char>x"
1863 [(set (match_operand:VI 0 "memory_operand" "=Z")
1864 (match_operand:VI 1 "register_operand" "v"))
1865 (unspec [(const_int 0)] UNSPEC_STVE)])]
1867 "stve<VI_char>x %1,%y0"
1868 [(set_attr "type" "vecstore")])
1870 (define_insn "*altivec_stvesfx"
1872 [(set (match_operand:V4SF 0 "memory_operand" "=Z")
1873 (match_operand:V4SF 1 "register_operand" "v"))
1874 (unspec [(const_int 0)] UNSPEC_STVE)])]
1877 [(set_attr "type" "vecstore")])
1879 (define_expand "vec_init<mode>"
1880 [(match_operand:V 0 "register_operand" "")
1881 (match_operand 1 "" "")]
1884 rs6000_expand_vector_init (operands[0], operands[1]);
1888 (define_expand "vec_setv4si"
1889 [(match_operand:V4SI 0 "register_operand" "")
1890 (match_operand:SI 1 "register_operand" "")
1891 (match_operand 2 "const_int_operand" "")]
1894 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1898 (define_expand "vec_setv8hi"
1899 [(match_operand:V8HI 0 "register_operand" "")
1900 (match_operand:HI 1 "register_operand" "")
1901 (match_operand 2 "const_int_operand" "")]
1904 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1908 (define_expand "vec_setv16qi"
1909 [(match_operand:V16QI 0 "register_operand" "")
1910 (match_operand:QI 1 "register_operand" "")
1911 (match_operand 2 "const_int_operand" "")]
1914 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1918 (define_expand "vec_setv4sf"
1919 [(match_operand:V4SF 0 "register_operand" "")
1920 (match_operand:SF 1 "register_operand" "")
1921 (match_operand 2 "const_int_operand" "")]
1924 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1928 (define_expand "vec_extractv4si"
1929 [(match_operand:SI 0 "register_operand" "")
1930 (match_operand:V4SI 1 "register_operand" "")
1931 (match_operand 2 "const_int_operand" "")]
1934 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1938 (define_expand "vec_extractv8hi"
1939 [(match_operand:HI 0 "register_operand" "")
1940 (match_operand:V8HI 1 "register_operand" "")
1941 (match_operand 2 "const_int_operand" "")]
1944 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1948 (define_expand "vec_extractv16qi"
1949 [(match_operand:QI 0 "register_operand" "")
1950 (match_operand:V16QI 1 "register_operand" "")
1951 (match_operand 2 "const_int_operand" "")]
1954 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1958 (define_expand "vec_extractv4sf"
1959 [(match_operand:SF 0 "register_operand" "")
1960 (match_operand:V4SF 1 "register_operand" "")
1961 (match_operand 2 "const_int_operand" "")]
1964 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1969 ;; vspltis? SCRATCH0,0
1970 ;; vsubu?m SCRATCH2,SCRATCH1,%1
1971 ;; vmaxs? %0,%1,SCRATCH2"
1972 (define_expand "abs<mode>2"
1973 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
1975 (minus:VI (match_dup 2)
1976 (match_operand:VI 1 "register_operand" "v")))
1977 (set (match_operand:VI 0 "register_operand" "=v")
1978 (smax:VI (match_dup 1) (match_dup 3)))]
1981 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
1982 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
1986 ;; vspltisw SCRATCH1,-1
1987 ;; vslw SCRATCH2,SCRATCH1,SCRATCH1
1988 ;; vandc %0,%1,SCRATCH2
1989 (define_expand "absv4sf2"
1991 (vec_duplicate:V4SI (const_int -1)))
1993 (unspec:V4SI [(match_dup 2) (match_dup 2)] UNSPEC_VSL))
1994 (set (match_operand:V4SF 0 "register_operand" "=v")
1995 (and:V4SF (not:V4SF (subreg:V4SF (match_dup 3) 0))
1996 (match_operand:V4SF 1 "register_operand" "v")))]
1999 operands[2] = gen_reg_rtx (V4SImode);
2000 operands[3] = gen_reg_rtx (V4SImode);
2004 ;; vspltis? SCRATCH0,0
2005 ;; vsubs?s SCRATCH2,SCRATCH1,%1
2006 ;; vmaxs? %0,%1,SCRATCH2"
2007 (define_expand "altivec_abss_<mode>"
2008 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
2009 (parallel [(set (match_dup 3)
2010 (unspec:VI [(match_dup 2)
2011 (match_operand:VI 1 "register_operand" "v")]
2013 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))])
2014 (set (match_operand:VI 0 "register_operand" "=v")
2015 (smax:VI (match_dup 1) (match_dup 3)))]
2018 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
2019 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
2022 ;; Vector shift left in bits. Currently supported ony for shift
2023 ;; amounts that can be expressed as byte shifts (divisible by 8).
2024 ;; General shift amounts can be supported using vslo + vsl. We're
2025 ;; not expecting to see these yet (the vectorizer currently
2026 ;; generates only shifts divisible by byte_size).
2027 (define_expand "vec_shl_<mode>"
2028 [(set (match_operand:V 0 "register_operand" "=v")
2029 (unspec:V [(match_operand:V 1 "register_operand" "v")
2030 (match_operand:QI 2 "reg_or_short_operand" "")]
2035 rtx bitshift = operands[2];
2036 rtx byteshift = gen_reg_rtx (QImode);
2037 HOST_WIDE_INT bitshift_val;
2038 HOST_WIDE_INT byteshift_val;
2040 if (! CONSTANT_P (bitshift))
2042 bitshift_val = INTVAL (bitshift);
2043 if (bitshift_val & 0x7)
2045 byteshift_val = bitshift_val >> 3;
2046 byteshift = gen_rtx_CONST_INT (QImode, byteshift_val);
2047 emit_insn (gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
2052 ;; Vector shift left in bits. Currently supported ony for shift
2053 ;; amounts that can be expressed as byte shifts (divisible by 8).
2054 ;; General shift amounts can be supported using vsro + vsr. We're
2055 ;; not expecting to see these yet (the vectorizer currently
2056 ;; generates only shifts divisible by byte_size).
2057 (define_expand "vec_shr_<mode>"
2058 [(set (match_operand:V 0 "register_operand" "=v")
2059 (unspec:V [(match_operand:V 1 "register_operand" "v")
2060 (match_operand:QI 2 "reg_or_short_operand" "")]
2065 rtx bitshift = operands[2];
2066 rtx byteshift = gen_reg_rtx (QImode);
2067 HOST_WIDE_INT bitshift_val;
2068 HOST_WIDE_INT byteshift_val;
2070 if (! CONSTANT_P (bitshift))
2072 bitshift_val = INTVAL (bitshift);
2073 if (bitshift_val & 0x7)
2075 byteshift_val = 16 - (bitshift_val >> 3);
2076 byteshift = gen_rtx_CONST_INT (QImode, byteshift_val);
2077 emit_insn (gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
2082 (define_insn "altivec_vsumsws_nomode"
2083 [(set (match_operand 0 "register_operand" "=v")
2084 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
2085 (match_operand:V4SI 2 "register_operand" "v")]
2087 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
2090 [(set_attr "type" "veccomplex")])
2092 (define_expand "reduc_splus_<mode>"
2093 [(set (match_operand:VIshort 0 "register_operand" "=v")
2094 (unspec:VIshort [(match_operand:VIshort 1 "register_operand" "v")]
2095 UNSPEC_REDUC_PLUS))]
2099 rtx vzero = gen_reg_rtx (V4SImode);
2100 rtx vtmp1 = gen_reg_rtx (V4SImode);
2102 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2103 emit_insn (gen_altivec_vsum4s<VI_char>s (vtmp1, operands[1], vzero));
2104 emit_insn (gen_altivec_vsumsws_nomode (operands[0], vtmp1, vzero));
2108 (define_expand "reduc_uplus_v16qi"
2109 [(set (match_operand:V16QI 0 "register_operand" "=v")
2110 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
2111 UNSPEC_REDUC_PLUS))]
2115 rtx vzero = gen_reg_rtx (V4SImode);
2116 rtx vtmp1 = gen_reg_rtx (V4SImode);
2118 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2119 emit_insn (gen_altivec_vsum4ubs (vtmp1, operands[1], vzero));
2120 emit_insn (gen_altivec_vsumsws_nomode (operands[0], vtmp1, vzero));
2124 (define_insn "vec_realign_load_<mode>"
2125 [(set (match_operand:V 0 "register_operand" "=v")
2126 (unspec:V [(match_operand:V 1 "register_operand" "v")
2127 (match_operand:V 2 "register_operand" "v")
2128 (match_operand:V16QI 3 "register_operand" "v")]
2129 UNSPEC_REALIGN_LOAD))]
2132 [(set_attr "type" "vecperm")])
2134 (define_expand "neg<mode>2"
2135 [(use (match_operand:VI 0 "register_operand" ""))
2136 (use (match_operand:VI 1 "register_operand" ""))]
2142 vzero = gen_reg_rtx (GET_MODE (operands[0]));
2143 emit_insn (gen_altivec_vspltis<VI_char> (vzero, const0_rtx));
2144 emit_insn (gen_sub<mode>3 (operands[0], vzero, operands[1]));
2149 (define_expand "udot_prod<mode>"
2150 [(set (match_operand:V4SI 0 "register_operand" "=v")
2151 (plus:V4SI (match_operand:V4SI 3 "register_operand" "v")
2152 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
2153 (match_operand:VIshort 2 "register_operand" "v")]
2158 emit_insn (gen_altivec_vmsumu<VI_char>m (operands[0], operands[1], operands[2], operands[3]));
2162 (define_expand "sdot_prodv8hi"
2163 [(set (match_operand:V4SI 0 "register_operand" "=v")
2164 (plus:V4SI (match_operand:V4SI 3 "register_operand" "v")
2165 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2166 (match_operand:V8HI 2 "register_operand" "v")]
2171 emit_insn (gen_altivec_vmsumshm (operands[0], operands[1], operands[2], operands[3]));
2175 (define_expand "widen_usum<mode>3"
2176 [(set (match_operand:V4SI 0 "register_operand" "=v")
2177 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
2178 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")]
2183 rtx vones = gen_reg_rtx (GET_MODE (operands[1]));
2185 emit_insn (gen_altivec_vspltis<VI_char> (vones, const1_rtx));
2186 emit_insn (gen_altivec_vmsumu<VI_char>m (operands[0], operands[1], vones, operands[2]));
2190 (define_expand "widen_ssumv16qi3"
2191 [(set (match_operand:V4SI 0 "register_operand" "=v")
2192 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
2193 (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")]
2198 rtx vones = gen_reg_rtx (V16QImode);
2200 emit_insn (gen_altivec_vspltisb (vones, const1_rtx));
2201 emit_insn (gen_altivec_vmsummbm (operands[0], operands[1], vones, operands[2]));
2205 (define_expand "widen_ssumv8hi3"
2206 [(set (match_operand:V4SI 0 "register_operand" "=v")
2207 (plus:V4SI (match_operand:V4SI 2 "register_operand" "v")
2208 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2213 rtx vones = gen_reg_rtx (V8HImode);
2215 emit_insn (gen_altivec_vspltish (vones, const1_rtx));
2216 emit_insn (gen_altivec_vmsumshm (operands[0], operands[1], vones, operands[2]));
2220 (define_expand "vec_unpacks_hi_v16qi"
2221 [(set (match_operand:V8HI 0 "register_operand" "=v")
2222 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2227 emit_insn (gen_altivec_vupkhsb (operands[0], operands[1]));
2231 (define_expand "vec_unpacks_hi_v8hi"
2232 [(set (match_operand:V4SI 0 "register_operand" "=v")
2233 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2238 emit_insn (gen_altivec_vupkhsh (operands[0], operands[1]));
2242 (define_expand "vec_unpacks_lo_v16qi"
2243 [(set (match_operand:V8HI 0 "register_operand" "=v")
2244 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2249 emit_insn (gen_altivec_vupklsb (operands[0], operands[1]));
2253 (define_expand "vec_unpacks_lo_v8hi"
2254 [(set (match_operand:V4SI 0 "register_operand" "=v")
2255 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2260 emit_insn (gen_altivec_vupklsh (operands[0], operands[1]));
2264 (define_insn "vperm_v8hiv4si"
2265 [(set (match_operand:V4SI 0 "register_operand" "=v")
2266 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2267 (match_operand:V4SI 2 "register_operand" "v")
2268 (match_operand:V16QI 3 "register_operand" "v")]
2272 [(set_attr "type" "vecperm")])
2274 (define_insn "vperm_v16qiv8hi"
2275 [(set (match_operand:V8HI 0 "register_operand" "=v")
2276 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2277 (match_operand:V8HI 2 "register_operand" "v")
2278 (match_operand:V16QI 3 "register_operand" "v")]
2282 [(set_attr "type" "vecperm")])
2285 (define_expand "vec_unpacku_hi_v16qi"
2286 [(set (match_operand:V8HI 0 "register_operand" "=v")
2287 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2292 rtx vzero = gen_reg_rtx (V8HImode);
2293 rtx mask = gen_reg_rtx (V16QImode);
2294 rtvec v = rtvec_alloc (16);
2296 emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
2298 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2299 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 0);
2300 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
2301 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
2302 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2303 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 2);
2304 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
2305 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
2306 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2307 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 4);
2308 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
2309 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
2310 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2311 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 6);
2312 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
2313 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
2315 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2316 emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
2320 (define_expand "vec_unpacku_hi_v8hi"
2321 [(set (match_operand:V4SI 0 "register_operand" "=v")
2322 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2327 rtx vzero = gen_reg_rtx (V4SImode);
2328 rtx mask = gen_reg_rtx (V16QImode);
2329 rtvec v = rtvec_alloc (16);
2331 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2333 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2334 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
2335 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 0);
2336 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 1);
2337 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2338 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
2339 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 2);
2340 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 3);
2341 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2342 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
2343 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 4);
2344 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 5);
2345 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2346 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
2347 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 6);
2348 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 7);
2350 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2351 emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
2355 (define_expand "vec_unpacku_lo_v16qi"
2356 [(set (match_operand:V8HI 0 "register_operand" "=v")
2357 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
2362 rtx vzero = gen_reg_rtx (V8HImode);
2363 rtx mask = gen_reg_rtx (V16QImode);
2364 rtvec v = rtvec_alloc (16);
2366 emit_insn (gen_altivec_vspltish (vzero, const0_rtx));
2368 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2369 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 8);
2370 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 16);
2371 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
2372 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2373 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 10);
2374 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 16);
2375 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
2376 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2377 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 12);
2378 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 16);
2379 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
2380 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2381 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 14);
2382 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 16);
2383 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
2385 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2386 emit_insn (gen_vperm_v16qiv8hi (operands[0], operands[1], vzero, mask));
2390 (define_expand "vec_unpacku_lo_v8hi"
2391 [(set (match_operand:V4SI 0 "register_operand" "=v")
2392 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
2397 rtx vzero = gen_reg_rtx (V4SImode);
2398 rtx mask = gen_reg_rtx (V16QImode);
2399 rtvec v = rtvec_alloc (16);
2401 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2403 RTVEC_ELT (v, 0) = gen_rtx_CONST_INT (QImode, 16);
2404 RTVEC_ELT (v, 1) = gen_rtx_CONST_INT (QImode, 17);
2405 RTVEC_ELT (v, 2) = gen_rtx_CONST_INT (QImode, 8);
2406 RTVEC_ELT (v, 3) = gen_rtx_CONST_INT (QImode, 9);
2407 RTVEC_ELT (v, 4) = gen_rtx_CONST_INT (QImode, 16);
2408 RTVEC_ELT (v, 5) = gen_rtx_CONST_INT (QImode, 17);
2409 RTVEC_ELT (v, 6) = gen_rtx_CONST_INT (QImode, 10);
2410 RTVEC_ELT (v, 7) = gen_rtx_CONST_INT (QImode, 11);
2411 RTVEC_ELT (v, 8) = gen_rtx_CONST_INT (QImode, 16);
2412 RTVEC_ELT (v, 9) = gen_rtx_CONST_INT (QImode, 17);
2413 RTVEC_ELT (v, 10) = gen_rtx_CONST_INT (QImode, 12);
2414 RTVEC_ELT (v, 11) = gen_rtx_CONST_INT (QImode, 13);
2415 RTVEC_ELT (v, 12) = gen_rtx_CONST_INT (QImode, 16);
2416 RTVEC_ELT (v, 13) = gen_rtx_CONST_INT (QImode, 17);
2417 RTVEC_ELT (v, 14) = gen_rtx_CONST_INT (QImode, 14);
2418 RTVEC_ELT (v, 15) = gen_rtx_CONST_INT (QImode, 15);
2420 emit_insn (gen_vec_initv16qi (mask, gen_rtx_PARALLEL (V16QImode, v)));
2421 emit_insn (gen_vperm_v8hiv4si (operands[0], operands[1], vzero, mask));
2425 (define_expand "vec_widen_umult_hi_v16qi"
2426 [(set (match_operand:V8HI 0 "register_operand" "=v")
2427 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2428 (match_operand:V16QI 2 "register_operand" "v")]
2433 rtx ve = gen_reg_rtx (V8HImode);
2434 rtx vo = gen_reg_rtx (V8HImode);
2436 emit_insn (gen_altivec_vmuleub (ve, operands[1], operands[2]));
2437 emit_insn (gen_altivec_vmuloub (vo, operands[1], operands[2]));
2438 emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
2442 (define_expand "vec_widen_umult_lo_v16qi"
2443 [(set (match_operand:V8HI 0 "register_operand" "=v")
2444 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2445 (match_operand:V16QI 2 "register_operand" "v")]
2450 rtx ve = gen_reg_rtx (V8HImode);
2451 rtx vo = gen_reg_rtx (V8HImode);
2453 emit_insn (gen_altivec_vmuleub (ve, operands[1], operands[2]));
2454 emit_insn (gen_altivec_vmuloub (vo, operands[1], operands[2]));
2455 emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
2459 (define_expand "vec_widen_smult_hi_v16qi"
2460 [(set (match_operand:V8HI 0 "register_operand" "=v")
2461 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2462 (match_operand:V16QI 2 "register_operand" "v")]
2467 rtx ve = gen_reg_rtx (V8HImode);
2468 rtx vo = gen_reg_rtx (V8HImode);
2470 emit_insn (gen_altivec_vmulesb (ve, operands[1], operands[2]));
2471 emit_insn (gen_altivec_vmulosb (vo, operands[1], operands[2]));
2472 emit_insn (gen_altivec_vmrghh (operands[0], ve, vo));
2476 (define_expand "vec_widen_smult_lo_v16qi"
2477 [(set (match_operand:V8HI 0 "register_operand" "=v")
2478 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
2479 (match_operand:V16QI 2 "register_operand" "v")]
2484 rtx ve = gen_reg_rtx (V8HImode);
2485 rtx vo = gen_reg_rtx (V8HImode);
2487 emit_insn (gen_altivec_vmulesb (ve, operands[1], operands[2]));
2488 emit_insn (gen_altivec_vmulosb (vo, operands[1], operands[2]));
2489 emit_insn (gen_altivec_vmrglh (operands[0], ve, vo));
2493 (define_expand "vec_widen_umult_hi_v8hi"
2494 [(set (match_operand:V4SI 0 "register_operand" "=v")
2495 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2496 (match_operand:V8HI 2 "register_operand" "v")]
2501 rtx ve = gen_reg_rtx (V4SImode);
2502 rtx vo = gen_reg_rtx (V4SImode);
2504 emit_insn (gen_altivec_vmuleuh (ve, operands[1], operands[2]));
2505 emit_insn (gen_altivec_vmulouh (vo, operands[1], operands[2]));
2506 emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
2510 (define_expand "vec_widen_umult_lo_v8hi"
2511 [(set (match_operand:V4SI 0 "register_operand" "=v")
2512 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2513 (match_operand:V8HI 2 "register_operand" "v")]
2518 rtx ve = gen_reg_rtx (V4SImode);
2519 rtx vo = gen_reg_rtx (V4SImode);
2521 emit_insn (gen_altivec_vmuleuh (ve, operands[1], operands[2]));
2522 emit_insn (gen_altivec_vmulouh (vo, operands[1], operands[2]));
2523 emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
2527 (define_expand "vec_widen_smult_hi_v8hi"
2528 [(set (match_operand:V4SI 0 "register_operand" "=v")
2529 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2530 (match_operand:V8HI 2 "register_operand" "v")]
2535 rtx ve = gen_reg_rtx (V4SImode);
2536 rtx vo = gen_reg_rtx (V4SImode);
2538 emit_insn (gen_altivec_vmulesh (ve, operands[1], operands[2]));
2539 emit_insn (gen_altivec_vmulosh (vo, operands[1], operands[2]));
2540 emit_insn (gen_altivec_vmrghw (operands[0], ve, vo));
2544 (define_expand "vec_widen_smult_lo_v8hi"
2545 [(set (match_operand:V4SI 0 "register_operand" "=v")
2546 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
2547 (match_operand:V8HI 2 "register_operand" "v")]
2552 rtx ve = gen_reg_rtx (V4SImode);
2553 rtx vo = gen_reg_rtx (V4SImode);
2555 emit_insn (gen_altivec_vmulesh (ve, operands[1], operands[2]));
2556 emit_insn (gen_altivec_vmulosh (vo, operands[1], operands[2]));
2557 emit_insn (gen_altivec_vmrglw (operands[0], ve, vo));
2561 (define_expand "vec_pack_mod_v8hi"
2562 [(set (match_operand:V16QI 0 "register_operand" "=v")
2563 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
2564 (match_operand:V8HI 2 "register_operand" "v")]
2569 emit_insn (gen_altivec_vpkuhum (operands[0], operands[1], operands[2]));
2573 (define_expand "vec_pack_mod_v4si"
2574 [(set (match_operand:V8HI 0 "register_operand" "=v")
2575 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
2576 (match_operand:V4SI 2 "register_operand" "v")]
2581 emit_insn (gen_altivec_vpkuwum (operands[0], operands[1], operands[2]));
2585 (define_expand "negv4sf2"
2586 [(use (match_operand:V4SF 0 "register_operand" ""))
2587 (use (match_operand:V4SF 1 "register_operand" ""))]
2593 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
2594 neg0 = gen_reg_rtx (V4SImode);
2595 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
2596 emit_insn (gen_altivec_vslw (neg0, neg0, neg0));
2599 emit_insn (gen_xorv4sf3 (operands[0],
2600 gen_lowpart (V4SFmode, neg0), operands[1]));