OSDN Git Service

2011-09-02 Richard Guenther <rguenther@suse.de>
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / vector.md
1 ;; Expander definitions for vector support between altivec & vsx.  No
2 ;; instructions are in this file, this file provides the generic vector
3 ;; expander, and the actual vector instructions will be in altivec.md and
4 ;; vsx.md
5
6 ;; Copyright (C) 2009, 2010, 2011
7 ;; Free Software Foundation, Inc.
8 ;; Contributed by Michael Meissner <meissner@linux.vnet.ibm.com>
9
10 ;; This file is part of GCC.
11
12 ;; GCC is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published
14 ;; by the Free Software Foundation; either version 3, or (at your
15 ;; option) any later version.
16
17 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
18 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
20 ;; License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GCC; see the file COPYING3.  If not see
24 ;; <http://www.gnu.org/licenses/>.
25
26
27 ;; Vector int modes
28 (define_mode_iterator VEC_I [V16QI V8HI V4SI])
29
30 ;; Vector float modes
31 (define_mode_iterator VEC_F [V4SF V2DF])
32
33 ;; Vector arithmetic modes
34 (define_mode_iterator VEC_A [V16QI V8HI V4SI V4SF V2DF])
35
36 ;; Vector modes that need alginment via permutes
37 (define_mode_iterator VEC_K [V16QI V8HI V4SI V4SF])
38
39 ;; Vector logical modes
40 (define_mode_iterator VEC_L [V16QI V8HI V4SI V2DI V4SF V2DF TI])
41
42 ;; Vector modes for moves.  Don't do TImode here.
43 (define_mode_iterator VEC_M [V16QI V8HI V4SI V2DI V4SF V2DF])
44
45 ;; Vector modes for types that don't need a realignment under VSX
46 (define_mode_iterator VEC_N [V4SI V4SF V2DI V2DF])
47
48 ;; Vector comparison modes
49 (define_mode_iterator VEC_C [V16QI V8HI V4SI V4SF V2DF])
50
51 ;; Vector init/extract modes
52 (define_mode_iterator VEC_E [V16QI V8HI V4SI V2DI V4SF V2DF])
53
54 ;; Vector modes for 64-bit base types
55 (define_mode_iterator VEC_64 [V2DI V2DF])
56
57 ;; Vector reload iterator
58 (define_mode_iterator VEC_R [V16QI V8HI V4SI V2DI V4SF V2DF DF TI])
59
60 ;; Base type from vector mode
61 (define_mode_attr VEC_base [(V16QI "QI")
62                             (V8HI  "HI")
63                             (V4SI  "SI")
64                             (V2DI  "DI")
65                             (V4SF  "SF")
66                             (V2DF  "DF")
67                             (TI    "TI")])
68
69 ;; Same size integer type for floating point data
70 (define_mode_attr VEC_int [(V4SF  "v4si")
71                            (V2DF  "v2di")])
72
73 (define_mode_attr VEC_INT [(V4SF  "V4SI")
74                            (V2DF  "V2DI")])
75
76 ;; constants for unspec
77 (define_c_enum "unspec" [UNSPEC_PREDICATE
78                          UNSPEC_REDUC])
79
80 ;; Vector reduction code iterators
81 (define_code_iterator VEC_reduc [plus smin smax])
82
83 (define_code_attr VEC_reduc_name [(plus "splus")
84                                   (smin "smin")
85                                   (smax "smax")])
86
87 (define_code_attr VEC_reduc_rtx [(plus "add")
88                                  (smin "smin")
89                                  (smax "smax")])
90
91 \f
92 ;; Vector move instructions.
93 (define_expand "mov<mode>"
94   [(set (match_operand:VEC_M 0 "nonimmediate_operand" "")
95         (match_operand:VEC_M 1 "any_operand" ""))]
96   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
97 {
98   if (can_create_pseudo_p ())
99     {
100       if (CONSTANT_P (operands[1])
101           && !easy_vector_constant (operands[1], <MODE>mode))
102         operands[1] = force_const_mem (<MODE>mode, operands[1]);
103
104       else if (!vlogical_operand (operands[0], <MODE>mode)
105                && !vlogical_operand (operands[1], <MODE>mode))
106         operands[1] = force_reg (<MODE>mode, operands[1]);
107     }
108 })
109
110 ;; Generic vector floating point load/store instructions.  These will match
111 ;; insns defined in vsx.md or altivec.md depending on the switches.
112 (define_expand "vector_load_<mode>"
113   [(set (match_operand:VEC_M 0 "vfloat_operand" "")
114         (match_operand:VEC_M 1 "memory_operand" ""))]
115   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
116   "")
117
118 (define_expand "vector_store_<mode>"
119   [(set (match_operand:VEC_M 0 "memory_operand" "")
120         (match_operand:VEC_M 1 "vfloat_operand" ""))]
121   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
122   "")
123
124 ;; Splits if a GPR register was chosen for the move
125 (define_split
126   [(set (match_operand:VEC_L 0 "nonimmediate_operand" "")
127         (match_operand:VEC_L 1 "input_operand" ""))]
128   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)
129    && reload_completed
130    && gpr_or_gpr_p (operands[0], operands[1])"
131   [(pc)]
132 {
133   rs6000_split_multireg_move (operands[0], operands[1]);
134   DONE;
135 })
136
137 ;; Vector floating point load/store instructions that uses the Altivec
138 ;; instructions even if we are compiling for VSX, since the Altivec
139 ;; instructions silently ignore the bottom 3 bits of the address, and VSX does
140 ;; not.
141 (define_expand "vector_altivec_load_<mode>"
142   [(set (match_operand:VEC_M 0 "vfloat_operand" "")
143         (match_operand:VEC_M 1 "memory_operand" ""))]
144   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
145   "
146 {
147   gcc_assert (VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode));
148
149   if (VECTOR_MEM_VSX_P (<MODE>mode))
150     {
151       operands[1] = rs6000_address_for_altivec (operands[1]);
152       emit_insn (gen_altivec_lvx_<mode> (operands[0], operands[1]));
153       DONE;
154     }
155 }")
156
157 (define_expand "vector_altivec_store_<mode>"
158   [(set (match_operand:VEC_M 0 "memory_operand" "")
159         (match_operand:VEC_M 1 "vfloat_operand" ""))]
160   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
161   "
162 {
163   gcc_assert (VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode));
164
165   if (VECTOR_MEM_VSX_P (<MODE>mode))
166     {
167       operands[0] = rs6000_address_for_altivec (operands[0]);
168       emit_insn (gen_altivec_stvx_<mode> (operands[0], operands[1]));
169       DONE;
170     }
171 }")
172
173
174 \f
175 ;; Reload patterns for vector operations.  We may need an addtional base
176 ;; register to convert the reg+offset addressing to reg+reg for vector
177 ;; registers and reg+reg or (reg+reg)&(-16) addressing to just an index
178 ;; register for gpr registers.
179 (define_expand "reload_<VEC_R:mode>_<P:mptrsize>_store"
180   [(parallel [(match_operand:VEC_R 0 "memory_operand" "m")
181               (match_operand:VEC_R 1 "gpc_reg_operand" "r")
182               (match_operand:P 2 "register_operand" "=&b")])]
183   "<P:tptrsize>"
184 {
185   rs6000_secondary_reload_inner (operands[1], operands[0], operands[2], true);
186   DONE;
187 })
188
189 (define_expand "reload_<VEC_R:mode>_<P:mptrsize>_load"
190   [(parallel [(match_operand:VEC_R 0 "gpc_reg_operand" "=&r")
191               (match_operand:VEC_R 1 "memory_operand" "m")
192               (match_operand:P 2 "register_operand" "=&b")])]
193   "<P:tptrsize>"
194 {
195   rs6000_secondary_reload_inner (operands[0], operands[1], operands[2], false);
196   DONE;
197 })
198
199 ;; Reload sometimes tries to move the address to a GPR, and can generate
200 ;; invalid RTL for addresses involving AND -16.  Allow addresses involving
201 ;; reg+reg, reg+small constant, or just reg, all wrapped in an AND -16.
202
203 (define_insn_and_split "*vec_reload_and_plus_<mptrsize>"
204   [(set (match_operand:P 0 "gpc_reg_operand" "=b")
205         (and:P (plus:P (match_operand:P 1 "gpc_reg_operand" "r")
206                        (match_operand:P 2 "reg_or_cint_operand" "rI"))
207                (const_int -16)))]
208   "(TARGET_ALTIVEC || TARGET_VSX) && (reload_in_progress || reload_completed)"
209   "#"
210   "&& reload_completed"
211   [(set (match_dup 0)
212         (plus:P (match_dup 1)
213                 (match_dup 2)))
214    (parallel [(set (match_dup 0)
215                    (and:P (match_dup 0)
216                           (const_int -16)))
217               (clobber:CC (scratch:CC))])])
218
219 ;; The normal ANDSI3/ANDDI3 won't match if reload decides to move an AND -16
220 ;; address to a register because there is no clobber of a (scratch), so we add
221 ;; it here.
222 (define_insn_and_split "*vec_reload_and_reg_<mptrsize>"
223   [(set (match_operand:P 0 "gpc_reg_operand" "=b")
224         (and:P (match_operand:P 1 "gpc_reg_operand" "r")
225                (const_int -16)))]
226   "(TARGET_ALTIVEC || TARGET_VSX) && (reload_in_progress || reload_completed)"
227   "#"
228   "&& reload_completed"
229   [(parallel [(set (match_dup 0)
230                    (and:P (match_dup 1)
231                           (const_int -16)))
232               (clobber:CC (scratch:CC))])])
233 \f
234 ;; Generic floating point vector arithmetic support
235 (define_expand "add<mode>3"
236   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
237         (plus:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
238                     (match_operand:VEC_F 2 "vfloat_operand" "")))]
239   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
240   "")
241
242 (define_expand "sub<mode>3"
243   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
244         (minus:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
245                      (match_operand:VEC_F 2 "vfloat_operand" "")))]
246   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
247   "")
248
249 (define_expand "mul<mode>3"
250   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
251         (mult:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
252                     (match_operand:VEC_F 2 "vfloat_operand" "")))]
253   "VECTOR_UNIT_VSX_P (<MODE>mode) || VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
254 {
255   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
256     {
257       emit_insn (gen_altivec_mulv4sf3 (operands[0], operands[1], operands[2]));
258       DONE;
259     }
260 })
261
262 (define_expand "div<mode>3"
263   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
264         (div:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")
265                    (match_operand:VEC_F 2 "vfloat_operand" "")))]
266   "VECTOR_UNIT_VSX_P (<MODE>mode)"
267   "")
268
269 (define_expand "neg<mode>2"
270   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
271         (neg:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
272   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
273   "
274 {
275   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
276     {
277       emit_insn (gen_altivec_negv4sf2 (operands[0], operands[1]));
278       DONE;
279     }
280 }")
281
282 (define_expand "abs<mode>2"
283   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
284         (abs:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
285   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
286   "
287 {
288   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
289     {
290       emit_insn (gen_altivec_absv4sf2 (operands[0], operands[1]));
291       DONE;
292     }
293 }")
294
295 (define_expand "smin<mode>3"
296   [(set (match_operand:VEC_F 0 "register_operand" "")
297         (smin:VEC_F (match_operand:VEC_F 1 "register_operand" "")
298                     (match_operand:VEC_F 2 "register_operand" "")))]
299   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
300   "")
301
302 (define_expand "smax<mode>3"
303   [(set (match_operand:VEC_F 0 "register_operand" "")
304         (smax:VEC_F (match_operand:VEC_F 1 "register_operand" "")
305                     (match_operand:VEC_F 2 "register_operand" "")))]
306   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
307   "")
308
309
310 (define_expand "sqrt<mode>2"
311   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
312         (sqrt:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
313   "VECTOR_UNIT_VSX_P (<MODE>mode)"
314   "")
315
316 (define_expand "rsqrte<mode>2"
317   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
318         (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
319                       UNSPEC_RSQRT))]
320   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
321   "")
322
323 (define_expand "re<mode>2"
324   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
325         (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "f")]
326                       UNSPEC_FRES))]
327   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
328   "")
329
330 (define_expand "ftrunc<mode>2"
331   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
332         (fix:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
333   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
334   "")
335
336 (define_expand "vector_ceil<mode>2"
337   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
338         (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
339                       UNSPEC_FRIP))]
340   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
341   "")
342
343 (define_expand "vector_floor<mode>2"
344   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
345         (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")]
346                       UNSPEC_FRIM))]
347   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
348   "")
349
350 (define_expand "vector_btrunc<mode>2"
351   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
352         (fix:VEC_F (match_operand:VEC_F 1 "vfloat_operand" "")))]
353   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
354   "")
355
356 (define_expand "vector_copysign<mode>3"
357   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
358         (unspec:VEC_F [(match_operand:VEC_F 1 "vfloat_operand" "")
359                        (match_operand:VEC_F 2 "vfloat_operand" "")] UNSPEC_COPYSIGN))]
360   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
361   "
362 {
363   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
364     {
365       emit_insn (gen_altivec_copysign_v4sf3 (operands[0], operands[1],
366                                              operands[2]));
367       DONE;
368     }
369 }")
370
371 \f
372 ;; Vector comparisons
373 (define_expand "vcond<mode><mode>"
374   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
375         (if_then_else:VEC_F
376          (match_operator 3 "comparison_operator"
377                          [(match_operand:VEC_F 4 "vfloat_operand" "")
378                           (match_operand:VEC_F 5 "vfloat_operand" "")])
379          (match_operand:VEC_F 1 "vfloat_operand" "")
380          (match_operand:VEC_F 2 "vfloat_operand" "")))]
381   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
382   "
383 {
384   if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
385                                     operands[3], operands[4], operands[5]))
386     DONE;
387   else
388     FAIL;
389 }")
390
391 (define_expand "vcond<mode><mode>"
392   [(set (match_operand:VEC_I 0 "vint_operand" "")
393         (if_then_else:VEC_I
394          (match_operator 3 "comparison_operator"
395                          [(match_operand:VEC_I 4 "vint_operand" "")
396                           (match_operand:VEC_I 5 "vint_operand" "")])
397          (match_operand:VEC_I 1 "vint_operand" "")
398          (match_operand:VEC_I 2 "vint_operand" "")))]
399   "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
400   "
401 {
402   if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
403                                     operands[3], operands[4], operands[5]))
404     DONE;
405   else
406     FAIL;
407 }")
408
409 (define_expand "vcondu<mode><mode>"
410   [(set (match_operand:VEC_I 0 "vint_operand" "")
411         (if_then_else:VEC_I
412          (match_operator 3 "comparison_operator"
413                          [(match_operand:VEC_I 4 "vint_operand" "")
414                           (match_operand:VEC_I 5 "vint_operand" "")])
415          (match_operand:VEC_I 1 "vint_operand" "")
416          (match_operand:VEC_I 2 "vint_operand" "")))]
417   "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
418   "
419 {
420   if (rs6000_emit_vector_cond_expr (operands[0], operands[1], operands[2],
421                                     operands[3], operands[4], operands[5]))
422     DONE;
423   else
424     FAIL;
425 }")
426
427 (define_expand "vector_eq<mode>"
428   [(set (match_operand:VEC_C 0 "vlogical_operand" "")
429         (eq:VEC_C (match_operand:VEC_C 1 "vlogical_operand" "")
430                   (match_operand:VEC_C 2 "vlogical_operand" "")))]
431   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
432   "")
433
434 (define_expand "vector_gt<mode>"
435   [(set (match_operand:VEC_C 0 "vlogical_operand" "")
436         (gt:VEC_C (match_operand:VEC_C 1 "vlogical_operand" "")
437                   (match_operand:VEC_C 2 "vlogical_operand" "")))]
438   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
439   "")
440
441 (define_expand "vector_ge<mode>"
442   [(set (match_operand:VEC_C 0 "vlogical_operand" "")
443         (ge:VEC_C (match_operand:VEC_C 1 "vlogical_operand" "")
444                   (match_operand:VEC_C 2 "vlogical_operand" "")))]
445   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
446   "")
447
448 (define_expand "vector_gtu<mode>"
449   [(set (match_operand:VEC_I 0 "vint_operand" "")
450         (gtu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
451                    (match_operand:VEC_I 2 "vint_operand" "")))]
452   "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
453   "")
454
455 (define_expand "vector_geu<mode>"
456   [(set (match_operand:VEC_I 0 "vint_operand" "")
457         (geu:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
458                    (match_operand:VEC_I 2 "vint_operand" "")))]
459   "VECTOR_UNIT_ALTIVEC_P (<MODE>mode)"
460   "")
461
462 ;; Note the arguments for __builtin_altivec_vsel are op2, op1, mask
463 ;; which is in the reverse order that we want
464 (define_expand "vector_select_<mode>"
465   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
466         (if_then_else:VEC_L
467          (ne:CC (match_operand:VEC_L 3 "vlogical_operand" "")
468                 (match_dup 4))
469          (match_operand:VEC_L 2 "vlogical_operand" "")
470          (match_operand:VEC_L 1 "vlogical_operand" "")))]
471   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
472   "operands[4] = CONST0_RTX (<MODE>mode);")
473
474 (define_expand "vector_select_<mode>_uns"
475   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
476         (if_then_else:VEC_L
477          (ne:CCUNS (match_operand:VEC_L 3 "vlogical_operand" "")
478                    (match_dup 4))
479          (match_operand:VEC_L 2 "vlogical_operand" "")
480          (match_operand:VEC_L 1 "vlogical_operand" "")))]
481   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
482   "operands[4] = CONST0_RTX (<MODE>mode);")
483
484 ;; Expansions that compare vectors producing a vector result and a predicate,
485 ;; setting CR6 to indicate a combined status
486 (define_expand "vector_eq_<mode>_p"
487   [(parallel
488     [(set (reg:CC 74)
489           (unspec:CC [(eq:CC (match_operand:VEC_A 1 "vlogical_operand" "")
490                              (match_operand:VEC_A 2 "vlogical_operand" ""))]
491                      UNSPEC_PREDICATE))
492      (set (match_operand:VEC_A 0 "vlogical_operand" "")
493           (eq:VEC_A (match_dup 1)
494                     (match_dup 2)))])]
495   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
496   "")
497
498 (define_expand "vector_gt_<mode>_p"
499   [(parallel
500     [(set (reg:CC 74)
501           (unspec:CC [(gt:CC (match_operand:VEC_A 1 "vlogical_operand" "")
502                              (match_operand:VEC_A 2 "vlogical_operand" ""))]
503                      UNSPEC_PREDICATE))
504      (set (match_operand:VEC_A 0 "vlogical_operand" "")
505           (gt:VEC_A (match_dup 1)
506                     (match_dup 2)))])]
507   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
508   "")
509
510 (define_expand "vector_ge_<mode>_p"
511   [(parallel
512     [(set (reg:CC 74)
513           (unspec:CC [(ge:CC (match_operand:VEC_F 1 "vfloat_operand" "")
514                              (match_operand:VEC_F 2 "vfloat_operand" ""))]
515                      UNSPEC_PREDICATE))
516      (set (match_operand:VEC_F 0 "vfloat_operand" "")
517           (ge:VEC_F (match_dup 1)
518                     (match_dup 2)))])]
519   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
520   "")
521
522 (define_expand "vector_gtu_<mode>_p"
523   [(parallel
524     [(set (reg:CC 74)
525           (unspec:CC [(gtu:CC (match_operand:VEC_I 1 "vint_operand" "")
526                               (match_operand:VEC_I 2 "vint_operand" ""))]
527                      UNSPEC_PREDICATE))
528      (set (match_operand:VEC_I 0 "vlogical_operand" "")
529           (gtu:VEC_I (match_dup 1)
530                      (match_dup 2)))])]
531   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
532   "")
533
534 ;; AltiVec/VSX predicates.
535
536 (define_expand "cr6_test_for_zero"
537   [(set (match_operand:SI 0 "register_operand" "=r")
538         (eq:SI (reg:CC 74)
539                (const_int 0)))]
540   "TARGET_ALTIVEC || TARGET_VSX"
541   "")
542
543 (define_expand "cr6_test_for_zero_reverse"
544   [(set (match_operand:SI 0 "register_operand" "=r")
545         (eq:SI (reg:CC 74)
546                (const_int 0)))
547    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
548   "TARGET_ALTIVEC || TARGET_VSX"
549   "")
550
551 (define_expand "cr6_test_for_lt"
552   [(set (match_operand:SI 0 "register_operand" "=r")
553         (lt:SI (reg:CC 74)
554                (const_int 0)))]
555   "TARGET_ALTIVEC || TARGET_VSX"
556   "")
557
558 (define_expand "cr6_test_for_lt_reverse"
559   [(set (match_operand:SI 0 "register_operand" "=r")
560         (lt:SI (reg:CC 74)
561                (const_int 0)))
562    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
563   "TARGET_ALTIVEC || TARGET_VSX"
564   "")
565
566 \f
567 ;; Vector logical instructions
568 (define_expand "xor<mode>3"
569   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
570         (xor:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
571                    (match_operand:VEC_L 2 "vlogical_operand" "")))]
572   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
573   "")
574
575 (define_expand "ior<mode>3"
576   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
577         (ior:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
578                    (match_operand:VEC_L 2 "vlogical_operand" "")))]
579   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
580   "")
581
582 (define_expand "and<mode>3"
583   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
584         (and:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
585                    (match_operand:VEC_L 2 "vlogical_operand" "")))]
586   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
587   "")
588
589 (define_expand "one_cmpl<mode>2"
590   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
591         (not:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")))]
592   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
593   "")
594
595 (define_expand "nor<mode>3"
596   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
597         (not:VEC_L (ior:VEC_L (match_operand:VEC_L 1 "vlogical_operand" "")
598                               (match_operand:VEC_L 2 "vlogical_operand" ""))))]
599   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
600   "")
601
602 (define_expand "andc<mode>3"
603   [(set (match_operand:VEC_L 0 "vlogical_operand" "")
604         (and:VEC_L (not:VEC_L (match_operand:VEC_L 2 "vlogical_operand" ""))
605                    (match_operand:VEC_L 1 "vlogical_operand" "")))]
606   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
607   "")
608
609 ;; Same size conversions
610 (define_expand "float<VEC_int><mode>2"
611   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
612         (float:VEC_F (match_operand:<VEC_INT> 1 "vint_operand" "")))]
613   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
614   "
615 {
616   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
617     {
618       emit_insn (gen_altivec_vcfsx (operands[0], operands[1], const0_rtx));
619       DONE;
620     }
621 }")
622
623 (define_expand "unsigned_float<VEC_int><mode>2"
624   [(set (match_operand:VEC_F 0 "vfloat_operand" "")
625         (unsigned_float:VEC_F (match_operand:<VEC_INT> 1 "vint_operand" "")))]
626   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
627   "
628 {
629   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
630     {
631       emit_insn (gen_altivec_vcfux (operands[0], operands[1], const0_rtx));
632       DONE;
633     }
634 }")
635
636 (define_expand "fix_trunc<mode><VEC_int>2"
637   [(set (match_operand:<VEC_INT> 0 "vint_operand" "")
638         (fix:<VEC_INT> (match_operand:VEC_F 1 "vfloat_operand" "")))]
639   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
640   "
641 {
642   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
643     {
644       emit_insn (gen_altivec_vctsxs (operands[0], operands[1], const0_rtx));
645       DONE;
646     }
647 }")
648
649 (define_expand "fixuns_trunc<mode><VEC_int>2"
650   [(set (match_operand:<VEC_INT> 0 "vint_operand" "")
651         (unsigned_fix:<VEC_INT> (match_operand:VEC_F 1 "vfloat_operand" "")))]
652   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (<MODE>mode)"
653   "
654 {
655   if (<MODE>mode == V4SFmode && VECTOR_UNIT_ALTIVEC_P (<MODE>mode))
656     {
657       emit_insn (gen_altivec_vctuxs (operands[0], operands[1], const0_rtx));
658       DONE;
659     }
660 }")
661
662 \f
663 ;; Vector initialization, set, extract
664 (define_expand "vec_init<mode>"
665   [(match_operand:VEC_E 0 "vlogical_operand" "")
666    (match_operand:VEC_E 1 "" "")]
667   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
668 {
669   rs6000_expand_vector_init (operands[0], operands[1]);
670   DONE;
671 })
672
673 (define_expand "vec_set<mode>"
674   [(match_operand:VEC_E 0 "vlogical_operand" "")
675    (match_operand:<VEC_base> 1 "register_operand" "")
676    (match_operand 2 "const_int_operand" "")]
677   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
678 {
679   rs6000_expand_vector_set (operands[0], operands[1], INTVAL (operands[2]));
680   DONE;
681 })
682
683 (define_expand "vec_extract<mode>"
684   [(match_operand:<VEC_base> 0 "register_operand" "")
685    (match_operand:VEC_E 1 "vlogical_operand" "")
686    (match_operand 2 "const_int_operand" "")]
687   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
688 {
689   rs6000_expand_vector_extract (operands[0], operands[1],
690                                 INTVAL (operands[2]));
691   DONE;
692 })
693
694 ;; Interleave patterns
695 (define_expand "vec_interleave_highv4sf"
696   [(set (match_operand:V4SF 0 "vfloat_operand" "")
697         (vec_merge:V4SF
698          (vec_select:V4SF (match_operand:V4SF 1 "vfloat_operand" "")
699                           (parallel [(const_int 0)
700                                      (const_int 2)
701                                      (const_int 1)
702                                      (const_int 3)]))
703          (vec_select:V4SF (match_operand:V4SF 2 "vfloat_operand" "")
704                           (parallel [(const_int 2)
705                                      (const_int 0)
706                                      (const_int 3)
707                                      (const_int 1)]))
708          (const_int 5)))]
709   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
710   "")
711
712 (define_expand "vec_interleave_lowv4sf"
713   [(set (match_operand:V4SF 0 "vfloat_operand" "")
714         (vec_merge:V4SF
715          (vec_select:V4SF (match_operand:V4SF 1 "vfloat_operand" "")
716                           (parallel [(const_int 2)
717                                      (const_int 0)
718                                      (const_int 3)
719                                      (const_int 1)]))
720          (vec_select:V4SF (match_operand:V4SF 2 "vfloat_operand" "")
721                           (parallel [(const_int 0)
722                                      (const_int 2)
723                                      (const_int 1)
724                                      (const_int 3)]))
725          (const_int 5)))]
726   "VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
727   "")
728
729 (define_expand "vec_interleave_high<mode>"
730   [(set (match_operand:VEC_64 0 "vfloat_operand" "")
731         (vec_concat:VEC_64
732          (vec_select:<VEC_base> (match_operand:VEC_64 1 "vfloat_operand" "")
733                                 (parallel [(const_int 0)]))
734          (vec_select:<VEC_base> (match_operand:VEC_64 2 "vfloat_operand" "")
735                                 (parallel [(const_int 0)]))))]
736   "VECTOR_UNIT_VSX_P (<MODE>mode)"
737   "")
738
739 (define_expand "vec_interleave_low<mode>"
740   [(set (match_operand:VEC_64 0 "vfloat_operand" "")
741         (vec_concat:VEC_64
742          (vec_select:<VEC_base> (match_operand:VEC_64 1 "vfloat_operand" "")
743                                 (parallel [(const_int 1)]))
744          (vec_select:<VEC_base> (match_operand:VEC_64 2 "vfloat_operand" "")
745                                 (parallel [(const_int 1)]))))]
746   "VECTOR_UNIT_VSX_P (<MODE>mode)"
747   "")
748
749 \f
750 ;; Convert double word types to single word types
751 (define_expand "vec_pack_trunc_v2df"
752   [(match_operand:V4SF 0 "vfloat_operand" "")
753    (match_operand:V2DF 1 "vfloat_operand" "")
754    (match_operand:V2DF 2 "vfloat_operand" "")]
755   "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
756 {
757   rtx r1 = gen_reg_rtx (V4SFmode);
758   rtx r2 = gen_reg_rtx (V4SFmode);
759
760   emit_insn (gen_vsx_xvcvdpsp (r1, operands[1]));
761   emit_insn (gen_vsx_xvcvdpsp (r2, operands[2]));
762   emit_insn (gen_vec_extract_evenv4sf (operands[0], r1, r2));
763   DONE;
764 })
765
766 (define_expand "vec_pack_sfix_trunc_v2df"
767   [(match_operand:V4SI 0 "vint_operand" "")
768    (match_operand:V2DF 1 "vfloat_operand" "")
769    (match_operand:V2DF 2 "vfloat_operand" "")]
770   "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
771 {
772   rtx r1 = gen_reg_rtx (V4SImode);
773   rtx r2 = gen_reg_rtx (V4SImode);
774
775   emit_insn (gen_vsx_xvcvdpsxws (r1, operands[1]));
776   emit_insn (gen_vsx_xvcvdpsxws (r2, operands[2]));
777   emit_insn (gen_vec_extract_evenv4si (operands[0], r1, r2));
778   DONE;
779 })
780
781 (define_expand "vec_pack_ufix_trunc_v2df"
782   [(match_operand:V4SI 0 "vint_operand" "")
783    (match_operand:V2DF 1 "vfloat_operand" "")
784    (match_operand:V2DF 2 "vfloat_operand" "")]
785   "VECTOR_UNIT_VSX_P (V2DFmode) && TARGET_ALTIVEC"
786 {
787   rtx r1 = gen_reg_rtx (V4SImode);
788   rtx r2 = gen_reg_rtx (V4SImode);
789
790   emit_insn (gen_vsx_xvcvdpuxws (r1, operands[1]));
791   emit_insn (gen_vsx_xvcvdpuxws (r2, operands[2]));
792   emit_insn (gen_vec_extract_evenv4si (operands[0], r1, r2));
793   DONE;
794 })
795
796 ;; Convert single word types to double word
797 (define_expand "vec_unpacks_hi_v4sf"
798   [(match_operand:V2DF 0 "vfloat_operand" "")
799    (match_operand:V4SF 1 "vfloat_operand" "")]
800   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
801 {
802   rtx reg = gen_reg_rtx (V4SFmode);
803
804   emit_insn (gen_vec_interleave_highv4sf (reg, operands[1], operands[1]));
805   emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
806   DONE;
807 })
808
809 (define_expand "vec_unpacks_lo_v4sf"
810   [(match_operand:V2DF 0 "vfloat_operand" "")
811    (match_operand:V4SF 1 "vfloat_operand" "")]
812   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SFmode)"
813 {
814   rtx reg = gen_reg_rtx (V4SFmode);
815
816   emit_insn (gen_vec_interleave_lowv4sf (reg, operands[1], operands[1]));
817   emit_insn (gen_vsx_xvcvspdp (operands[0], reg));
818   DONE;
819 })
820
821 (define_expand "vec_unpacks_float_hi_v4si"
822   [(match_operand:V2DF 0 "vfloat_operand" "")
823    (match_operand:V4SI 1 "vint_operand" "")]
824   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
825 {
826   rtx reg = gen_reg_rtx (V4SImode);
827
828   emit_insn (gen_vec_interleave_highv4si (reg, operands[1], operands[1]));
829   emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
830   DONE;
831 })
832
833 (define_expand "vec_unpacks_float_lo_v4si"
834   [(match_operand:V2DF 0 "vfloat_operand" "")
835    (match_operand:V4SI 1 "vint_operand" "")]
836   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
837 {
838   rtx reg = gen_reg_rtx (V4SImode);
839
840   emit_insn (gen_vec_interleave_lowv4si (reg, operands[1], operands[1]));
841   emit_insn (gen_vsx_xvcvsxwdp (operands[0], reg));
842   DONE;
843 })
844
845 (define_expand "vec_unpacku_float_hi_v4si"
846   [(match_operand:V2DF 0 "vfloat_operand" "")
847    (match_operand:V4SI 1 "vint_operand" "")]
848   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
849 {
850   rtx reg = gen_reg_rtx (V4SImode);
851
852   emit_insn (gen_vec_interleave_highv4si (reg, operands[1], operands[1]));
853   emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
854   DONE;
855 })
856
857 (define_expand "vec_unpacku_float_lo_v4si"
858   [(match_operand:V2DF 0 "vfloat_operand" "")
859    (match_operand:V4SI 1 "vint_operand" "")]
860   "VECTOR_UNIT_VSX_P (V2DFmode) && VECTOR_UNIT_ALTIVEC_OR_VSX_P (V4SImode)"
861 {
862   rtx reg = gen_reg_rtx (V4SImode);
863
864   emit_insn (gen_vec_interleave_lowv4si (reg, operands[1], operands[1]));
865   emit_insn (gen_vsx_xvcvuxwdp (operands[0], reg));
866   DONE;
867 })
868
869 \f
870 ;; Align vector loads with a permute.
871 (define_expand "vec_realign_load_<mode>"
872   [(match_operand:VEC_K 0 "vlogical_operand" "")
873    (match_operand:VEC_K 1 "vlogical_operand" "")
874    (match_operand:VEC_K 2 "vlogical_operand" "")
875    (match_operand:V16QI 3 "vlogical_operand" "")]
876   "VECTOR_MEM_ALTIVEC_OR_VSX_P (<MODE>mode)"
877 {
878   emit_insn (gen_altivec_vperm_<mode> (operands[0], operands[1], operands[2],
879                                        operands[3]));
880   DONE;
881 })
882
883 ;; Under VSX, vectors of 4/8 byte alignments do not need to be aligned
884 ;; since the load already handles it.
885 (define_expand "movmisalign<mode>"
886  [(set (match_operand:VEC_N 0 "nonimmediate_operand" "")
887        (match_operand:VEC_N 1 "any_operand" ""))]
888  "VECTOR_MEM_VSX_P (<MODE>mode) && TARGET_ALLOW_MOVMISALIGN"
889  "")
890
891 \f
892 ;; Vector shift left in bits.  Currently supported ony for shift
893 ;; amounts that can be expressed as byte shifts (divisible by 8).
894 ;; General shift amounts can be supported using vslo + vsl. We're
895 ;; not expecting to see these yet (the vectorizer currently
896 ;; generates only shifts divisible by byte_size).
897 (define_expand "vec_shl_<mode>"
898   [(match_operand:VEC_L 0 "vlogical_operand" "")
899    (match_operand:VEC_L 1 "vlogical_operand" "")
900    (match_operand:QI 2 "reg_or_short_operand" "")]
901   "TARGET_ALTIVEC"
902   "
903 {
904   rtx bitshift = operands[2];
905   rtx shift;
906   rtx insn;
907   HOST_WIDE_INT bitshift_val;
908   HOST_WIDE_INT byteshift_val;
909
910   if (! CONSTANT_P (bitshift))
911     FAIL;
912   bitshift_val = INTVAL (bitshift);
913   if (bitshift_val & 0x7)
914     FAIL;
915   byteshift_val = bitshift_val >> 3;
916   if (TARGET_VSX && (byteshift_val & 0x3) == 0)
917     {
918       shift = gen_rtx_CONST_INT (QImode, byteshift_val >> 2);
919       insn = gen_vsx_xxsldwi_<mode> (operands[0], operands[1], operands[1],
920                                      shift);
921     }
922   else
923     {
924       shift = gen_rtx_CONST_INT (QImode, byteshift_val);
925       insn = gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
926                                         shift);
927     }
928
929   emit_insn (insn);
930   DONE;
931 }")
932
933 ;; Vector shift right in bits. Currently supported ony for shift
934 ;; amounts that can be expressed as byte shifts (divisible by 8).
935 ;; General shift amounts can be supported using vsro + vsr. We're
936 ;; not expecting to see these yet (the vectorizer currently
937 ;; generates only shifts divisible by byte_size).
938 (define_expand "vec_shr_<mode>"
939   [(match_operand:VEC_L 0 "vlogical_operand" "")
940    (match_operand:VEC_L 1 "vlogical_operand" "")
941    (match_operand:QI 2 "reg_or_short_operand" "")]
942   "TARGET_ALTIVEC"
943   "
944 {
945   rtx bitshift = operands[2];
946   rtx shift;
947   rtx insn;
948   HOST_WIDE_INT bitshift_val;
949   HOST_WIDE_INT byteshift_val;
950
951   if (! CONSTANT_P (bitshift))
952     FAIL;
953   bitshift_val = INTVAL (bitshift);
954   if (bitshift_val & 0x7)
955     FAIL;
956   byteshift_val = 16 - (bitshift_val >> 3);
957   if (TARGET_VSX && (byteshift_val & 0x3) == 0)
958     {
959       shift = gen_rtx_CONST_INT (QImode, byteshift_val >> 2);
960       insn = gen_vsx_xxsldwi_<mode> (operands[0], operands[1], operands[1],
961                                      shift);
962     }
963   else
964     {
965       shift = gen_rtx_CONST_INT (QImode, byteshift_val);
966       insn = gen_altivec_vsldoi_<mode> (operands[0], operands[1], operands[1],
967                                         shift);
968     }
969
970   emit_insn (insn);
971   DONE;
972 }")
973
974 ;; Expanders for rotate each element in a vector
975 (define_expand "vrotl<mode>3"
976   [(set (match_operand:VEC_I 0 "vint_operand" "")
977         (rotate:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
978                       (match_operand:VEC_I 2 "vint_operand" "")))]
979   "TARGET_ALTIVEC"
980   "")
981
982 ;; Expanders for arithmetic shift left on each vector element
983 (define_expand "vashl<mode>3"
984   [(set (match_operand:VEC_I 0 "vint_operand" "")
985         (ashift:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
986                       (match_operand:VEC_I 2 "vint_operand" "")))]
987   "TARGET_ALTIVEC"
988   "")
989
990 ;; Expanders for logical shift right on each vector element
991 (define_expand "vlshr<mode>3"
992   [(set (match_operand:VEC_I 0 "vint_operand" "")
993         (lshiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
994                         (match_operand:VEC_I 2 "vint_operand" "")))]
995   "TARGET_ALTIVEC"
996   "")
997
998 ;; Expanders for arithmetic shift right on each vector element
999 (define_expand "vashr<mode>3"
1000   [(set (match_operand:VEC_I 0 "vint_operand" "")
1001         (ashiftrt:VEC_I (match_operand:VEC_I 1 "vint_operand" "")
1002                         (match_operand:VEC_I 2 "vint_operand" "")))]
1003   "TARGET_ALTIVEC"
1004   "")
1005 \f
1006 ;; Vector reduction expanders for VSX
1007
1008 (define_expand "reduc_<VEC_reduc_name>_v2df"
1009   [(parallel [(set (match_operand:V2DF 0 "vfloat_operand" "")
1010                    (VEC_reduc:V2DF
1011                     (vec_concat:V2DF
1012                      (vec_select:DF
1013                       (match_operand:V2DF 1 "vfloat_operand" "")
1014                       (parallel [(const_int 1)]))
1015                      (vec_select:DF
1016                       (match_dup 1)
1017                       (parallel [(const_int 0)])))
1018                     (match_dup 1)))
1019               (clobber (match_scratch:V2DF 2 ""))])]
1020   "VECTOR_UNIT_VSX_P (V2DFmode)"
1021   "")
1022
1023 ; The (VEC_reduc:V4SF
1024 ;       (op1)
1025 ;       (unspec:V4SF [(const_int 0)] UNSPEC_REDUC))
1026 ;
1027 ; is to allow us to use a code iterator, but not completely list all of the
1028 ; vector rotates, etc. to prevent canonicalization
1029
1030 (define_expand "reduc_<VEC_reduc_name>_v4sf"
1031   [(parallel [(set (match_operand:V4SF 0 "vfloat_operand" "")
1032                    (VEC_reduc:V4SF
1033                     (unspec:V4SF [(const_int 0)] UNSPEC_REDUC)
1034                     (match_operand:V4SF 1 "vfloat_operand" "")))
1035               (clobber (match_scratch:V4SF 2 ""))
1036               (clobber (match_scratch:V4SF 3 ""))])]
1037   "VECTOR_UNIT_VSX_P (V4SFmode)"
1038   "")
1039
1040 \f
1041 ;;; Expanders for vector insn patterns shared between the SPE and TARGET_PAIRED systems.
1042
1043 (define_expand "absv2sf2"
1044   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1045         (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")))]
1046   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1047   "")
1048
1049 (define_expand "negv2sf2"
1050   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1051         (neg:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")))]
1052   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1053   "")
1054
1055 (define_expand "addv2sf3"
1056   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1057         (plus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1058                    (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1059   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1060   "
1061 {
1062   if (TARGET_SPE)
1063     {
1064       /* We need to make a note that we clobber SPEFSCR.  */
1065       rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1066
1067       XVECEXP (par, 0, 0) = gen_rtx_SET (VOIDmode, operands[0],
1068                                          gen_rtx_PLUS (V2SFmode, operands[1], operands[2]));
1069       XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1070       emit_insn (par);
1071       DONE;
1072     }
1073 }")
1074
1075 (define_expand "subv2sf3"
1076   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1077         (minus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1078                     (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1079   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1080   "
1081 {
1082   if (TARGET_SPE)
1083     {
1084       /* We need to make a note that we clobber SPEFSCR.  */
1085       rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1086
1087       XVECEXP (par, 0, 0) = gen_rtx_SET (VOIDmode, operands[0],
1088                                          gen_rtx_MINUS (V2SFmode, operands[1], operands[2]));
1089       XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1090       emit_insn (par);
1091       DONE;
1092     }
1093 }")
1094
1095 (define_expand "mulv2sf3"
1096   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1097         (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1098                    (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1099   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1100   "
1101 {
1102   if (TARGET_SPE)
1103     {
1104       /* We need to make a note that we clobber SPEFSCR.  */
1105       rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1106
1107       XVECEXP (par, 0, 0) = gen_rtx_SET (VOIDmode, operands[0],
1108                                          gen_rtx_MULT (V2SFmode, operands[1], operands[2]));
1109       XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1110       emit_insn (par);
1111       DONE;
1112     }
1113 }")
1114
1115 (define_expand "divv2sf3"
1116   [(set (match_operand:V2SF 0 "gpc_reg_operand" "")
1117         (div:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "")
1118                   (match_operand:V2SF 2 "gpc_reg_operand" "")))]
1119   "TARGET_PAIRED_FLOAT || TARGET_SPE"
1120   "
1121 {
1122   if (TARGET_SPE)
1123     {
1124       /* We need to make a note that we clobber SPEFSCR.  */
1125       rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2));
1126
1127       XVECEXP (par, 0, 0) = gen_rtx_SET (VOIDmode, operands[0],
1128                                          gen_rtx_DIV (V2SFmode, operands[1], operands[2]));
1129       XVECEXP (par, 0, 1) = gen_rtx_CLOBBER (VOIDmode, gen_rtx_REG (SImode, SPEFSCR_REGNO));
1130       emit_insn (par);
1131       DONE;
1132     }
1133 }")