OSDN Git Service

libitm: Remove unused code.
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / vect.md
1 ;; IA-64 machine description for vector operations.
2 ;; Copyright (C) 2004, 2005, 2007, 2010 Free Software Foundation, Inc.
3 ;;
4 ;; This file is part of GCC.
5 ;;
6 ;; GCC is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published by
8 ;; the Free Software Foundation; either version 3, or (at your option)
9 ;; any later version.
10 ;;
11 ;; GCC is distributed in the hope that it will be useful,
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 ;; GNU General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with GCC; see the file COPYING3.  If not see
18 ;; <http://www.gnu.org/licenses/>.
19
20
21 ;; Integer vector operations
22
23 (define_mode_iterator VECINT [V8QI V4HI V2SI])
24 (define_mode_iterator VECINT12 [V8QI V4HI])
25 (define_mode_iterator VECINT24 [V4HI V2SI])
26 (define_mode_attr vecsize [(V8QI "1") (V4HI "2") (V2SI "4")])
27 (define_mode_attr vecwider [(V8QI "V4HI") (V4HI "V2SI")])
28
29 (define_expand "mov<mode>"
30   [(set (match_operand:VECINT 0 "general_operand" "")
31         (match_operand:VECINT 1 "general_operand" ""))]
32   ""
33 {
34   rtx op1 = ia64_expand_move (operands[0], operands[1]);
35   if (!op1)
36     DONE;
37   operands[1] = op1;
38 })
39
40 (define_insn "*mov<mode>_internal"
41   [(set (match_operand:VECINT 0 "destination_operand"
42                                         "=r,r,r,r,m ,*f ,*f,Q ,r ,*f")
43         (match_operand:VECINT 1 "move_operand"
44                                         "rU,W,i,m,rU,U*f,Q ,*f,*f,r "))]
45   "ia64_move_ok (operands[0], operands[1])"
46   "@
47    mov %0 = %r1
48    addl %0 = %v1, r0
49    movl %0 = %v1
50    ld8%O1 %0 = %1%P1
51    st8%Q0 %0 = %r1%P0
52    mov %0 = %F1
53    ldf8 %0 = %1%P1
54    stf8 %0 = %1%P0
55    getf.sig %0 = %1
56    setf.sig %0 = %1"
57   [(set_attr "itanium_class" "ialu,ialu,long_i,ld,st,fmisc,fld,stf,frfr,tofr")])
58
59 (define_insn "one_cmpl<mode>2"
60   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
61         (not:VECINT (match_operand:VECINT 1 "gr_register_operand" "r")))]
62   ""
63   "andcm %0 = -1, %1"
64   [(set_attr "itanium_class" "ilog")])
65
66 (define_insn "and<mode>3"
67   [(set (match_operand:VECINT 0 "grfr_register_operand" "=r,*f")
68         (and:VECINT
69           (match_operand:VECINT 1 "grfr_register_operand" "r,*f")
70           (match_operand:VECINT 2 "grfr_reg_or_8bit_operand" "r,*f")))]
71   ""
72   "@
73    and %0 = %2, %1
74    fand %0 = %2, %1"
75   [(set_attr "itanium_class" "ilog,fmisc")])
76
77 (define_insn "*andnot<mode>"
78   [(set (match_operand:VECINT 0 "grfr_register_operand" "=r,*f")
79         (and:VECINT
80           (not:VECINT (match_operand:VECINT 1 "grfr_register_operand" "r,*f"))
81           (match_operand:VECINT 2 "grfr_reg_or_8bit_operand" "r,*f")))]
82   ""
83   "@
84    andcm %0 = %2, %1
85    fandcm %0 = %2, %1"
86   [(set_attr "itanium_class" "ilog,fmisc")])
87
88 (define_insn "ior<mode>3"
89   [(set (match_operand:VECINT 0 "grfr_register_operand" "=r,*f")
90         (ior:VECINT
91           (match_operand:VECINT 1 "grfr_register_operand" "r,*f")
92           (match_operand:VECINT 2 "grfr_reg_or_8bit_operand" "r,*f")))]
93   ""
94   "@
95    or %0 = %2, %1
96    for %0 = %2, %1"
97   [(set_attr "itanium_class" "ilog,fmisc")])
98
99 (define_insn "xor<mode>3"
100   [(set (match_operand:VECINT 0 "grfr_register_operand" "=r,*f")
101         (xor:VECINT
102           (match_operand:VECINT 1 "grfr_register_operand" "r,*f")
103           (match_operand:VECINT 2 "grfr_reg_or_8bit_operand" "r,*f")))]
104   ""
105   "@
106    xor %0 = %2, %1
107    fxor %0 = %2, %1"
108   [(set_attr "itanium_class" "ilog,fmisc")])
109
110 (define_insn "neg<mode>2"
111   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
112         (neg:VECINT (match_operand:VECINT 1 "gr_register_operand" "r")))]
113   ""
114   "psub<vecsize> %0 = r0, %1"
115   [(set_attr "itanium_class" "mmalua")])
116
117 (define_insn "add<mode>3"
118   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
119         (plus:VECINT (match_operand:VECINT 1 "gr_register_operand" "r")
120                      (match_operand:VECINT 2 "gr_register_operand" "r")))]
121   ""
122   "padd<vecsize> %0 = %1, %2"
123   [(set_attr "itanium_class" "mmalua")])
124
125 (define_insn "*ssadd<mode>3"
126   [(set (match_operand:VECINT12 0 "gr_register_operand" "=r")
127         (ss_plus:VECINT12
128           (match_operand:VECINT12 1 "gr_register_operand" "r")
129           (match_operand:VECINT12 2 "gr_register_operand" "r")))]
130   ""
131   "padd<vecsize>.sss %0 = %1, %2"
132   [(set_attr "itanium_class" "mmalua")])
133
134 (define_insn "*usadd<mode>3"
135   [(set (match_operand:VECINT12 0 "gr_register_operand" "=r")
136         (us_plus:VECINT12
137           (match_operand:VECINT12 1 "gr_register_operand" "r")
138           (match_operand:VECINT12 2 "gr_register_operand" "r")))]
139   ""
140   "padd<vecsize>.uuu %0 = %1, %2"
141   [(set_attr "itanium_class" "mmalua")])
142
143 (define_insn "sub<mode>3"
144   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
145         (minus:VECINT (match_operand:VECINT 1 "gr_register_operand" "r")
146                       (match_operand:VECINT 2 "gr_register_operand" "r")))]
147   ""
148   "psub<vecsize> %0 = %1, %2"
149   [(set_attr "itanium_class" "mmalua")])
150
151 (define_insn "*sssub<mode>3"
152   [(set (match_operand:VECINT12 0 "gr_register_operand" "=r")
153         (ss_minus:VECINT12
154           (match_operand:VECINT12 1 "gr_register_operand" "r")
155           (match_operand:VECINT12 2 "gr_register_operand" "r")))]
156   ""
157   "psub<vecsize>.sss %0 = %1, %2"
158   [(set_attr "itanium_class" "mmalua")])
159
160 (define_insn "*ussub<mode>3"
161   [(set (match_operand:VECINT12 0 "gr_register_operand" "=r")
162         (us_minus:VECINT12
163           (match_operand:VECINT12 1 "gr_register_operand" "r")
164           (match_operand:VECINT12 2 "gr_register_operand" "r")))]
165   ""
166   "psub<vecsize>.uuu %0 = %1, %2"
167   [(set_attr "itanium_class" "mmalua")])
168
169 (define_expand "mulv8qi3"
170   [(set (match_operand:V8QI 0 "gr_register_operand" "")
171         (mult:V8QI (match_operand:V8QI 1 "gr_register_operand" "r")
172                    (match_operand:V8QI 2 "gr_register_operand" "r")))]
173   ""
174 {
175   rtx l = gen_reg_rtx (V4HImode);
176   rtx h = gen_reg_rtx (V4HImode);
177   emit_insn (gen_vec_widen_umult_lo_v8qi (l, operands[1], operands[2]));
178   emit_insn (gen_vec_widen_umult_hi_v8qi (h, operands[1], operands[2]));
179   if (TARGET_BIG_ENDIAN)
180     emit_insn (gen_vec_pack_trunc_v4hi (operands[0], h, l));
181   else
182     emit_insn (gen_vec_pack_trunc_v4hi (operands[0], l, h));
183   DONE;
184 })
185
186 (define_expand "vec_widen_umult_lo_v8qi"
187   [(match_operand:V4HI 0 "gr_register_operand" "")
188    (match_operand:V8QI 1 "gr_register_operand" "")
189    (match_operand:V8QI 2 "gr_register_operand" "")]
190   ""
191 {
192   rtx op1 = gen_reg_rtx (V4HImode);
193   rtx op2 = gen_reg_rtx (V4HImode);
194   emit_insn (gen_vec_unpacku_lo_v8qi (op1, operands[1]));
195   emit_insn (gen_vec_unpacku_lo_v8qi (op2, operands[2]));
196   emit_insn (gen_mulv4hi3 (operands[0], op1, op2));
197   DONE;
198 });
199   
200 (define_expand "vec_widen_umult_hi_v8qi"
201   [(match_operand:V4HI 0 "gr_register_operand" "")
202    (match_operand:V8QI 1 "gr_register_operand" "")
203    (match_operand:V8QI 2 "gr_register_operand" "")]
204   ""
205 {
206   rtx op1 = gen_reg_rtx (V4HImode);
207   rtx op2 = gen_reg_rtx (V4HImode);
208   emit_insn (gen_vec_unpacku_hi_v8qi (op1, operands[1]));
209   emit_insn (gen_vec_unpacku_hi_v8qi (op2, operands[2]));
210   emit_insn (gen_mulv4hi3 (operands[0], op1, op2));
211   DONE;
212 });
213   
214 (define_expand "vec_widen_smult_lo_v8qi"
215   [(match_operand:V4HI 0 "gr_register_operand" "")
216    (match_operand:V8QI 1 "gr_register_operand" "")
217    (match_operand:V8QI 2 "gr_register_operand" "")]
218   ""
219 {
220   rtx op1 = gen_reg_rtx (V4HImode);
221   rtx op2 = gen_reg_rtx (V4HImode);
222   emit_insn (gen_vec_unpacks_lo_v8qi (op1, operands[1]));
223   emit_insn (gen_vec_unpacks_lo_v8qi (op2, operands[2]));
224   emit_insn (gen_mulv4hi3 (operands[0], op1, op2));
225   DONE;
226 });
227   
228 (define_expand "vec_widen_smult_hi_v8qi"
229   [(match_operand:V4HI 0 "gr_register_operand" "")
230    (match_operand:V8QI 1 "gr_register_operand" "")
231    (match_operand:V8QI 2 "gr_register_operand" "")]
232   ""
233 {
234   rtx op1 = gen_reg_rtx (V4HImode);
235   rtx op2 = gen_reg_rtx (V4HImode);
236   emit_insn (gen_vec_unpacks_hi_v8qi (op1, operands[1]));
237   emit_insn (gen_vec_unpacks_hi_v8qi (op2, operands[2]));
238   emit_insn (gen_mulv4hi3 (operands[0], op1, op2));
239   DONE;
240 });
241   
242 (define_insn "mulv4hi3"
243   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
244         (mult:V4HI (match_operand:V4HI 1 "gr_register_operand" "r")
245                    (match_operand:V4HI 2 "gr_register_operand" "r")))]
246   ""
247   "pmpyshr2 %0 = %1, %2, 0"
248   [(set_attr "itanium_class" "mmmul")])
249
250 (define_insn "pmpyshr2"
251   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
252         (truncate:V4HI
253           (ashiftrt:V4SI
254             (mult:V4SI
255               (sign_extend:V4SI
256                 (match_operand:V4HI 1 "gr_register_operand" "r"))
257               (sign_extend:V4SI
258                 (match_operand:V4HI 2 "gr_register_operand" "r")))
259             (match_operand:SI 3 "pmpyshr_operand" "n"))))]
260   ""
261   "pmpyshr2 %0 = %1, %2, %3"
262   [(set_attr "itanium_class" "mmmul")])
263
264 (define_insn "pmpyshr2_u"
265   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
266         (truncate:V4HI
267           (lshiftrt:V4SI
268             (mult:V4SI
269               (zero_extend:V4SI
270                 (match_operand:V4HI 1 "gr_register_operand" "r"))
271               (zero_extend:V4SI
272                 (match_operand:V4HI 2 "gr_register_operand" "r")))
273             (match_operand:SI 3 "pmpyshr_operand" "n"))))]
274   ""
275   "pmpyshr2.u %0 = %1, %2, %3"
276   [(set_attr "itanium_class" "mmmul")])
277
278 (define_insn "pmpy2_even"
279   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
280         (mult:V2SI
281           (vec_select:V2SI
282             (sign_extend:V4SI
283               (match_operand:V4HI 1 "gr_register_operand" "r"))
284             (parallel [(const_int 0) (const_int 2)]))
285           (vec_select:V2SI
286             (sign_extend:V4SI
287               (match_operand:V4HI 2 "gr_register_operand" "r"))
288             (parallel [(const_int 0) (const_int 2)]))))]
289   ""
290 {
291   /* Recall that vector elements are numbered in memory order.  */
292   if (TARGET_BIG_ENDIAN)
293     return "%,pmpy2.l %0 = %1, %2";
294   else
295     return "%,pmpy2.r %0 = %1, %2";
296 }
297   [(set_attr "itanium_class" "mmshf")])
298
299 (define_insn "pmpy2_odd"
300   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
301         (mult:V2SI
302           (vec_select:V2SI
303             (sign_extend:V4SI
304               (match_operand:V4HI 1 "gr_register_operand" "r"))
305             (parallel [(const_int 1) (const_int 3)]))
306           (vec_select:V2SI
307             (sign_extend:V4SI
308               (match_operand:V4HI 2 "gr_register_operand" "r"))
309             (parallel [(const_int 1) (const_int 3)]))))]
310   ""
311 {
312   /* Recall that vector elements are numbered in memory order.  */
313   if (TARGET_BIG_ENDIAN)
314     return "%,pmpy2.r %0 = %1, %2";
315   else
316     return "%,pmpy2.l %0 = %1, %2";
317 }
318   [(set_attr "itanium_class" "mmshf")])
319
320 (define_expand "vec_widen_smult_lo_v4hi"
321   [(match_operand:V2SI 0 "gr_register_operand" "")
322    (match_operand:V4HI 1 "gr_register_operand" "")
323    (match_operand:V4HI 2 "gr_register_operand" "")]
324   ""
325 {
326   rtx l = gen_reg_rtx (V4HImode);
327   rtx h = gen_reg_rtx (V4HImode);
328   emit_insn (gen_mulv4hi3 (l, operands[1], operands[2]));
329   emit_insn (gen_pmpyshr2 (h, operands[1], operands[2], GEN_INT (16)));
330   ia64_unpack_assemble (operands[0], l, h, false);
331   DONE;
332 })
333
334 (define_expand "vec_widen_smult_hi_v4hi"
335   [(match_operand:V2SI 0 "gr_register_operand" "")
336    (match_operand:V4HI 1 "gr_register_operand" "")
337    (match_operand:V4HI 2 "gr_register_operand" "")]
338   ""
339 {
340   rtx l = gen_reg_rtx (V4HImode);
341   rtx h = gen_reg_rtx (V4HImode);
342   emit_insn (gen_mulv4hi3 (l, operands[1], operands[2]));
343   emit_insn (gen_pmpyshr2 (h, operands[1], operands[2], GEN_INT (16)));
344   ia64_unpack_assemble (operands[0], l, h, true);
345   DONE;
346 })
347
348 (define_expand "vec_widen_umult_lo_v4hi"
349   [(match_operand:V2SI 0 "gr_register_operand" "")
350    (match_operand:V4HI 1 "gr_register_operand" "")
351    (match_operand:V4HI 2 "gr_register_operand" "")]
352   ""
353 {
354   rtx l = gen_reg_rtx (V4HImode);
355   rtx h = gen_reg_rtx (V4HImode);
356   emit_insn (gen_mulv4hi3 (l, operands[1], operands[2]));
357   emit_insn (gen_pmpyshr2_u (h, operands[1], operands[2], GEN_INT (16)));
358   ia64_unpack_assemble (operands[0], l, h, false);
359   DONE;
360 })
361
362 (define_expand "vec_widen_umult_hi_v4hi"
363   [(match_operand:V2SI 0 "gr_register_operand" "")
364    (match_operand:V4HI 1 "gr_register_operand" "")
365    (match_operand:V4HI 2 "gr_register_operand" "")]
366   ""
367 {
368   rtx l = gen_reg_rtx (V4HImode);
369   rtx h = gen_reg_rtx (V4HImode);
370   emit_insn (gen_mulv4hi3 (l, operands[1], operands[2]));
371   emit_insn (gen_pmpyshr2_u (h, operands[1], operands[2], GEN_INT (16)));
372   ia64_unpack_assemble (operands[0], l, h, true);
373   DONE;
374 })
375
376 (define_expand "mulv2si3"
377   [(set (match_operand:V2SI 0 "gr_register_operand" "")
378         (mult:V2SI (match_operand:V2SI 1 "gr_register_operand" "r")
379                    (match_operand:V2SI 2 "gr_register_operand" "r")))]
380   ""
381 {
382   rtx t0, t1, t2, t3, t4, t5, t6, t7, x;
383   rtx op1h = gen_lowpart (V4HImode, operands[1]);
384   rtx op2h = gen_lowpart (V4HImode, operands[2]);
385
386   t0 = gen_reg_rtx (V4HImode);
387   t1 = gen_reg_rtx (V4HImode);
388   t2 = gen_reg_rtx (V4HImode);
389   t3 = gen_reg_rtx (V4HImode);
390   t4 = gen_reg_rtx (V2SImode);
391   t5 = gen_reg_rtx (V2SImode);
392   t6 = gen_reg_rtx (V2SImode);
393   t7 = gen_reg_rtx (V2SImode);
394
395   /* Consider the HImode components of op1 = DCBA, op2 = ZYXW.
396      Consider .l and .h suffixes below the low and high 16 bits
397      of the full 32-bit product.  */
398
399   /* T0 = CDBA.  */
400   x = gen_rtx_PARALLEL (VOIDmode, gen_rtvec (4, const1_rtx, const0_rtx,
401                                              GEN_INT (3), const2_rtx));
402   x = gen_rtx_VEC_SELECT (V4HImode, op1h, x);
403   emit_insn (gen_rtx_SET (VOIDmode, t0, x));
404
405   /* T1 = DZ.l, CY.l, BX.l, AW.l.  */
406   emit_insn (gen_mulv4hi3 (t1, op1h, op2h));
407
408   /* T2 = DZ.h, CY.h, BX.h, AW.h.  */
409   emit_insn (gen_pmpyshr2_u (t2, op1h, op2h, GEN_INT (16)));
410
411   /* T3 = CZ.l, DY.l, AX.l, BW.l.  */
412   emit_insn (gen_mulv4hi3 (t3, t0, op2h));
413
414   /* T4 = CY.h, CY.l, AW.h, AW.l = CY, AW.  */
415   x = gen_lowpart (V4HImode, t4);
416   if (TARGET_BIG_ENDIAN)
417     x = gen_mix2_odd (x, t2, t1);
418   else
419     x = gen_mix2_even (x, t1, t2);
420   emit_insn (x);
421
422   /* T5 = CZ.l, 0, AX.l, 0 = CZ << 16, AX << 16.  */
423   x = gen_lowpart (V4HImode, t5);
424   if (TARGET_BIG_ENDIAN)
425     x = gen_mix2_even (x, t3, CONST0_RTX (V4HImode));
426   else
427     x = gen_mix2_odd (x, CONST0_RTX (V4HImode), t3);
428   emit_insn (x);
429
430   /* T6 = DY.l, 0, BW.l, 0 = DY << 16, BW << 16.  */
431   x = gen_lowpart (V4HImode, t6);
432   if (TARGET_BIG_ENDIAN)
433     x = gen_mix2_odd (x, t3, CONST0_RTX (V4HImode));
434   else
435     x = gen_mix2_even (x, CONST0_RTX (V4HImode), t3);
436   emit_insn (x);
437
438   emit_insn (gen_addv2si3 (t7, t4, t5));
439   emit_insn (gen_addv2si3 (operands[0], t6, t7));
440   DONE;
441 })
442
443 (define_expand "umax<mode>3"
444   [(set (match_operand:VECINT 0 "gr_register_operand" "")
445         (umax:VECINT (match_operand:VECINT 1 "gr_register_operand" "")
446                      (match_operand:VECINT 2 "gr_register_operand" "")))]
447   ""
448 {
449   if (ia64_expand_vecint_minmax (UMAX, <MODE>mode, operands))
450     DONE;
451 })
452
453 (define_expand "smax<mode>3"
454   [(set (match_operand:VECINT 0 "gr_register_operand" "")
455         (smax:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
456                      (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
457   ""
458 {
459   if (ia64_expand_vecint_minmax (SMAX, <MODE>mode, operands))
460     DONE;
461 })
462
463 (define_expand "umin<mode>3"
464   [(set (match_operand:VECINT 0 "gr_register_operand" "")
465         (umin:VECINT (match_operand:VECINT 1 "gr_register_operand" "")
466                      (match_operand:VECINT 2 "gr_register_operand" "")))]
467   ""
468 {
469   if (ia64_expand_vecint_minmax (UMIN, <MODE>mode, operands))
470     DONE;
471 })
472
473 (define_expand "smin<mode>3"
474   [(set (match_operand:VECINT 0 "gr_register_operand" "")
475         (smin:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
476                      (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
477   ""
478 {
479   if (ia64_expand_vecint_minmax (SMIN, <MODE>mode, operands))
480     DONE;
481 })
482
483 (define_insn "*umaxv8qi3"
484   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
485         (umax:V8QI (match_operand:V8QI 1 "gr_register_operand" "r")
486                    (match_operand:V8QI 2 "gr_register_operand" "r")))]
487   ""
488   "pmax1.u %0 = %1, %2"
489   [(set_attr "itanium_class" "mmshf")])
490
491 (define_insn "*smaxv4hi3"
492   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
493         (smax:V4HI (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
494                    (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU")))]
495   ""
496   "pmax2 %0 = %r1, %r2"
497   [(set_attr "itanium_class" "mmshf")])
498
499 (define_insn "*uminv8qi3"
500   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
501         (umin:V8QI (match_operand:V8QI 1 "gr_register_operand" "r")
502                    (match_operand:V8QI 2 "gr_register_operand" "r")))]
503   ""
504   "pmin1.u %0 = %1, %2"
505   [(set_attr "itanium_class" "mmshf")])
506
507 (define_insn "*sminv4hi3"
508   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
509         (smin:V4HI (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
510                    (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU")))]
511   ""
512   "pmin2 %0 = %r1, %r2"
513   [(set_attr "itanium_class" "mmshf")])
514
515 (define_insn "ashl<mode>3"
516   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
517         (ashift:VECINT24
518           (match_operand:VECINT24 1 "gr_register_operand" "r")
519           (match_operand:DI 2 "gr_reg_or_5bit_operand" "rn")))]
520   ""
521   "pshl<vecsize> %0 = %1, %2"
522   [(set_attr "itanium_class" "mmshf")])
523
524 (define_insn "ashr<mode>3"
525   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
526         (ashiftrt:VECINT24
527           (match_operand:VECINT24 1 "gr_register_operand" "r")
528           (match_operand:DI 2 "gr_reg_or_5bit_operand" "rn")))]
529   ""
530   "pshr<vecsize> %0 = %1, %2"
531   [(set_attr "itanium_class" "mmshf")])
532
533 (define_insn "lshr<mode>3"
534   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
535         (lshiftrt:VECINT24
536           (match_operand:VECINT24 1 "gr_register_operand" "r")
537           (match_operand:DI 2 "gr_reg_or_5bit_operand" "rn")))]
538   ""
539   "pshr<vecsize>.u %0 = %1, %2"
540   [(set_attr "itanium_class" "mmshf")])
541
542 (define_expand "vec_shl_<mode>"
543   [(set (match_operand:VECINT 0 "gr_register_operand" "")
544         (ashift:DI (match_operand:VECINT 1 "gr_register_operand" "")
545                    (match_operand:DI 2 "gr_reg_or_6bit_operand" "")))]
546   ""
547 {
548   operands[0] = gen_lowpart (DImode, operands[0]);
549   operands[1] = gen_lowpart (DImode, operands[1]);
550 })
551
552 (define_expand "vec_shr_<mode>"
553   [(set (match_operand:VECINT 0 "gr_register_operand" "")
554         (lshiftrt:DI (match_operand:VECINT 1 "gr_register_operand" "")
555                      (match_operand:DI 2 "gr_reg_or_6bit_operand" "")))]
556   ""
557 {
558   operands[0] = gen_lowpart (DImode, operands[0]);
559   operands[1] = gen_lowpart (DImode, operands[1]);
560 })
561
562 (define_expand "widen_usumv8qi3"
563   [(match_operand:V4HI 0 "gr_register_operand" "")
564    (match_operand:V8QI 1 "gr_register_operand" "")
565    (match_operand:V4HI 2 "gr_register_operand" "")]
566   ""
567 {
568   ia64_expand_widen_sum (operands, true);
569   DONE;
570 })
571
572 (define_expand "widen_usumv4hi3"
573   [(match_operand:V2SI 0 "gr_register_operand" "")
574    (match_operand:V4HI 1 "gr_register_operand" "")
575    (match_operand:V2SI 2 "gr_register_operand" "")]
576   ""
577 {
578   ia64_expand_widen_sum (operands, true);
579   DONE;
580 })
581
582 (define_expand "widen_ssumv8qi3"
583   [(match_operand:V4HI 0 "gr_register_operand" "")
584    (match_operand:V8QI 1 "gr_register_operand" "")
585    (match_operand:V4HI 2 "gr_register_operand" "")]
586   ""
587 {
588   ia64_expand_widen_sum (operands, false);
589   DONE;
590 })
591
592 (define_expand "widen_ssumv4hi3"
593   [(match_operand:V2SI 0 "gr_register_operand" "")
594    (match_operand:V4HI 1 "gr_register_operand" "")
595    (match_operand:V2SI 2 "gr_register_operand" "")]
596   ""
597 {
598   ia64_expand_widen_sum (operands, false);
599   DONE;
600 })
601
602 (define_expand "udot_prodv8qi"
603   [(match_operand:V2SI 0 "gr_register_operand" "")
604    (match_operand:V8QI 1 "gr_register_operand" "")
605    (match_operand:V8QI 2 "gr_register_operand" "")
606    (match_operand:V2SI 3 "gr_register_operand" "")]
607   ""
608 {
609   ia64_expand_dot_prod_v8qi (operands, true);
610   DONE;
611 })
612
613 (define_expand "sdot_prodv8qi"
614   [(match_operand:V2SI 0 "gr_register_operand" "")
615    (match_operand:V8QI 1 "gr_register_operand" "")
616    (match_operand:V8QI 2 "gr_register_operand" "")
617    (match_operand:V2SI 3 "gr_register_operand" "")]
618   ""
619 {
620   ia64_expand_dot_prod_v8qi (operands, false);
621   DONE;
622 })
623
624 (define_expand "sdot_prodv4hi"
625   [(match_operand:V2SI 0 "gr_register_operand" "")
626    (match_operand:V4HI 1 "gr_register_operand" "")
627    (match_operand:V4HI 2 "gr_register_operand" "")
628    (match_operand:V2SI 3 "gr_register_operand" "")]
629   ""
630 {
631   rtx e, o, t;
632
633   e = gen_reg_rtx (V2SImode);
634   o = gen_reg_rtx (V2SImode);
635   t = gen_reg_rtx (V2SImode);
636
637   emit_insn (gen_pmpy2_even (e, operands[1], operands[2]));
638   emit_insn (gen_pmpy2_odd (o, operands[1], operands[2]));
639   emit_insn (gen_addv2si3 (t, e, operands[3]));
640   emit_insn (gen_addv2si3 (operands[0], t, o));
641   DONE;
642 })
643
644 (define_expand "udot_prodv4hi"
645   [(match_operand:V2SI 0 "gr_register_operand" "")
646    (match_operand:V4HI 1 "gr_register_operand" "")
647    (match_operand:V4HI 2 "gr_register_operand" "")
648    (match_operand:V2SI 3 "gr_register_operand" "")]
649   ""
650 {
651   rtx l, h, t;
652
653   l = gen_reg_rtx (V2SImode);
654   h = gen_reg_rtx (V2SImode);
655   t = gen_reg_rtx (V2SImode);
656
657   emit_insn (gen_vec_widen_umult_lo_v4hi (l, operands[1], operands[2]));
658   emit_insn (gen_vec_widen_umult_hi_v4hi (h, operands[1], operands[2]));
659   emit_insn (gen_addv2si3 (t, l, operands[3]));
660   emit_insn (gen_addv2si3 (operands[0], t, h));
661   DONE;
662 })
663
664 (define_expand "vcond<mode><mode>"
665   [(set (match_operand:VECINT 0 "gr_register_operand" "")
666         (if_then_else:VECINT
667           (match_operator 3 "" 
668             [(match_operand:VECINT 4 "gr_reg_or_0_operand" "")
669              (match_operand:VECINT 5 "gr_reg_or_0_operand" "")])
670           (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
671           (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
672   ""
673 {
674   ia64_expand_vecint_cmov (operands);
675   DONE;
676 })
677
678 (define_expand "vcondu<mode><mode>"
679   [(set (match_operand:VECINT 0 "gr_register_operand" "")
680         (if_then_else:VECINT
681           (match_operator 3 "" 
682             [(match_operand:VECINT 4 "gr_reg_or_0_operand" "")
683              (match_operand:VECINT 5 "gr_reg_or_0_operand" "")])
684           (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
685           (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
686   ""
687 {
688   ia64_expand_vecint_cmov (operands);
689   DONE;
690 })
691
692 (define_insn "*cmpeq_<mode>"
693   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
694         (eq:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "rU")
695                    (match_operand:VECINT 2 "gr_reg_or_0_operand" "rU")))]
696   ""
697   "pcmp<vecsize>.eq %0 = %r1, %r2"
698   [(set_attr "itanium_class" "mmalua")])
699
700 (define_insn "*cmpgt_<mode>"
701   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
702         (gt:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "rU")
703                    (match_operand:VECINT 2 "gr_reg_or_0_operand" "rU")))]
704   ""
705   "pcmp<vecsize>.gt %0 = %r1, %r2"
706   [(set_attr "itanium_class" "mmalua")])
707
708 (define_insn "vec_pack_ssat_v4hi"
709   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
710         (vec_concat:V8QI
711           (ss_truncate:V4QI
712             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU"))
713           (ss_truncate:V4QI
714             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))))]
715   ""
716 {
717   /* Recall that vector elements are numbered in memory order.  */
718   if (TARGET_BIG_ENDIAN)
719     return "%,pack2.sss %0 = %r2, %r1";
720   else
721     return "%,pack2.sss %0 = %r1, %r2";
722 }
723   [(set_attr "itanium_class" "mmshf")])
724
725 (define_insn "vec_pack_usat_v4hi"
726   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
727         (vec_concat:V8QI
728           (us_truncate:V4QI
729             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU"))
730           (us_truncate:V4QI
731             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))))]
732   ""
733 {
734   /* Recall that vector elements are numbered in memory order.  */
735   if (TARGET_BIG_ENDIAN)
736     return "%,pack2.uss %0 = %r2, %r1";
737   else
738     return "%,pack2.uss %0 = %r1, %r2";
739 }
740   [(set_attr "itanium_class" "mmshf")])
741
742 (define_insn "vec_pack_ssat_v2si"
743   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
744         (vec_concat:V4HI
745           (ss_truncate:V2HI
746             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU"))
747           (ss_truncate:V2HI
748             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))))]
749   ""
750 {
751   /* Recall that vector elements are numbered in memory order.  */
752   if (TARGET_BIG_ENDIAN)
753     return "%,pack4.sss %0 = %r2, %r1";
754   else
755     return "%,pack4.sss %0 = %r1, %r2";
756 }
757   [(set_attr "itanium_class" "mmshf")])
758
759 (define_insn "vec_interleave_lowv8qi"
760   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
761         (vec_select:V8QI
762           (vec_concat:V16QI
763             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
764             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
765           (parallel [(const_int 0) (const_int 8)
766                      (const_int 1) (const_int 9)
767                      (const_int 2) (const_int 10)
768                      (const_int 3) (const_int 11)])))]
769   ""
770 {
771   /* Recall that vector elements are numbered in memory order.  */
772   if (TARGET_BIG_ENDIAN)
773     return "%,unpack1.l %0 = %r1, %r2";
774   else
775     return "%,unpack1.l %0 = %r2, %r1";
776 }
777   [(set_attr "itanium_class" "mmshf")])
778
779 (define_insn "vec_interleave_highv8qi"
780   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
781         (vec_select:V8QI
782           (vec_concat:V16QI
783             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
784             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
785           (parallel [(const_int 4) (const_int 12)
786                      (const_int 5) (const_int 13)
787                      (const_int 6) (const_int 14)
788                      (const_int 7) (const_int 15)])))]
789   ""
790 {
791   /* Recall that vector elements are numbered in memory order.  */
792   if (TARGET_BIG_ENDIAN)
793     return "%,unpack1.h %0 = %r1, %r2";
794   else
795     return "%,unpack1.h %0 = %r2, %r1";
796 }
797   [(set_attr "itanium_class" "mmshf")])
798
799 (define_insn "mix1_even"
800   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
801         (vec_select:V8QI
802           (vec_concat:V16QI
803             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
804             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
805           (parallel [(const_int 0) (const_int 8)
806                      (const_int 2) (const_int 10)
807                      (const_int 4) (const_int 12)
808                      (const_int 6) (const_int 14)])))]
809   ""
810 {
811   /* Recall that vector elements are numbered in memory order.  */
812   if (TARGET_BIG_ENDIAN)
813     return "%,mix1.l %0 = %r1, %r2";
814   else
815     return "%,mix1.r %0 = %r2, %r1";
816 }
817   [(set_attr "itanium_class" "mmshf")])
818
819 (define_insn "mix1_odd"
820   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
821         (vec_select:V8QI
822           (vec_concat:V16QI
823             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
824             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
825           (parallel [(const_int 1) (const_int 9)
826                      (const_int 3) (const_int 11)
827                      (const_int 5) (const_int 13)
828                      (const_int 7) (const_int 15)])))]
829   ""
830 {
831   /* Recall that vector elements are numbered in memory order.  */
832   if (TARGET_BIG_ENDIAN)
833     return "%,mix1.r %0 = %r1, %r2";
834   else
835     return "%,mix1.l %0 = %r2, %r1";
836 }
837   [(set_attr "itanium_class" "mmshf")])
838
839 (define_insn "*mux1_rev"
840   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
841         (vec_select:V8QI
842           (match_operand:V8QI 1 "gr_register_operand" "r")
843           (parallel [(const_int 7) (const_int 6)
844                      (const_int 5) (const_int 4)
845                      (const_int 3) (const_int 2)
846                      (const_int 1) (const_int 0)])))]
847   ""
848   "mux1 %0 = %1, @rev"
849   [(set_attr "itanium_class" "mmshf")])
850
851 (define_insn "*mux1_mix"
852   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
853         (vec_select:V8QI
854           (match_operand:V8QI 1 "gr_register_operand" "r")
855           (parallel [(const_int 0) (const_int 4)
856                      (const_int 2) (const_int 6)
857                      (const_int 1) (const_int 5)
858                      (const_int 3) (const_int 7)])))]
859   ""
860   "mux1 %0 = %1, @mix"
861   [(set_attr "itanium_class" "mmshf")])
862
863 (define_insn "*mux1_shuf"
864   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
865         (vec_select:V8QI
866           (match_operand:V8QI 1 "gr_register_operand" "r")
867           (parallel [(const_int 0) (const_int 4)
868                      (const_int 1) (const_int 5)
869                      (const_int 2) (const_int 6)
870                      (const_int 3) (const_int 7)])))]
871   ""
872   "mux1 %0 = %1, @shuf"
873   [(set_attr "itanium_class" "mmshf")])
874
875 (define_insn "mux1_alt"
876   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
877         (vec_select:V8QI
878           (match_operand:V8QI 1 "gr_register_operand" "r")
879           (parallel [(const_int 0) (const_int 2)
880                      (const_int 4) (const_int 6)
881                      (const_int 1) (const_int 3)
882                      (const_int 5) (const_int 7)])))]
883   ""
884   "mux1 %0 = %1, @alt"
885   [(set_attr "itanium_class" "mmshf")])
886
887 (define_insn "*mux1_brcst_v8qi"
888   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
889         (vec_select:V8QI
890           (match_operand:V8QI 1 "gr_register_operand" "r")
891           (parallel [(match_operand 2 "mux1_brcst_element" "")
892                      (match_dup 2)
893                      (match_dup 2)
894                      (match_dup 2)
895                      (match_dup 2)
896                      (match_dup 2)
897                      (match_dup 2)
898                      (match_dup 2)])))]
899   ""
900   "mux1 %0 = %1, @brcst"
901   [(set_attr "itanium_class" "mmshf")])
902
903 (define_insn "*mux1_brcst_qi"
904   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
905         (vec_duplicate:V8QI
906           (match_operand:QI 1 "gr_register_operand" "r")))]
907   ""
908   "mux1 %0 = %1, @brcst"
909   [(set_attr "itanium_class" "mmshf")])
910
911 (define_expand "vec_extract_evenv8qi"
912   [(match_operand:V8QI 0 "gr_register_operand" "")
913    (match_operand:V8QI 1 "gr_register_operand" "")
914    (match_operand:V8QI 2 "gr_register_operand" "")]
915   ""
916 {
917   rtx temp = gen_reg_rtx (V8QImode);
918   emit_insn (gen_mix1_even (temp, operands[1], operands[2]));
919   emit_insn (gen_mux1_alt (operands[0], temp));
920   DONE;
921 })
922
923 (define_expand "vec_extract_oddv8qi"
924   [(match_operand:V8QI 0 "gr_register_operand" "")
925    (match_operand:V8QI 1 "gr_register_operand" "")
926    (match_operand:V8QI 2 "gr_register_operand" "")]
927   ""
928 {
929   rtx temp = gen_reg_rtx (V8QImode);
930   emit_insn (gen_mix1_odd (temp, operands[1], operands[2]));
931   emit_insn (gen_mux1_alt (operands[0], temp));
932   DONE;
933 })
934
935 (define_insn "vec_interleave_lowv4hi"
936   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
937         (vec_select:V4HI
938           (vec_concat:V8HI
939             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
940             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
941           (parallel [(const_int 0) (const_int 4)
942                      (const_int 1) (const_int 5)])))]
943   ""
944 {
945   /* Recall that vector elements are numbered in memory order.  */
946   if (TARGET_BIG_ENDIAN)
947     return "%,unpack2.l %0 = %r1, %r2";
948   else
949     return "%,unpack2.l %0 = %r2, %r1";
950 }
951   [(set_attr "itanium_class" "mmshf")])
952
953 (define_insn "vec_interleave_highv4hi"
954   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
955         (vec_select:V4HI
956           (vec_concat:V8HI
957             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
958             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
959           (parallel [(const_int 2) (const_int 6)
960                      (const_int 3) (const_int 7)])))]
961   ""
962 {
963   /* Recall that vector elements are numbered in memory order.  */
964   if (TARGET_BIG_ENDIAN)
965     return "%,unpack2.h %0 = %r1, %r2";
966   else
967     return "%,unpack2.h %0 = %r2, %r1";
968 }
969   [(set_attr "itanium_class" "mmshf")])
970
971 (define_insn "mix2_even"
972   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
973         (vec_select:V4HI
974           (vec_concat:V8HI
975             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
976             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
977           (parallel [(const_int 0) (const_int 4)
978                      (const_int 2) (const_int 6)])))]
979   ""
980 {
981   /* Recall that vector elements are numbered in memory order.  */
982   if (TARGET_BIG_ENDIAN)
983     return "%,mix2.l %0 = %r1, %r2";
984   else
985     return "%,mix2.r %0 = %r2, %r1";
986 }
987   [(set_attr "itanium_class" "mmshf")])
988
989 (define_insn "mix2_odd"
990   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
991         (vec_select:V4HI
992           (vec_concat:V8HI
993             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
994             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
995           (parallel [(const_int 1) (const_int 5)
996                      (const_int 3) (const_int 7)])))]
997   ""
998 {
999   /* Recall that vector elements are numbered in memory order.  */
1000   if (TARGET_BIG_ENDIAN)
1001     return "%,mix2.r %0 = %r1, %r2";
1002   else
1003     return "%,mix2.l %0 = %r2, %r1";
1004 }
1005   [(set_attr "itanium_class" "mmshf")])
1006
1007 (define_insn "*mux2"
1008   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
1009         (vec_select:V4HI
1010           (match_operand:V4HI 1 "gr_register_operand" "r")
1011           (parallel [(match_operand 2 "const_int_2bit_operand" "")
1012                      (match_operand 3 "const_int_2bit_operand" "")
1013                      (match_operand 4 "const_int_2bit_operand" "")
1014                      (match_operand 5 "const_int_2bit_operand" "")])))]
1015   ""
1016 {
1017   int mask = 0;
1018   if (TARGET_BIG_ENDIAN)
1019     {
1020       mask |= (3 - INTVAL (operands[2])) << 6;
1021       mask |= (3 - INTVAL (operands[3])) << 4;
1022       mask |= (3 - INTVAL (operands[4])) << 2;
1023       mask |= 3 - INTVAL (operands[5]);
1024     }
1025   else
1026     {
1027       mask |= INTVAL (operands[2]);
1028       mask |= INTVAL (operands[3]) << 2;
1029       mask |= INTVAL (operands[4]) << 4;
1030       mask |= INTVAL (operands[5]) << 6;
1031     }
1032   operands[2] = GEN_INT (mask);
1033   return "%,mux2 %0 = %1, %2";
1034 }
1035   [(set_attr "itanium_class" "mmshf")])
1036
1037 (define_expand "vec_extract_evenodd_helper"
1038   [(set (match_operand:V4HI 0 "gr_register_operand" "")
1039         (vec_select:V4HI
1040           (match_operand:V4HI 1 "gr_register_operand" "")
1041           (parallel [(const_int 0) (const_int 2)
1042                      (const_int 1) (const_int 3)])))]
1043   "")
1044
1045 (define_expand "vec_extract_evenv4hi"
1046   [(match_operand:V4HI 0 "gr_register_operand")
1047    (match_operand:V4HI 1 "gr_reg_or_0_operand")
1048    (match_operand:V4HI 2 "gr_reg_or_0_operand")]
1049   ""
1050 {
1051   rtx temp = gen_reg_rtx (V4HImode);
1052   emit_insn (gen_mix2_even (temp, operands[1], operands[2]));
1053   emit_insn (gen_vec_extract_evenodd_helper (operands[0], temp));
1054   DONE;
1055 })
1056
1057 (define_expand "vec_extract_oddv4hi"
1058   [(match_operand:V4HI 0 "gr_register_operand")
1059    (match_operand:V4HI 1 "gr_reg_or_0_operand")
1060    (match_operand:V4HI 2 "gr_reg_or_0_operand")]
1061   ""
1062 {
1063   rtx temp = gen_reg_rtx (V4HImode);
1064   emit_insn (gen_mix2_odd (temp, operands[1], operands[2]));
1065   emit_insn (gen_vec_extract_evenodd_helper (operands[0], temp));
1066   DONE;
1067 })
1068
1069 (define_insn "*mux2_brcst_hi"
1070   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
1071         (vec_duplicate:V4HI
1072           (match_operand:HI 1 "gr_register_operand" "r")))]
1073   ""
1074   "mux2 %0 = %1, 0"
1075   [(set_attr "itanium_class" "mmshf")])
1076
1077 (define_insn "vec_interleave_lowv2si"
1078   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
1079         (vec_select:V2SI
1080           (vec_concat:V4SI
1081             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU")
1082             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))
1083           (parallel [(const_int 0) (const_int 2)])))]
1084   ""
1085 {
1086   /* Recall that vector elements are numbered in memory order.  */
1087   if (TARGET_BIG_ENDIAN)
1088     return "%,unpack4.l %0 = %r1, %r2";
1089   else
1090     return "%,unpack4.l %0 = %r2, %r1";
1091 }
1092   [(set_attr "itanium_class" "mmshf")])
1093
1094 (define_insn "vec_interleave_highv2si"
1095   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
1096         (vec_select:V2SI
1097           (vec_concat:V4SI
1098             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU")
1099             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))
1100           (parallel [(const_int 1) (const_int 3)])))]
1101   ""
1102 {
1103   /* Recall that vector elements are numbered in memory order.  */
1104   if (TARGET_BIG_ENDIAN)
1105     return "%,unpack4.h %0 = %r1, %r2";
1106   else
1107     return "%,unpack4.h %0 = %r2, %r1";
1108 }
1109   [(set_attr "itanium_class" "mmshf")])
1110
1111 (define_expand "vec_extract_evenv2si"
1112   [(match_operand:V2SI 0 "gr_register_operand" "")
1113    (match_operand:V2SI 1 "gr_register_operand" "")
1114    (match_operand:V2SI 2 "gr_register_operand" "")]
1115   ""
1116 {
1117   if (TARGET_BIG_ENDIAN)
1118     emit_insn (gen_vec_interleave_highv2si (operands[0], operands[1],
1119                                             operands[2]));
1120   else
1121     emit_insn (gen_vec_interleave_lowv2si (operands[0], operands[1],
1122                                            operands[2]));
1123   DONE;
1124 })
1125
1126 (define_expand "vec_extract_oddv2si"
1127   [(match_operand:V2SI 0 "gr_register_operand" "")
1128    (match_operand:V2SI 1 "gr_register_operand" "")
1129    (match_operand:V2SI 2 "gr_register_operand" "")]
1130   ""
1131 {
1132   if (TARGET_BIG_ENDIAN)
1133     emit_insn (gen_vec_interleave_lowv2si (operands[0], operands[1],
1134                                            operands[2]));
1135   else
1136     emit_insn (gen_vec_interleave_highv2si (operands[0], operands[1],
1137                                             operands[2]));
1138   DONE;
1139 })
1140
1141 (define_expand "vec_initv2si"
1142   [(match_operand:V2SI 0 "gr_register_operand" "")
1143    (match_operand 1 "" "")]
1144   ""
1145 {
1146   rtx op1 = XVECEXP (operands[1], 0, 0);
1147   rtx op2 = XVECEXP (operands[1], 0, 1);
1148   rtx x;
1149
1150   if (GET_CODE (op1) == CONST_INT && GET_CODE (op2) == CONST_INT)
1151     {
1152       x = gen_rtx_CONST_VECTOR (V2SImode, XVEC (operands[1], 0));
1153       emit_move_insn (operands[0], x);
1154       DONE;
1155     }
1156
1157   if (!gr_reg_or_0_operand (op1, SImode))
1158     op1 = force_reg (SImode, op1);
1159   if (!gr_reg_or_0_operand (op2, SImode))
1160     op2 = force_reg (SImode, op2);
1161
1162   x = gen_rtx_VEC_CONCAT (V2SImode, op1, op2);
1163   emit_insn (gen_rtx_SET (VOIDmode, operands[0], x));
1164   DONE;
1165 })
1166
1167 (define_insn "*vecinit_v2si"
1168   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
1169         (vec_concat:V2SI
1170           (match_operand:SI 1 "gr_reg_or_0_operand" "rO")
1171           (match_operand:SI 2 "gr_reg_or_0_operand" "rO")))]
1172   ""
1173 {
1174   /* Recall that vector elements are numbered in memory order.  */
1175   if (TARGET_BIG_ENDIAN)
1176     return "%,unpack4.l %0 = %r1, %r2";
1177   else
1178     return "%,unpack4.l %0 = %r2, %r1";
1179 }
1180   [(set_attr "itanium_class" "mmshf")])
1181
1182 ;; Missing operations
1183 ;; padd.uus
1184 ;; pavg
1185 ;; pavgsub
1186 ;; psad
1187 ;; pshladd
1188 ;; pshradd
1189 ;; psub.uus
1190 \f
1191 ;; Floating point vector operations
1192
1193 (define_expand "movv2sf"
1194   [(set (match_operand:V2SF 0 "general_operand" "")
1195         (match_operand:V2SF 1 "general_operand" ""))]
1196   ""
1197 {
1198   rtx op1 = ia64_expand_move (operands[0], operands[1]);
1199   if (!op1)
1200     DONE;
1201   operands[1] = op1;
1202 })
1203
1204 (define_insn "*movv2sf_internal"
1205   [(set (match_operand:V2SF 0 "destination_operand"
1206                                         "=f,f,f,Q,*r ,*r,*r,*r,m ,f ,*r")
1207         (match_operand:V2SF 1 "move_operand"
1208                                         "fU,Y,Q,f,U*r,W ,i ,m ,*r,*r,f "))]
1209   "ia64_move_ok (operands[0], operands[1])"
1210 {
1211   static const char * const alt[] = {
1212     "%,mov %0 = %F1",
1213     "%,fpack %0 = %F2, %F1",
1214     "%,ldf8 %0 = %1%P1",
1215     "%,stf8 %0 = %1%P0",
1216     "%,mov %0 = %r1",
1217     "%,addl %0 = %v1, r0",
1218     "%,movl %0 = %v1",
1219     "%,ld8%O1 %0 = %1%P1",
1220     "%,st8%Q0 %0 = %r1%P0",
1221     "%,setf.sig %0 = %1",
1222     "%,getf.sig %0 = %1"
1223   };
1224
1225   if (which_alternative == 1)
1226     {
1227       operands[2] = XVECEXP (operands[1], 0, TARGET_BIG_ENDIAN ? 0 : 1);
1228       operands[1] = XVECEXP (operands[1], 0, TARGET_BIG_ENDIAN ? 1 : 0);
1229     }
1230
1231   return alt[which_alternative];
1232 }
1233   [(set_attr "itanium_class" "fmisc,fmisc,fld,stf,ialu,ialu,long_i,ld,st,tofr,frfr")])
1234
1235 (define_insn "absv2sf2"
1236   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1237         (abs:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")))]
1238   ""
1239   "fpabs %0 = %1"
1240   [(set_attr "itanium_class" "fmisc")])
1241
1242 (define_insn "negv2sf2"
1243   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1244         (neg:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")))]
1245   ""
1246   "fpneg %0 = %1"
1247   [(set_attr "itanium_class" "fmisc")])
1248
1249 (define_insn "*negabsv2sf2"
1250   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1251         (neg:V2SF
1252           (abs:V2SF (match_operand:V2SF 1 "fr_register_operand" "f"))))]
1253   ""
1254   "fpnegabs %0 = %1"
1255   [(set_attr "itanium_class" "fmisc")])
1256
1257 (define_expand "addv2sf3"
1258   [(set (match_operand:V2SF 0 "fr_register_operand" "")
1259         (fma:V2SF (match_operand:V2SF 1 "fr_register_operand" "")
1260                   (match_dup 3)
1261                   (match_operand:V2SF 2 "fr_register_operand" "")))]
1262   ""
1263 {
1264   rtvec v = gen_rtvec (2, CONST1_RTX (SFmode), CONST1_RTX (SFmode));
1265   operands[3] = force_reg (V2SFmode, gen_rtx_CONST_VECTOR (V2SFmode, v));
1266 })
1267
1268 (define_expand "subv2sf3"
1269   [(set (match_operand:V2SF 0 "fr_register_operand" "")
1270         (fma:V2SF
1271           (match_operand:V2SF 1 "fr_register_operand" "")
1272           (match_dup 3)
1273           (neg:V2SF (match_operand:V2SF 2 "fr_register_operand" ""))))]
1274   ""
1275 {
1276   rtvec v = gen_rtvec (2, CONST1_RTX (SFmode), CONST1_RTX (SFmode));
1277   operands[3] = force_reg (V2SFmode, gen_rtx_CONST_VECTOR (V2SFmode, v));
1278 })
1279
1280 (define_insn "mulv2sf3"
1281   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1282         (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
1283                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
1284   ""
1285   "fpmpy %0 = %1, %2"
1286   [(set_attr "itanium_class" "fmac")])
1287
1288 (define_insn "fmav2sf4"
1289   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1290         (fma:V2SF
1291           (match_operand:V2SF 1 "fr_register_operand" "f")
1292           (match_operand:V2SF 2 "fr_register_operand" "f")
1293           (match_operand:V2SF 3 "fr_register_operand" "f")))]
1294   ""
1295   "fpma %0 = %1, %2, %3"
1296   [(set_attr "itanium_class" "fmac")])
1297
1298 (define_insn "fmsv2sf4"
1299   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1300         (fma:V2SF
1301           (match_operand:V2SF 1 "fr_register_operand" "f")
1302           (match_operand:V2SF 2 "fr_register_operand" "f")
1303           (neg:V2SF (match_operand:V2SF 3 "fr_register_operand" "f"))))]
1304   ""
1305   "fpms %0 = %1, %2, %3"
1306   [(set_attr "itanium_class" "fmac")])
1307
1308 (define_insn "*fpnmpy"
1309   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1310         (neg:V2SF
1311           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
1312                      (match_operand:V2SF 2 "fr_register_operand" "f"))))]
1313   ""
1314   "fpnmpy %0 = %1, %2"
1315   [(set_attr "itanium_class" "fmac")])
1316
1317 (define_insn "fnmav2sf4"
1318   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1319         (fma:V2SF
1320           (neg:V2SF (match_operand:V2SF 1 "fr_register_operand" "f"))
1321           (match_operand:V2SF 2 "fr_register_operand" "f")
1322           (match_operand:V2SF 3 "fr_register_operand" "f")))]
1323   ""
1324   "fpnma %0 = %1, %2, %3"
1325   [(set_attr "itanium_class" "fmac")])
1326
1327 (define_insn "smaxv2sf3"
1328   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1329         (smax:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
1330                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
1331   ""
1332   "fpmax %0 = %1, %2"
1333   [(set_attr "itanium_class" "fmisc")])
1334
1335 (define_insn "sminv2sf3"
1336   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1337         (smin:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
1338                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
1339   ""
1340   "fpmin %0 = %1, %2"
1341   [(set_attr "itanium_class" "fmisc")])
1342
1343 (define_expand "reduc_splus_v2sf"
1344   [(match_operand:V2SF 0 "fr_register_operand" "")
1345    (match_operand:V2SF 1 "fr_register_operand" "")]
1346   ""
1347 {
1348   rtx tmp = gen_reg_rtx (V2SFmode);
1349   if (TARGET_BIG_ENDIAN)
1350     emit_insn (gen_fswap (tmp, CONST0_RTX (V2SFmode), operands[1]));
1351   else
1352     emit_insn (gen_fswap (tmp, operands[1], CONST0_RTX (V2SFmode)));
1353   emit_insn (gen_addv2sf3 (operands[0], operands[1], tmp));
1354   DONE;
1355 })
1356
1357 (define_expand "reduc_smax_v2sf"
1358   [(match_operand:V2SF 0 "fr_register_operand" "")
1359    (match_operand:V2SF 1 "fr_register_operand" "")]
1360   ""
1361 {
1362   rtx tmp = gen_reg_rtx (V2SFmode);
1363   if (TARGET_BIG_ENDIAN)
1364     emit_insn (gen_fswap (tmp, CONST0_RTX (V2SFmode), operands[1]));
1365   else
1366     emit_insn (gen_fswap (tmp, operands[1], CONST0_RTX (V2SFmode)));
1367   emit_insn (gen_smaxv2sf3 (operands[0], operands[1], tmp));
1368   DONE;
1369 })
1370
1371 (define_expand "reduc_smin_v2sf"
1372   [(match_operand:V2SF 0 "fr_register_operand" "")
1373    (match_operand:V2SF 1 "fr_register_operand" "")]
1374   ""
1375 {
1376   rtx tmp = gen_reg_rtx (V2SFmode);
1377   if (TARGET_BIG_ENDIAN)
1378     emit_insn (gen_fswap (tmp, CONST0_RTX (V2SFmode), operands[1]));
1379   else
1380     emit_insn (gen_fswap (tmp, operands[1], CONST0_RTX (V2SFmode)));
1381   emit_insn (gen_sminv2sf3 (operands[0], operands[1], tmp));
1382   DONE;
1383 })
1384
1385 (define_expand "vcondv2sfv2sf"
1386   [(set (match_operand:V2SF 0 "fr_register_operand" "")
1387         (if_then_else:V2SF
1388           (match_operator 3 "" 
1389             [(match_operand:V2SF 4 "fr_reg_or_0_operand" "")
1390              (match_operand:V2SF 5 "fr_reg_or_0_operand" "")])
1391           (match_operand:V2SF 1 "fr_reg_or_0_operand" "")
1392           (match_operand:V2SF 2 "fr_reg_or_0_operand" "")))]
1393   ""
1394 {
1395   rtx x, cmp;
1396
1397   cmp = gen_reg_rtx (V2SFmode);
1398   PUT_MODE (operands[3], V2SFmode);
1399   emit_insn (gen_rtx_SET (VOIDmode, cmp, operands[3]));
1400
1401   x = gen_rtx_IF_THEN_ELSE (V2SFmode, cmp, operands[1], operands[2]);
1402   emit_insn (gen_rtx_SET (VOIDmode, operands[0], x));
1403   DONE;
1404 })
1405
1406 (define_insn "*fpcmp"
1407   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1408         (match_operator:V2SF 3 "comparison_operator"
1409           [(match_operand:V2SF 1 "fr_reg_or_0_operand" "fU")
1410            (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU")]))]
1411   ""
1412   "fpcmp.%D3 %0 = %F1, %F2"
1413   [(set_attr "itanium_class" "fmisc")])
1414
1415 (define_insn "*fselect"
1416   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1417         (if_then_else:V2SF
1418           (match_operand:V2SF 1 "fr_register_operand" "f")
1419           (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU")
1420           (match_operand:V2SF 3 "fr_reg_or_0_operand" "fU")))]
1421   ""
1422   "fselect %0 = %F2, %F3, %1"
1423   [(set_attr "itanium_class" "fmisc")])
1424
1425 (define_expand "vec_initv2sf"
1426   [(match_operand:V2SF 0 "fr_register_operand" "")
1427    (match_operand 1 "" "")]
1428   ""
1429 {
1430   rtx op1 = XVECEXP (operands[1], 0, 0);
1431   rtx op2 = XVECEXP (operands[1], 0, 1);
1432   rtx x;
1433
1434   if (GET_CODE (op1) == CONST_DOUBLE && GET_CODE (op2) == CONST_DOUBLE)
1435     {
1436       x = gen_rtx_CONST_VECTOR (V2SFmode, XVEC (operands[1], 0));
1437       emit_move_insn (operands[0], x);
1438       DONE;
1439     }
1440
1441   if (!fr_reg_or_fp01_operand (op1, SFmode))
1442     op1 = force_reg (SFmode, op1);
1443   if (!fr_reg_or_fp01_operand (op2, SFmode))
1444     op2 = force_reg (SFmode, op2);
1445
1446   emit_insn (gen_fpack (operands[0], op1, op2));
1447   DONE;
1448 })
1449
1450 (define_insn "fpack"
1451   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1452         (vec_concat:V2SF
1453           (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
1454           (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
1455   ""
1456 {
1457   /* Recall that vector elements are numbered in memory order.  */
1458   if (TARGET_BIG_ENDIAN)
1459     return "%,fpack %0 = %F1, %F2";
1460   else
1461     return "%,fpack %0 = %F2, %F1";
1462 }
1463   [(set_attr "itanium_class" "fmisc")])
1464
1465 (define_insn "fswap"
1466   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1467         (vec_select:V2SF
1468           (vec_concat:V4SF
1469             (match_operand:V2SF 1 "fr_reg_or_0_operand" "fU")
1470             (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU"))
1471           (parallel [(const_int 1) (const_int 2)])))]
1472   ""
1473 {
1474   /* Recall that vector elements are numbered in memory order.  */
1475   if (TARGET_BIG_ENDIAN)
1476     return "%,fswap %0 = %F2, %F1";
1477   else
1478     return "%,fswap %0 = %F1, %F2";
1479 }
1480   [(set_attr "itanium_class" "fmisc")])
1481
1482 (define_insn "vec_interleave_highv2sf"
1483   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1484         (vec_select:V2SF
1485           (vec_concat:V4SF
1486             (match_operand:V2SF 1 "fr_reg_or_0_operand" "fU")
1487             (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU"))
1488           (parallel [(const_int 1) (const_int 3)])))]
1489   ""
1490 {
1491   /* Recall that vector elements are numbered in memory order.  */
1492   if (TARGET_BIG_ENDIAN)
1493     return "%,fmix.l %0 = %F1, %F2";
1494   else
1495     return "%,fmix.l %0 = %F2, %F1";
1496 }
1497   [(set_attr "itanium_class" "fmisc")])
1498
1499 (define_insn "vec_interleave_lowv2sf"
1500   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1501         (vec_select:V2SF
1502           (vec_concat:V4SF
1503             (match_operand:V2SF 1 "fr_reg_or_0_operand" "fU")
1504             (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU"))
1505           (parallel [(const_int 0) (const_int 2)])))]
1506   ""
1507 {
1508   /* Recall that vector elements are numbered in memory order.  */
1509   if (TARGET_BIG_ENDIAN)
1510     return "%,fmix.r %0 = %F1, %F2";
1511   else
1512     return "%,fmix.r %0 = %F2, %F1";
1513 }
1514   [(set_attr "itanium_class" "fmisc")])
1515
1516 (define_insn "fmix_lr"
1517   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
1518         (vec_select:V2SF
1519           (vec_concat:V4SF
1520             (match_operand:V2SF 1 "fr_reg_or_0_operand" "fU")
1521             (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU"))
1522           (parallel [(const_int 0) (const_int 3)])))]
1523   ""
1524 {
1525   /* Recall that vector elements are numbered in memory order.  */
1526   if (TARGET_BIG_ENDIAN)
1527     return "%,fmix.lr %0 = %F1, %F2";
1528   else
1529     return "%,fmix.lr %0 = %F2, %F1";
1530 }
1531   [(set_attr "itanium_class" "fmisc")])
1532
1533 (define_expand "vec_extract_evenv2sf"
1534   [(match_operand:V2SF 0 "gr_register_operand" "")
1535    (match_operand:V2SF 1 "gr_register_operand" "")
1536    (match_operand:V2SF 2 "gr_register_operand" "")]
1537   ""
1538 {
1539   if (TARGET_BIG_ENDIAN)
1540     emit_insn (gen_vec_interleave_highv2sf (operands[0], operands[1],
1541                                             operands[2]));
1542   else
1543     emit_insn (gen_vec_interleave_lowv2sf (operands[0], operands[1],
1544                                            operands[2]));
1545   DONE;
1546 })
1547
1548 (define_expand "vec_extract_oddv2sf"
1549   [(match_operand:V2SF 0 "gr_register_operand" "")
1550    (match_operand:V2SF 1 "gr_register_operand" "")
1551    (match_operand:V2SF 2 "gr_register_operand" "")]
1552   ""
1553 {
1554   if (TARGET_BIG_ENDIAN)
1555     emit_insn (gen_vec_interleave_lowv2sf (operands[0], operands[1],
1556                                            operands[2]));
1557   else
1558     emit_insn (gen_vec_interleave_highv2sf (operands[0], operands[1],
1559                                             operands[2]));
1560   DONE;
1561 })
1562
1563 (define_expand "vec_setv2sf"
1564   [(match_operand:V2SF 0 "fr_register_operand" "")
1565    (match_operand:SF 1 "fr_register_operand" "")
1566    (match_operand 2 "const_int_operand" "")]
1567   ""
1568 {
1569   rtx op0 = operands[0];
1570   rtx tmp = gen_reg_rtx (V2SFmode);
1571
1572   emit_insn (gen_fpack (tmp, operands[1], CONST0_RTX (SFmode)));
1573
1574   switch (INTVAL (operands[2]))
1575     {
1576     case 0:
1577       emit_insn (gen_fmix_lr (op0, tmp, op0));
1578       break;
1579     case 1:
1580       emit_insn (gen_vec_interleave_lowv2sf (op0, op0, tmp));
1581       break;
1582     default:
1583       gcc_unreachable ();
1584     }
1585   DONE;
1586 })
1587
1588 (define_insn_and_split "*vec_extractv2sf_0_le"
1589   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,f,m")
1590         (unspec:SF [(match_operand:V2SF 1 "nonimmediate_operand" "rfm,rm,r")
1591                     (const_int 0)]
1592                    UNSPEC_VECT_EXTR))]
1593   "!TARGET_BIG_ENDIAN"
1594   "#"
1595   "reload_completed"
1596   [(set (match_dup 0) (match_dup 1))]
1597 {
1598   if (REG_P (operands[1]) && FR_REGNO_P (REGNO (operands[1])))
1599     operands[0] = gen_rtx_REG (V2SFmode, REGNO (operands[0]));
1600   else if (MEM_P (operands[1]))
1601     operands[1] = adjust_address (operands[1], SFmode, 0);
1602   else
1603     operands[1] = gen_rtx_REG (SFmode, REGNO (operands[1]));
1604 })
1605
1606 (define_insn_and_split "*vec_extractv2sf_0_be"
1607   [(set (match_operand:SF 0 "register_operand" "=rf,r")
1608         (unspec:SF [(match_operand:V2SF 1 "nonimmediate_operand" "m,r")
1609                     (const_int 0)]
1610                    UNSPEC_VECT_EXTR))]
1611   "TARGET_BIG_ENDIAN"
1612   "#"
1613   "reload_completed"
1614   [(set (match_dup 0) (match_dup 1))]
1615 {
1616   if (MEM_P (operands[1]))
1617     operands[1] = adjust_address (operands[1], SFmode, 0);
1618   else
1619     {
1620       emit_insn (gen_lshrdi3 (operands[0], operands[1], GEN_INT (32)));
1621       DONE;
1622     }
1623 })
1624
1625 (define_insn_and_split "*vec_extractv2sf_1_le"
1626   [(set (match_operand:SF 0 "register_operand" "=r")
1627         (unspec:SF [(match_operand:V2SF 1 "register_operand" "r")
1628                     (const_int 1)]
1629                    UNSPEC_VECT_EXTR))]
1630   "!TARGET_BIG_ENDIAN"
1631   "#"
1632   "&& reload_completed"
1633   [(const_int 0)]
1634 {
1635   operands[0] = gen_rtx_REG (DImode, REGNO (operands[0]));
1636   operands[1] = gen_rtx_REG (DImode, REGNO (operands[1]));
1637   emit_insn (gen_lshrdi3 (operands[0], operands[1], GEN_INT (32)));
1638   DONE;
1639 })
1640
1641 (define_insn_and_split "*vec_extractv2sf_1_be"
1642   [(set (match_operand:SF 0 "register_operand" "=rf")
1643         (unspec:SF [(match_operand:V2SF 1 "register_operand" "r")
1644                     (const_int 1)]
1645                    UNSPEC_VECT_EXTR))]
1646   "TARGET_BIG_ENDIAN"
1647   "#"
1648   "&& reload_completed"
1649   [(set (match_dup 0) (match_dup 1))]
1650 {
1651   operands[1] = gen_rtx_REG (SFmode, REGNO (operands[1]));
1652 })
1653
1654 (define_expand "vec_extractv2sf"
1655   [(set (match_operand:SF 0 "register_operand" "")
1656         (unspec:SF [(match_operand:V2SF 1 "register_operand" "")
1657                     (match_operand:DI 2 "const_int_operand" "")]
1658                    UNSPEC_VECT_EXTR))]
1659   ""
1660   "")
1661
1662 (define_expand "vec_unpacku_lo_<mode>"
1663   [(match_operand:<vecwider> 0 "register_operand" "")
1664    (match_operand:VECINT12   1 "register_operand" "")]
1665   ""
1666 {
1667   ia64_expand_unpack (operands, true, false);
1668   DONE;
1669 })
1670
1671 (define_expand "vec_unpacku_hi_<mode>"
1672   [(match_operand:<vecwider> 0 "register_operand" "")
1673    (match_operand:VECINT12   1 "register_operand" "")]
1674   ""
1675 {
1676   ia64_expand_unpack (operands, true, true);
1677   DONE;
1678 })
1679
1680 (define_expand "vec_unpacks_lo_<mode>"
1681   [(match_operand:<vecwider> 0 "register_operand" "")
1682    (match_operand:VECINT12   1 "register_operand" "")]
1683   ""
1684 {
1685   ia64_expand_unpack (operands, false, false);
1686   DONE;
1687 })
1688
1689 (define_expand "vec_unpacks_hi_<mode>"
1690   [(match_operand:<vecwider> 0 "register_operand" "")
1691    (match_operand:VECINT12   1 "register_operand" "")]
1692   ""
1693 {
1694   ia64_expand_unpack (operands, false, true);
1695   DONE;
1696 })
1697
1698 (define_expand "vec_pack_trunc_v4hi"
1699   [(match_operand:V8QI 0 "gr_register_operand" "")
1700    (match_operand:V4HI 1 "gr_register_operand" "")
1701    (match_operand:V4HI 2 "gr_register_operand" "")]
1702   ""
1703 {
1704   rtx op1 = gen_lowpart (V8QImode, operands[1]);
1705   rtx op2 = gen_lowpart (V8QImode, operands[2]);
1706   if (TARGET_BIG_ENDIAN)
1707     emit_insn (gen_vec_extract_oddv8qi (operands[0], op1, op2));
1708   else
1709     emit_insn (gen_vec_extract_evenv8qi (operands[0], op1, op2));
1710   DONE;
1711 })
1712
1713 (define_expand "vec_pack_trunc_v2si"
1714   [(match_operand:V4HI 0 "gr_register_operand" "")
1715    (match_operand:V2SI 1 "gr_register_operand" "")
1716    (match_operand:V2SI 2 "gr_register_operand" "")]
1717   ""
1718 {
1719   rtx op1 = gen_lowpart (V4HImode, operands[1]);
1720   rtx op2 = gen_lowpart (V4HImode, operands[2]);
1721   if (TARGET_BIG_ENDIAN)
1722     emit_insn (gen_vec_extract_oddv4hi (operands[0], op1, op2));
1723   else
1724     emit_insn (gen_vec_extract_evenv4hi (operands[0], op1, op2));
1725   DONE;
1726 })
1727
1728 ;; Missing operations
1729 ;; fprcpa
1730 ;; fpsqrta