2 ;; Copyright (C) 2002, 2003, 2004, 2005 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)
128 [(UNSPECV_SET_VRSAVE 30)
136 (define_mode_macro VI [V4SI V8HI V16QI])
137 ;; Short vec in modes
138 (define_mode_macro VIshort [V8HI V16QI])
140 (define_mode_macro VF [V4SF])
141 ;; Vec modes, pity mode macros are not composable
142 (define_mode_macro V [V4SI V8HI V16QI V4SF])
144 (define_mode_attr VI_char [(V4SI "w") (V8HI "h") (V16QI "b")])
146 ;; Generic LVX load instruction.
147 (define_insn "altivec_lvx_<mode>"
148 [(set (match_operand:V 0 "altivec_register_operand" "=v")
149 (match_operand:V 1 "memory_operand" "Z"))]
152 [(set_attr "type" "vecload")])
154 ;; Generic STVX store instruction.
155 (define_insn "altivec_stvx_<mode>"
156 [(set (match_operand:V 0 "memory_operand" "=Z")
157 (match_operand:V 1 "altivec_register_operand" "v"))]
160 [(set_attr "type" "vecstore")])
162 ;; Vector move instructions.
163 (define_expand "mov<mode>"
164 [(set (match_operand:V 0 "nonimmediate_operand" "")
165 (match_operand:V 1 "any_operand" ""))]
168 rs6000_emit_move (operands[0], operands[1], <MODE>mode);
172 (define_insn "*mov<mode>_internal"
173 [(set (match_operand:V 0 "nonimmediate_operand" "=Z,v,v,o,r,r,v")
174 (match_operand:V 1 "input_operand" "v,Z,v,r,o,r,W"))]
176 && (register_operand (operands[0], <MODE>mode)
177 || register_operand (operands[1], <MODE>mode))"
179 switch (which_alternative)
181 case 0: return "stvx %1,%y0";
182 case 1: return "lvx %0,%y1";
183 case 2: return "vor %0,%1,%1";
187 case 6: return output_vec_const_move (operands);
188 default: gcc_unreachable ();
191 [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,*")])
194 [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
195 (match_operand:V4SI 1 "input_operand" ""))]
196 "TARGET_ALTIVEC && reload_completed
197 && gpr_or_gpr_p (operands[0], operands[1])"
200 rs6000_split_multireg_move (operands[0], operands[1]); DONE;
204 [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
205 (match_operand:V8HI 1 "input_operand" ""))]
206 "TARGET_ALTIVEC && reload_completed
207 && gpr_or_gpr_p (operands[0], operands[1])"
209 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
212 [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
213 (match_operand:V16QI 1 "input_operand" ""))]
214 "TARGET_ALTIVEC && reload_completed
215 && gpr_or_gpr_p (operands[0], operands[1])"
217 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
220 [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
221 (match_operand:V4SF 1 "input_operand" ""))]
222 "TARGET_ALTIVEC && reload_completed
223 && gpr_or_gpr_p (operands[0], operands[1])"
226 rs6000_split_multireg_move (operands[0], operands[1]); DONE;
230 [(set (match_operand:VI 0 "altivec_register_operand" "")
231 (match_operand:VI 1 "easy_vector_constant_add_self" ""))]
232 "TARGET_ALTIVEC && reload_completed"
233 [(set (match_dup 0) (match_dup 3))
234 (set (match_dup 0) (plus:VI (match_dup 0)
237 rtx dup = gen_easy_altivec_constant (operands[1]);
240 /* Divide the operand of the resulting VEC_DUPLICATE, and use
241 simplify_rtx to make a CONST_VECTOR. */
242 XEXP (dup, 0) = simplify_const_binary_operation (ASHIFTRT, QImode,
243 XEXP (dup, 0), const1_rtx);
244 const_vec = simplify_rtx (dup);
246 if (GET_MODE (const_vec) == <MODE>mode)
247 operands[3] = const_vec;
249 operands[3] = gen_lowpart (<MODE>mode, const_vec);
252 (define_insn "get_vrsave_internal"
253 [(set (match_operand:SI 0 "register_operand" "=r")
254 (unspec:SI [(reg:SI 109)] UNSPEC_GET_VRSAVE))]
258 return "mfspr %0,256";
260 return "mfvrsave %0";
262 [(set_attr "type" "*")])
264 (define_insn "*set_vrsave_internal"
265 [(match_parallel 0 "vrsave_operation"
267 (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
268 (reg:SI 109)] UNSPECV_SET_VRSAVE))])]
272 return "mtspr 256,%1";
274 return "mtvrsave %1";
276 [(set_attr "type" "*")])
278 (define_insn "*save_world"
279 [(match_parallel 0 "save_world_operation"
280 [(clobber (match_operand:SI 1 "register_operand" "=l"))
281 (use (match_operand:SI 2 "call_operand" "s"))])]
282 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
284 [(set_attr "type" "branch")
285 (set_attr "length" "4")])
287 (define_insn "*restore_world"
288 [(match_parallel 0 "restore_world_operation"
290 (use (match_operand:SI 1 "register_operand" "l"))
291 (use (match_operand:SI 2 "call_operand" "s"))
292 (clobber (match_operand:SI 3 "gpc_reg_operand" "=r"))])]
293 "TARGET_MACHO && (DEFAULT_ABI == ABI_DARWIN) && TARGET_32BIT"
296 ;; Simple binary operations.
299 (define_insn "add<mode>3"
300 [(set (match_operand:VI 0 "register_operand" "=v")
301 (plus:VI (match_operand:VI 1 "register_operand" "v")
302 (match_operand:VI 2 "register_operand" "v")))]
304 "vaddu<VI_char>m %0,%1,%2"
305 [(set_attr "type" "vecsimple")])
307 (define_insn "addv4sf3"
308 [(set (match_operand:V4SF 0 "register_operand" "=v")
309 (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
310 (match_operand:V4SF 2 "register_operand" "v")))]
313 [(set_attr "type" "vecfloat")])
315 (define_insn "altivec_vaddcuw"
316 [(set (match_operand:V4SI 0 "register_operand" "=v")
317 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
318 (match_operand:V4SI 2 "register_operand" "v")]
322 [(set_attr "type" "vecsimple")])
324 (define_insn "altivec_vaddu<VI_char>s"
325 [(set (match_operand:VI 0 "register_operand" "=v")
326 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
327 (match_operand:VI 2 "register_operand" "v")]
329 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
331 "vaddu<VI_char>s %0,%1,%2"
332 [(set_attr "type" "vecsimple")])
334 (define_insn "altivec_vadds<VI_char>s"
335 [(set (match_operand:VI 0 "register_operand" "=v")
336 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
337 (match_operand:VI 2 "register_operand" "v")]
339 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
341 "vadds<VI_char>s %0,%1,%2"
342 [(set_attr "type" "vecsimple")])
345 (define_insn "sub<mode>3"
346 [(set (match_operand:VI 0 "register_operand" "=v")
347 (minus:VI (match_operand:VI 1 "register_operand" "v")
348 (match_operand:VI 2 "register_operand" "v")))]
350 "vsubu<VI_char>m %0,%1,%2"
351 [(set_attr "type" "vecsimple")])
353 (define_insn "subv4sf3"
354 [(set (match_operand:V4SF 0 "register_operand" "=v")
355 (minus:V4SF (match_operand:V4SF 1 "register_operand" "v")
356 (match_operand:V4SF 2 "register_operand" "v")))]
359 [(set_attr "type" "vecfloat")])
361 (define_insn "altivec_vsubcuw"
362 [(set (match_operand:V4SI 0 "register_operand" "=v")
363 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
364 (match_operand:V4SI 2 "register_operand" "v")]
368 [(set_attr "type" "vecsimple")])
370 (define_insn "altivec_vsubu<VI_char>s"
371 [(set (match_operand:VI 0 "register_operand" "=v")
372 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
373 (match_operand:VI 2 "register_operand" "v")]
375 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
377 "vsubu<VI_char>s %0,%1,%2"
378 [(set_attr "type" "vecsimple")])
380 (define_insn "altivec_vsubs<VI_char>s"
381 [(set (match_operand:VI 0 "register_operand" "=v")
382 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
383 (match_operand:VI 2 "register_operand" "v")]
385 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
387 "vsubs<VI_char>s %0,%1,%2"
388 [(set_attr "type" "vecsimple")])
391 (define_insn "altivec_vavgu<VI_char>"
392 [(set (match_operand:VI 0 "register_operand" "=v")
393 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
394 (match_operand:VI 2 "register_operand" "v")]
397 "vavgu<VI_char> %0,%1,%2"
398 [(set_attr "type" "vecsimple")])
400 (define_insn "altivec_vavgs<VI_char>"
401 [(set (match_operand:VI 0 "register_operand" "=v")
402 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
403 (match_operand:VI 2 "register_operand" "v")]
406 "vavgs<VI_char> %0,%1,%2"
407 [(set_attr "type" "vecsimple")])
409 (define_insn "altivec_vcmpbfp"
410 [(set (match_operand:V4SI 0 "register_operand" "=v")
411 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
412 (match_operand:V4SF 2 "register_operand" "v")]
416 [(set_attr "type" "veccmp")])
418 (define_insn "altivec_vcmpequb"
419 [(set (match_operand:V16QI 0 "register_operand" "=v")
420 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
421 (match_operand:V16QI 2 "register_operand" "v")]
425 [(set_attr "type" "vecsimple")])
427 (define_insn "altivec_vcmpequh"
428 [(set (match_operand:V8HI 0 "register_operand" "=v")
429 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
430 (match_operand:V8HI 2 "register_operand" "v")]
434 [(set_attr "type" "vecsimple")])
436 (define_insn "altivec_vcmpequw"
437 [(set (match_operand:V4SI 0 "register_operand" "=v")
438 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
439 (match_operand:V4SI 2 "register_operand" "v")]
443 [(set_attr "type" "vecsimple")])
445 (define_insn "altivec_vcmpeqfp"
446 [(set (match_operand:V4SI 0 "register_operand" "=v")
447 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
448 (match_operand:V4SF 2 "register_operand" "v")]
452 [(set_attr "type" "veccmp")])
454 (define_insn "altivec_vcmpgefp"
455 [(set (match_operand:V4SI 0 "register_operand" "=v")
456 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
457 (match_operand:V4SF 2 "register_operand" "v")]
461 [(set_attr "type" "veccmp")])
463 (define_insn "altivec_vcmpgtub"
464 [(set (match_operand:V16QI 0 "register_operand" "=v")
465 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
466 (match_operand:V16QI 2 "register_operand" "v")]
470 [(set_attr "type" "vecsimple")])
472 (define_insn "altivec_vcmpgtsb"
473 [(set (match_operand:V16QI 0 "register_operand" "=v")
474 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
475 (match_operand:V16QI 2 "register_operand" "v")]
479 [(set_attr "type" "vecsimple")])
481 (define_insn "altivec_vcmpgtuh"
482 [(set (match_operand:V8HI 0 "register_operand" "=v")
483 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
484 (match_operand:V8HI 2 "register_operand" "v")]
488 [(set_attr "type" "vecsimple")])
490 (define_insn "altivec_vcmpgtsh"
491 [(set (match_operand:V8HI 0 "register_operand" "=v")
492 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
493 (match_operand:V8HI 2 "register_operand" "v")]
497 [(set_attr "type" "vecsimple")])
499 (define_insn "altivec_vcmpgtuw"
500 [(set (match_operand:V4SI 0 "register_operand" "=v")
501 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
502 (match_operand:V4SI 2 "register_operand" "v")]
506 [(set_attr "type" "vecsimple")])
508 (define_insn "altivec_vcmpgtsw"
509 [(set (match_operand:V4SI 0 "register_operand" "=v")
510 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
511 (match_operand:V4SI 2 "register_operand" "v")]
515 [(set_attr "type" "vecsimple")])
517 (define_insn "altivec_vcmpgtfp"
518 [(set (match_operand:V4SI 0 "register_operand" "=v")
519 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
520 (match_operand:V4SF 2 "register_operand" "v")]
524 [(set_attr "type" "veccmp")])
526 ;; Fused multiply add
527 (define_insn "altivec_vmaddfp"
528 [(set (match_operand:V4SF 0 "register_operand" "=v")
529 (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
530 (match_operand:V4SF 2 "register_operand" "v"))
531 (match_operand:V4SF 3 "register_operand" "v")))]
533 "vmaddfp %0,%1,%2,%3"
534 [(set_attr "type" "vecfloat")])
536 ;; We do multiply as a fused multiply-add with an add of a -0.0 vector.
538 (define_expand "mulv4sf3"
539 [(use (match_operand:V4SF 0 "register_operand" ""))
540 (use (match_operand:V4SF 1 "register_operand" ""))
541 (use (match_operand:V4SF 2 "register_operand" ""))]
542 "TARGET_ALTIVEC && TARGET_FUSED_MADD"
547 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
548 neg0 = gen_reg_rtx (V4SImode);
549 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
550 emit_insn (gen_altivec_vslw (neg0, neg0, neg0));
552 /* Use the multiply-add. */
553 emit_insn (gen_altivec_vmaddfp (operands[0], operands[1], operands[2],
554 gen_lowpart (V4SFmode, neg0)));
558 ;; 32 bit integer multiplication
559 ;; A_high = Operand_0 & 0xFFFF0000 >> 16
560 ;; A_low = Operand_0 & 0xFFFF
561 ;; B_high = Operand_1 & 0xFFFF0000 >> 16
562 ;; B_low = Operand_1 & 0xFFFF
563 ;; result = A_low * B_low + (A_high * B_low + B_high * A_low) << 16
565 ;; (define_insn "mulv4si3"
566 ;; [(set (match_operand:V4SI 0 "register_operand" "=v")
567 ;; (mult:V4SI (match_operand:V4SI 1 "register_operand" "v")
568 ;; (match_operand:V4SI 2 "register_operand" "v")))]
569 (define_expand "mulv4si3"
570 [(use (match_operand:V4SI 0 "register_operand" ""))
571 (use (match_operand:V4SI 1 "register_operand" ""))
572 (use (match_operand:V4SI 2 "register_operand" ""))]
585 zero = gen_reg_rtx (V4SImode);
586 emit_insn (gen_altivec_vspltisw (zero, const0_rtx));
588 sixteen = gen_reg_rtx (V4SImode);
589 emit_insn (gen_altivec_vspltisw (sixteen, gen_rtx_CONST_INT (V4SImode, -16)));
591 swap = gen_reg_rtx (V4SImode);
592 emit_insn (gen_altivec_vrlw (swap, operands[2], sixteen));
594 one = gen_reg_rtx (V8HImode);
595 convert_move (one, operands[1], 0);
597 two = gen_reg_rtx (V8HImode);
598 convert_move (two, operands[2], 0);
600 small_swap = gen_reg_rtx (V8HImode);
601 convert_move (small_swap, swap, 0);
603 low_product = gen_reg_rtx (V4SImode);
604 emit_insn (gen_altivec_vmulouh (low_product, one, two));
606 high_product = gen_reg_rtx (V4SImode);
607 emit_insn (gen_altivec_vmsumuhm (high_product, one, small_swap, zero));
609 emit_insn (gen_altivec_vslw (high_product, high_product, sixteen));
611 emit_insn (gen_addv4si3 (operands[0], high_product, low_product));
617 ;; Fused multiply subtract
618 (define_insn "altivec_vnmsubfp"
619 [(set (match_operand:V4SF 0 "register_operand" "=v")
620 (neg:V4SF (minus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
621 (match_operand:V4SF 2 "register_operand" "v"))
622 (match_operand:V4SF 3 "register_operand" "v"))))]
624 "vnmsubfp %0,%1,%2,%3"
625 [(set_attr "type" "vecfloat")])
627 (define_insn "altivec_vmsumu<VI_char>m"
628 [(set (match_operand:V4SI 0 "register_operand" "=v")
629 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
630 (match_operand:VIshort 2 "register_operand" "v")
631 (match_operand:V4SI 3 "register_operand" "v")]
634 "vmsumu<VI_char>m %0,%1,%2,%3"
635 [(set_attr "type" "veccomplex")])
637 (define_insn "altivec_vmsumm<VI_char>m"
638 [(set (match_operand:V4SI 0 "register_operand" "=v")
639 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
640 (match_operand:VIshort 2 "register_operand" "v")
641 (match_operand:V4SI 3 "register_operand" "v")]
644 "vmsumm<VI_char>m %0,%1,%2,%3"
645 [(set_attr "type" "veccomplex")])
647 (define_insn "altivec_vmsumshm"
648 [(set (match_operand:V4SI 0 "register_operand" "=v")
649 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
650 (match_operand:V8HI 2 "register_operand" "v")
651 (match_operand:V4SI 3 "register_operand" "v")]
654 "vmsumshm %0,%1,%2,%3"
655 [(set_attr "type" "veccomplex")])
657 (define_insn "altivec_vmsumuhs"
658 [(set (match_operand:V4SI 0 "register_operand" "=v")
659 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
660 (match_operand:V8HI 2 "register_operand" "v")
661 (match_operand:V4SI 3 "register_operand" "v")]
663 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
665 "vmsumuhs %0,%1,%2,%3"
666 [(set_attr "type" "veccomplex")])
668 (define_insn "altivec_vmsumshs"
669 [(set (match_operand:V4SI 0 "register_operand" "=v")
670 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
671 (match_operand:V8HI 2 "register_operand" "v")
672 (match_operand:V4SI 3 "register_operand" "v")]
674 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
676 "vmsumshs %0,%1,%2,%3"
677 [(set_attr "type" "veccomplex")])
681 (define_insn "umax<mode>3"
682 [(set (match_operand:VI 0 "register_operand" "=v")
683 (umax:VI (match_operand:VI 1 "register_operand" "v")
684 (match_operand:VI 2 "register_operand" "v")))]
686 "vmaxu<VI_char> %0,%1,%2"
687 [(set_attr "type" "vecsimple")])
689 (define_insn "smax<mode>3"
690 [(set (match_operand:VI 0 "register_operand" "=v")
691 (smax:VI (match_operand:VI 1 "register_operand" "v")
692 (match_operand:VI 2 "register_operand" "v")))]
694 "vmaxs<VI_char> %0,%1,%2"
695 [(set_attr "type" "vecsimple")])
697 (define_insn "smaxv4sf3"
698 [(set (match_operand:V4SF 0 "register_operand" "=v")
699 (smax:V4SF (match_operand:V4SF 1 "register_operand" "v")
700 (match_operand:V4SF 2 "register_operand" "v")))]
703 [(set_attr "type" "veccmp")])
705 (define_insn "umin<mode>3"
706 [(set (match_operand:VI 0 "register_operand" "=v")
707 (umin:VI (match_operand:VI 1 "register_operand" "v")
708 (match_operand:VI 2 "register_operand" "v")))]
710 "vminu<VI_char> %0,%1,%2"
711 [(set_attr "type" "vecsimple")])
713 (define_insn "smin<mode>3"
714 [(set (match_operand:VI 0 "register_operand" "=v")
715 (smin:VI (match_operand:VI 1 "register_operand" "v")
716 (match_operand:VI 2 "register_operand" "v")))]
718 "vmins<VI_char> %0,%1,%2"
719 [(set_attr "type" "vecsimple")])
721 (define_insn "sminv4sf3"
722 [(set (match_operand:V4SF 0 "register_operand" "=v")
723 (smin:V4SF (match_operand:V4SF 1 "register_operand" "v")
724 (match_operand:V4SF 2 "register_operand" "v")))]
727 [(set_attr "type" "veccmp")])
729 (define_insn "altivec_vmhaddshs"
730 [(set (match_operand:V8HI 0 "register_operand" "=v")
731 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
732 (match_operand:V8HI 2 "register_operand" "v")
733 (match_operand:V8HI 3 "register_operand" "v")]
735 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
737 "vmhaddshs %0,%1,%2,%3"
738 [(set_attr "type" "veccomplex")])
740 (define_insn "altivec_vmhraddshs"
741 [(set (match_operand:V8HI 0 "register_operand" "=v")
742 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
743 (match_operand:V8HI 2 "register_operand" "v")
744 (match_operand:V8HI 3 "register_operand" "v")]
746 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
748 "vmhraddshs %0,%1,%2,%3"
749 [(set_attr "type" "veccomplex")])
751 (define_insn "altivec_vmladduhm"
752 [(set (match_operand:V8HI 0 "register_operand" "=v")
753 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
754 (match_operand:V8HI 2 "register_operand" "v")
755 (match_operand:V8HI 3 "register_operand" "v")]
758 "vmladduhm %0,%1,%2,%3"
759 [(set_attr "type" "veccomplex")])
761 (define_insn "altivec_vmrghb"
762 [(set (match_operand:V16QI 0 "register_operand" "=v")
763 (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
764 (parallel [(const_int 0)
780 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
781 (parallel [(const_int 8)
800 [(set_attr "type" "vecperm")])
802 (define_insn "altivec_vmrghh"
803 [(set (match_operand:V8HI 0 "register_operand" "=v")
804 (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
805 (parallel [(const_int 0)
813 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
814 (parallel [(const_int 4)
825 [(set_attr "type" "vecperm")])
827 (define_insn "altivec_vmrghw"
828 [(set (match_operand:V4SI 0 "register_operand" "=v")
829 (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
830 (parallel [(const_int 0)
834 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
835 (parallel [(const_int 2)
842 [(set_attr "type" "vecperm")])
844 (define_insn "altivec_vmrglb"
845 [(set (match_operand:V16QI 0 "register_operand" "=v")
846 (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
847 (parallel [(const_int 8)
863 (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
864 (parallel [(const_int 0)
883 [(set_attr "type" "vecperm")])
885 (define_insn "altivec_vmrglh"
886 [(set (match_operand:V8HI 0 "register_operand" "=v")
887 (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
888 (parallel [(const_int 4)
896 (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
897 (parallel [(const_int 0)
908 [(set_attr "type" "vecperm")])
910 (define_insn "altivec_vmrglw"
911 [(set (match_operand:V4SI 0 "register_operand" "=v")
912 (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
913 (parallel [(const_int 2)
917 (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
918 (parallel [(const_int 0)
925 [(set_attr "type" "vecperm")])
927 (define_insn "altivec_vmuleub"
928 [(set (match_operand:V8HI 0 "register_operand" "=v")
929 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
930 (match_operand:V16QI 2 "register_operand" "v")]
934 [(set_attr "type" "veccomplex")])
936 (define_insn "altivec_vmulesb"
937 [(set (match_operand:V8HI 0 "register_operand" "=v")
938 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
939 (match_operand:V16QI 2 "register_operand" "v")]
943 [(set_attr "type" "veccomplex")])
945 (define_insn "altivec_vmuleuh"
946 [(set (match_operand:V4SI 0 "register_operand" "=v")
947 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
948 (match_operand:V8HI 2 "register_operand" "v")]
952 [(set_attr "type" "veccomplex")])
954 (define_insn "altivec_vmulesh"
955 [(set (match_operand:V4SI 0 "register_operand" "=v")
956 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
957 (match_operand:V8HI 2 "register_operand" "v")]
961 [(set_attr "type" "veccomplex")])
963 (define_insn "altivec_vmuloub"
964 [(set (match_operand:V8HI 0 "register_operand" "=v")
965 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
966 (match_operand:V16QI 2 "register_operand" "v")]
970 [(set_attr "type" "veccomplex")])
972 (define_insn "altivec_vmulosb"
973 [(set (match_operand:V8HI 0 "register_operand" "=v")
974 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
975 (match_operand:V16QI 2 "register_operand" "v")]
979 [(set_attr "type" "veccomplex")])
981 (define_insn "altivec_vmulouh"
982 [(set (match_operand:V4SI 0 "register_operand" "=v")
983 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
984 (match_operand:V8HI 2 "register_operand" "v")]
988 [(set_attr "type" "veccomplex")])
990 (define_insn "altivec_vmulosh"
991 [(set (match_operand:V4SI 0 "register_operand" "=v")
992 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
993 (match_operand:V8HI 2 "register_operand" "v")]
997 [(set_attr "type" "veccomplex")])
1002 (define_insn "and<mode>3"
1003 [(set (match_operand:VI 0 "register_operand" "=v")
1004 (and:VI (match_operand:VI 1 "register_operand" "v")
1005 (match_operand:VI 2 "register_operand" "v")))]
1008 [(set_attr "type" "vecsimple")])
1010 (define_insn "ior<mode>3"
1011 [(set (match_operand:VI 0 "register_operand" "=v")
1012 (ior:VI (match_operand:VI 1 "register_operand" "v")
1013 (match_operand:VI 2 "register_operand" "v")))]
1016 [(set_attr "type" "vecsimple")])
1018 (define_insn "xor<mode>3"
1019 [(set (match_operand:VI 0 "register_operand" "=v")
1020 (xor:VI (match_operand:VI 1 "register_operand" "v")
1021 (match_operand:VI 2 "register_operand" "v")))]
1024 [(set_attr "type" "vecsimple")])
1026 (define_insn "xorv4sf3"
1027 [(set (match_operand:V4SF 0 "register_operand" "=v")
1028 (xor:V4SF (match_operand:V4SF 1 "register_operand" "v")
1029 (match_operand:V4SF 2 "register_operand" "v")))]
1032 [(set_attr "type" "vecsimple")])
1034 (define_insn "one_cmpl<mode>2"
1035 [(set (match_operand:VI 0 "register_operand" "=v")
1036 (not:VI (match_operand:VI 1 "register_operand" "v")))]
1039 [(set_attr "type" "vecsimple")])
1041 (define_insn "altivec_nor<mode>3"
1042 [(set (match_operand:VI 0 "register_operand" "=v")
1043 (not:VI (ior:VI (match_operand:VI 1 "register_operand" "v")
1044 (match_operand:VI 2 "register_operand" "v"))))]
1047 [(set_attr "type" "vecsimple")])
1049 (define_insn "andc<mode>3"
1050 [(set (match_operand:VI 0 "register_operand" "=v")
1051 (and:VI (not:VI (match_operand:VI 2 "register_operand" "v"))
1052 (match_operand:VI 1 "register_operand" "v")))]
1055 [(set_attr "type" "vecsimple")])
1057 (define_insn "*andc3_v4sf"
1058 [(set (match_operand:V4SF 0 "register_operand" "=v")
1059 (and:V4SF (not:V4SF (match_operand:V4SF 2 "register_operand" "v"))
1060 (match_operand:V4SF 1 "register_operand" "v")))]
1063 [(set_attr "type" "vecsimple")])
1065 (define_insn "altivec_vpkuhum"
1066 [(set (match_operand:V16QI 0 "register_operand" "=v")
1067 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1068 (match_operand:V8HI 2 "register_operand" "v")]
1072 [(set_attr "type" "vecperm")])
1074 (define_insn "altivec_vpkuwum"
1075 [(set (match_operand:V8HI 0 "register_operand" "=v")
1076 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1077 (match_operand:V4SI 2 "register_operand" "v")]
1081 [(set_attr "type" "vecperm")])
1083 (define_insn "altivec_vpkpx"
1084 [(set (match_operand:V8HI 0 "register_operand" "=v")
1085 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1086 (match_operand:V4SI 2 "register_operand" "v")]
1090 [(set_attr "type" "vecperm")])
1092 (define_insn "altivec_vpkshss"
1093 [(set (match_operand:V16QI 0 "register_operand" "=v")
1094 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1095 (match_operand:V8HI 2 "register_operand" "v")]
1097 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1100 [(set_attr "type" "vecperm")])
1102 (define_insn "altivec_vpkswss"
1103 [(set (match_operand:V8HI 0 "register_operand" "=v")
1104 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1105 (match_operand:V4SI 2 "register_operand" "v")]
1107 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1110 [(set_attr "type" "vecperm")])
1112 (define_insn "altivec_vpkuhus"
1113 [(set (match_operand:V16QI 0 "register_operand" "=v")
1114 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1115 (match_operand:V8HI 2 "register_operand" "v")]
1117 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1120 [(set_attr "type" "vecperm")])
1122 (define_insn "altivec_vpkshus"
1123 [(set (match_operand:V16QI 0 "register_operand" "=v")
1124 (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
1125 (match_operand:V8HI 2 "register_operand" "v")]
1127 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1130 [(set_attr "type" "vecperm")])
1132 (define_insn "altivec_vpkuwus"
1133 [(set (match_operand:V8HI 0 "register_operand" "=v")
1134 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1135 (match_operand:V4SI 2 "register_operand" "v")]
1137 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1140 [(set_attr "type" "vecperm")])
1142 (define_insn "altivec_vpkswus"
1143 [(set (match_operand:V8HI 0 "register_operand" "=v")
1144 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1145 (match_operand:V4SI 2 "register_operand" "v")]
1147 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1150 [(set_attr "type" "vecperm")])
1152 (define_insn "altivec_vrl<VI_char>"
1153 [(set (match_operand:VI 0 "register_operand" "=v")
1154 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
1155 (match_operand:VI 2 "register_operand" "v")]
1158 "vrl<VI_char> %0,%1,%2"
1159 [(set_attr "type" "vecsimple")])
1161 (define_insn "altivec_vsl<VI_char>"
1162 [(set (match_operand:VI 0 "register_operand" "=v")
1163 (unspec:VI [(match_operand:VI 1 "register_operand" "v")
1164 (match_operand:VI 2 "register_operand" "v")]
1167 "vsl<VI_char> %0,%1,%2"
1168 [(set_attr "type" "vecsimple")])
1170 (define_insn "altivec_vsl"
1171 [(set (match_operand:V4SI 0 "register_operand" "=v")
1172 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1173 (match_operand:V4SI 2 "register_operand" "v")]
1177 [(set_attr "type" "vecperm")])
1179 (define_insn "altivec_vslo"
1180 [(set (match_operand:V4SI 0 "register_operand" "=v")
1181 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1182 (match_operand:V4SI 2 "register_operand" "v")]
1186 [(set_attr "type" "vecperm")])
1188 (define_insn "lshr<mode>3"
1189 [(set (match_operand:VI 0 "register_operand" "=v")
1190 (lshiftrt:VI (match_operand:VI 1 "register_operand" "v")
1191 (match_operand:VI 2 "register_operand" "v") ))]
1193 "vsr<VI_char> %0,%1,%2"
1194 [(set_attr "type" "vecsimple")])
1196 (define_insn "ashr<mode>3"
1197 [(set (match_operand:VI 0 "register_operand" "=v")
1198 (ashiftrt:VI (match_operand:VI 1 "register_operand" "v")
1199 (match_operand:VI 2 "register_operand" "v") ))]
1201 "vsra<VI_char> %0,%1,%2"
1202 [(set_attr "type" "vecsimple")])
1204 (define_insn "altivec_vsr"
1205 [(set (match_operand:V4SI 0 "register_operand" "=v")
1206 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1207 (match_operand:V4SI 2 "register_operand" "v")]
1211 [(set_attr "type" "vecperm")])
1213 (define_insn "altivec_vsro"
1214 [(set (match_operand:V4SI 0 "register_operand" "=v")
1215 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1216 (match_operand:V4SI 2 "register_operand" "v")]
1220 [(set_attr "type" "vecperm")])
1222 (define_insn "altivec_vsum4ubs"
1223 [(set (match_operand:V4SI 0 "register_operand" "=v")
1224 (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
1225 (match_operand:V4SI 2 "register_operand" "v")]
1227 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1230 [(set_attr "type" "veccomplex")])
1232 (define_insn "altivec_vsum4s<VI_char>s"
1233 [(set (match_operand:V4SI 0 "register_operand" "=v")
1234 (unspec:V4SI [(match_operand:VIshort 1 "register_operand" "v")
1235 (match_operand:V4SI 2 "register_operand" "v")]
1237 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1239 "vsum4s<VI_char>s %0,%1,%2"
1240 [(set_attr "type" "veccomplex")])
1242 (define_insn "altivec_vsum2sws"
1243 [(set (match_operand:V4SI 0 "register_operand" "=v")
1244 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1245 (match_operand:V4SI 2 "register_operand" "v")]
1247 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1250 [(set_attr "type" "veccomplex")])
1252 (define_insn "altivec_vsumsws"
1253 [(set (match_operand:V4SI 0 "register_operand" "=v")
1254 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1255 (match_operand:V4SI 2 "register_operand" "v")]
1257 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1260 [(set_attr "type" "veccomplex")])
1262 (define_insn "altivec_vspltb"
1263 [(set (match_operand:V16QI 0 "register_operand" "=v")
1264 (vec_duplicate:V16QI
1265 (vec_select:QI (match_operand:V16QI 1 "register_operand" "v")
1267 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1270 [(set_attr "type" "vecperm")])
1272 (define_insn "altivec_vsplth"
1273 [(set (match_operand:V8HI 0 "register_operand" "=v")
1275 (vec_select:HI (match_operand:V8HI 1 "register_operand" "v")
1277 [(match_operand:QI 2 "u5bit_cint_operand" "")]))))]
1280 [(set_attr "type" "vecperm")])
1282 (define_insn "altivec_vspltw"
1283 [(set (match_operand:V4SI 0 "register_operand" "=v")
1285 (vec_select:SI (match_operand:V4SI 1 "register_operand" "v")
1287 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1290 [(set_attr "type" "vecperm")])
1292 (define_insn "*altivec_vspltsf"
1293 [(set (match_operand:V4SF 0 "register_operand" "=v")
1295 (vec_select:SF (match_operand:V4SF 1 "register_operand" "v")
1297 [(match_operand:QI 2 "u5bit_cint_operand" "i")]))))]
1300 [(set_attr "type" "vecperm")])
1302 (define_insn "altivec_vspltis<VI_char>"
1303 [(set (match_operand:VI 0 "register_operand" "=v")
1305 (match_operand:QI 1 "s5bit_cint_operand" "i")))]
1307 "vspltis<VI_char> %0,%1"
1308 [(set_attr "type" "vecperm")])
1310 (define_insn "ftruncv4sf2"
1311 [(set (match_operand:V4SF 0 "register_operand" "=v")
1312 (fix:V4SF (match_operand:V4SF 1 "register_operand" "v")))]
1315 [(set_attr "type" "vecfloat")])
1317 (define_insn "altivec_vperm_<mode>"
1318 [(set (match_operand:V 0 "register_operand" "=v")
1319 (unspec:V [(match_operand:V 1 "register_operand" "v")
1320 (match_operand:V 2 "register_operand" "v")
1321 (match_operand:V16QI 3 "register_operand" "v")]
1325 [(set_attr "type" "vecperm")])
1327 (define_insn "altivec_vrfip"
1328 [(set (match_operand:V4SF 0 "register_operand" "=v")
1329 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1333 [(set_attr "type" "vecfloat")])
1335 (define_insn "altivec_vrfin"
1336 [(set (match_operand:V4SF 0 "register_operand" "=v")
1337 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1341 [(set_attr "type" "vecfloat")])
1343 (define_insn "altivec_vrfim"
1344 [(set (match_operand:V4SF 0 "register_operand" "=v")
1345 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1349 [(set_attr "type" "vecfloat")])
1351 (define_insn "altivec_vcfux"
1352 [(set (match_operand:V4SF 0 "register_operand" "=v")
1353 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1354 (match_operand:QI 2 "immediate_operand" "i")]
1358 [(set_attr "type" "vecfloat")])
1360 (define_insn "altivec_vcfsx"
1361 [(set (match_operand:V4SF 0 "register_operand" "=v")
1362 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1363 (match_operand:QI 2 "immediate_operand" "i")]
1367 [(set_attr "type" "vecfloat")])
1369 (define_insn "altivec_vctuxs"
1370 [(set (match_operand:V4SI 0 "register_operand" "=v")
1371 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1372 (match_operand:QI 2 "immediate_operand" "i")]
1374 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1377 [(set_attr "type" "vecfloat")])
1379 (define_insn "altivec_vctsxs"
1380 [(set (match_operand:V4SI 0 "register_operand" "=v")
1381 (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
1382 (match_operand:QI 2 "immediate_operand" "i")]
1384 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
1387 [(set_attr "type" "vecfloat")])
1389 (define_insn "altivec_vlogefp"
1390 [(set (match_operand:V4SF 0 "register_operand" "=v")
1391 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1395 [(set_attr "type" "vecfloat")])
1397 (define_insn "altivec_vexptefp"
1398 [(set (match_operand:V4SF 0 "register_operand" "=v")
1399 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1403 [(set_attr "type" "vecfloat")])
1405 (define_insn "altivec_vrsqrtefp"
1406 [(set (match_operand:V4SF 0 "register_operand" "=v")
1407 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1411 [(set_attr "type" "vecfloat")])
1413 (define_insn "altivec_vrefp"
1414 [(set (match_operand:V4SF 0 "register_operand" "=v")
1415 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
1419 [(set_attr "type" "vecfloat")])
1421 (define_expand "vcondv4si"
1422 [(set (match_operand:V4SI 0 "register_operand" "=v")
1423 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1424 (match_operand:V4SI 2 "register_operand" "v")
1425 (match_operand:V4SI 3 "comparison_operator" "")
1426 (match_operand:V4SI 4 "register_operand" "v")
1427 (match_operand:V4SI 5 "register_operand" "v")
1428 ] UNSPEC_VCOND_V4SI))]
1432 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1433 operands[3], operands[4], operands[5]))
1440 (define_expand "vconduv4si"
1441 [(set (match_operand:V4SI 0 "register_operand" "=v")
1442 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1443 (match_operand:V4SI 2 "register_operand" "v")
1444 (match_operand:V4SI 3 "comparison_operator" "")
1445 (match_operand:V4SI 4 "register_operand" "v")
1446 (match_operand:V4SI 5 "register_operand" "v")
1447 ] UNSPEC_VCONDU_V4SI))]
1451 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1452 operands[3], operands[4], operands[5]))
1459 (define_expand "vcondv4sf"
1460 [(set (match_operand:V4SF 0 "register_operand" "=v")
1461 (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
1462 (match_operand:V4SF 2 "register_operand" "v")
1463 (match_operand:V4SF 3 "comparison_operator" "")
1464 (match_operand:V4SF 4 "register_operand" "v")
1465 (match_operand:V4SF 5 "register_operand" "v")
1466 ] UNSPEC_VCOND_V4SF))]
1470 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1471 operands[3], operands[4], operands[5]))
1478 (define_expand "vcondv8hi"
1479 [(set (match_operand:V4SF 0 "register_operand" "=v")
1480 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1481 (match_operand:V8HI 2 "register_operand" "v")
1482 (match_operand:V8HI 3 "comparison_operator" "")
1483 (match_operand:V8HI 4 "register_operand" "v")
1484 (match_operand:V8HI 5 "register_operand" "v")
1485 ] UNSPEC_VCOND_V8HI))]
1489 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1490 operands[3], operands[4], operands[5]))
1497 (define_expand "vconduv8hi"
1498 [(set (match_operand:V4SF 0 "register_operand" "=v")
1499 (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
1500 (match_operand:V8HI 2 "register_operand" "v")
1501 (match_operand:V8HI 3 "comparison_operator" "")
1502 (match_operand:V8HI 4 "register_operand" "v")
1503 (match_operand:V8HI 5 "register_operand" "v")
1504 ] UNSPEC_VCONDU_V8HI))]
1508 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1509 operands[3], operands[4], operands[5]))
1516 (define_expand "vcondv16qi"
1517 [(set (match_operand:V4SF 0 "register_operand" "=v")
1518 (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")
1519 (match_operand:V16QI 2 "register_operand" "v")
1520 (match_operand:V16QI 3 "comparison_operator" "")
1521 (match_operand:V16QI 4 "register_operand" "v")
1522 (match_operand:V16QI 5 "register_operand" "v")
1523 ] UNSPEC_VCOND_V16QI))]
1527 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1528 operands[3], operands[4], operands[5]))
1535 (define_expand "vconduv16qi"
1536 [(set (match_operand:V4SF 0 "register_operand" "=v")
1537 (unspec:V16QI [(match_operand:V4SI 1 "register_operand" "v")
1538 (match_operand:V16QI 2 "register_operand" "v")
1539 (match_operand:V16QI 3 "comparison_operator" "")
1540 (match_operand:V16QI 4 "register_operand" "v")
1541 (match_operand:V16QI 5 "register_operand" "v")
1542 ] UNSPEC_VCONDU_V16QI))]
1546 if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
1547 operands[3], operands[4], operands[5]))
1555 (define_insn "altivec_vsel_v4si"
1556 [(set (match_operand:V4SI 0 "register_operand" "=v")
1557 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
1558 (match_operand:V4SI 2 "register_operand" "v")
1559 (match_operand:V4SI 3 "register_operand" "v")]
1563 [(set_attr "type" "vecperm")])
1565 (define_insn "altivec_vsel_v4sf"
1566 [(set (match_operand:V4SF 0 "register_operand" "=v")
1567 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
1568 (match_operand:V4SF 2 "register_operand" "v")
1569 (match_operand:V4SI 3 "register_operand" "v")]
1573 [(set_attr "type" "vecperm")])
1575 (define_insn "altivec_vsel_v8hi"
1576 [(set (match_operand:V8HI 0 "register_operand" "=v")
1577 (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
1578 (match_operand:V8HI 2 "register_operand" "v")
1579 (match_operand:V8HI 3 "register_operand" "v")]
1583 [(set_attr "type" "vecperm")])
1585 (define_insn "altivec_vsel_v16qi"
1586 [(set (match_operand:V16QI 0 "register_operand" "=v")
1587 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
1588 (match_operand:V16QI 2 "register_operand" "v")
1589 (match_operand:V16QI 3 "register_operand" "v")]
1593 [(set_attr "type" "vecperm")])
1595 (define_insn "altivec_vsldoi_<mode>"
1596 [(set (match_operand:V 0 "register_operand" "=v")
1597 (unspec:V [(match_operand:V 1 "register_operand" "v")
1598 (match_operand:V 2 "register_operand" "v")
1599 (match_operand:QI 3 "immediate_operand" "i")]
1602 "vsldoi %0,%1,%2,%3"
1603 [(set_attr "type" "vecperm")])
1605 (define_insn "altivec_vupkhsb"
1606 [(set (match_operand:V8HI 0 "register_operand" "=v")
1607 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1611 [(set_attr "type" "vecperm")])
1613 (define_insn "altivec_vupkhpx"
1614 [(set (match_operand:V4SI 0 "register_operand" "=v")
1615 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1619 [(set_attr "type" "vecperm")])
1621 (define_insn "altivec_vupkhsh"
1622 [(set (match_operand:V4SI 0 "register_operand" "=v")
1623 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1627 [(set_attr "type" "vecperm")])
1629 (define_insn "altivec_vupklsb"
1630 [(set (match_operand:V8HI 0 "register_operand" "=v")
1631 (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")]
1635 [(set_attr "type" "vecperm")])
1637 (define_insn "altivec_vupklpx"
1638 [(set (match_operand:V4SI 0 "register_operand" "=v")
1639 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1643 [(set_attr "type" "vecperm")])
1645 (define_insn "altivec_vupklsh"
1646 [(set (match_operand:V4SI 0 "register_operand" "=v")
1647 (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")]
1651 [(set_attr "type" "vecperm")])
1653 ;; AltiVec predicates.
1655 (define_expand "cr6_test_for_zero"
1656 [(set (match_operand:SI 0 "register_operand" "=r")
1662 (define_expand "cr6_test_for_zero_reverse"
1663 [(set (match_operand:SI 0 "register_operand" "=r")
1666 (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
1670 (define_expand "cr6_test_for_lt"
1671 [(set (match_operand:SI 0 "register_operand" "=r")
1677 (define_expand "cr6_test_for_lt_reverse"
1678 [(set (match_operand:SI 0 "register_operand" "=r")
1681 (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
1685 ;; We can get away with generating the opcode on the fly (%3 below)
1686 ;; because all the predicates have the same scheduling parameters.
1688 (define_insn "altivec_predicate_<mode>"
1690 (unspec:CC [(match_operand:V 1 "register_operand" "v")
1691 (match_operand:V 2 "register_operand" "v")
1692 (match_operand 3 "any_operand" "")] UNSPEC_PREDICATE))
1693 (clobber (match_scratch:V 0 "=v"))]
1696 [(set_attr "type" "veccmp")])
1698 (define_insn "altivec_mtvscr"
1701 [(match_operand:V4SI 0 "register_operand" "v")] UNSPECV_MTVSCR))]
1704 [(set_attr "type" "vecsimple")])
1706 (define_insn "altivec_mfvscr"
1707 [(set (match_operand:V8HI 0 "register_operand" "=v")
1708 (unspec_volatile:V8HI [(reg:SI 110)] UNSPECV_MFVSCR))]
1711 [(set_attr "type" "vecsimple")])
1713 (define_insn "altivec_dssall"
1714 [(unspec_volatile [(const_int 0)] UNSPECV_DSSALL)]
1717 [(set_attr "type" "vecsimple")])
1719 (define_insn "altivec_dss"
1720 [(unspec_volatile [(match_operand:QI 0 "immediate_operand" "i")]
1724 [(set_attr "type" "vecsimple")])
1726 (define_insn "altivec_dst"
1727 [(unspec [(match_operand 0 "register_operand" "b")
1728 (match_operand:SI 1 "register_operand" "r")
1729 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DST)]
1730 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1732 [(set_attr "type" "vecsimple")])
1734 (define_insn "altivec_dstt"
1735 [(unspec [(match_operand 0 "register_operand" "b")
1736 (match_operand:SI 1 "register_operand" "r")
1737 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTT)]
1738 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1740 [(set_attr "type" "vecsimple")])
1742 (define_insn "altivec_dstst"
1743 [(unspec [(match_operand 0 "register_operand" "b")
1744 (match_operand:SI 1 "register_operand" "r")
1745 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTST)]
1746 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1748 [(set_attr "type" "vecsimple")])
1750 (define_insn "altivec_dststt"
1751 [(unspec [(match_operand 0 "register_operand" "b")
1752 (match_operand:SI 1 "register_operand" "r")
1753 (match_operand:QI 2 "immediate_operand" "i")] UNSPEC_DSTSTT)]
1754 "TARGET_ALTIVEC && GET_MODE (operands[0]) == Pmode"
1756 [(set_attr "type" "vecsimple")])
1758 (define_insn "altivec_lvsl"
1759 [(set (match_operand:V16QI 0 "register_operand" "=v")
1760 (unspec:V16QI [(match_operand 1 "memory_operand" "Z")] UNSPEC_LVSL))]
1763 [(set_attr "type" "vecload")])
1765 (define_insn "altivec_lvsr"
1766 [(set (match_operand:V16QI 0 "register_operand" "=v")
1767 (unspec:V16QI [(match_operand 1 "memory_operand" "Z")] UNSPEC_LVSR))]
1770 [(set_attr "type" "vecload")])
1772 (define_expand "build_vector_mask_for_load"
1773 [(set (match_operand:V16QI 0 "register_operand" "")
1774 (unspec:V16QI [(match_operand 1 "memory_operand" "")] UNSPEC_LVSR))]
1781 gcc_assert (GET_CODE (operands[1]) == MEM);
1783 addr = XEXP (operands[1], 0);
1784 temp = gen_reg_rtx (GET_MODE (addr));
1785 emit_insn (gen_rtx_SET (VOIDmode, temp,
1786 gen_rtx_NEG (GET_MODE (addr), addr)));
1787 emit_insn (gen_altivec_lvsr (operands[0],
1788 replace_equiv_address (operands[1], temp)));
1792 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
1793 ;; identical rtl but different instructions-- and gcc gets confused.
1795 (define_insn "altivec_lve<VI_char>x"
1797 [(set (match_operand:VI 0 "register_operand" "=v")
1798 (match_operand:VI 1 "memory_operand" "Z"))
1799 (unspec [(const_int 0)] UNSPEC_LVE)])]
1801 "lve<VI_char>x %0,%y1"
1802 [(set_attr "type" "vecload")])
1804 (define_insn "*altivec_lvesfx"
1806 [(set (match_operand:V4SF 0 "register_operand" "=v")
1807 (match_operand:V4SF 1 "memory_operand" "Z"))
1808 (unspec [(const_int 0)] UNSPEC_LVE)])]
1811 [(set_attr "type" "vecload")])
1813 (define_insn "altivec_lvxl"
1815 [(set (match_operand:V4SI 0 "register_operand" "=v")
1816 (match_operand:V4SI 1 "memory_operand" "Z"))
1817 (unspec [(const_int 0)] UNSPEC_SET_VSCR)])]
1820 [(set_attr "type" "vecload")])
1822 (define_insn "altivec_lvx"
1823 [(set (match_operand:V4SI 0 "register_operand" "=v")
1824 (match_operand:V4SI 1 "memory_operand" "Z"))]
1827 [(set_attr "type" "vecload")])
1829 (define_insn "altivec_stvx"
1831 [(set (match_operand:V4SI 0 "memory_operand" "=Z")
1832 (match_operand:V4SI 1 "register_operand" "v"))
1833 (unspec [(const_int 0)] UNSPEC_STVX)])]
1836 [(set_attr "type" "vecstore")])
1838 (define_insn "altivec_stvxl"
1840 [(set (match_operand:V4SI 0 "memory_operand" "=Z")
1841 (match_operand:V4SI 1 "register_operand" "v"))
1842 (unspec [(const_int 0)] UNSPEC_STVXL)])]
1845 [(set_attr "type" "vecstore")])
1847 (define_insn "altivec_stve<VI_char>x"
1849 [(set (match_operand:VI 0 "memory_operand" "=Z")
1850 (match_operand:VI 1 "register_operand" "v"))
1851 (unspec [(const_int 0)] UNSPEC_STVE)])]
1853 "stve<VI_char>x %1,%y0"
1854 [(set_attr "type" "vecstore")])
1856 (define_insn "*altivec_stvesfx"
1858 [(set (match_operand:V4SF 0 "memory_operand" "=Z")
1859 (match_operand:V4SF 1 "register_operand" "v"))
1860 (unspec [(const_int 0)] UNSPEC_STVE)])]
1863 [(set_attr "type" "vecstore")])
1865 (define_expand "vec_init<mode>"
1866 [(match_operand:V 0 "register_operand" "")
1867 (match_operand 1 "" "")]
1870 rs6000_expand_vector_init (operands[0], operands[1]);
1874 (define_expand "vec_setv4si"
1875 [(match_operand:V4SI 0 "register_operand" "")
1876 (match_operand:SI 1 "register_operand" "")
1877 (match_operand 2 "const_int_operand" "")]
1880 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1884 (define_expand "vec_setv8hi"
1885 [(match_operand:V8HI 0 "register_operand" "")
1886 (match_operand:HI 1 "register_operand" "")
1887 (match_operand 2 "const_int_operand" "")]
1890 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1894 (define_expand "vec_setv16qi"
1895 [(match_operand:V16QI 0 "register_operand" "")
1896 (match_operand:QI 1 "register_operand" "")
1897 (match_operand 2 "const_int_operand" "")]
1900 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1904 (define_expand "vec_setv4sf"
1905 [(match_operand:V4SF 0 "register_operand" "")
1906 (match_operand:SF 1 "register_operand" "")
1907 (match_operand 2 "const_int_operand" "")]
1910 rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
1914 (define_expand "vec_extractv4si"
1915 [(match_operand:SI 0 "register_operand" "")
1916 (match_operand:V4SI 1 "register_operand" "")
1917 (match_operand 2 "const_int_operand" "")]
1920 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1924 (define_expand "vec_extractv8hi"
1925 [(match_operand:HI 0 "register_operand" "")
1926 (match_operand:V8HI 1 "register_operand" "")
1927 (match_operand 2 "const_int_operand" "")]
1930 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1934 (define_expand "vec_extractv16qi"
1935 [(match_operand:QI 0 "register_operand" "")
1936 (match_operand:V16QI 1 "register_operand" "")
1937 (match_operand 2 "const_int_operand" "")]
1940 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1944 (define_expand "vec_extractv4sf"
1945 [(match_operand:SF 0 "register_operand" "")
1946 (match_operand:V4SF 1 "register_operand" "")
1947 (match_operand 2 "const_int_operand" "")]
1950 rs6000_expand_vector_extract (operands[0], operands[1], INTVAL (operands[2]));
1955 ;; vspltis? SCRATCH0,0
1956 ;; vsubu?m SCRATCH2,SCRATCH1,%1
1957 ;; vmaxs? %0,%1,SCRATCH2"
1958 (define_expand "abs<mode>2"
1959 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
1961 (minus:VI (match_dup 2)
1962 (match_operand:VI 1 "register_operand" "v")))
1963 (set (match_operand:VI 0 "register_operand" "=v")
1964 (smax:VI (match_dup 1) (match_dup 3)))]
1967 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
1968 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
1972 ;; vspltisw SCRATCH1,-1
1973 ;; vslw SCRATCH2,SCRATCH1,SCRATCH1
1974 ;; vandc %0,%1,SCRATCH2
1975 (define_expand "absv4sf2"
1977 (vec_duplicate:V4SI (const_int -1)))
1979 (unspec:V4SI [(match_dup 2) (match_dup 2)] UNSPEC_VSL))
1980 (set (match_operand:V4SF 0 "register_operand" "=v")
1981 (and:V4SF (not:V4SF (subreg:V4SF (match_dup 3) 0))
1982 (match_operand:V4SF 1 "register_operand" "v")))]
1985 operands[2] = gen_reg_rtx (V4SImode);
1986 operands[3] = gen_reg_rtx (V4SImode);
1990 ;; vspltis? SCRATCH0,0
1991 ;; vsubs?s SCRATCH2,SCRATCH1,%1
1992 ;; vmaxs? %0,%1,SCRATCH2"
1993 (define_expand "altivec_abss_<mode>"
1994 [(set (match_dup 2) (vec_duplicate:VI (const_int 0)))
1995 (parallel [(set (match_dup 3)
1996 (unspec:VI [(match_dup 2)
1997 (match_operand:VI 1 "register_operand" "v")]
1999 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))])
2000 (set (match_operand:VI 0 "register_operand" "=v")
2001 (smax:VI (match_dup 1) (match_dup 3)))]
2004 operands[2] = gen_reg_rtx (GET_MODE (operands[0]));
2005 operands[3] = gen_reg_rtx (GET_MODE (operands[0]));
2008 ;; Vector shift left in bits. Currently supported ony for shift
2009 ;; amounts that can be expressed as byte shifts (divisible by 8).
2010 ;; General shift amounts can be supported using vslo + vsl. We're
2011 ;; not expecting to see these yet (the vectorizer currently
2012 ;; generates only shifts divisible by byte_size).
2013 (define_expand "vec_shl_<mode>"
2014 [(set (match_operand:V 0 "register_operand" "=v")
2015 (unspec:V [(match_operand:V 1 "register_operand" "v")
2016 (match_operand:QI 2 "reg_or_short_operand" "")]
2021 rtx bitshift = operands[2];
2022 rtx byteshift = gen_reg_rtx (QImode);
2023 HOST_WIDE_INT bitshift_val;
2024 HOST_WIDE_INT byteshift_val;
2026 if (! CONSTANT_P (bitshift))
2028 bitshift_val = INTVAL (bitshift);
2029 if (bitshift_val & 0x7)
2031 byteshift_val = bitshift_val >> 3;
2032 byteshift = gen_rtx_CONST_INT (QImode, byteshift_val);
2033 emit_insn (gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
2038 ;; Vector shift left in bits. Currently supported ony for shift
2039 ;; amounts that can be expressed as byte shifts (divisible by 8).
2040 ;; General shift amounts can be supported using vsro + vsr. We're
2041 ;; not expecting to see these yet (the vectorizer currently
2042 ;; generates only shifts divisible by byte_size).
2043 (define_expand "vec_shr_<mode>"
2044 [(set (match_operand:V 0 "register_operand" "=v")
2045 (unspec:V [(match_operand:V 1 "register_operand" "v")
2046 (match_operand:QI 2 "reg_or_short_operand" "")]
2051 rtx bitshift = operands[2];
2052 rtx byteshift = gen_reg_rtx (QImode);
2053 HOST_WIDE_INT bitshift_val;
2054 HOST_WIDE_INT byteshift_val;
2056 if (! CONSTANT_P (bitshift))
2058 bitshift_val = INTVAL (bitshift);
2059 if (bitshift_val & 0x7)
2061 byteshift_val = 16 - (bitshift_val >> 3);
2062 byteshift = gen_rtx_CONST_INT (QImode, byteshift_val);
2063 emit_insn (gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
2068 (define_insn "altivec_vsumsws_nomode"
2069 [(set (match_operand 0 "register_operand" "=v")
2070 (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
2071 (match_operand:V4SI 2 "register_operand" "v")]
2073 (set (reg:SI 110) (unspec:SI [(const_int 0)] UNSPEC_SET_VSCR))]
2076 [(set_attr "type" "veccomplex")])
2078 (define_expand "reduc_splus_<mode>"
2079 [(set (match_operand:VIshort 0 "register_operand" "=v")
2080 (unspec:VIshort [(match_operand:VIshort 1 "register_operand" "v")]
2081 UNSPEC_REDUC_PLUS))]
2085 rtx vzero = gen_reg_rtx (V4SImode);
2086 rtx vtmp1 = gen_reg_rtx (V4SImode);
2088 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2089 emit_insn (gen_altivec_vsum4s<VI_char>s (vtmp1, operands[1], vzero));
2090 emit_insn (gen_altivec_vsumsws_nomode (operands[0], vtmp1, vzero));
2094 (define_expand "reduc_uplus_v16qi"
2095 [(set (match_operand:V16QI 0 "register_operand" "=v")
2096 (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")]
2097 UNSPEC_REDUC_PLUS))]
2101 rtx vzero = gen_reg_rtx (V4SImode);
2102 rtx vtmp1 = gen_reg_rtx (V4SImode);
2104 emit_insn (gen_altivec_vspltisw (vzero, const0_rtx));
2105 emit_insn (gen_altivec_vsum4ubs (vtmp1, operands[1], vzero));
2106 emit_insn (gen_altivec_vsumsws_nomode (operands[0], vtmp1, vzero));
2110 (define_insn "vec_realign_load_<mode>"
2111 [(set (match_operand:V 0 "register_operand" "=v")
2112 (unspec:V [(match_operand:V 1 "register_operand" "v")
2113 (match_operand:V 2 "register_operand" "v")
2114 (match_operand:V16QI 3 "register_operand" "v")]
2115 UNSPEC_REALIGN_LOAD))]
2118 [(set_attr "type" "vecperm")])
2120 (define_expand "neg<mode>2"
2121 [(use (match_operand:VI 0 "register_operand" ""))
2122 (use (match_operand:VI 1 "register_operand" ""))]
2128 vzero = gen_reg_rtx (GET_MODE (operands[0]));
2129 emit_insn (gen_altivec_vspltis<VI_char> (vzero, const0_rtx));
2130 emit_insn (gen_sub<mode>3 (operands[0], vzero, operands[1]));
2135 (define_expand "negv4sf2"
2136 [(use (match_operand:V4SF 0 "register_operand" ""))
2137 (use (match_operand:V4SF 1 "register_operand" ""))]
2143 /* Generate [-0.0, -0.0, -0.0, -0.0]. */
2144 neg0 = gen_reg_rtx (V4SImode);
2145 emit_insn (gen_altivec_vspltisw (neg0, constm1_rtx));
2146 emit_insn (gen_altivec_vslw (neg0, neg0, neg0));
2149 emit_insn (gen_xorv4sf3 (operands[0],
2150 gen_lowpart (V4SFmode, neg0), operands[1]));