OSDN Git Service

* config/ia64/ia64.c (ia64_encode_addr_area): Use gcc_assert and
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / vect.md
1 ;; IA-64 machine description for vector operations.
2 ;; Copyright (C) 2004
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 2, 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 COPYING.  If not, write to
18 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
19 ;; Boston, MA 02111-1307, USA.
20
21
22 ;; Integer vector operations
23
24 (define_mode_macro VECINT [V8QI V4HI V2SI])
25 (define_mode_macro VECINT12 [V8QI V4HI])
26 (define_mode_macro VECINT24 [V4HI V2SI])
27 (define_mode_attr vecsize [(V8QI "1") (V4HI "2") (V2SI "4")])
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 r1, l1, r2, l2, rm, lm;
176
177   r1 = gen_reg_rtx (V4HImode);
178   l1 = gen_reg_rtx (V4HImode);
179   r2 = gen_reg_rtx (V4HImode);
180   l2 = gen_reg_rtx (V4HImode);
181
182   /* Zero-extend the QImode elements into two words of HImode elements
183      by interleaving them with zero bytes.  */
184   emit_insn (gen_mix1_r (gen_lowpart (V8QImode, r1),
185                          operands[1], CONST0_RTX (V8QImode)));
186   emit_insn (gen_mix1_r (gen_lowpart (V8QImode, r2),
187                          operands[2], CONST0_RTX (V8QImode)));
188   emit_insn (gen_mix1_l (gen_lowpart (V8QImode, l1),
189                          operands[1], CONST0_RTX (V8QImode)));
190   emit_insn (gen_mix1_l (gen_lowpart (V8QImode, l2),
191                          operands[2], CONST0_RTX (V8QImode)));
192
193   /* Multiply.  */
194   rm = gen_reg_rtx (V4HImode);
195   lm = gen_reg_rtx (V4HImode);
196   emit_insn (gen_mulv4hi3 (rm, r1, r2));
197   emit_insn (gen_mulv4hi3 (lm, l1, l2));
198
199   /* Zap the high order bytes of the HImode elements by overwriting those
200      in one part with the low order bytes of the other.  */
201   emit_insn (gen_mix1_r (operands[0],
202                          gen_lowpart (V8QImode, rm),
203                          gen_lowpart (V8QImode, lm)));
204   DONE;
205 })
206
207 (define_insn "mulv4hi3"
208   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
209         (mult:V4HI (match_operand:V4HI 1 "gr_register_operand" "r")
210                    (match_operand:V4HI 2 "gr_register_operand" "r")))]
211   ""
212   "pmpyshr2 %0 = %1, %2, 0"
213   [(set_attr "itanium_class" "mmmul")])
214
215 (define_expand "umax<mode>3"
216   [(set (match_operand:VECINT 0 "gr_register_operand" "")
217         (smax:VECINT (match_operand:VECINT 1 "gr_register_operand" "")
218                      (match_operand:VECINT 2 "gr_register_operand" "")))]
219   ""
220 {
221   if (ia64_expand_vecint_minmax (UMAX, <MODE>mode, operands))
222     DONE;
223 })
224
225 (define_expand "smax<mode>3"
226   [(set (match_operand:VECINT 0 "gr_register_operand" "")
227         (smax:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
228                      (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
229   ""
230 {
231   if (ia64_expand_vecint_minmax (SMAX, <MODE>mode, operands))
232     DONE;
233 })
234
235 (define_expand "umin<mode>3"
236   [(set (match_operand:VECINT 0 "gr_register_operand" "")
237         (umin:VECINT (match_operand:VECINT 1 "gr_register_operand" "")
238                      (match_operand:VECINT 2 "gr_register_operand" "")))]
239   ""
240 {
241   if (ia64_expand_vecint_minmax (UMIN, <MODE>mode, operands))
242     DONE;
243 })
244
245 (define_expand "smin<mode>3"
246   [(set (match_operand:VECINT 0 "gr_register_operand" "")
247         (smin:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
248                      (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
249   ""
250 {
251   if (ia64_expand_vecint_minmax (SMIN, <MODE>mode, operands))
252     DONE;
253 })
254
255 (define_insn "*umaxv8qi3"
256   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
257         (umax:V8QI (match_operand:V8QI 1 "gr_register_operand" "r")
258                    (match_operand:V8QI 2 "gr_register_operand" "r")))]
259   ""
260   "pmax1.u %0 = %1, %2"
261   [(set_attr "itanium_class" "mmshf")])
262
263 (define_insn "*smaxv4hi3"
264   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
265         (smax:V4HI (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
266                    (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU")))]
267   ""
268   "pmax2 %0 = %r1, %r2"
269   [(set_attr "itanium_class" "mmshf")])
270
271 (define_insn "*uminv8qi3"
272   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
273         (umin:V8QI (match_operand:V8QI 1 "gr_register_operand" "r")
274                    (match_operand:V8QI 2 "gr_register_operand" "r")))]
275   ""
276   "pmin1.u %0 = %1, %2"
277   [(set_attr "itanium_class" "mmshf")])
278
279 (define_insn "*sminv4hi3"
280   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
281         (smin:V4HI (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
282                    (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU")))]
283   ""
284   "pmin2 %0 = %r1, %r2"
285   [(set_attr "itanium_class" "mmshf")])
286
287 (define_insn "ashl<mode>3"
288   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
289         (ashift:VECINT24
290           (match_operand:VECINT24 1 "gr_register_operand" "r")
291           (match_operand:VECINT24 2 "gr_reg_or_5bit_operand" "rn")))]
292   ""
293   "pshl<vecsize> %0 = %1, %2"
294   [(set_attr "itanium_class" "mmshf")])
295
296 (define_insn "ashr<mode>3"
297   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
298         (ashiftrt:VECINT24
299           (match_operand:VECINT24 1 "gr_register_operand" "r")
300           (match_operand:VECINT24 2 "gr_reg_or_5bit_operand" "rn")))]
301   ""
302   "pshr<vecsize> %0 = %1, %2"
303   [(set_attr "itanium_class" "mmshf")])
304
305 (define_insn "lshr<mode>3"
306   [(set (match_operand:VECINT24 0 "gr_register_operand" "=r")
307         (lshiftrt:VECINT24
308           (match_operand:VECINT24 1 "gr_register_operand" "r")
309           (match_operand:VECINT24 2 "gr_reg_or_5bit_operand" "rn")))]
310   ""
311   "pshr<vecsize>.u %0 = %1, %2"
312   [(set_attr "itanium_class" "mmshf")])
313
314 (define_expand "vcond<mode>"
315   [(set (match_operand:VECINT 0 "gr_register_operand" "")
316         (if_then_else:VECINT
317           (match_operator 3 "" 
318             [(match_operand:VECINT 4 "gr_reg_or_0_operand" "")
319              (match_operand:VECINT 5 "gr_reg_or_0_operand" "")])
320           (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
321           (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
322   ""
323 {
324   ia64_expand_vecint_cmov (operands);
325   DONE;
326 })
327
328 (define_expand "vcondu<mode>"
329   [(set (match_operand:VECINT 0 "gr_register_operand" "")
330         (if_then_else:VECINT
331           (match_operator 3 "" 
332             [(match_operand:VECINT 4 "gr_reg_or_0_operand" "")
333              (match_operand:VECINT 5 "gr_reg_or_0_operand" "")])
334           (match_operand:VECINT 1 "gr_reg_or_0_operand" "")
335           (match_operand:VECINT 2 "gr_reg_or_0_operand" "")))]
336   ""
337 {
338   ia64_expand_vecint_cmov (operands);
339   DONE;
340 })
341
342 (define_insn "*cmpeq_<mode>"
343   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
344         (eq:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "rU")
345                    (match_operand:VECINT 2 "gr_reg_or_0_operand" "rU")))]
346   ""
347   "pcmp<vecsize>.eq %0 = %r1, %r2"
348   [(set_attr "itanium_class" "mmalua")])
349
350 (define_insn "*cmpgt_<mode>"
351   [(set (match_operand:VECINT 0 "gr_register_operand" "=r")
352         (gt:VECINT (match_operand:VECINT 1 "gr_reg_or_0_operand" "rU")
353                    (match_operand:VECINT 2 "gr_reg_or_0_operand" "rU")))]
354   ""
355   "pcmp<vecsize>.gt %0 = %r1, %r2"
356   [(set_attr "itanium_class" "mmalua")])
357
358 (define_insn "pack2_sss"
359   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
360         (vec_concat:V8QI
361           (ss_truncate:V4QI
362             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU"))
363           (ss_truncate:V4QI
364             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))))]
365   ""
366   "pack2.sss %0 = %r1, %r2"
367   [(set_attr "itanium_class" "mmshf")])
368
369 (define_insn "*pack2_uss"
370   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
371         (vec_concat:V8QI
372           (us_truncate:V4QI
373             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU"))
374           (us_truncate:V4QI
375             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))))]
376   ""
377   "pack2.uss %0 = %r1, %r2"
378   [(set_attr "itanium_class" "mmshf")])
379
380 (define_insn "pack4_sss"
381   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
382         (vec_concat:V4HI
383           (ss_truncate:V2HI
384             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU"))
385           (ss_truncate:V2HI
386             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))))]
387   ""
388   "pack4.sss %0 = %r1, %r2"
389   [(set_attr "itanium_class" "mmshf")])
390
391 (define_insn "unpack1_l"
392   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
393         (vec_select:V8QI
394           (vec_concat:V16QI
395             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
396             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
397           (parallel [(const_int 0)
398                      (const_int 1)
399                      (const_int 2)
400                      (const_int 3)
401                      (const_int 8)
402                      (const_int 9)
403                      (const_int 10)
404                      (const_int 11)])))]
405   ""
406   "unpack1.l %0 = %r2, %r1"
407   [(set_attr "itanium_class" "mmshf")])
408
409 (define_insn "unpack1_h"
410   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
411         (vec_select:V8QI
412           (vec_concat:V16QI
413             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
414             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
415           (parallel [(const_int 4)
416                      (const_int 5)
417                      (const_int 6)
418                      (const_int 7)
419                      (const_int 12)
420                      (const_int 13)
421                      (const_int 14)
422                      (const_int 15)])))]
423   ""
424   "unpack1.h %0 = %r2, %r1"
425   [(set_attr "itanium_class" "mmshf")])
426
427 (define_insn "mix1_r"
428   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
429         (vec_select:V8QI
430           (vec_concat:V16QI
431             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
432             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
433           (parallel [(const_int 0)
434                      (const_int 8)
435                      (const_int 2)
436                      (const_int 10)
437                      (const_int 4)
438                      (const_int 12)
439                      (const_int 6)
440                      (const_int 14)])))]
441   ""
442   "mix1.r %0 = %r2, %r1"
443   [(set_attr "itanium_class" "mmshf")])
444
445 (define_insn "mix1_l"
446   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
447         (vec_select:V8QI
448           (vec_concat:V16QI
449             (match_operand:V8QI 1 "gr_reg_or_0_operand" "rU")
450             (match_operand:V8QI 2 "gr_reg_or_0_operand" "rU"))
451           (parallel [(const_int 1)
452                      (const_int 9)
453                      (const_int 3)
454                      (const_int 11)
455                      (const_int 5)
456                      (const_int 13)
457                      (const_int 7)
458                      (const_int 15)])))]
459   ""
460   "mix1.l %0 = %r2, %r1"
461   [(set_attr "itanium_class" "mmshf")])
462
463 (define_insn "*mux1_rev"
464   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
465         (vec_select:V8QI
466           (match_operand:V8QI 1 "gr_register_operand" "r")
467           (parallel [(const_int 7)
468                      (const_int 6)
469                      (const_int 5)
470                      (const_int 4)
471                      (const_int 3)
472                      (const_int 2)
473                      (const_int 1)
474                      (const_int 0)])))]
475   ""
476   "mux1 %0 = %1, @rev"
477   [(set_attr "itanium_class" "mmshf")])
478
479 (define_insn "*mux1_mix"
480   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
481         (vec_select:V8QI
482           (match_operand:V8QI 1 "gr_register_operand" "r")
483           (parallel [(const_int 0)
484                      (const_int 4)
485                      (const_int 2)
486                      (const_int 6)
487                      (const_int 1)
488                      (const_int 5)
489                      (const_int 3)
490                      (const_int 7)])))]
491   ""
492   "mux1 %0 = %1, @mix"
493   [(set_attr "itanium_class" "mmshf")])
494
495 (define_insn "*mux1_shuf"
496   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
497         (vec_select:V8QI
498           (match_operand:V8QI 1 "gr_register_operand" "r")
499           (parallel [(const_int 0)
500                      (const_int 4)
501                      (const_int 1)
502                      (const_int 5)
503                      (const_int 2)
504                      (const_int 6)
505                      (const_int 3)
506                      (const_int 7)])))]
507   ""
508   "mux1 %0 = %1, @shuf"
509   [(set_attr "itanium_class" "mmshf")])
510
511 (define_insn "*mux1_alt"
512   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
513         (vec_select:V8QI
514           (match_operand:V8QI 1 "gr_register_operand" "r")
515           (parallel [(const_int 0)
516                      (const_int 2)
517                      (const_int 4)
518                      (const_int 6)
519                      (const_int 1)
520                      (const_int 3)
521                      (const_int 5)
522                      (const_int 7)])))]
523   ""
524   "mux1 %0 = %1, @alt"
525   [(set_attr "itanium_class" "mmshf")])
526
527 (define_insn "*mux1_brcst_v8qi"
528   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
529         (vec_select:V8QI
530           (match_operand:V8QI 1 "gr_register_operand" "r")
531           (parallel [(const_int 0)
532                      (const_int 0)
533                      (const_int 0)
534                      (const_int 0)
535                      (const_int 0)
536                      (const_int 0)
537                      (const_int 0)
538                      (const_int 0)])))]
539   ""
540   "mux1 %0 = %1, @brcst"
541   [(set_attr "itanium_class" "mmshf")])
542
543 (define_insn "*mux1_brcst_qi"
544   [(set (match_operand:V8QI 0 "gr_register_operand" "=r")
545         (vec_duplicate:V8QI
546           (match_operand:QI 1 "gr_register_operand" "r")))]
547   ""
548   "mux1 %0 = %1, @brcst"
549   [(set_attr "itanium_class" "mmshf")])
550
551 (define_insn "unpack2_l"
552   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
553         (vec_select:V4HI
554           (vec_concat:V8HI
555             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
556             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
557           (parallel [(const_int 0)
558                      (const_int 4)
559                      (const_int 1)
560                      (const_int 5)])))]
561   ""
562   "unpack2.l %0 = %r2, %r1"
563   [(set_attr "itanium_class" "mmshf")])
564
565 (define_insn "unpack2_h"
566   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
567         (vec_select:V4HI
568           (vec_concat:V8HI
569             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
570             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
571           (parallel [(const_int 2)
572                      (const_int 6)
573                      (const_int 3)
574                      (const_int 7)])))]
575   ""
576   "unpack2.h %0 = %r2, %r1"
577   [(set_attr "itanium_class" "mmshf")])
578
579 (define_insn "*mix2_r"
580   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
581         (vec_select:V4HI
582           (vec_concat:V8HI
583             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
584             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
585           (parallel [(const_int 0)
586                      (const_int 4)
587                      (const_int 2)
588                      (const_int 6)])))]
589   ""
590   "mix2.r %0 = %r2, %r1"
591   [(set_attr "itanium_class" "mmshf")])
592
593 (define_insn "*mix2_l"
594   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
595         (vec_select:V4HI
596           (vec_concat:V8HI
597             (match_operand:V4HI 1 "gr_reg_or_0_operand" "rU")
598             (match_operand:V4HI 2 "gr_reg_or_0_operand" "rU"))
599           (parallel [(const_int 1)
600                      (const_int 5)
601                      (const_int 3)
602                      (const_int 7)])))]
603   ""
604   "mix2.l %0 = %r2, %r1"
605   [(set_attr "itanium_class" "mmshf")])
606
607 (define_insn "*mux2"
608   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
609         (vec_select:V4HI
610           (match_operand:V4HI 1 "gr_register_operand" "r")
611           (parallel [(match_operand 2 "const_int_2bit_operand" "")
612                      (match_operand 3 "const_int_2bit_operand" "")
613                      (match_operand 4 "const_int_2bit_operand" "")
614                      (match_operand 5 "const_int_2bit_operand" "")])))]
615   ""
616 {
617   int mask;
618   mask  = INTVAL (operands[2]);
619   mask |= INTVAL (operands[3]) << 2;
620   mask |= INTVAL (operands[4]) << 4;
621   mask |= INTVAL (operands[5]) << 6;
622   operands[2] = GEN_INT (mask);
623   return "%,mux2 %0 = %1, %2";
624 }
625   [(set_attr "itanium_class" "mmshf")])
626
627 (define_insn "*mux2_brcst_hi"
628   [(set (match_operand:V4HI 0 "gr_register_operand" "=r")
629         (vec_duplicate:V4HI
630           (match_operand:HI 1 "gr_register_operand" "r")))]
631   ""
632   "mux2 %0 = %1, 0"
633   [(set_attr "itanium_class" "mmshf")])
634
635 ;; Note that mix4.r performs the exact same operation.
636 (define_insn "*unpack4_l"
637   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
638         (vec_select:V2SI
639           (vec_concat:V4SI
640             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU")
641             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))
642           (parallel [(const_int 0)
643                      (const_int 2)])))]
644   ""
645   "unpack4.l %0 = %r2, %r1"
646   [(set_attr "itanium_class" "mmshf")])
647
648 ;; Note that mix4.l performs the exact same operation.
649 (define_insn "*unpack4_h"
650   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
651         (vec_select:V2SI
652           (vec_concat:V4SI
653             (match_operand:V2SI 1 "gr_reg_or_0_operand" "rU")
654             (match_operand:V2SI 2 "gr_reg_or_0_operand" "rU"))
655           (parallel [(const_int 1)
656                      (const_int 3)])))]
657   ""
658   "unpack4.h %0 = %r2, %r1"
659   [(set_attr "itanium_class" "mmshf")])
660
661 (define_expand "vec_initv2si"
662   [(match_operand:V2SF 0 "gr_register_operand" "")
663    (match_operand 1 "" "")]
664   ""
665 {
666   rtx op1 = XVECEXP (operands[1], 0, 0);
667   rtx op2 = XVECEXP (operands[1], 0, 1);
668   rtx x;
669
670   if (GET_CODE (op1) == CONST_INT && GET_CODE (op2) == CONST_INT)
671     {
672       x = gen_rtx_CONST_VECTOR (V2SImode, XVEC (operands[1], 0));
673       emit_move_insn (operands[0], x);
674       DONE;
675     }
676
677   if (!gr_reg_or_0_operand (op1, SImode))
678     op1 = force_reg (SImode, op1);
679   if (!gr_reg_or_0_operand (op2, SImode))
680     op2 = force_reg (SImode, op2);
681
682   x = gen_rtx_VEC_CONCAT (V2SImode, op1, op2);
683   emit_insn (gen_rtx_SET (VOIDmode, operands[0], x));
684   DONE;
685 })
686
687 (define_insn "*vecinit_v2si"
688   [(set (match_operand:V2SI 0 "gr_register_operand" "=r")
689         (vec_concat:V2SI
690           (match_operand:SI 1 "gr_reg_or_0_operand" "rO")
691           (match_operand:SI 2 "gr_reg_or_0_operand" "rO")))]
692   ""
693   "unpack4.l %0 = %r2, %r1"
694   [(set_attr "itanium_class" "mmshf")])
695
696 ;; Missing operations
697 ;; padd.uus
698 ;; pavg
699 ;; pavgsub
700 ;; pmpy
701 ;; pmpyshr, general form
702 ;; psad
703 ;; pshladd
704 ;; pshradd
705 ;; psub.uus
706 ;; vec_set<mode>
707 ;; vec_extract<mode>
708 ;; vec_init<mode>
709 \f
710 ;; Floating point vector operations
711
712 (define_expand "movv2sf"
713   [(set (match_operand:V2SF 0 "general_operand" "")
714         (match_operand:V2SF 1 "general_operand" ""))]
715   ""
716 {
717   rtx op1 = ia64_expand_move (operands[0], operands[1]);
718   if (!op1)
719     DONE;
720   operands[1] = op1;
721 })
722
723 (define_insn "*movv2sf_internal"
724   [(set (match_operand:V2SF 0 "destination_operand"
725                                         "=f,f,f,Q,*r ,*r,*r,*r,m ,f ,*r")
726         (match_operand:V2SF 1 "move_operand"
727                                         "fU,Y,Q,f,U*r,W ,i ,m ,*r,*r,f "))]
728   "ia64_move_ok (operands[0], operands[1])"
729 {
730   static const char * const alt[] = {
731     "%,mov %0 = %F1",
732     "%,fpack %0 = %F2, %F1",
733     "%,ldf8 %0 = %1%P1",
734     "%,stf8 %0 = %1%P0",
735     "%,mov %0 = %r1",
736     "%,addl %0 = %v1, r0",
737     "%,movl %0 = %v1",
738     "%,ld8%O1 %0 = %1%P1",
739     "%,st8%Q0 %0 = %r1%P0",
740     "%,setf.sig %0 = %1",
741     "%,getf.sig %0 = %1"
742   };
743
744   if (which_alternative == 1)
745     {
746       operands[2] = XVECEXP (operands[1], 0, 1);
747       operands[1] = XVECEXP (operands[1], 0, 0);
748     }
749
750   return alt[which_alternative];
751 }
752   [(set_attr "itanium_class" "fmisc,fmisc,fld,stf,ialu,ialu,long_i,ld,st,tofr,frfr")])
753
754 (define_insn "absv2sf2"
755   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
756         (abs:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")))]
757   ""
758   "fpabs %0 = %1"
759   [(set_attr "itanium_class" "fmisc")])
760
761 (define_insn "negv2sf2"
762   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
763         (neg:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")))]
764   ""
765   "fpneg %0 = %1"
766   [(set_attr "itanium_class" "fmisc")])
767
768 (define_insn "*negabsv2sf2"
769   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
770         (neg:V2SF
771           (abs:V2SF (match_operand:V2SF 1 "fr_register_operand" "f"))))]
772   ""
773   "fpnegabs %0 = %1"
774   [(set_attr "itanium_class" "fmisc")])
775
776 (define_expand "addv2sf3"
777   [(set (match_operand:V2SF 0 "fr_register_operand" "")
778         (plus:V2SF
779           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "")
780                      (match_dup 3))
781           (match_operand:V2SF 2 "fr_register_operand" "")))]
782   ""
783 {
784   rtvec v = gen_rtvec (2, CONST1_RTX (SFmode), CONST1_RTX (SFmode));
785   operands[3] = force_reg (V2SFmode, gen_rtx_CONST_VECTOR (V2SFmode, v));
786 })
787
788 (define_expand "subv2sf3"
789   [(set (match_operand:V2SF 0 "fr_register_operand" "")
790         (minus:V2SF
791           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "")
792                      (match_dup 3))
793           (match_operand:V2SF 2 "fr_register_operand" "")))]
794   ""
795 {
796   rtvec v = gen_rtvec (2, CONST1_RTX (SFmode), CONST1_RTX (SFmode));
797   operands[3] = force_reg (V2SFmode, gen_rtx_CONST_VECTOR (V2SFmode, v));
798 })
799
800 (define_insn "mulv2sf3"
801   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
802         (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
803                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
804   ""
805   "fpmpy %0 = %1, %2"
806   [(set_attr "itanium_class" "fmac")])
807
808 (define_insn "*fpma"
809   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
810         (plus:V2SF
811           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
812                      (match_operand:V2SF 2 "fr_register_operand" "f"))
813           (match_operand:V2SF 3 "fr_register_operand" "f")))]
814   ""
815   "fpma %0 = %1, %2, %3"
816   [(set_attr "itanium_class" "fmac")])
817
818 (define_insn "*fpms"
819   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
820         (minus:V2SF
821           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
822                      (match_operand:V2SF 2 "fr_register_operand" "f"))
823           (match_operand:V2SF 3 "fr_register_operand" "f")))]
824   ""
825   "fpms %0 = %1, %2, %3"
826   [(set_attr "itanium_class" "fmac")])
827
828 (define_insn "*fpnmpy"
829   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
830         (neg:V2SF
831           (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
832                      (match_operand:V2SF 2 "fr_register_operand" "f"))))]
833   ""
834   "fpnmpy %0 = %1, %2"
835   [(set_attr "itanium_class" "fmac")])
836
837 (define_insn "*fpnma"
838   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
839         (plus:V2SF
840           (neg:V2SF
841             (mult:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
842                        (match_operand:V2SF 2 "fr_register_operand" "f")))
843           (match_operand:V2SF 3 "fr_register_operand" "f")))]
844   ""
845   "fpnma %0 = %1, %2, %3"
846   [(set_attr "itanium_class" "fmac")])
847
848 (define_insn "smaxv2sf2"
849   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
850         (smax:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
851                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
852   ""
853   "fpmax %0 = %1, %2"
854   [(set_attr "itanium_class" "fmisc")])
855
856 (define_insn "sminv2sf2"
857   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
858         (smin:V2SF (match_operand:V2SF 1 "fr_register_operand" "f")
859                    (match_operand:V2SF 2 "fr_register_operand" "f")))]
860   ""
861   "fpmin %0 = %1, %2"
862   [(set_attr "itanium_class" "fmisc")])
863
864 (define_expand "vcondv2sf"
865   [(set (match_operand:V2SF 0 "fr_register_operand" "")
866         (if_then_else:V2SF
867           (match_operator 3 "" 
868             [(match_operand:V2SF 4 "fr_reg_or_0_operand" "")
869              (match_operand:V2SF 5 "fr_reg_or_0_operand" "")])
870           (match_operand:V2SF 1 "fr_reg_or_0_operand" "")
871           (match_operand:V2SF 2 "fr_reg_or_0_operand" "")))]
872   ""
873 {
874   rtx x, cmp;
875
876   PUT_MODE (operands[3], V2SFmode);
877   switch (GET_CODE (operands[3]))
878     {
879     case EQ:
880     case NE:
881     case LT:
882     case LE:
883     case UNORDERED:
884     case ORDERED:
885       break;
886
887     case GT:
888     case GE:
889       x = XEXP (operands[3], 0);
890       XEXP (operands[3], 0) = XEXP (operands[3], 1);
891       XEXP (operands[3], 1) = x;
892       PUT_CODE (operands[3], swap_condition (GET_CODE (operands[3])));
893       break;
894
895     default:
896       gcc_unreachable ();
897     }
898
899   cmp = gen_reg_rtx (V2SFmode);
900   emit_insn (gen_rtx_SET (VOIDmode, cmp, operands[3]));
901
902   x = gen_rtx_IF_THEN_ELSE (V2SFmode, cmp, operands[1], operands[2]);
903   emit_insn (gen_rtx_SET (VOIDmode, operands[0], x));
904   DONE;
905 })
906
907 (define_insn "*fpcmp"
908   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
909         (if_then_else:V2SF
910           (match_operand:V2SF 1 "fr_register_operand" "f")
911           (match_operand:V2SF 2 "fr_reg_or_0_operand" "fU")
912           (match_operand:V2SF 3 "fr_reg_or_0_operand" "fU")))]
913   ""
914   "fselect %0 = %2, %3, %1"
915   [(set_attr "itanium_class" "fmisc")])
916
917 (define_expand "vec_initv2sf"
918   [(match_operand:V2SF 0 "fr_register_operand" "")
919    (match_operand 1 "" "")]
920   ""
921 {
922   rtx op1 = XVECEXP (operands[1], 0, 0);
923   rtx op2 = XVECEXP (operands[1], 0, 1);
924   rtx x;
925
926   if (GET_CODE (op1) == CONST_DOUBLE && GET_CODE (op2) == CONST_DOUBLE)
927     {
928       x = gen_rtx_CONST_VECTOR (V2SFmode, XVEC (operands[1], 0));
929       emit_move_insn (operands[0], x);
930       DONE;
931     }
932
933   if (!fr_reg_or_fp01_operand (op1, SFmode))
934     op1 = force_reg (SFmode, op1);
935   if (!fr_reg_or_fp01_operand (op2, SFmode))
936     op2 = force_reg (SFmode, op2);
937
938   x = gen_rtx_VEC_CONCAT (V2SFmode, op1, op2);
939   emit_insn (gen_rtx_SET (VOIDmode, operands[0], x));
940   DONE;
941 })
942
943 (define_insn "*fpack"
944   [(set (match_operand:V2SF 0 "fr_register_operand" "=f")
945         (vec_concat:V2SF
946           (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
947           (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
948   ""
949   "fpack %0 = %F2, %F1"
950   [(set_attr "itanium_class" "fmisc")])
951
952 ;; Missing operations
953 ;; fprcpa
954 ;; fpsqrta
955 ;; vec_setv2sf
956 ;; vec_extractv2sf