1 ;; PowerPC paired single and double hummer description
2 ;; Copyright (C) 2007, 2009, 2010, 2011
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by David Edelsohn <edelsohn@gnu.org> and Revital Eres
7 ;; This file is part of GCC.
9 ;; GCC is free software; you can redistribute it and/or modify it
10 ;; under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 3, or (at your
12 ;; option) any later version.
14 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
15 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 ;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
17 ;; License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program; see the file COPYING3. If not see
21 ;; <http://www.gnu.org/licenses/>.
23 (define_c_enum "unspec"
30 (define_insn "paired_negv2sf2"
31 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
32 (neg:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
35 [(set_attr "type" "fp")])
37 (define_insn "sqrtv2sf2"
38 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
39 (sqrt:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
42 [(set_attr "type" "fp")])
44 (define_insn "paired_absv2sf2"
45 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
46 (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
49 [(set_attr "type" "fp")])
51 (define_insn "nabsv2sf2"
52 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
53 (neg:V2SF (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f"))))]
56 [(set_attr "type" "fp")])
58 (define_insn "paired_addv2sf3"
59 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
60 (plus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
61 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
64 [(set_attr "type" "fp")])
66 (define_insn "paired_subv2sf3"
67 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
68 (minus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
69 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
72 [(set_attr "type" "fp")])
74 (define_insn "paired_mulv2sf3"
75 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
76 (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
77 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
80 [(set_attr "type" "fp")])
82 (define_insn "resv2sf2"
83 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
84 (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
85 "TARGET_PAIRED_FLOAT && flag_finite_math_only"
87 [(set_attr "type" "fp")])
89 (define_insn "paired_divv2sf3"
90 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
91 (div:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
92 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
95 [(set_attr "type" "sdiv")])
97 (define_insn "paired_madds0"
98 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
101 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
102 (parallel [(const_int 0)]))
103 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
104 (parallel [(const_int 0)]))
105 (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
106 (parallel [(const_int 0)])))
108 (vec_select:SF (match_dup 1)
109 (parallel [(const_int 1)]))
110 (vec_select:SF (match_dup 2)
111 (parallel [(const_int 0)]))
112 (vec_select:SF (match_dup 3)
113 (parallel [(const_int 1)])))))]
114 "TARGET_PAIRED_FLOAT"
115 "ps_madds0 %0,%1,%2,%3"
116 [(set_attr "type" "fp")])
118 (define_insn "paired_madds1"
119 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
122 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
123 (parallel [(const_int 0)]))
124 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
125 (parallel [(const_int 1)]))
126 (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
127 (parallel [(const_int 0)])))
129 (vec_select:SF (match_dup 1)
130 (parallel [(const_int 1)]))
131 (vec_select:SF (match_dup 2)
132 (parallel [(const_int 1)]))
133 (vec_select:SF (match_dup 3)
134 (parallel [(const_int 1)])))))]
135 "TARGET_PAIRED_FLOAT"
136 "ps_madds1 %0,%1,%2,%3"
137 [(set_attr "type" "fp")])
139 (define_insn "*paired_madd"
140 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
142 (match_operand:V2SF 1 "gpc_reg_operand" "f")
143 (match_operand:V2SF 2 "gpc_reg_operand" "f")
144 (match_operand:V2SF 3 "gpc_reg_operand" "f")))]
145 "TARGET_PAIRED_FLOAT"
146 "ps_madd %0,%1,%2,%3"
147 [(set_attr "type" "fp")])
149 (define_insn "*paired_msub"
150 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
152 (match_operand:V2SF 1 "gpc_reg_operand" "f")
153 (match_operand:V2SF 2 "gpc_reg_operand" "f")
154 (neg:V2SF (match_operand:V2SF 3 "gpc_reg_operand" "f"))))]
155 "TARGET_PAIRED_FLOAT"
156 "ps_msub %0,%1,%2,%3"
157 [(set_attr "type" "fp")])
159 (define_insn "*paired_nmadd"
160 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
163 (match_operand:V2SF 1 "gpc_reg_operand" "f")
164 (match_operand:V2SF 2 "gpc_reg_operand" "f")
165 (match_operand:V2SF 3 "gpc_reg_operand" "f"))))]
166 "TARGET_PAIRED_FLOAT"
167 "ps_nmadd %0,%1,%2,%3"
168 [(set_attr "type" "fp")])
170 (define_insn "*paired_nmsub"
171 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
174 (match_operand:V2SF 1 "gpc_reg_operand" "f")
175 (match_operand:V2SF 2 "gpc_reg_operand" "f")
176 (neg:V2SF (match_operand:V2SF 3 "gpc_reg_operand" "f")))))]
177 "TARGET_PAIRED_FLOAT"
178 "ps_nmsub %0,%1,%2,%3"
179 [(set_attr "type" "dmul")])
181 (define_insn "selv2sf4"
182 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
184 (if_then_else:SF (ge (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
185 (parallel [(const_int 0)]))
186 (match_operand:SF 4 "zero_fp_constant" "F"))
187 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
188 (parallel [(const_int 0)]))
189 (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
190 (parallel [(const_int 0)])))
191 (if_then_else:SF (ge (vec_select:SF (match_dup 1)
192 (parallel [(const_int 1)]))
194 (vec_select:SF (match_dup 2)
195 (parallel [(const_int 1)]))
196 (vec_select:SF (match_dup 3)
197 (parallel [(const_int 1)])))))]
199 "TARGET_PAIRED_FLOAT"
201 [(set_attr "type" "fp")])
203 (define_insn "*movv2sf_paired"
204 [(set (match_operand:V2SF 0 "nonimmediate_operand" "=Z,f,f,o,r,r,f")
205 (match_operand:V2SF 1 "input_operand" "f,Z,f,r,o,r,W"))]
207 && (register_operand (operands[0], V2SFmode)
208 || register_operand (operands[1], V2SFmode))"
210 switch (which_alternative)
212 case 0: return "psq_stx %1,%y0,0,0";
213 case 1: return "psq_lx %0,%y1,0,0";
214 case 2: return "ps_mr %0,%1";
219 default: gcc_unreachable ();
222 [(set_attr "type" "fpstore,fpload,fp,*,*,*,*")])
224 (define_insn "paired_stx"
225 [(set (match_operand:V2SF 0 "memory_operand" "=Z")
226 (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
227 "TARGET_PAIRED_FLOAT"
229 [(set_attr "type" "fpstore")])
231 (define_insn "paired_lx"
232 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
233 (match_operand:V2SF 1 "memory_operand" "Z"))]
234 "TARGET_PAIRED_FLOAT"
236 [(set_attr "type" "fpload")])
240 [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
241 (match_operand:V2SF 1 "input_operand" ""))]
242 "TARGET_PAIRED_FLOAT && reload_completed
243 && gpr_or_gpr_p (operands[0], operands[1])"
246 rs6000_split_multireg_move (operands[0], operands[1]); DONE;
249 (define_insn "paired_cmpu0"
250 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
251 (compare:CCFP (vec_select:SF
252 (match_operand:V2SF 1 "gpc_reg_operand" "f")
253 (parallel [(const_int 0)]))
255 (match_operand:V2SF 2 "gpc_reg_operand" "f")
256 (parallel [(const_int 0)]))))]
257 "TARGET_PAIRED_FLOAT"
259 [(set_attr "type" "fpcompare")])
261 (define_insn "paired_cmpu1"
262 [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
263 (compare:CCFP (vec_select:SF
264 (match_operand:V2SF 1 "gpc_reg_operand" "f")
265 (parallel [(const_int 1)]))
267 (match_operand:V2SF 2 "gpc_reg_operand" "f")
268 (parallel [(const_int 1)]))))]
269 "TARGET_PAIRED_FLOAT"
271 [(set_attr "type" "fpcompare")])
273 (define_insn "paired_merge00"
274 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
276 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
277 (parallel [(const_int 0)]))
278 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
279 (parallel [(const_int 0)]))))]
280 "TARGET_PAIRED_FLOAT"
281 "ps_merge00 %0, %1, %2"
282 [(set_attr "type" "fp")])
284 (define_insn "paired_merge01"
285 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
287 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
288 (parallel [(const_int 0)]))
289 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
290 (parallel [(const_int 1)]))))]
291 "TARGET_PAIRED_FLOAT"
292 "ps_merge01 %0, %1, %2"
293 [(set_attr "type" "fp")])
295 (define_insn "paired_merge10"
296 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
298 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
299 (parallel [(const_int 1)]))
300 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
301 (parallel [(const_int 0)]))))]
302 "TARGET_PAIRED_FLOAT"
303 "ps_merge10 %0, %1, %2"
304 [(set_attr "type" "fp")])
306 (define_insn "paired_merge11"
307 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
309 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
310 (parallel [(const_int 1)]))
311 (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
312 (parallel [(const_int 1)]))))]
313 "TARGET_PAIRED_FLOAT"
314 "ps_merge11 %0, %1, %2"
315 [(set_attr "type" "fp")])
317 (define_insn "paired_sum0"
318 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
319 (vec_concat:V2SF (plus:SF (vec_select:SF
320 (match_operand:V2SF 1 "gpc_reg_operand" "f")
321 (parallel [(const_int 0)]))
323 (match_operand:V2SF 2 "gpc_reg_operand" "f")
324 (parallel [(const_int 1)])))
326 (match_operand:V2SF 3 "gpc_reg_operand" "f")
327 (parallel [(const_int 1)]))))]
328 "TARGET_PAIRED_FLOAT"
329 "ps_sum0 %0,%1,%2,%3"
330 [(set_attr "type" "fp")])
332 (define_insn "paired_sum1"
333 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
334 (vec_concat:V2SF (vec_select:SF
335 (match_operand:V2SF 2 "gpc_reg_operand" "f")
336 (parallel [(const_int 1)]))
337 (plus:SF (vec_select:SF
338 (match_operand:V2SF 1 "gpc_reg_operand" "f")
339 (parallel [(const_int 0)]))
341 (match_operand:V2SF 3 "gpc_reg_operand" "f")
342 (parallel [(const_int 1)])))))]
343 "TARGET_PAIRED_FLOAT"
344 "ps_sum1 %0,%1,%2,%3"
345 [(set_attr "type" "fp")])
347 (define_insn "paired_muls0"
348 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
349 (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
351 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
352 (parallel [(const_int 0)])))))]
353 "TARGET_PAIRED_FLOAT"
354 "ps_muls0 %0, %1, %2"
355 [(set_attr "type" "fp")])
358 (define_insn "paired_muls1"
359 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
360 (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
362 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
363 (parallel [(const_int 1)])))))]
364 "TARGET_PAIRED_FLOAT"
365 "ps_muls1 %0, %1, %2"
366 [(set_attr "type" "fp")])
368 (define_expand "vec_initv2sf"
369 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
370 (match_operand 1 "" "")]
371 "TARGET_PAIRED_FLOAT"
373 paired_expand_vector_init (operands[0], operands[1]);
377 (define_insn "*vconcatsf"
378 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
380 (match_operand:SF 1 "gpc_reg_operand" "f")
381 (match_operand:SF 2 "gpc_reg_operand" "f")))]
382 "TARGET_PAIRED_FLOAT"
383 "ps_merge00 %0, %1, %2"
384 [(set_attr "type" "fp")])
386 (define_expand "sminv2sf3"
387 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
388 (smin:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
389 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
390 "TARGET_PAIRED_FLOAT"
392 rtx tmp = gen_reg_rtx (V2SFmode);
394 emit_insn (gen_subv2sf3 (tmp, operands[1], operands[2]));
395 emit_insn (gen_selv2sf4 (operands[0], tmp, operands[2], operands[1], CONST0_RTX (SFmode)));
399 (define_expand "smaxv2sf3"
400 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
401 (smax:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
402 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
403 "TARGET_PAIRED_FLOAT"
405 rtx tmp = gen_reg_rtx (V2SFmode);
407 emit_insn (gen_subv2sf3 (tmp, operands[1], operands[2]));
408 emit_insn (gen_selv2sf4 (operands[0], tmp, operands[1], operands[2], CONST0_RTX (SFmode)));
412 (define_expand "reduc_smax_v2sf"
413 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
414 (match_operand:V2SF 1 "gpc_reg_operand" "f")]
415 "TARGET_PAIRED_FLOAT"
417 rtx tmp_swap = gen_reg_rtx (V2SFmode);
418 rtx tmp = gen_reg_rtx (V2SFmode);
420 emit_insn (gen_paired_merge10 (tmp_swap, operands[1], operands[1]));
421 emit_insn (gen_subv2sf3 (tmp, operands[1], tmp_swap));
422 emit_insn (gen_selv2sf4 (operands[0], tmp, operands[1], tmp_swap, CONST0_RTX (SFmode)));
427 (define_expand "reduc_smin_v2sf"
428 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
429 (match_operand:V2SF 1 "gpc_reg_operand" "f")]
430 "TARGET_PAIRED_FLOAT"
432 rtx tmp_swap = gen_reg_rtx (V2SFmode);
433 rtx tmp = gen_reg_rtx (V2SFmode);
435 emit_insn (gen_paired_merge10 (tmp_swap, operands[1], operands[1]));
436 emit_insn (gen_subv2sf3 (tmp, operands[1], tmp_swap));
437 emit_insn (gen_selv2sf4 (operands[0], tmp, tmp_swap, operands[1], CONST0_RTX (SFmode)));
442 (define_expand "vec_interleave_highv2sf"
443 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
444 (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")
445 (match_operand:V2SF 2 "gpc_reg_operand" "f")]
446 UNSPEC_INTERHI_V2SF))]
447 "TARGET_PAIRED_FLOAT"
450 emit_insn (gen_paired_merge00 (operands[0], operands[1], operands[2]));
454 (define_expand "vec_interleave_lowv2sf"
455 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
456 (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")
457 (match_operand:V2SF 2 "gpc_reg_operand" "f")]
458 UNSPEC_INTERLO_V2SF))]
459 "TARGET_PAIRED_FLOAT"
462 emit_insn (gen_paired_merge11 (operands[0], operands[1], operands[2]));
466 (define_expand "vec_extract_evenv2sf"
467 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
468 (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")
469 (match_operand:V2SF 2 "gpc_reg_operand" "f")]
470 UNSPEC_EXTEVEN_V2SF))]
471 "TARGET_PAIRED_FLOAT"
474 emit_insn (gen_paired_merge00 (operands[0], operands[1], operands[2]));
478 (define_expand "vec_extract_oddv2sf"
479 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
480 (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")
481 (match_operand:V2SF 2 "gpc_reg_operand" "f")]
482 UNSPEC_EXTODD_V2SF))]
483 "TARGET_PAIRED_FLOAT"
486 emit_insn (gen_paired_merge11 (operands[0], operands[1], operands[2]));
491 (define_expand "reduc_splus_v2sf"
492 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
493 (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
494 "TARGET_PAIRED_FLOAT"
497 emit_insn (gen_paired_sum1 (operands[0], operands[1], operands[1], operands[1]));
501 (define_expand "movmisalignv2sf"
502 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
503 (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
504 "TARGET_PAIRED_FLOAT"
506 paired_expand_vector_move (operands);
510 (define_expand "vcondv2sfv2sf"
511 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
513 (match_operator 3 "gpc_reg_operand"
514 [(match_operand:V2SF 4 "gpc_reg_operand" "f")
515 (match_operand:V2SF 5 "gpc_reg_operand" "f")])
516 (match_operand:V2SF 1 "gpc_reg_operand" "f")
517 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
518 "TARGET_PAIRED_FLOAT && flag_unsafe_math_optimizations"
521 if (paired_emit_vector_cond_expr (operands[0], operands[1], operands[2],
522 operands[3], operands[4], operands[5]))