OSDN Git Service

ad3001d884c6f2842a682384ee89470360e78231
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / paired.md
1 ;; PowerPC paired single and double hummer description
2 ;; Copyright (C) 2007
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by David Edelsohn <edelsohn@gnu.org> and Revital Eres
5 ;; <eres@il.ibm.com>
6
7 ;; This file is part of GCC.
8
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 2, or (at your
12 ;; option) any later version.
13
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.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
22 ;; MA 02110-1301, USA.
23
24
25 (define_insn "negv2sf2"
26   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
27         (neg:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
28   "TARGET_PAIRED_FLOAT"
29   "ps_neg %0,%1"
30   [(set_attr "type" "fp")])
31
32 (define_insn "sqrtv2sf2"
33   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
34         (sqrt:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
35   "TARGET_PAIRED_FLOAT"
36   "ps_rsqrte %0,%1"
37   [(set_attr "type" "fp")])
38
39 (define_insn "absv2sf2"
40   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
41         (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")))]
42   "TARGET_PAIRED_FLOAT"
43   "ps_abs %0,%1"
44   [(set_attr "type" "fp")])
45
46 (define_insn "nabsv2sf2"
47   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
48         (neg:V2SF (abs:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f"))))]
49   "TARGET_PAIRED_FLOAT"
50   "ps_nabs %0,%1"
51   [(set_attr "type" "fp")])
52
53 (define_insn "addv2sf3"
54   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
55         (plus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
56                    (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
57   "TARGET_PAIRED_FLOAT"
58   "ps_add %0,%1,%2"
59   [(set_attr "type" "fp")])
60
61 (define_insn "subv2sf3"
62   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
63         (minus:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
64                     (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
65   "TARGET_PAIRED_FLOAT"
66   "ps_sub %0,%1,%2"
67   [(set_attr "type" "fp")])
68
69 (define_insn "mulv2sf3"
70   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
71         (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
72                    (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
73   "TARGET_PAIRED_FLOAT"
74   "ps_mul %0,%1,%2"
75   [(set_attr "type" "fp")])
76
77 (define_insn "resv2sf2"
78   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
79         (unspec:V2SF [(match_operand:V2SF 1 "gpc_reg_operand" "f")] UNSPEC_FRES))]
80   "TARGET_PAIRED_FLOAT && flag_finite_math_only"
81   "ps_res %0,%1"
82   [(set_attr "type" "fp")])
83
84 (define_insn "divv2sf3"
85   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
86         (div:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
87                   (match_operand:V2SF 2 "gpc_reg_operand" "f")))]
88   "TARGET_PAIRED_FLOAT"
89   "ps_div %0,%1,%2"
90   [(set_attr "type" "sdiv")])
91
92 (define_insn "paired_madds0"
93  [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
94                  (vec_concat:V2SF
95                  (plus:SF (mult:SF (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
96                                                   (parallel [(const_int 0)]))
97                                    (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
98                                          (parallel [(const_int 0)])))
99                           (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
100                                          (parallel [(const_int 0)])))
101                  (plus:SF (mult:SF (vec_select:SF (match_dup 1)
102                                          (parallel [(const_int 1)]))
103                                      (vec_select:SF (match_dup 2)
104                                          (parallel [(const_int 0)])))
105                           (vec_select:SF (match_dup 3)
106                                          (parallel [(const_int 1)])))))]
107   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD"
108   "ps_madds0 %0,%1,%2,%3"
109   [(set_attr "type" "fp")])
110
111 (define_insn "paired_madds1"
112  [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
113                  (vec_concat:V2SF
114                  (plus:SF (mult:SF (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
115                                                   (parallel [(const_int 0)]))
116                                    (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
117                                          (parallel [(const_int 1)])))
118                           (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
119                                          (parallel [(const_int 0)])))
120                  (plus:SF (mult:SF (vec_select:SF (match_dup 1)
121                                          (parallel [(const_int 1)]))
122                                      (vec_select:SF (match_dup 2)
123                                          (parallel [(const_int 1)])))
124                           (vec_select:SF (match_dup 3)
125                                          (parallel [(const_int 1)])))))]
126   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD"
127   "ps_madds1 %0,%1,%2,%3"
128   [(set_attr "type" "fp")])
129
130 (define_insn "paired_madd"
131   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
132         (plus:V2SF (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
133                               (match_operand:V2SF 2 "gpc_reg_operand" "f"))
134                    (match_operand:V2SF 3 "gpc_reg_operand" "f")))]
135   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD"
136   "ps_madd %0,%1,%2,%3"
137   [(set_attr "type" "fp")]) 
138
139 (define_insn "paired_msub"
140   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
141         (minus:V2SF (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
142                                (match_operand:V2SF 2 "gpc_reg_operand" "f"))
143                     (match_operand:V2SF 3 "gpc_reg_operand" "f")))]
144   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD"
145   "ps_msub %0,%1,%2,%3"
146   [(set_attr "type" "fp")])
147
148 (define_insn "paired_nmadd"
149   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
150         (neg:V2SF (plus:V2SF (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
151                                         (match_operand:V2SF 2 "gpc_reg_operand" "f"))
152                              (match_operand:V2SF 3 "gpc_reg_operand" "f"))))]
153   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD
154    && HONOR_SIGNED_ZEROS (SFmode)"
155   "ps_nmadd %0,%1,%2,%3"
156   [(set_attr "type" "fp")])
157
158 (define_insn "paired_nmsub"
159   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
160         (neg:V2SF (minus:V2SF (mult:V2SF (match_operand:V2SF 1 "gpc_reg_operand" "%f")
161                                          (match_operand:V2SF 2 "gpc_reg_operand" "f"))
162                               (match_operand:V2SF 3 "gpc_reg_operand" "f"))))]
163   "TARGET_PAIRED_FLOAT && TARGET_FUSED_MADD
164    && HONOR_SIGNED_ZEROS (DFmode)"
165   "ps_nmsub %0,%1,%2,%3"
166   [(set_attr "type" "dmul")])
167
168 (define_insn "selv2sf4"
169   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
170         (vec_concat:V2SF
171          (if_then_else:SF (ge (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
172                                              (parallel [(const_int 0)]))
173                               (match_operand:SF 4 "zero_fp_constant" "F"))
174                           (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
175                                          (parallel [(const_int 0)]))
176                           (vec_select:SF (match_operand:V2SF 3 "gpc_reg_operand" "f")
177                                          (parallel [(const_int 0)])))
178          (if_then_else:SF (ge (vec_select:SF (match_dup 1)
179                                              (parallel [(const_int 1)]))
180                               (match_dup 4))
181                           (vec_select:SF (match_dup 2)
182                                          (parallel [(const_int 1)]))
183                           (vec_select:SF (match_dup 3)
184                                          (parallel [(const_int 1)])))))]
185
186   "TARGET_PAIRED_FLOAT"
187   "ps_sel %0,%1,%2,%3"
188   [(set_attr "type" "fp")])
189
190 (define_insn "*movv2sf_paired"
191   [(set (match_operand:V2SF 0 "nonimmediate_operand" "=Z,f,f,o,r,r,v")
192                  (match_operand:V2SF 1 "input_operand" "f,Z,f,r,o,r,W"))]
193   "TARGET_PAIRED_FLOAT
194    && (register_operand (operands[0], V2SFmode) 
195        || register_operand (operands[1], V2SFmode))"
196 {
197   switch (which_alternative)
198     {
199     case 0: return "psq_stx %1,%y0,0,0";
200     case 1: return "psq_lx %0,%y1,0,0";
201     case 2: return "ps_mr %0,%1";
202     case 3: return "#";
203     case 4: return "#";
204     case 5: return "#";
205     case 6: return output_vec_const_move (operands);
206     default: gcc_unreachable ();
207     }
208 }
209   [(set_attr "type" "fpstore,fpload,fp,*,*,*,*")])
210
211 (define_insn "paired_stx"
212   [(set (match_operand:V2SF 0 "memory_operand" "=Z")
213         (match_operand:V2SF 1 "gpc_reg_operand" "f"))]
214   "TARGET_PAIRED_FLOAT"
215   "psq_stx %1,%y0,0,0"
216   [(set_attr "type" "fpstore")])
217
218 (define_insn "paired_lx"
219   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
220         (match_operand:V2SF 1 "memory_operand" "Z"))]
221   "TARGET_PAIRED_FLOAT"
222   "psq_lx %0,%y1,0,0"
223   [(set_attr "type" "fpload")])
224
225
226 (define_split
227   [(set (match_operand:V2SF 0 "nonimmediate_operand" "")
228         (match_operand:V2SF 1 "input_operand" ""))]
229   "TARGET_PAIRED_FLOAT && reload_completed
230    && gpr_or_gpr_p (operands[0], operands[1])"
231   [(pc)]
232   {
233   rs6000_split_multireg_move (operands[0], operands[1]); DONE;
234   })
235
236 (define_insn "paired_cmpu0"
237   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
238         (compare:CCFP (vec_select:SF
239                        (match_operand:V2SF 1 "gpc_reg_operand" "f")
240                        (parallel [(const_int 0)]))
241                       (vec_select:SF
242                        (match_operand:V2SF 2 "gpc_reg_operand" "f")
243                        (parallel [(const_int 0)]))))]
244   "TARGET_PAIRED_FLOAT"
245   "ps_cmpu0 %0,%1,%2"
246   [(set_attr "type" "fpcompare")])
247
248 (define_insn "paired_cmpu1"
249   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
250         (compare:CCFP (vec_select:SF
251                        (match_operand:V2SF 1 "gpc_reg_operand" "f")
252                        (parallel [(const_int 1)]))
253                       (vec_select:SF
254                        (match_operand:V2SF 2 "gpc_reg_operand" "f")
255                        (parallel [(const_int 1)]))))]
256   "TARGET_PAIRED_FLOAT"
257   "ps_cmpu1 %0,%1,%2"
258   [(set_attr "type" "fpcompare")])
259
260 (define_insn "paired_merge00"
261   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
262         (vec_concat:V2SF
263          (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
264                         (parallel [(const_int 0)]))
265          (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
266                         (parallel [(const_int 0)]))))]
267   "TARGET_PAIRED_FLOAT"
268   "ps_merge00 %0, %1, %2"
269   [(set_attr "type" "fp")])
270
271 (define_insn "paired_merge01"
272   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
273         (vec_concat:V2SF
274          (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
275                         (parallel [(const_int 0)]))
276          (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
277                         (parallel [(const_int 1)]))))]
278   "TARGET_PAIRED_FLOAT"
279   "ps_merge01 %0, %1, %2"
280   [(set_attr "type" "fp")])
281
282 (define_insn "paired_merge10"
283   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
284         (vec_concat:V2SF
285          (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
286                         (parallel [(const_int 1)]))
287          (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
288                         (parallel [(const_int 0)]))))]
289   "TARGET_PAIRED_FLOAT"
290   "ps_merge10 %0, %1, %2"
291   [(set_attr "type" "fp")])
292
293 (define_insn "paired_merge11"
294   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
295         (vec_concat:V2SF
296          (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
297                         (parallel [(const_int 1)]))
298          (vec_select:SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
299                         (parallel [(const_int 1)]))))]
300   "TARGET_PAIRED_FLOAT"
301   "ps_merge11 %0, %1, %2"
302   [(set_attr "type" "fp")])
303
304 (define_insn "paired_sum0"
305   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
306         (vec_concat:V2SF (plus:SF (vec_select:SF
307                                    (match_operand:V2SF 1 "gpc_reg_operand" "f")
308                                    (parallel [(const_int 0)]))
309                                   (vec_select:SF
310                                    (match_operand:V2SF 2 "gpc_reg_operand" "f")
311                                    (parallel [(const_int 1)])))
312                          (vec_select:SF
313                           (match_operand:V2SF 3 "gpc_reg_operand" "f")
314                           (parallel [(const_int 1)]))))]
315   "TARGET_PAIRED_FLOAT"
316   "ps_sum0 %0,%1,%2,%3"
317   [(set_attr "type" "fp")])
318
319 (define_insn "paired_sum1"
320   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
321         (vec_concat:V2SF (vec_select:SF
322                           (match_operand:V2SF 2 "gpc_reg_operand" "f")
323                           (parallel [(const_int 1)]))
324                          (plus:SF (vec_select:SF
325                                    (match_operand:V2SF 1 "gpc_reg_operand" "f")
326                                    (parallel [(const_int 0)]))
327                                   (vec_select:SF
328                                    (match_operand:V2SF 3 "gpc_reg_operand" "f")
329                                    (parallel [(const_int 1)])))))]
330   "TARGET_PAIRED_FLOAT"
331   "ps_sum1 %0,%1,%2,%3"
332   [(set_attr "type" "fp")])
333
334 (define_insn "paired_muls0"
335   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
336         (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
337                    (vec_duplicate:V2SF
338                     (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
339                                    (parallel [(const_int 0)])))))]
340   "TARGET_PAIRED_FLOAT"
341   "ps_muls0 %0, %1, %2"
342   [(set_attr "type" "fp")])
343
344
345 (define_insn "paired_muls1"
346   [(set (match_operand:V2SF 0 "gpc_reg_operand" "=f")
347         (mult:V2SF (match_operand:V2SF 2 "gpc_reg_operand" "f")
348                    (vec_duplicate:V2SF
349                     (vec_select:SF (match_operand:V2SF 1 "gpc_reg_operand" "f")
350                                    (parallel [(const_int 1)])))))]
351   "TARGET_PAIRED_FLOAT"
352   "ps_muls1 %0, %1, %2"
353   [(set_attr "type" "fp")])
354
355