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")
277 (match_operand:V2SF 1 "gpc_reg_operand" "f")
278 (match_operand:V2SF 2 "gpc_reg_operand" "f"))
279 (parallel [(const_int 0) (const_int 2)])))]
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")
288 (match_operand:V2SF 1 "gpc_reg_operand" "f")
289 (match_operand:V2SF 2 "gpc_reg_operand" "f"))
290 (parallel [(const_int 0) (const_int 3)])))]
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")
299 (match_operand:V2SF 1 "gpc_reg_operand" "f")
300 (match_operand:V2SF 2 "gpc_reg_operand" "f"))
301 (parallel [(const_int 1) (const_int 2)])))]
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")
310 (match_operand:V2SF 1 "gpc_reg_operand" "f")
311 (match_operand:V2SF 2 "gpc_reg_operand" "f"))
312 (parallel [(const_int 1) (const_int 3)])))]
313 "TARGET_PAIRED_FLOAT"
314 "ps_merge11 %0, %1, %2"
315 [(set_attr "type" "fp")])
317 (define_expand "vec_perm_constv2sf"
318 [(match_operand:V2SF 0 "gpc_reg_operand" "")
319 (match_operand:V2SF 1 "gpc_reg_operand" "")
320 (match_operand:V2SF 2 "gpc_reg_operand" "")
321 (match_operand:V2SI 3 "" "")]
322 "TARGET_PAIRED_FLOAT"
324 if (rs6000_expand_vec_perm_const (operands))
330 (define_insn "paired_sum0"
331 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
332 (vec_concat:V2SF (plus:SF (vec_select:SF
333 (match_operand:V2SF 1 "gpc_reg_operand" "f")
334 (parallel [(const_int 0)]))
336 (match_operand:V2SF 2 "gpc_reg_operand" "f")
337 (parallel [(const_int 1)])))
339 (match_operand:V2SF 3 "gpc_reg_operand" "f")
340 (parallel [(const_int 1)]))))]
341 "TARGET_PAIRED_FLOAT"
342 "ps_sum0 %0,%1,%2,%3"
343 [(set_attr "type" "fp")])
345 (define_insn "paired_sum1"
346 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
347 (vec_concat:V2SF (vec_select:SF
348 (match_operand:V2SF 2 "gpc_reg_operand" "f")
349 (parallel [(const_int 1)]))
350 (plus:SF (vec_select:SF
351 (match_operand:V2SF 1 "gpc_reg_operand" "f")
352 (parallel [(const_int 0)]))
354 (match_operand:V2SF 3 "gpc_reg_operand" "f")
355 (parallel [(const_int 1)])))))]
356 "TARGET_PAIRED_FLOAT"
357 "ps_sum1 %0,%1,%2,%3"
358 [(set_attr "type" "fp")])
360 (define_insn "paired_muls0"
361 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
362 (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
364 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
365 (parallel [(const_int 0)])))))]
366 "TARGET_PAIRED_FLOAT"
367 "ps_muls0 %0, %1, %2"
368 [(set_attr "type" "fp")])
371 (define_insn "paired_muls1"
372 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
373 (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
375 (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
376 (parallel [(const_int 1)])))))]
377 "TARGET_PAIRED_FLOAT"
378 "ps_muls1 %0, %1, %2"
379 [(set_attr "type" "fp")])
381 (define_expand "vec_initv2sf"
382 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
383 (match_operand 1 "" "")]
384 "TARGET_PAIRED_FLOAT"
386 paired_expand_vector_init (operands[0], operands[1]);
390 (define_insn "*vconcatsf"
391 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
393 (match_operand:SF 1 "gpc_reg_operand" "f")
394 (match_operand:SF 2 "gpc_reg_operand" "f")))]
395 "TARGET_PAIRED_FLOAT"
396 "ps_merge00 %0, %1, %2"
397 [(set_attr "type" "fp")])
399 (define_expand "sminv2sf3"
400 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
401 (smin: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[2], operands[1], CONST0_RTX (SFmode)));
412 (define_expand "smaxv2sf3"
413 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
414 (smax:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
415 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
416 "TARGET_PAIRED_FLOAT"
418 rtx tmp = gen_reg_rtx (V2SFmode);
420 emit_insn (gen_subv2sf3 (tmp, operands[1], operands[2]));
421 emit_insn (gen_selv2sf4 (operands[0], tmp, operands[1], operands[2], CONST0_RTX (SFmode)));
425 (define_expand "reduc_smax_v2sf"
426 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
427 (match_operand:V2SF 1 "gpc_reg_operand" "f")]
428 "TARGET_PAIRED_FLOAT"
430 rtx tmp_swap = gen_reg_rtx (V2SFmode);
431 rtx tmp = gen_reg_rtx (V2SFmode);
433 emit_insn (gen_paired_merge10 (tmp_swap, operands[1], operands[1]));
434 emit_insn (gen_subv2sf3 (tmp, operands[1], tmp_swap));
435 emit_insn (gen_selv2sf4 (operands[0], tmp, operands[1], tmp_swap, CONST0_RTX (SFmode)));
440 (define_expand "reduc_smin_v2sf"
441 [(match_operand:V2SF 0 "gpc_reg_operand" "=f")
442 (match_operand:V2SF 1 "gpc_reg_operand" "f")]
443 "TARGET_PAIRED_FLOAT"
445 rtx tmp_swap = gen_reg_rtx (V2SFmode);
446 rtx tmp = gen_reg_rtx (V2SFmode);
448 emit_insn (gen_paired_merge10 (tmp_swap, operands[1], operands[1]));
449 emit_insn (gen_subv2sf3 (tmp, operands[1], tmp_swap));
450 emit_insn (gen_selv2sf4 (operands[0], tmp, tmp_swap, operands[1], CONST0_RTX (SFmode)));
455 (define_expand "reduc_splus_v2sf"
456 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
457 (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
458 "TARGET_PAIRED_FLOAT"
461 emit_insn (gen_paired_sum1 (operands[0], operands[1], operands[1], operands[1]));
465 (define_expand "movmisalignv2sf"
466 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
467 (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
468 "TARGET_PAIRED_FLOAT"
470 paired_expand_vector_move (operands);
474 (define_expand "vcondv2sfv2sf"
475 [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
477 (match_operator 3 "gpc_reg_operand"
478 [(match_operand:V2SF 4 "gpc_reg_operand" "f")
479 (match_operand:V2SF 5 "gpc_reg_operand" "f")])
480 (match_operand:V2SF 1 "gpc_reg_operand" "f")
481 (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
482 "TARGET_PAIRED_FLOAT && flag_unsafe_math_optimizations"
484 if (paired_emit_vector_cond_expr (operands[0], operands[1], operands[2],
485 operands[3], operands[4], operands[5]))