OSDN Git Service

* config/rs6000/rs6000.md (UNSPEC constants): Add UNSPEC_STFIWX.
[pf3gnuchains/gcc-fork.git] / gcc / config / rs6000 / rs6000.md
1 ;; Machine description for IBM RISC System 6000 (POWER) for GNU C compiler
2 ;; Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
3 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5
6 ;; This file is part of GCC.
7
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 2, or (at your
11 ;; option) any later version.
12
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING.  If not, write to the
20 ;; Free Software Foundation, 59 Temple Place - Suite 330, Boston,
21 ;; MA 02111-1307, USA.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 ;;
26 ;; UNSPEC usage
27 ;;
28
29 (define_constants
30   [(UNSPEC_FRSP                 0)      ; frsp for POWER machines
31    (UNSPEC_TIE                  5)      ; tie stack contents and stack pointer
32    (UNSPEC_TOCPTR               6)      ; address of a word pointing to the TOC
33    (UNSPEC_TOC                  7)      ; address of the TOC (more-or-less)
34    (UNSPEC_MOVSI_GOT            8)
35    (UNSPEC_MV_CR_OV             9)      ; move_from_CR_ov_bit
36    (UNSPEC_FCTIWZ               10)
37    (UNSPEC_LD_MPIC              15)     ; load_macho_picbase
38    (UNSPEC_MPIC_CORRECT         16)     ; macho_correct_pic
39    (UNSPEC_TLSGD                17)
40    (UNSPEC_TLSLD                18)
41    (UNSPEC_MOVESI_FROM_CR       19)
42    (UNSPEC_MOVESI_TO_CR         20)
43    (UNSPEC_TLSDTPREL            21)
44    (UNSPEC_TLSDTPRELHA          22)
45    (UNSPEC_TLSDTPRELLO          23)
46    (UNSPEC_TLSGOTDTPREL         24)
47    (UNSPEC_TLSTPREL             25)
48    (UNSPEC_TLSTPRELHA           26)
49    (UNSPEC_TLSTPRELLO           27)
50    (UNSPEC_TLSGOTTPREL          28)
51    (UNSPEC_TLSTLS               29)
52    (UNSPEC_FIX_TRUNC_TF         30)     ; fadd, rounding towards zero
53    (UNSPEC_MV_CR_GT             31)     ; move_from_CR_eq_bit
54    (UNSPEC_STFIWX               32)
55   ])
56
57 ;;
58 ;; UNSPEC_VOLATILE usage
59 ;;
60
61 (define_constants
62   [(UNSPECV_BLOCK               0)
63    (UNSPECV_EH_RR               9)      ; eh_reg_restore
64   ])
65 \f
66 ;; Define an insn type attribute.  This is used in function unit delay
67 ;; computations.
68 (define_attr "type" "integer,two,three,load,load_ext,load_ext_u,load_ext_ux,load_ux,load_u,store,store_ux,store_u,fpload,fpload_ux,fpload_u,fpstore,fpstore_ux,fpstore_u,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,insert_word,branch,cmp,fast_compare,compare,delayed_compare,imul_compare,lmul_compare,fpcompare,cr_logical,delayed_cr,mfcr,mfcrf,mtcr,mfjmpr,mtjmpr,fp,fpsimple,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,brinc,vecsimple,veccomplex,vecdiv,veccmp,veccmpsimple,vecperm,vecfloat,vecfdiv"
69   (const_string "integer"))
70
71 ;; Length (in bytes).
72 ; '(pc)' in the following doesn't include the instruction itself; it is
73 ; calculated as if the instruction had zero size.
74 (define_attr "length" ""
75   (if_then_else (eq_attr "type" "branch")
76                 (if_then_else (and (ge (minus (match_dup 0) (pc))
77                                        (const_int -32768))
78                                    (lt (minus (match_dup 0) (pc))
79                                        (const_int 32764)))
80                               (const_int 4)
81                               (const_int 8))
82                 (const_int 4)))
83
84 ;; Processor type -- this attribute must exactly match the processor_type
85 ;; enumeration in rs6000.h.
86
87 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc440,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4,power5"
88   (const (symbol_ref "rs6000_cpu_attr")))
89
90 (automata_option "ndfa")
91
92 (include "rios1.md")
93 (include "rios2.md")
94 (include "rs64.md")
95 (include "mpc.md")
96 (include "40x.md")
97 (include "440.md")
98 (include "603.md")
99 (include "6xx.md")
100 (include "7xx.md")
101 (include "7450.md")
102 (include "8540.md")
103 (include "power4.md")
104 (include "power5.md")
105
106 (include "predicates.md")
107
108 (include "darwin.md")
109
110 \f
111 ;; This mode macro allows :P to be used for patterns that operate on
112 ;; pointer-sized quantities.  Exactly one of the two alternatives will match.
113 (define_mode_macro P [(SI "Pmode == SImode") (DI "Pmode == DImode")])
114
115 ;; Start with fixed-point load and store insns.  Here we put only the more
116 ;; complex forms.  Basic data transfer is done later.
117
118 (define_expand "zero_extendqidi2"
119   [(set (match_operand:DI 0 "gpc_reg_operand" "")
120         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
121   "TARGET_POWERPC64"
122   "")
123
124 (define_insn ""
125   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
126         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
127   "TARGET_POWERPC64"
128   "@
129    lbz%U1%X1 %0,%1
130    rldicl %0,%1,0,56"
131   [(set_attr "type" "load,*")])
132
133 (define_insn ""
134   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
135         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
136                     (const_int 0)))
137    (clobber (match_scratch:DI 2 "=r,r"))]
138   "TARGET_64BIT"
139   "@
140    rldicl. %2,%1,0,56
141    #"
142   [(set_attr "type" "compare")
143    (set_attr "length" "4,8")])
144
145 (define_split
146   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
147         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
148                     (const_int 0)))
149    (clobber (match_scratch:DI 2 ""))]
150   "TARGET_POWERPC64 && reload_completed"
151   [(set (match_dup 2)
152         (zero_extend:DI (match_dup 1)))
153    (set (match_dup 0)
154         (compare:CC (match_dup 2)
155                     (const_int 0)))]
156   "")
157
158 (define_insn ""
159   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
160         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
161                     (const_int 0)))
162    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
163         (zero_extend:DI (match_dup 1)))]
164   "TARGET_64BIT"
165   "@
166    rldicl. %0,%1,0,56
167    #"
168   [(set_attr "type" "compare")
169    (set_attr "length" "4,8")])
170
171 (define_split
172   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
173         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
174                     (const_int 0)))
175    (set (match_operand:DI 0 "gpc_reg_operand" "")
176         (zero_extend:DI (match_dup 1)))]
177   "TARGET_POWERPC64 && reload_completed"
178   [(set (match_dup 0)
179         (zero_extend:DI (match_dup 1)))
180    (set (match_dup 2)
181         (compare:CC (match_dup 0)
182                     (const_int 0)))]
183   "")
184
185 (define_insn "extendqidi2"
186   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
187         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
188   "TARGET_POWERPC64"
189   "extsb %0,%1")
190
191 (define_insn ""
192   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
193         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
194                     (const_int 0)))
195    (clobber (match_scratch:DI 2 "=r,r"))]
196   "TARGET_64BIT"
197   "@
198    extsb. %2,%1
199    #"
200   [(set_attr "type" "compare")
201    (set_attr "length" "4,8")])
202
203 (define_split
204   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
205         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
206                     (const_int 0)))
207    (clobber (match_scratch:DI 2 ""))]
208   "TARGET_POWERPC64 && reload_completed"
209   [(set (match_dup 2)
210         (sign_extend:DI (match_dup 1)))
211    (set (match_dup 0)
212         (compare:CC (match_dup 2)
213                     (const_int 0)))]
214   "")
215
216 (define_insn ""
217   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
218         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
219                     (const_int 0)))
220    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
221         (sign_extend:DI (match_dup 1)))]
222   "TARGET_64BIT"
223   "@
224    extsb. %0,%1
225    #"
226   [(set_attr "type" "compare")
227    (set_attr "length" "4,8")])
228
229 (define_split
230   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
231         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
232                     (const_int 0)))
233    (set (match_operand:DI 0 "gpc_reg_operand" "")
234         (sign_extend:DI (match_dup 1)))]
235   "TARGET_POWERPC64 && reload_completed"
236   [(set (match_dup 0)
237         (sign_extend:DI (match_dup 1)))
238    (set (match_dup 2)
239         (compare:CC (match_dup 0)
240                     (const_int 0)))]
241   "")
242
243 (define_expand "zero_extendhidi2"
244   [(set (match_operand:DI 0 "gpc_reg_operand" "")
245         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
246   "TARGET_POWERPC64"
247   "")
248
249 (define_insn ""
250   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
251         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
252   "TARGET_POWERPC64"
253   "@
254    lhz%U1%X1 %0,%1
255    rldicl %0,%1,0,48"
256   [(set_attr "type" "load,*")])
257
258 (define_insn ""
259   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
260         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
261                     (const_int 0)))
262    (clobber (match_scratch:DI 2 "=r,r"))]
263   "TARGET_64BIT"
264   "@
265    rldicl. %2,%1,0,48
266    #"
267   [(set_attr "type" "compare")
268    (set_attr "length" "4,8")])
269
270 (define_split
271   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
272         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
273                     (const_int 0)))
274    (clobber (match_scratch:DI 2 ""))]
275   "TARGET_POWERPC64 && reload_completed"
276   [(set (match_dup 2)
277         (zero_extend:DI (match_dup 1)))
278    (set (match_dup 0)
279         (compare:CC (match_dup 2)
280                     (const_int 0)))]
281   "")
282
283 (define_insn ""
284   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
285         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
286                     (const_int 0)))
287    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
288         (zero_extend:DI (match_dup 1)))]
289   "TARGET_64BIT"
290   "@
291    rldicl. %0,%1,0,48
292    #"
293   [(set_attr "type" "compare")
294    (set_attr "length" "4,8")])
295
296 (define_split
297   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
298         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
299                     (const_int 0)))
300    (set (match_operand:DI 0 "gpc_reg_operand" "")
301         (zero_extend:DI (match_dup 1)))]
302   "TARGET_POWERPC64 && reload_completed"
303   [(set (match_dup 0)
304         (zero_extend:DI (match_dup 1)))
305    (set (match_dup 2)
306         (compare:CC (match_dup 0)
307                     (const_int 0)))]
308   "")
309
310 (define_expand "extendhidi2"
311   [(set (match_operand:DI 0 "gpc_reg_operand" "")
312         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
313   "TARGET_POWERPC64"
314   "")
315
316 (define_insn ""
317   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
318         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
319   "TARGET_POWERPC64"
320   "@
321    lha%U1%X1 %0,%1
322    extsh %0,%1"
323   [(set_attr "type" "load_ext,*")])
324
325 (define_insn ""
326   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
327         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
328                     (const_int 0)))
329    (clobber (match_scratch:DI 2 "=r,r"))]
330   "TARGET_64BIT"
331   "@
332    extsh. %2,%1
333    #"
334   [(set_attr "type" "compare")
335    (set_attr "length" "4,8")])
336
337 (define_split
338   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
339         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
340                     (const_int 0)))
341    (clobber (match_scratch:DI 2 ""))]
342   "TARGET_POWERPC64 && reload_completed"
343   [(set (match_dup 2)
344         (sign_extend:DI (match_dup 1)))
345    (set (match_dup 0)
346         (compare:CC (match_dup 2)
347                     (const_int 0)))]
348   "")
349
350 (define_insn ""
351   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
352         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
353                     (const_int 0)))
354    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
355         (sign_extend:DI (match_dup 1)))]
356   "TARGET_64BIT"
357   "@
358    extsh. %0,%1
359    #"
360   [(set_attr "type" "compare")
361    (set_attr "length" "4,8")])
362
363 (define_split
364   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
365         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
366                     (const_int 0)))
367    (set (match_operand:DI 0 "gpc_reg_operand" "")
368         (sign_extend:DI (match_dup 1)))]
369   "TARGET_POWERPC64 && reload_completed"
370   [(set (match_dup 0)
371         (sign_extend:DI (match_dup 1)))
372    (set (match_dup 2)
373         (compare:CC (match_dup 0)
374                     (const_int 0)))]
375   "")
376
377 (define_expand "zero_extendsidi2"
378   [(set (match_operand:DI 0 "gpc_reg_operand" "")
379         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
380   "TARGET_POWERPC64"
381   "")
382
383 (define_insn ""
384   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
385         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
386   "TARGET_POWERPC64"
387   "@
388    lwz%U1%X1 %0,%1
389    rldicl %0,%1,0,32"
390   [(set_attr "type" "load,*")])
391
392 (define_insn ""
393   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
394         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
395                     (const_int 0)))
396    (clobber (match_scratch:DI 2 "=r,r"))]
397   "TARGET_64BIT"
398   "@
399    rldicl. %2,%1,0,32
400    #"
401   [(set_attr "type" "compare")
402    (set_attr "length" "4,8")])
403
404 (define_split
405   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
406         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
407                     (const_int 0)))
408    (clobber (match_scratch:DI 2 ""))]
409   "TARGET_POWERPC64 && reload_completed"
410   [(set (match_dup 2)
411         (zero_extend:DI (match_dup 1)))
412    (set (match_dup 0)
413         (compare:CC (match_dup 2)
414                     (const_int 0)))]
415   "")
416
417 (define_insn ""
418   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
419         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
420                     (const_int 0)))
421    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
422         (zero_extend:DI (match_dup 1)))]
423   "TARGET_64BIT"
424   "@
425    rldicl. %0,%1,0,32
426    #"
427   [(set_attr "type" "compare")
428    (set_attr "length" "4,8")])
429
430 (define_split
431   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
432         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
433                     (const_int 0)))
434    (set (match_operand:DI 0 "gpc_reg_operand" "")
435         (zero_extend:DI (match_dup 1)))]
436   "TARGET_POWERPC64 && reload_completed"
437   [(set (match_dup 0)
438         (zero_extend:DI (match_dup 1)))
439    (set (match_dup 2)
440         (compare:CC (match_dup 0)
441                     (const_int 0)))]
442   "")
443
444 (define_expand "extendsidi2"
445   [(set (match_operand:DI 0 "gpc_reg_operand" "")
446         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
447   "TARGET_POWERPC64"
448   "")
449
450 (define_insn ""
451   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
452         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
453   "TARGET_POWERPC64"
454   "@
455    lwa%U1%X1 %0,%1
456    extsw %0,%1"
457   [(set_attr "type" "load_ext,*")])
458
459 (define_insn ""
460   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
461         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
462                     (const_int 0)))
463    (clobber (match_scratch:DI 2 "=r,r"))]
464   "TARGET_64BIT"
465   "@
466    extsw. %2,%1
467    #"
468   [(set_attr "type" "compare")
469    (set_attr "length" "4,8")])
470
471 (define_split
472   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
473         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
474                     (const_int 0)))
475    (clobber (match_scratch:DI 2 ""))]
476   "TARGET_POWERPC64 && reload_completed"
477   [(set (match_dup 2)
478         (sign_extend:DI (match_dup 1)))
479    (set (match_dup 0)
480         (compare:CC (match_dup 2)
481                     (const_int 0)))]
482   "")
483
484 (define_insn ""
485   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
486         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
487                     (const_int 0)))
488    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
489         (sign_extend:DI (match_dup 1)))]
490   "TARGET_64BIT"
491   "@
492    extsw. %0,%1
493    #"
494   [(set_attr "type" "compare")
495    (set_attr "length" "4,8")])
496
497 (define_split
498   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
499         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
500                     (const_int 0)))
501    (set (match_operand:DI 0 "gpc_reg_operand" "")
502         (sign_extend:DI (match_dup 1)))]
503   "TARGET_POWERPC64 && reload_completed"
504   [(set (match_dup 0)
505         (sign_extend:DI (match_dup 1)))
506    (set (match_dup 2)
507         (compare:CC (match_dup 0)
508                     (const_int 0)))]
509   "")
510
511 (define_expand "zero_extendqisi2"
512   [(set (match_operand:SI 0 "gpc_reg_operand" "")
513         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
514   ""
515   "")
516
517 (define_insn ""
518   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
519         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
520   ""
521   "@
522    lbz%U1%X1 %0,%1
523    {rlinm|rlwinm} %0,%1,0,0xff"
524   [(set_attr "type" "load,*")])
525
526 (define_insn ""
527   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
528         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
529                     (const_int 0)))
530    (clobber (match_scratch:SI 2 "=r,r"))]
531   ""
532   "@
533    {andil.|andi.} %2,%1,0xff
534    #"
535   [(set_attr "type" "compare")
536    (set_attr "length" "4,8")])
537
538 (define_split
539   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
540         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
541                     (const_int 0)))
542    (clobber (match_scratch:SI 2 ""))]
543   "reload_completed"
544   [(set (match_dup 2)
545         (zero_extend:SI (match_dup 1)))
546    (set (match_dup 0)
547         (compare:CC (match_dup 2)
548                     (const_int 0)))]
549   "")
550
551 (define_insn ""
552   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
553         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
554                     (const_int 0)))
555    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
556         (zero_extend:SI (match_dup 1)))]
557   ""
558   "@
559    {andil.|andi.} %0,%1,0xff
560    #"
561   [(set_attr "type" "compare")
562    (set_attr "length" "4,8")])
563
564 (define_split
565   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
566         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
567                     (const_int 0)))
568    (set (match_operand:SI 0 "gpc_reg_operand" "")
569         (zero_extend:SI (match_dup 1)))]
570   "reload_completed"
571   [(set (match_dup 0)
572         (zero_extend:SI (match_dup 1)))
573    (set (match_dup 2)
574         (compare:CC (match_dup 0)
575                     (const_int 0)))]
576   "")
577
578 (define_expand "extendqisi2"
579   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
580    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
581   ""
582   "
583 {
584   if (TARGET_POWERPC)
585     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
586   else if (TARGET_POWER)
587     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
588   else
589     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
590   DONE;
591 }")
592
593 (define_insn "extendqisi2_ppc"
594   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
595         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
596   "TARGET_POWERPC"
597   "extsb %0,%1")
598
599 (define_insn ""
600   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
601         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
602                     (const_int 0)))
603    (clobber (match_scratch:SI 2 "=r,r"))]
604   "TARGET_POWERPC"
605   "@
606    extsb. %2,%1
607    #"
608   [(set_attr "type" "compare")
609    (set_attr "length" "4,8")])
610
611 (define_split
612   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
613         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
614                     (const_int 0)))
615    (clobber (match_scratch:SI 2 ""))]
616   "TARGET_POWERPC && reload_completed"
617   [(set (match_dup 2)
618         (sign_extend:SI (match_dup 1)))
619    (set (match_dup 0)
620         (compare:CC (match_dup 2)
621                     (const_int 0)))]
622   "")
623
624 (define_insn ""
625   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
626         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
627                     (const_int 0)))
628    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
629         (sign_extend:SI (match_dup 1)))]
630   "TARGET_POWERPC"
631   "@
632    extsb. %0,%1
633    #"
634   [(set_attr "type" "compare")
635    (set_attr "length" "4,8")])
636
637 (define_split
638   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
639         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
640                     (const_int 0)))
641    (set (match_operand:SI 0 "gpc_reg_operand" "")
642         (sign_extend:SI (match_dup 1)))]
643   "TARGET_POWERPC && reload_completed"
644   [(set (match_dup 0)
645         (sign_extend:SI (match_dup 1)))
646    (set (match_dup 2)
647         (compare:CC (match_dup 0)
648                     (const_int 0)))]
649   "")
650
651 (define_expand "extendqisi2_power"
652   [(parallel [(set (match_dup 2)
653                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
654                               (const_int 24)))
655               (clobber (scratch:SI))])
656    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
657                    (ashiftrt:SI (match_dup 2)
658                                 (const_int 24)))
659               (clobber (scratch:SI))])]
660   "TARGET_POWER"
661   "
662 { operands[1] = gen_lowpart (SImode, operands[1]);
663   operands[2] = gen_reg_rtx (SImode); }")
664
665 (define_expand "extendqisi2_no_power"
666   [(set (match_dup 2)
667         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
668                    (const_int 24)))
669    (set (match_operand:SI 0 "gpc_reg_operand" "")
670         (ashiftrt:SI (match_dup 2)
671                      (const_int 24)))]
672   "! TARGET_POWER && ! TARGET_POWERPC"
673   "
674 { operands[1] = gen_lowpart (SImode, operands[1]);
675   operands[2] = gen_reg_rtx (SImode); }")
676
677 (define_expand "zero_extendqihi2"
678   [(set (match_operand:HI 0 "gpc_reg_operand" "")
679         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
680   ""
681   "")
682
683 (define_insn ""
684   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
685         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
686   ""
687   "@
688    lbz%U1%X1 %0,%1
689    {rlinm|rlwinm} %0,%1,0,0xff"
690   [(set_attr "type" "load,*")])
691
692 (define_insn ""
693   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
694         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
695                     (const_int 0)))
696    (clobber (match_scratch:HI 2 "=r,r"))]
697   ""
698   "@
699    {andil.|andi.} %2,%1,0xff
700    #"
701   [(set_attr "type" "compare")
702    (set_attr "length" "4,8")])
703
704 (define_split
705   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
706         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
707                     (const_int 0)))
708    (clobber (match_scratch:HI 2 ""))]
709   "reload_completed"
710   [(set (match_dup 2)
711         (zero_extend:HI (match_dup 1)))
712    (set (match_dup 0)
713         (compare:CC (match_dup 2)
714                     (const_int 0)))]
715   "")
716
717 (define_insn ""
718   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
719         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
720                     (const_int 0)))
721    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
722         (zero_extend:HI (match_dup 1)))]
723   ""
724   "@
725    {andil.|andi.} %0,%1,0xff
726    #"
727   [(set_attr "type" "compare")
728    (set_attr "length" "4,8")])
729
730 (define_split
731   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
732         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
733                     (const_int 0)))
734    (set (match_operand:HI 0 "gpc_reg_operand" "")
735         (zero_extend:HI (match_dup 1)))]
736   "reload_completed"
737   [(set (match_dup 0)
738         (zero_extend:HI (match_dup 1)))
739    (set (match_dup 2)
740         (compare:CC (match_dup 0)
741                     (const_int 0)))]
742   "")
743
744 (define_expand "extendqihi2"
745   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
746    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
747   ""
748   "
749 {
750   if (TARGET_POWERPC)
751     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
752   else if (TARGET_POWER)
753     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
754   else
755     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
756   DONE;
757 }")
758
759 (define_insn "extendqihi2_ppc"
760   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
761         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
762   "TARGET_POWERPC"
763   "extsb %0,%1")
764
765 (define_insn ""
766   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
767         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
768                     (const_int 0)))
769    (clobber (match_scratch:HI 2 "=r,r"))]
770   "TARGET_POWERPC"
771   "@
772    extsb. %2,%1
773    #"
774   [(set_attr "type" "compare")
775    (set_attr "length" "4,8")])
776
777 (define_split
778   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
779         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
780                     (const_int 0)))
781    (clobber (match_scratch:HI 2 ""))]
782   "TARGET_POWERPC && reload_completed"
783   [(set (match_dup 2)
784         (sign_extend:HI (match_dup 1)))
785    (set (match_dup 0)
786         (compare:CC (match_dup 2)
787                     (const_int 0)))]
788   "")
789
790 (define_insn ""
791   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
792         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
793                     (const_int 0)))
794    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
795         (sign_extend:HI (match_dup 1)))]
796   "TARGET_POWERPC"
797   "@
798    extsb. %0,%1
799    #"
800   [(set_attr "type" "compare")
801    (set_attr "length" "4,8")])
802
803 (define_split
804   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
805         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
806                     (const_int 0)))
807    (set (match_operand:HI 0 "gpc_reg_operand" "")
808         (sign_extend:HI (match_dup 1)))]
809   "TARGET_POWERPC && reload_completed"
810   [(set (match_dup 0)
811         (sign_extend:HI (match_dup 1)))
812    (set (match_dup 2)
813         (compare:CC (match_dup 0)
814                     (const_int 0)))]
815   "")
816
817 (define_expand "extendqihi2_power"
818   [(parallel [(set (match_dup 2)
819                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
820                               (const_int 24)))
821               (clobber (scratch:SI))])
822    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
823                    (ashiftrt:SI (match_dup 2)
824                                 (const_int 24)))
825               (clobber (scratch:SI))])]
826   "TARGET_POWER"
827   "
828 { operands[0] = gen_lowpart (SImode, operands[0]);
829   operands[1] = gen_lowpart (SImode, operands[1]);
830   operands[2] = gen_reg_rtx (SImode); }")
831
832 (define_expand "extendqihi2_no_power"
833   [(set (match_dup 2)
834         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
835                    (const_int 24)))
836    (set (match_operand:HI 0 "gpc_reg_operand" "")
837         (ashiftrt:SI (match_dup 2)
838                      (const_int 24)))]
839   "! TARGET_POWER && ! TARGET_POWERPC"
840   "
841 { operands[0] = gen_lowpart (SImode, operands[0]);
842   operands[1] = gen_lowpart (SImode, operands[1]);
843   operands[2] = gen_reg_rtx (SImode); }")
844
845 (define_expand "zero_extendhisi2"
846   [(set (match_operand:SI 0 "gpc_reg_operand" "")
847         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
848   ""
849   "")
850
851 (define_insn ""
852   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
853         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
854   ""
855   "@
856    lhz%U1%X1 %0,%1
857    {rlinm|rlwinm} %0,%1,0,0xffff"
858   [(set_attr "type" "load,*")])
859
860 (define_insn ""
861   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
862         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
863                     (const_int 0)))
864    (clobber (match_scratch:SI 2 "=r,r"))]
865   ""
866   "@
867    {andil.|andi.} %2,%1,0xffff
868    #"
869   [(set_attr "type" "compare")
870    (set_attr "length" "4,8")])
871
872 (define_split
873   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
874         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
875                     (const_int 0)))
876    (clobber (match_scratch:SI 2 ""))]
877   "reload_completed"
878   [(set (match_dup 2)
879         (zero_extend:SI (match_dup 1)))
880    (set (match_dup 0)
881         (compare:CC (match_dup 2)
882                     (const_int 0)))]
883   "")
884
885 (define_insn ""
886   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
887         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
888                     (const_int 0)))
889    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
890         (zero_extend:SI (match_dup 1)))]
891   ""
892   "@
893    {andil.|andi.} %0,%1,0xffff
894    #"
895   [(set_attr "type" "compare")
896    (set_attr "length" "4,8")])
897
898 (define_split
899   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
900         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
901                     (const_int 0)))
902    (set (match_operand:SI 0 "gpc_reg_operand" "")
903         (zero_extend:SI (match_dup 1)))]
904   "reload_completed"
905   [(set (match_dup 0)
906         (zero_extend:SI (match_dup 1)))
907    (set (match_dup 2)
908         (compare:CC (match_dup 0)
909                     (const_int 0)))]
910   "")
911
912 (define_expand "extendhisi2"
913   [(set (match_operand:SI 0 "gpc_reg_operand" "")
914         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
915   ""
916   "")
917
918 (define_insn ""
919   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
920         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
921   ""
922   "@
923    lha%U1%X1 %0,%1
924    {exts|extsh} %0,%1"
925   [(set_attr "type" "load_ext,*")])
926
927 (define_insn ""
928   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
929         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
930                     (const_int 0)))
931    (clobber (match_scratch:SI 2 "=r,r"))]
932   ""
933   "@
934    {exts.|extsh.} %2,%1
935    #"
936   [(set_attr "type" "compare")
937    (set_attr "length" "4,8")])
938
939 (define_split
940   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
941         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
942                     (const_int 0)))
943    (clobber (match_scratch:SI 2 ""))]
944   "reload_completed"
945   [(set (match_dup 2)
946         (sign_extend:SI (match_dup 1)))
947    (set (match_dup 0)
948         (compare:CC (match_dup 2)
949                     (const_int 0)))]
950   "")
951
952 (define_insn ""
953   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
954         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
955                     (const_int 0)))
956    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
957         (sign_extend:SI (match_dup 1)))]
958   ""
959   "@
960    {exts.|extsh.} %0,%1
961    #"
962   [(set_attr "type" "compare")
963    (set_attr "length" "4,8")])
964 \f
965 (define_split
966   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
967         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
968                     (const_int 0)))
969    (set (match_operand:SI 0 "gpc_reg_operand" "")
970         (sign_extend:SI (match_dup 1)))]
971   "reload_completed"
972   [(set (match_dup 0)
973         (sign_extend:SI (match_dup 1)))
974    (set (match_dup 2)
975         (compare:CC (match_dup 0)
976                     (const_int 0)))]
977   "")
978
979 ;; Fixed-point arithmetic insns.
980
981 ;; Discourage ai/addic because of carry but provide it in an alternative
982 ;; allowing register zero as source.
983 (define_expand "addsi3"
984   [(set (match_operand:SI 0 "gpc_reg_operand" "")
985         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
986                  (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
987   ""
988   "
989 {
990   if (GET_CODE (operands[2]) == CONST_INT
991                 && ! add_operand (operands[2], SImode))
992     {
993       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
994                  ? operands[0] : gen_reg_rtx (SImode));
995
996       HOST_WIDE_INT val = INTVAL (operands[2]);
997       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
998       HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
999
1000       /* The ordering here is important for the prolog expander.
1001          When space is allocated from the stack, adding 'low' first may
1002          produce a temporary deallocation (which would be bad).  */
1003       emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
1004       emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
1005       DONE;
1006     }
1007 }")
1008
1009 (define_insn "*addsi3_internal1"
1010   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
1011         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
1012                  (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1013   ""
1014   "@
1015    {cax|add} %0,%1,%2
1016    {cal %0,%2(%1)|addi %0,%1,%2}
1017    {ai|addic} %0,%1,%2
1018    {cau|addis} %0,%1,%v2"
1019   [(set_attr "length" "4,4,4,4")])
1020
1021 (define_insn "addsi3_high"
1022   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1023         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1024                  (high:SI (match_operand 2 "" ""))))]
1025   "TARGET_MACHO && !TARGET_64BIT"
1026   "{cau|addis} %0,%1,ha16(%2)"
1027   [(set_attr "length" "4")])
1028
1029 (define_insn "*addsi3_internal2"
1030   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1031         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1032                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1033                     (const_int 0)))
1034    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1035   "TARGET_32BIT"
1036   "@
1037    {cax.|add.} %3,%1,%2
1038    {ai.|addic.} %3,%1,%2
1039    #
1040    #"
1041   [(set_attr "type" "fast_compare,compare,compare,compare")
1042    (set_attr "length" "4,4,8,8")])
1043
1044 (define_split
1045   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1046         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1047                              (match_operand:SI 2 "reg_or_short_operand" ""))
1048                     (const_int 0)))
1049    (clobber (match_scratch:SI 3 ""))]
1050   "TARGET_32BIT && reload_completed"
1051   [(set (match_dup 3)
1052         (plus:SI (match_dup 1)
1053                  (match_dup 2)))
1054    (set (match_dup 0)
1055         (compare:CC (match_dup 3)
1056                     (const_int 0)))]
1057   "")
1058
1059 (define_insn "*addsi3_internal3"
1060   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1061         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1062                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1063                     (const_int 0)))
1064    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1065         (plus:SI (match_dup 1)
1066                  (match_dup 2)))]
1067   "TARGET_32BIT"
1068   "@
1069    {cax.|add.} %0,%1,%2
1070    {ai.|addic.} %0,%1,%2
1071    #
1072    #"
1073   [(set_attr "type" "fast_compare,compare,compare,compare")
1074    (set_attr "length" "4,4,8,8")])
1075
1076 (define_split
1077   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1078         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1079                              (match_operand:SI 2 "reg_or_short_operand" ""))
1080                     (const_int 0)))
1081    (set (match_operand:SI 0 "gpc_reg_operand" "")
1082         (plus:SI (match_dup 1) (match_dup 2)))]
1083   "TARGET_32BIT && reload_completed"
1084   [(set (match_dup 0)
1085         (plus:SI (match_dup 1)
1086                  (match_dup 2)))
1087    (set (match_dup 3)
1088         (compare:CC (match_dup 0)
1089                     (const_int 0)))]
1090   "")
1091
1092 ;; Split an add that we can't do in one insn into two insns, each of which
1093 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
1094 ;; add should be last in case the result gets used in an address.
1095
1096 (define_split
1097   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1098         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1099                  (match_operand:SI 2 "non_add_cint_operand" "")))]
1100   ""
1101   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1102    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1103 "
1104 {
1105   HOST_WIDE_INT val = INTVAL (operands[2]);
1106   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1107   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1108
1109   operands[3] = GEN_INT (rest);
1110   operands[4] = GEN_INT (low);
1111 }")
1112
1113 (define_insn "one_cmplsi2"
1114   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1115         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1116   ""
1117   "nor %0,%1,%1")
1118
1119 (define_insn ""
1120   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1121         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1122                     (const_int 0)))
1123    (clobber (match_scratch:SI 2 "=r,r"))]
1124   "TARGET_32BIT"
1125   "@
1126    nor. %2,%1,%1
1127    #"
1128   [(set_attr "type" "compare")
1129    (set_attr "length" "4,8")])
1130
1131 (define_split
1132   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1133         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1134                     (const_int 0)))
1135    (clobber (match_scratch:SI 2 ""))]
1136   "TARGET_32BIT && reload_completed"
1137   [(set (match_dup 2)
1138         (not:SI (match_dup 1)))
1139    (set (match_dup 0)
1140         (compare:CC (match_dup 2)
1141                     (const_int 0)))]
1142   "")
1143
1144 (define_insn ""
1145   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1146         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1147                     (const_int 0)))
1148    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1149         (not:SI (match_dup 1)))]
1150   "TARGET_32BIT"
1151   "@
1152    nor. %0,%1,%1
1153    #"
1154   [(set_attr "type" "compare")
1155    (set_attr "length" "4,8")])
1156
1157 (define_split
1158   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1159         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1160                     (const_int 0)))
1161    (set (match_operand:SI 0 "gpc_reg_operand" "")
1162         (not:SI (match_dup 1)))]
1163   "TARGET_32BIT && reload_completed"
1164   [(set (match_dup 0)
1165         (not:SI (match_dup 1)))
1166    (set (match_dup 2)
1167         (compare:CC (match_dup 0)
1168                     (const_int 0)))]
1169   "")
1170
1171 (define_insn ""
1172   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1173         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1174                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
1175   "! TARGET_POWERPC"
1176   "{sf%I1|subf%I1c} %0,%2,%1")
1177
1178 (define_insn ""
1179   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1180         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1181                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1182   "TARGET_POWERPC"
1183   "@
1184    subf %0,%2,%1
1185    subfic %0,%2,%1")
1186
1187 (define_insn ""
1188   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1189         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1190                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1191                     (const_int 0)))
1192    (clobber (match_scratch:SI 3 "=r,r"))]
1193   "! TARGET_POWERPC"
1194   "@
1195    {sf.|subfc.} %3,%2,%1
1196    #"
1197   [(set_attr "type" "compare")
1198    (set_attr "length" "4,8")])
1199
1200 (define_insn ""
1201   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1202         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1203                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1204                     (const_int 0)))
1205    (clobber (match_scratch:SI 3 "=r,r"))]
1206   "TARGET_POWERPC && TARGET_32BIT"
1207   "@
1208    subf. %3,%2,%1
1209    #"
1210   [(set_attr "type" "fast_compare")
1211    (set_attr "length" "4,8")])
1212
1213 (define_split
1214   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1215         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1216                               (match_operand:SI 2 "gpc_reg_operand" ""))
1217                     (const_int 0)))
1218    (clobber (match_scratch:SI 3 ""))]
1219   "TARGET_32BIT && reload_completed"
1220   [(set (match_dup 3)
1221         (minus:SI (match_dup 1)
1222                   (match_dup 2)))
1223    (set (match_dup 0)
1224         (compare:CC (match_dup 3)
1225                     (const_int 0)))]
1226   "")
1227
1228 (define_insn ""
1229   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1230         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1231                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1232                     (const_int 0)))
1233    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1234         (minus:SI (match_dup 1) (match_dup 2)))]
1235   "! TARGET_POWERPC"
1236   "@
1237    {sf.|subfc.} %0,%2,%1
1238    #"
1239   [(set_attr "type" "compare")
1240    (set_attr "length" "4,8")])
1241
1242 (define_insn ""
1243   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1244         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1245                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1246                     (const_int 0)))
1247    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1248         (minus:SI (match_dup 1)
1249                   (match_dup 2)))]
1250   "TARGET_POWERPC && TARGET_32BIT"
1251   "@
1252    subf. %0,%2,%1
1253    #"
1254   [(set_attr "type" "fast_compare")
1255    (set_attr "length" "4,8")])
1256
1257 (define_split
1258   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1259         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1260                               (match_operand:SI 2 "gpc_reg_operand" ""))
1261                     (const_int 0)))
1262    (set (match_operand:SI 0 "gpc_reg_operand" "")
1263         (minus:SI (match_dup 1)
1264                   (match_dup 2)))]
1265   "TARGET_32BIT && reload_completed"
1266   [(set (match_dup 0)
1267         (minus:SI (match_dup 1)
1268                   (match_dup 2)))
1269    (set (match_dup 3)
1270         (compare:CC (match_dup 0)
1271                     (const_int 0)))]
1272   "")
1273
1274 (define_expand "subsi3"
1275   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1276         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
1277                   (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1278   ""
1279   "
1280 {
1281   if (GET_CODE (operands[2]) == CONST_INT)
1282     {
1283       emit_insn (gen_addsi3 (operands[0], operands[1],
1284                              negate_rtx (SImode, operands[2])));
1285       DONE;
1286     }
1287 }")
1288
1289 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1290 ;; instruction and some auxiliary computations.  Then we just have a single
1291 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1292 ;; combine.
1293
1294 (define_expand "sminsi3"
1295   [(set (match_dup 3)
1296         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1297                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1298                          (const_int 0)
1299                          (minus:SI (match_dup 2) (match_dup 1))))
1300    (set (match_operand:SI 0 "gpc_reg_operand" "")
1301         (minus:SI (match_dup 2) (match_dup 3)))]
1302   "TARGET_POWER || TARGET_ISEL"
1303   "
1304 {
1305   if (TARGET_ISEL)
1306     {
1307       operands[2] = force_reg (SImode, operands[2]);
1308       rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
1309       DONE;
1310     }
1311
1312   operands[3] = gen_reg_rtx (SImode);
1313 }")
1314
1315 (define_split
1316   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1317         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1318                  (match_operand:SI 2 "reg_or_short_operand" "")))
1319    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1320   "TARGET_POWER"
1321   [(set (match_dup 3)
1322         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1323                          (const_int 0)
1324                          (minus:SI (match_dup 2) (match_dup 1))))
1325    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1326   "")
1327
1328 (define_expand "smaxsi3"
1329   [(set (match_dup 3)
1330         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1331                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1332                          (const_int 0)
1333                          (minus:SI (match_dup 2) (match_dup 1))))
1334    (set (match_operand:SI 0 "gpc_reg_operand" "")
1335         (plus:SI (match_dup 3) (match_dup 1)))]
1336   "TARGET_POWER || TARGET_ISEL"
1337   "
1338 {
1339   if (TARGET_ISEL)
1340     {
1341       operands[2] = force_reg (SImode, operands[2]);
1342       rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
1343       DONE;
1344     }
1345   operands[3] = gen_reg_rtx (SImode);
1346 }")
1347
1348 (define_split
1349   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1350         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1351                  (match_operand:SI 2 "reg_or_short_operand" "")))
1352    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1353   "TARGET_POWER"
1354   [(set (match_dup 3)
1355         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1356                          (const_int 0)
1357                          (minus:SI (match_dup 2) (match_dup 1))))
1358    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1359   "")
1360
1361 (define_expand "uminsi3"
1362   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1363                               (match_dup 5)))
1364    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1365                               (match_dup 5)))
1366    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1367                                        (const_int 0)
1368                                        (minus:SI (match_dup 4) (match_dup 3))))
1369    (set (match_operand:SI 0 "gpc_reg_operand" "")
1370         (minus:SI (match_dup 2) (match_dup 3)))]
1371   "TARGET_POWER || TARGET_ISEL"
1372   "
1373 {
1374   if (TARGET_ISEL)
1375     {
1376       rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
1377       DONE;
1378     }
1379   operands[3] = gen_reg_rtx (SImode);
1380   operands[4] = gen_reg_rtx (SImode);
1381   operands[5] = GEN_INT (-2147483647 - 1);
1382 }")
1383
1384 (define_expand "umaxsi3"
1385   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1386                               (match_dup 5)))
1387    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1388                               (match_dup 5)))
1389    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1390                                        (const_int 0)
1391                                        (minus:SI (match_dup 4) (match_dup 3))))
1392    (set (match_operand:SI 0 "gpc_reg_operand" "")
1393         (plus:SI (match_dup 3) (match_dup 1)))]
1394   "TARGET_POWER || TARGET_ISEL"
1395   "
1396 {
1397   if (TARGET_ISEL)
1398     {
1399       rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
1400       DONE;
1401     }
1402   operands[3] = gen_reg_rtx (SImode);
1403   operands[4] = gen_reg_rtx (SImode);
1404   operands[5] = GEN_INT (-2147483647 - 1);
1405 }")
1406
1407 (define_insn ""
1408   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1409         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
1410                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
1411                          (const_int 0)
1412                          (minus:SI (match_dup 2) (match_dup 1))))]
1413   "TARGET_POWER"
1414   "doz%I2 %0,%1,%2")
1415
1416 (define_insn ""
1417   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1418         (compare:CC
1419          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1420                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1421                           (const_int 0)
1422                           (minus:SI (match_dup 2) (match_dup 1)))
1423          (const_int 0)))
1424    (clobber (match_scratch:SI 3 "=r,r"))]
1425   "TARGET_POWER"
1426   "@
1427    doz%I2. %3,%1,%2
1428    #"
1429   [(set_attr "type" "delayed_compare")
1430    (set_attr "length" "4,8")])
1431
1432 (define_split
1433   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1434         (compare:CC
1435          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1436                               (match_operand:SI 2 "reg_or_short_operand" ""))
1437                           (const_int 0)
1438                           (minus:SI (match_dup 2) (match_dup 1)))
1439          (const_int 0)))
1440    (clobber (match_scratch:SI 3 ""))]
1441   "TARGET_POWER && reload_completed"
1442   [(set (match_dup 3)
1443         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1444                           (const_int 0)
1445                           (minus:SI (match_dup 2) (match_dup 1))))
1446    (set (match_dup 0)
1447         (compare:CC (match_dup 3)
1448                     (const_int 0)))]
1449   "")
1450
1451 (define_insn ""
1452   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1453         (compare:CC
1454          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
1455                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
1456                           (const_int 0)
1457                           (minus:SI (match_dup 2) (match_dup 1)))
1458          (const_int 0)))
1459    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1460         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1461                          (const_int 0)
1462                          (minus:SI (match_dup 2) (match_dup 1))))]
1463   "TARGET_POWER"
1464   "@
1465    doz%I2. %0,%1,%2
1466    #"
1467   [(set_attr "type" "delayed_compare")
1468    (set_attr "length" "4,8")])
1469
1470 (define_split
1471   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1472         (compare:CC
1473          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
1474                               (match_operand:SI 2 "reg_or_short_operand" ""))
1475                           (const_int 0)
1476                           (minus:SI (match_dup 2) (match_dup 1)))
1477          (const_int 0)))
1478    (set (match_operand:SI 0 "gpc_reg_operand" "")
1479         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1480                          (const_int 0)
1481                          (minus:SI (match_dup 2) (match_dup 1))))]
1482   "TARGET_POWER && reload_completed"
1483   [(set (match_dup 0)
1484         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
1485                          (const_int 0)
1486                          (minus:SI (match_dup 2) (match_dup 1))))
1487    (set (match_dup 3)
1488         (compare:CC (match_dup 0)
1489                     (const_int 0)))]
1490   "")
1491
1492 ;; We don't need abs with condition code because such comparisons should
1493 ;; never be done.
1494 (define_expand "abssi2"
1495   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1496         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
1497   ""
1498   "
1499 {
1500   if (TARGET_ISEL)
1501     {
1502       emit_insn (gen_abssi2_isel (operands[0], operands[1]));
1503       DONE;
1504     }
1505   else if (! TARGET_POWER)
1506     {
1507       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
1508       DONE;
1509     }
1510 }")
1511
1512 (define_insn "*abssi2_power"
1513   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1514         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1515   "TARGET_POWER"
1516   "abs %0,%1")
1517
1518 (define_insn_and_split "abssi2_isel"
1519   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1520         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
1521    (clobber (match_scratch:SI 2 "=&b"))
1522    (clobber (match_scratch:CC 3 "=y"))]
1523   "TARGET_ISEL"
1524   "#"
1525   "&& reload_completed"
1526   [(set (match_dup 2) (neg:SI (match_dup 1)))
1527    (set (match_dup 3)
1528         (compare:CC (match_dup 1)
1529                     (const_int 0)))
1530    (set (match_dup 0)
1531         (if_then_else:SI (ge (match_dup 3)
1532                              (const_int 0))
1533                          (match_dup 1)
1534                          (match_dup 2)))]
1535   "")
1536
1537 (define_insn_and_split "abssi2_nopower"
1538   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1539         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
1540    (clobber (match_scratch:SI 2 "=&r,&r"))]
1541   "! TARGET_POWER && ! TARGET_ISEL"
1542   "#"
1543   "&& reload_completed"
1544   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1545    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1546    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
1547   "")
1548
1549 (define_insn "*nabs_power"
1550   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1551         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
1552   "TARGET_POWER"
1553   "nabs %0,%1")
1554
1555 (define_insn_and_split "*nabs_nopower"
1556   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
1557         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
1558    (clobber (match_scratch:SI 2 "=&r,&r"))]
1559   "! TARGET_POWER"
1560   "#"
1561   "&& reload_completed"
1562   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
1563    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
1564    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
1565   "")
1566
1567 (define_insn "negsi2"
1568   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1569         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1570   ""
1571   "neg %0,%1")
1572
1573 (define_insn ""
1574   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1575         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1576                     (const_int 0)))
1577    (clobber (match_scratch:SI 2 "=r,r"))]
1578   "TARGET_32BIT"
1579   "@
1580    neg. %2,%1
1581    #"
1582   [(set_attr "type" "fast_compare")
1583    (set_attr "length" "4,8")])
1584
1585 (define_split
1586   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1587         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1588                     (const_int 0)))
1589    (clobber (match_scratch:SI 2 ""))]
1590   "TARGET_32BIT && reload_completed"
1591   [(set (match_dup 2)
1592         (neg:SI (match_dup 1)))
1593    (set (match_dup 0)
1594         (compare:CC (match_dup 2)
1595                     (const_int 0)))]
1596   "")
1597
1598 (define_insn ""
1599   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1600         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1601                     (const_int 0)))
1602    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1603         (neg:SI (match_dup 1)))]
1604   "TARGET_32BIT"
1605   "@
1606    neg. %0,%1
1607    #"
1608   [(set_attr "type" "fast_compare")
1609    (set_attr "length" "4,8")])
1610
1611 (define_split
1612   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1613         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1614                     (const_int 0)))
1615    (set (match_operand:SI 0 "gpc_reg_operand" "")
1616         (neg:SI (match_dup 1)))]
1617   "TARGET_32BIT && reload_completed"
1618   [(set (match_dup 0)
1619         (neg:SI (match_dup 1)))
1620    (set (match_dup 2)
1621         (compare:CC (match_dup 0)
1622                     (const_int 0)))]
1623   "")
1624
1625 (define_insn "clzsi2"
1626   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1627         (clz:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1628   ""
1629   "{cntlz|cntlzw} %0,%1")
1630
1631 (define_expand "ctzsi2"
1632   [(set (match_dup 2)
1633         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1634    (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1635                                          (match_dup 2)))
1636               (clobber (scratch:CC))])
1637    (set (match_dup 4) (clz:SI (match_dup 3)))
1638    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1639         (minus:SI (const_int 31) (match_dup 4)))]
1640   ""
1641   {
1642      operands[2] = gen_reg_rtx (SImode);
1643      operands[3] = gen_reg_rtx (SImode);
1644      operands[4] = gen_reg_rtx (SImode);
1645   })
1646
1647 (define_expand "ffssi2"
1648   [(set (match_dup 2)
1649         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
1650    (parallel [(set (match_dup 3) (and:SI (match_dup 1)
1651                                          (match_dup 2)))
1652               (clobber (scratch:CC))])
1653    (set (match_dup 4) (clz:SI (match_dup 3)))
1654    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
1655         (minus:SI (const_int 32) (match_dup 4)))]
1656   ""
1657   {
1658      operands[2] = gen_reg_rtx (SImode);
1659      operands[3] = gen_reg_rtx (SImode);
1660      operands[4] = gen_reg_rtx (SImode);
1661   })
1662
1663 (define_expand "mulsi3"
1664   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1665    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1666    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
1667   ""
1668   "
1669 {
1670   if (TARGET_POWER)
1671     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
1672   else
1673     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
1674   DONE;
1675 }")
1676
1677 (define_insn "mulsi3_mq"
1678   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1679         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1680                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
1681    (clobber (match_scratch:SI 3 "=q,q"))]
1682   "TARGET_POWER"
1683   "@
1684    {muls|mullw} %0,%1,%2
1685    {muli|mulli} %0,%1,%2"
1686    [(set (attr "type")
1687       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1688                 (const_string "imul3")
1689              (match_operand:SI 2 "short_cint_operand" "")
1690                 (const_string "imul2")]
1691         (const_string "imul")))])
1692
1693 (define_insn "mulsi3_no_mq"
1694   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1695         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1696                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
1697   "! TARGET_POWER"
1698   "@
1699    {muls|mullw} %0,%1,%2
1700    {muli|mulli} %0,%1,%2"
1701    [(set (attr "type")
1702       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
1703                 (const_string "imul3")
1704              (match_operand:SI 2 "short_cint_operand" "")
1705                 (const_string "imul2")]
1706         (const_string "imul")))])
1707
1708 (define_insn "*mulsi3_mq_internal1"
1709   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1710         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1711                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1712                     (const_int 0)))
1713    (clobber (match_scratch:SI 3 "=r,r"))
1714    (clobber (match_scratch:SI 4 "=q,q"))]
1715   "TARGET_POWER"
1716   "@
1717    {muls.|mullw.} %3,%1,%2
1718    #"
1719   [(set_attr "type" "imul_compare")
1720    (set_attr "length" "4,8")])
1721
1722 (define_split
1723   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1724         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1725                              (match_operand:SI 2 "gpc_reg_operand" ""))
1726                     (const_int 0)))
1727    (clobber (match_scratch:SI 3 ""))
1728    (clobber (match_scratch:SI 4 ""))]
1729   "TARGET_POWER && reload_completed"
1730   [(parallel [(set (match_dup 3)
1731         (mult:SI (match_dup 1) (match_dup 2)))
1732    (clobber (match_dup 4))])
1733    (set (match_dup 0)
1734         (compare:CC (match_dup 3)
1735                     (const_int 0)))]
1736   "")
1737
1738 (define_insn "*mulsi3_no_mq_internal1"
1739   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1740         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1741                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1742                     (const_int 0)))
1743    (clobber (match_scratch:SI 3 "=r,r"))]
1744   "! TARGET_POWER"
1745   "@
1746    {muls.|mullw.} %3,%1,%2
1747    #"
1748   [(set_attr "type" "imul_compare")
1749    (set_attr "length" "4,8")])
1750
1751 (define_split
1752   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1753         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1754                              (match_operand:SI 2 "gpc_reg_operand" ""))
1755                     (const_int 0)))
1756    (clobber (match_scratch:SI 3 ""))]
1757   "! TARGET_POWER && reload_completed"
1758   [(set (match_dup 3)
1759         (mult:SI (match_dup 1) (match_dup 2)))
1760    (set (match_dup 0)
1761         (compare:CC (match_dup 3)
1762                     (const_int 0)))]
1763   "")
1764
1765 (define_insn "*mulsi3_mq_internal2"
1766   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1767         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1768                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1769                     (const_int 0)))
1770    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1771         (mult:SI (match_dup 1) (match_dup 2)))
1772    (clobber (match_scratch:SI 4 "=q,q"))]
1773   "TARGET_POWER"
1774   "@
1775    {muls.|mullw.} %0,%1,%2
1776    #"
1777   [(set_attr "type" "imul_compare")
1778    (set_attr "length" "4,8")])
1779
1780 (define_split
1781   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1782         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1783                              (match_operand:SI 2 "gpc_reg_operand" ""))
1784                     (const_int 0)))
1785    (set (match_operand:SI 0 "gpc_reg_operand" "")
1786         (mult:SI (match_dup 1) (match_dup 2)))
1787    (clobber (match_scratch:SI 4 ""))]
1788   "TARGET_POWER && reload_completed"
1789   [(parallel [(set (match_dup 0)
1790         (mult:SI (match_dup 1) (match_dup 2)))
1791    (clobber (match_dup 4))])
1792    (set (match_dup 3)
1793         (compare:CC (match_dup 0)
1794                     (const_int 0)))]
1795   "")
1796
1797 (define_insn "*mulsi3_no_mq_internal2"
1798   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1799         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
1800                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1801                     (const_int 0)))
1802    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1803         (mult:SI (match_dup 1) (match_dup 2)))]
1804   "! TARGET_POWER"
1805   "@
1806    {muls.|mullw.} %0,%1,%2
1807    #"
1808   [(set_attr "type" "imul_compare")
1809    (set_attr "length" "4,8")])
1810
1811 (define_split
1812   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1813         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
1814                              (match_operand:SI 2 "gpc_reg_operand" ""))
1815                     (const_int 0)))
1816    (set (match_operand:SI 0 "gpc_reg_operand" "")
1817         (mult:SI (match_dup 1) (match_dup 2)))]
1818   "! TARGET_POWER && reload_completed"
1819   [(set (match_dup 0)
1820         (mult:SI (match_dup 1) (match_dup 2)))
1821    (set (match_dup 3)
1822         (compare:CC (match_dup 0)
1823                     (const_int 0)))]
1824   "")
1825
1826 ;; Operand 1 is divided by operand 2; quotient goes to operand
1827 ;; 0 and remainder to operand 3.
1828 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
1829
1830 (define_expand "divmodsi4"
1831   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1832                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1833                            (match_operand:SI 2 "gpc_reg_operand" "")))
1834               (set (match_operand:SI 3 "register_operand" "")
1835                    (mod:SI (match_dup 1) (match_dup 2)))])]
1836   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
1837   "
1838 {
1839   if (! TARGET_POWER && ! TARGET_POWERPC)
1840     {
1841       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1842       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1843       emit_insn (gen_divss_call ());
1844       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1845       emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
1846       DONE;
1847     }
1848 }")
1849
1850 (define_insn "*divmodsi4_internal"
1851   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1852         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1853                 (match_operand:SI 2 "gpc_reg_operand" "r")))
1854    (set (match_operand:SI 3 "register_operand" "=q")
1855         (mod:SI (match_dup 1) (match_dup 2)))]
1856   "TARGET_POWER"
1857   "divs %0,%1,%2"
1858   [(set_attr "type" "idiv")])
1859
1860 (define_expand "udivsi3"
1861   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1862         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
1863                  (match_operand:SI 2 "gpc_reg_operand" "")))]
1864   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
1865   "
1866 {
1867   if (! TARGET_POWER && ! TARGET_POWERPC)
1868     {
1869       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1870       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1871       emit_insn (gen_quous_call ());
1872       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1873       DONE;
1874     }
1875   else if (TARGET_POWER)
1876     {
1877       emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
1878       DONE;
1879     }
1880 }")
1881
1882 (define_insn "udivsi3_mq"
1883   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1884         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1885                  (match_operand:SI 2 "gpc_reg_operand" "r")))
1886    (clobber (match_scratch:SI 3 "=q"))]
1887   "TARGET_POWERPC && TARGET_POWER"
1888   "divwu %0,%1,%2"
1889   [(set_attr "type" "idiv")])
1890
1891 (define_insn "*udivsi3_no_mq"
1892   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1893         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1894                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
1895   "TARGET_POWERPC && ! TARGET_POWER"
1896   "divwu %0,%1,%2"
1897   [(set_attr "type" "idiv")])
1898
1899 ;; For powers of two we can do srai/aze for divide and then adjust for
1900 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
1901 ;; used; for PowerPC, force operands into register and do a normal divide;
1902 ;; for AIX common-mode, use quoss call on register operands.
1903 (define_expand "divsi3"
1904   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1905         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
1906                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
1907   ""
1908   "
1909 {
1910   if (GET_CODE (operands[2]) == CONST_INT
1911       && INTVAL (operands[2]) > 0
1912       && exact_log2 (INTVAL (operands[2])) >= 0)
1913     ;
1914   else if (TARGET_POWERPC)
1915     {
1916       operands[2] = force_reg (SImode, operands[2]);
1917       if (TARGET_POWER)
1918         {
1919           emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
1920           DONE;
1921         }
1922     }
1923   else if (TARGET_POWER)
1924     FAIL;
1925   else
1926     {
1927       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
1928       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
1929       emit_insn (gen_quoss_call ());
1930       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
1931       DONE;
1932     }
1933 }")
1934
1935 (define_insn "divsi3_mq"
1936   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1937         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1938                 (match_operand:SI 2 "gpc_reg_operand" "r")))
1939    (clobber (match_scratch:SI 3 "=q"))]
1940   "TARGET_POWERPC && TARGET_POWER"
1941   "divw %0,%1,%2"
1942   [(set_attr "type" "idiv")])
1943
1944 (define_insn "*divsi3_no_mq"
1945   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1946         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1947                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
1948   "TARGET_POWERPC && ! TARGET_POWER"
1949   "divw %0,%1,%2"
1950   [(set_attr "type" "idiv")])
1951
1952 (define_expand "modsi3"
1953   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1954    (use (match_operand:SI 1 "gpc_reg_operand" ""))
1955    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
1956   ""
1957   "
1958 {
1959   int i;
1960   rtx temp1;
1961   rtx temp2;
1962
1963   if (GET_CODE (operands[2]) != CONST_INT
1964       || INTVAL (operands[2]) <= 0
1965       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
1966     FAIL;
1967
1968   temp1 = gen_reg_rtx (SImode);
1969   temp2 = gen_reg_rtx (SImode);
1970
1971   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
1972   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
1973   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
1974   DONE;
1975 }")
1976
1977 (define_insn ""
1978   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1979         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
1980                 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
1981   ""
1982   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
1983   [(set_attr "type" "two")
1984    (set_attr "length" "8")])
1985
1986 (define_insn ""
1987   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1988         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1989                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
1990                     (const_int 0)))
1991    (clobber (match_scratch:SI 3 "=r,r"))]
1992   ""
1993   "@
1994    {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
1995    #"
1996   [(set_attr "type" "compare")
1997    (set_attr "length" "8,12")])
1998
1999 (define_split
2000   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2001         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2002                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2003                     (const_int 0)))
2004    (clobber (match_scratch:SI 3 ""))]
2005   "reload_completed"
2006   [(set (match_dup 3)
2007         (div:SI (match_dup 1) (match_dup 2)))
2008    (set (match_dup 0)
2009         (compare:CC (match_dup 3)
2010                     (const_int 0)))]
2011   "")
2012
2013 (define_insn ""
2014   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2015         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2016                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2017                     (const_int 0)))
2018    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2019         (div:SI (match_dup 1) (match_dup 2)))]
2020   ""
2021   "@
2022    {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2023    #"
2024   [(set_attr "type" "compare")
2025    (set_attr "length" "8,12")])
2026
2027 (define_split
2028   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2029         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2030                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2031                     (const_int 0)))
2032    (set (match_operand:SI 0 "gpc_reg_operand" "")
2033         (div:SI (match_dup 1) (match_dup 2)))]
2034   "reload_completed"
2035   [(set (match_dup 0)
2036         (div:SI (match_dup 1) (match_dup 2)))
2037    (set (match_dup 3)
2038         (compare:CC (match_dup 0)
2039                     (const_int 0)))]
2040   "")
2041
2042 (define_insn ""
2043   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2044         (udiv:SI
2045          (plus:DI (ashift:DI
2046                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2047                    (const_int 32))
2048                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2049          (match_operand:SI 3 "gpc_reg_operand" "r")))
2050    (set (match_operand:SI 2 "register_operand" "=*q")
2051         (umod:SI
2052          (plus:DI (ashift:DI
2053                    (zero_extend:DI (match_dup 1)) (const_int 32))
2054                   (zero_extend:DI (match_dup 4)))
2055          (match_dup 3)))]
2056   "TARGET_POWER"
2057   "div %0,%1,%3"
2058   [(set_attr "type" "idiv")])
2059
2060 ;; To do unsigned divide we handle the cases of the divisor looking like a
2061 ;; negative number.  If it is a constant that is less than 2**31, we don't
2062 ;; have to worry about the branches.  So make a few subroutines here.
2063 ;;
2064 ;; First comes the normal case.
2065 (define_expand "udivmodsi4_normal"
2066   [(set (match_dup 4) (const_int 0))
2067    (parallel [(set (match_operand:SI 0 "" "")
2068                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2069                                                 (const_int 32))
2070                                      (zero_extend:DI (match_operand:SI 1 "" "")))
2071                             (match_operand:SI 2 "" "")))
2072               (set (match_operand:SI 3 "" "")
2073                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2074                                                 (const_int 32))
2075                                      (zero_extend:DI (match_dup 1)))
2076                             (match_dup 2)))])]
2077   "TARGET_POWER"
2078   "
2079 { operands[4] = gen_reg_rtx (SImode); }")
2080
2081 ;; This handles the branches.
2082 (define_expand "udivmodsi4_tests"
2083   [(set (match_operand:SI 0 "" "") (const_int 0))
2084    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2085    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2086    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2087                            (label_ref (match_operand:SI 4 "" "")) (pc)))
2088    (set (match_dup 0) (const_int 1))
2089    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2090    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2091    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2092                            (label_ref (match_dup 4)) (pc)))]
2093   "TARGET_POWER"
2094   "
2095 { operands[5] = gen_reg_rtx (CCUNSmode);
2096   operands[6] = gen_reg_rtx (CCmode);
2097 }")
2098
2099 (define_expand "udivmodsi4"
2100   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2101                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2102                             (match_operand:SI 2 "reg_or_cint_operand" "")))
2103               (set (match_operand:SI 3 "gpc_reg_operand" "")
2104                    (umod:SI (match_dup 1) (match_dup 2)))])]
2105   ""
2106   "
2107 {
2108   rtx label = 0;
2109
2110   if (! TARGET_POWER)
2111     {
2112       if (! TARGET_POWERPC)
2113         {
2114           emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2115           emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2116           emit_insn (gen_divus_call ());
2117           emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2118           emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2119           DONE;
2120         }
2121       else
2122         FAIL;
2123     }
2124
2125   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2126     {
2127       operands[2] = force_reg (SImode, operands[2]);
2128       label = gen_label_rtx ();
2129       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2130                                   operands[3], label));
2131     }
2132   else
2133     operands[2] = force_reg (SImode, operands[2]);
2134
2135   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2136                                operands[3]));
2137   if (label)
2138     emit_label (label);
2139
2140   DONE;
2141 }")
2142
2143 ;; AIX architecture-independent common-mode multiply (DImode),
2144 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
2145 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2146 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2147 ;; assumed unused if generating common-mode, so ignore.
2148 (define_insn "mulh_call"
2149   [(set (reg:SI 3)
2150         (truncate:SI
2151          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2152                                (sign_extend:DI (reg:SI 4)))
2153                       (const_int 32))))
2154    (clobber (match_scratch:SI 0 "=l"))]
2155   "! TARGET_POWER && ! TARGET_POWERPC"
2156   "bla __mulh"
2157   [(set_attr "type" "imul")])
2158
2159 (define_insn "mull_call"
2160   [(set (reg:DI 3)
2161         (mult:DI (sign_extend:DI (reg:SI 3))
2162                  (sign_extend:DI (reg:SI 4))))
2163    (clobber (match_scratch:SI 0 "=l"))
2164    (clobber (reg:SI 0))]
2165   "! TARGET_POWER && ! TARGET_POWERPC"
2166   "bla __mull"
2167   [(set_attr "type" "imul")])
2168
2169 (define_insn "divss_call"
2170   [(set (reg:SI 3)
2171         (div:SI (reg:SI 3) (reg:SI 4)))
2172    (set (reg:SI 4)
2173         (mod:SI (reg:SI 3) (reg:SI 4)))
2174    (clobber (match_scratch:SI 0 "=l"))
2175    (clobber (reg:SI 0))]
2176   "! TARGET_POWER && ! TARGET_POWERPC"
2177   "bla __divss"
2178   [(set_attr "type" "idiv")])
2179
2180 (define_insn "divus_call"
2181   [(set (reg:SI 3)
2182         (udiv:SI (reg:SI 3) (reg:SI 4)))
2183    (set (reg:SI 4)
2184         (umod:SI (reg:SI 3) (reg:SI 4)))
2185    (clobber (match_scratch:SI 0 "=l"))
2186    (clobber (reg:SI 0))
2187    (clobber (match_scratch:CC 1 "=x"))
2188    (clobber (reg:CC 69))]
2189   "! TARGET_POWER && ! TARGET_POWERPC"
2190   "bla __divus"
2191   [(set_attr "type" "idiv")])
2192
2193 (define_insn "quoss_call"
2194   [(set (reg:SI 3)
2195         (div:SI (reg:SI 3) (reg:SI 4)))
2196    (clobber (match_scratch:SI 0 "=l"))]
2197   "! TARGET_POWER && ! TARGET_POWERPC"
2198   "bla __quoss"
2199   [(set_attr "type" "idiv")])
2200
2201 (define_insn "quous_call"
2202   [(set (reg:SI 3)
2203         (udiv:SI (reg:SI 3) (reg:SI 4)))
2204    (clobber (match_scratch:SI 0 "=l"))
2205    (clobber (reg:SI 0))
2206    (clobber (match_scratch:CC 1 "=x"))
2207    (clobber (reg:CC 69))]
2208   "! TARGET_POWER && ! TARGET_POWERPC"
2209   "bla __quous"
2210   [(set_attr "type" "idiv")])
2211 \f
2212 ;; Logical instructions
2213 ;; The logical instructions are mostly combined by using match_operator,
2214 ;; but the plain AND insns are somewhat different because there is no
2215 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2216 ;; those rotate-and-mask operations.  Thus, the AND insns come first.
2217
2218 (define_insn "andsi3"
2219   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2220         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2221                 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2222    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2223   ""
2224   "@
2225    and %0,%1,%2
2226    {rlinm|rlwinm} %0,%1,0,%m2,%M2
2227    {andil.|andi.} %0,%1,%b2
2228    {andiu.|andis.} %0,%1,%u2"
2229   [(set_attr "type" "*,*,compare,compare")])
2230
2231 ;; Note to set cr's other than cr0 we do the and immediate and then
2232 ;; the test again -- this avoids a mfcr which on the higher end
2233 ;; machines causes an execution serialization
2234
2235 (define_insn "*andsi3_internal2"
2236   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2237         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2238                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2239                     (const_int 0)))
2240    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2241    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2242   "TARGET_32BIT"
2243   "@
2244    and. %3,%1,%2
2245    {andil.|andi.} %3,%1,%b2
2246    {andiu.|andis.} %3,%1,%u2
2247    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2248    #
2249    #
2250    #
2251    #"
2252   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2253    (set_attr "length" "4,4,4,4,8,8,8,8")])
2254
2255 (define_insn "*andsi3_internal3"
2256   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2257         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2258                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2259                     (const_int 0)))
2260    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2261    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2262   "TARGET_64BIT"
2263   "@
2264    #
2265    {andil.|andi.} %3,%1,%b2
2266    {andiu.|andis.} %3,%1,%u2
2267    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2268    #
2269    #
2270    #
2271    #"
2272   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2273    (set_attr "length" "8,4,4,4,8,8,8,8")])
2274
2275 (define_split
2276   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2277         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2278                             (match_operand:SI 2 "and_operand" ""))
2279                     (const_int 0)))
2280    (clobber (match_scratch:SI 3 ""))
2281    (clobber (match_scratch:CC 4 ""))]
2282   "reload_completed"
2283   [(parallel [(set (match_dup 3)
2284                    (and:SI (match_dup 1)
2285                            (match_dup 2)))
2286               (clobber (match_dup 4))])
2287    (set (match_dup 0)
2288         (compare:CC (match_dup 3)
2289                     (const_int 0)))]
2290   "")
2291
2292 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64.  cr is set from the
2293 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
2294
2295 (define_split
2296   [(set (match_operand:CC 0 "cc_reg_operand" "")
2297         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2298                             (match_operand:SI 2 "gpc_reg_operand" ""))
2299                     (const_int 0)))
2300    (clobber (match_scratch:SI 3 ""))
2301    (clobber (match_scratch:CC 4 ""))]
2302   "TARGET_POWERPC64 && reload_completed"
2303   [(parallel [(set (match_dup 3)
2304                    (and:SI (match_dup 1)
2305                            (match_dup 2)))
2306               (clobber (match_dup 4))])
2307    (set (match_dup 0)
2308         (compare:CC (match_dup 3)
2309                     (const_int 0)))]
2310   "")
2311
2312 (define_insn "*andsi3_internal4"
2313   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2314         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2315                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2316                     (const_int 0)))
2317    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2318         (and:SI (match_dup 1)
2319                 (match_dup 2)))
2320    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2321   "TARGET_32BIT"
2322   "@
2323    and. %0,%1,%2
2324    {andil.|andi.} %0,%1,%b2
2325    {andiu.|andis.} %0,%1,%u2
2326    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2327    #
2328    #
2329    #
2330    #"
2331   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2332    (set_attr "length" "4,4,4,4,8,8,8,8")])
2333
2334 (define_insn "*andsi3_internal5"
2335   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2336         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2337                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2338                     (const_int 0)))
2339    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2340         (and:SI (match_dup 1)
2341                 (match_dup 2)))
2342    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2343   "TARGET_64BIT"
2344   "@
2345    #
2346    {andil.|andi.} %0,%1,%b2
2347    {andiu.|andis.} %0,%1,%u2
2348    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2349    #
2350    #
2351    #
2352    #"
2353   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2354    (set_attr "length" "8,4,4,4,8,8,8,8")])
2355
2356 (define_split
2357   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2358         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2359                             (match_operand:SI 2 "and_operand" ""))
2360                     (const_int 0)))
2361    (set (match_operand:SI 0 "gpc_reg_operand" "")
2362         (and:SI (match_dup 1)
2363                 (match_dup 2)))
2364    (clobber (match_scratch:CC 4 ""))]
2365   "reload_completed"
2366   [(parallel [(set (match_dup 0)
2367                    (and:SI (match_dup 1)
2368                            (match_dup 2)))
2369               (clobber (match_dup 4))])
2370    (set (match_dup 3)
2371         (compare:CC (match_dup 0)
2372                     (const_int 0)))]
2373   "")
2374
2375 (define_split
2376   [(set (match_operand:CC 3 "cc_reg_operand" "")
2377         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2378                             (match_operand:SI 2 "gpc_reg_operand" ""))
2379                     (const_int 0)))
2380    (set (match_operand:SI 0 "gpc_reg_operand" "")
2381         (and:SI (match_dup 1)
2382                 (match_dup 2)))
2383    (clobber (match_scratch:CC 4 ""))]
2384   "TARGET_POWERPC64 && reload_completed"
2385   [(parallel [(set (match_dup 0)
2386                    (and:SI (match_dup 1)
2387                            (match_dup 2)))
2388               (clobber (match_dup 4))])
2389    (set (match_dup 3)
2390         (compare:CC (match_dup 0)
2391                     (const_int 0)))]
2392   "")
2393
2394 ;; Handle the PowerPC64 rlwinm corner case
2395
2396 (define_insn_and_split "*andsi3_internal6"
2397   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2398         (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2399                 (match_operand:SI 2 "mask_operand_wrap" "i")))]
2400   "TARGET_POWERPC64"
2401   "#"
2402   "TARGET_POWERPC64"
2403   [(set (match_dup 0)
2404         (and:SI (rotate:SI (match_dup 1) (match_dup 3))
2405                 (match_dup 4)))
2406    (set (match_dup 0)
2407         (rotate:SI (match_dup 0) (match_dup 5)))]
2408   "
2409 {
2410   int mb = extract_MB (operands[2]);
2411   int me = extract_ME (operands[2]);
2412   operands[3] = GEN_INT (me + 1);
2413   operands[5] = GEN_INT (32 - (me + 1));
2414   operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
2415 }"
2416   [(set_attr "length" "8")])
2417
2418 (define_expand "iorsi3"
2419   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2420         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2421                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2422   ""
2423   "
2424 {
2425   if (GET_CODE (operands[2]) == CONST_INT
2426       && ! logical_operand (operands[2], SImode))
2427     {
2428       HOST_WIDE_INT value = INTVAL (operands[2]);
2429       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2430                  ? operands[0] : gen_reg_rtx (SImode));
2431
2432       emit_insn (gen_iorsi3 (tmp, operands[1],
2433                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2434       emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2435       DONE;
2436     }
2437 }")
2438
2439 (define_expand "xorsi3"
2440   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2441         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2442                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2443   ""
2444   "
2445 {
2446   if (GET_CODE (operands[2]) == CONST_INT
2447       && ! logical_operand (operands[2], SImode))
2448     {
2449       HOST_WIDE_INT value = INTVAL (operands[2]);
2450       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2451                  ? operands[0] : gen_reg_rtx (SImode));
2452
2453       emit_insn (gen_xorsi3 (tmp, operands[1],
2454                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2455       emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2456       DONE;
2457     }
2458 }")
2459
2460 (define_insn "*boolsi3_internal1"
2461   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2462         (match_operator:SI 3 "boolean_or_operator"
2463          [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2464           (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2465   ""
2466   "@
2467    %q3 %0,%1,%2
2468    {%q3il|%q3i} %0,%1,%b2
2469    {%q3iu|%q3is} %0,%1,%u2")
2470
2471 (define_insn "*boolsi3_internal2"
2472   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2473         (compare:CC (match_operator:SI 4 "boolean_or_operator"
2474          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2475           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2476          (const_int 0)))
2477    (clobber (match_scratch:SI 3 "=r,r"))]
2478   "TARGET_32BIT"
2479   "@
2480    %q4. %3,%1,%2
2481    #"
2482   [(set_attr "type" "compare")
2483    (set_attr "length" "4,8")])
2484
2485 (define_split
2486   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2487         (compare:CC (match_operator:SI 4 "boolean_operator"
2488          [(match_operand:SI 1 "gpc_reg_operand" "")
2489           (match_operand:SI 2 "gpc_reg_operand" "")])
2490          (const_int 0)))
2491    (clobber (match_scratch:SI 3 ""))]
2492   "TARGET_32BIT && reload_completed"
2493   [(set (match_dup 3) (match_dup 4))
2494    (set (match_dup 0)
2495         (compare:CC (match_dup 3)
2496                     (const_int 0)))]
2497   "")
2498
2499 (define_insn "*boolsi3_internal3"
2500   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2501         (compare:CC (match_operator:SI 4 "boolean_operator"
2502          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2503           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2504          (const_int 0)))
2505    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2506         (match_dup 4))]
2507   "TARGET_32BIT"
2508   "@
2509    %q4. %0,%1,%2
2510    #"
2511   [(set_attr "type" "compare")
2512    (set_attr "length" "4,8")])
2513
2514 (define_split
2515   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2516         (compare:CC (match_operator:SI 4 "boolean_operator"
2517          [(match_operand:SI 1 "gpc_reg_operand" "")
2518           (match_operand:SI 2 "gpc_reg_operand" "")])
2519          (const_int 0)))
2520    (set (match_operand:SI 0 "gpc_reg_operand" "")
2521         (match_dup 4))]
2522   "TARGET_32BIT && reload_completed"
2523   [(set (match_dup 0) (match_dup 4))
2524    (set (match_dup 3)
2525         (compare:CC (match_dup 0)
2526                     (const_int 0)))]
2527   "")
2528
2529 ;; Split a logical operation that we can't do in one insn into two insns,
2530 ;; each of which does one 16-bit part.  This is used by combine.
2531
2532 (define_split
2533   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2534         (match_operator:SI 3 "boolean_or_operator"
2535          [(match_operand:SI 1 "gpc_reg_operand" "")
2536           (match_operand:SI 2 "non_logical_cint_operand" "")]))]
2537   ""
2538   [(set (match_dup 0) (match_dup 4))
2539    (set (match_dup 0) (match_dup 5))]
2540 "
2541 {
2542   rtx i;
2543   i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
2544   operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2545                                 operands[1], i);
2546   i = GEN_INT (INTVAL (operands[2]) & 0xffff);
2547   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
2548                                 operands[0], i);
2549 }")
2550
2551 (define_insn "*boolcsi3_internal1"
2552   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2553         (match_operator:SI 3 "boolean_operator"
2554          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2555           (match_operand:SI 2 "gpc_reg_operand" "r")]))]
2556   ""
2557   "%q3 %0,%2,%1")
2558
2559 (define_insn "*boolcsi3_internal2"
2560   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2561         (compare:CC (match_operator:SI 4 "boolean_operator"
2562          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2563           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2564          (const_int 0)))
2565    (clobber (match_scratch:SI 3 "=r,r"))]
2566   "TARGET_32BIT"
2567   "@
2568    %q4. %3,%2,%1
2569    #"
2570   [(set_attr "type" "compare")
2571    (set_attr "length" "4,8")])
2572
2573 (define_split
2574   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2575         (compare:CC (match_operator:SI 4 "boolean_operator"
2576          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2577           (match_operand:SI 2 "gpc_reg_operand" "")])
2578          (const_int 0)))
2579    (clobber (match_scratch:SI 3 ""))]
2580   "TARGET_32BIT && reload_completed"
2581   [(set (match_dup 3) (match_dup 4))
2582    (set (match_dup 0)
2583         (compare:CC (match_dup 3)
2584                     (const_int 0)))]
2585   "")
2586
2587 (define_insn "*boolcsi3_internal3"
2588   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2589         (compare:CC (match_operator:SI 4 "boolean_operator"
2590          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2591           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2592          (const_int 0)))
2593    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2594         (match_dup 4))]
2595   "TARGET_32BIT"
2596   "@
2597    %q4. %0,%2,%1
2598    #"
2599   [(set_attr "type" "compare")
2600    (set_attr "length" "4,8")])
2601
2602 (define_split
2603   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2604         (compare:CC (match_operator:SI 4 "boolean_operator"
2605          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2606           (match_operand:SI 2 "gpc_reg_operand" "")])
2607          (const_int 0)))
2608    (set (match_operand:SI 0 "gpc_reg_operand" "")
2609         (match_dup 4))]
2610   "TARGET_32BIT && reload_completed"
2611   [(set (match_dup 0) (match_dup 4))
2612    (set (match_dup 3)
2613         (compare:CC (match_dup 0)
2614                     (const_int 0)))]
2615   "")
2616
2617 (define_insn "*boolccsi3_internal1"
2618   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2619         (match_operator:SI 3 "boolean_operator"
2620          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
2621           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
2622   ""
2623   "%q3 %0,%1,%2")
2624
2625 (define_insn "*boolccsi3_internal2"
2626   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2627         (compare:CC (match_operator:SI 4 "boolean_operator"
2628          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2629           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2630          (const_int 0)))
2631    (clobber (match_scratch:SI 3 "=r,r"))]
2632   "TARGET_32BIT"
2633   "@
2634    %q4. %3,%1,%2
2635    #"
2636   [(set_attr "type" "compare")
2637    (set_attr "length" "4,8")])
2638
2639 (define_split
2640   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2641         (compare:CC (match_operator:SI 4 "boolean_operator"
2642          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2643           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2644          (const_int 0)))
2645    (clobber (match_scratch:SI 3 ""))]
2646   "TARGET_32BIT && reload_completed"
2647   [(set (match_dup 3) (match_dup 4))
2648    (set (match_dup 0)
2649         (compare:CC (match_dup 3)
2650                     (const_int 0)))]
2651   "")
2652
2653 (define_insn "*boolccsi3_internal3"
2654   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2655         (compare:CC (match_operator:SI 4 "boolean_operator"
2656          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
2657           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
2658          (const_int 0)))
2659    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2660         (match_dup 4))]
2661   "TARGET_32BIT"
2662   "@
2663    %q4. %0,%1,%2
2664    #"
2665   [(set_attr "type" "compare")
2666    (set_attr "length" "4,8")])
2667
2668 (define_split
2669   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2670         (compare:CC (match_operator:SI 4 "boolean_operator"
2671          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2672           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
2673          (const_int 0)))
2674    (set (match_operand:SI 0 "gpc_reg_operand" "")
2675         (match_dup 4))]
2676   "TARGET_32BIT && reload_completed"
2677   [(set (match_dup 0) (match_dup 4))
2678    (set (match_dup 3)
2679         (compare:CC (match_dup 0)
2680                     (const_int 0)))]
2681   "")
2682
2683 ;; maskir insn.  We need four forms because things might be in arbitrary
2684 ;; orders.  Don't define forms that only set CR fields because these
2685 ;; would modify an input register.
2686
2687 (define_insn "*maskir_internal1"
2688   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2689         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2690                         (match_operand:SI 1 "gpc_reg_operand" "0"))
2691                 (and:SI (match_dup 2)
2692                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
2693   "TARGET_POWER"
2694   "maskir %0,%3,%2")
2695
2696 (define_insn "*maskir_internal2"
2697   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2698         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
2699                         (match_operand:SI 1 "gpc_reg_operand" "0"))
2700                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2701                         (match_dup 2))))]
2702   "TARGET_POWER"
2703   "maskir %0,%3,%2")
2704
2705 (define_insn "*maskir_internal3"
2706   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2707         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
2708                         (match_operand:SI 3 "gpc_reg_operand" "r"))
2709                 (and:SI (not:SI (match_dup 2))
2710                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2711   "TARGET_POWER"
2712   "maskir %0,%3,%2")
2713
2714 (define_insn "*maskir_internal4"
2715   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2716         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2717                         (match_operand:SI 2 "gpc_reg_operand" "r"))
2718                 (and:SI (not:SI (match_dup 2))
2719                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
2720   "TARGET_POWER"
2721   "maskir %0,%3,%2")
2722
2723 (define_insn "*maskir_internal5"
2724   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2725         (compare:CC
2726          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2727                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2728                  (and:SI (match_dup 2)
2729                          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
2730          (const_int 0)))
2731    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2732         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2733                 (and:SI (match_dup 2) (match_dup 3))))]
2734   "TARGET_POWER"
2735   "@
2736    maskir. %0,%3,%2
2737    #"
2738   [(set_attr "type" "compare")
2739    (set_attr "length" "4,8")])
2740
2741 (define_split
2742   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2743         (compare:CC
2744          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2745                          (match_operand:SI 1 "gpc_reg_operand" ""))
2746                  (and:SI (match_dup 2)
2747                          (match_operand:SI 3 "gpc_reg_operand" "")))
2748          (const_int 0)))
2749    (set (match_operand:SI 0 "gpc_reg_operand" "")
2750         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2751                 (and:SI (match_dup 2) (match_dup 3))))]
2752   "TARGET_POWER && reload_completed"
2753   [(set (match_dup 0)
2754         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2755                 (and:SI (match_dup 2) (match_dup 3))))
2756    (set (match_dup 4)
2757         (compare:CC (match_dup 0)
2758                     (const_int 0)))]
2759   "")
2760
2761 (define_insn "*maskir_internal6"
2762   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2763         (compare:CC
2764          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2765                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
2766                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2767                          (match_dup 2)))
2768          (const_int 0)))
2769    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2770         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2771                 (and:SI (match_dup 3) (match_dup 2))))]
2772   "TARGET_POWER"
2773   "@
2774    maskir. %0,%3,%2
2775    #"
2776   [(set_attr "type" "compare")
2777    (set_attr "length" "4,8")])
2778
2779 (define_split
2780   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2781         (compare:CC
2782          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
2783                          (match_operand:SI 1 "gpc_reg_operand" ""))
2784                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2785                          (match_dup 2)))
2786          (const_int 0)))
2787    (set (match_operand:SI 0 "gpc_reg_operand" "")
2788         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2789                 (and:SI (match_dup 3) (match_dup 2))))]
2790   "TARGET_POWER && reload_completed"
2791   [(set (match_dup 0)
2792         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
2793                 (and:SI (match_dup 3) (match_dup 2))))
2794    (set (match_dup 4)
2795         (compare:CC (match_dup 0)
2796                     (const_int 0)))]
2797   "")
2798
2799 (define_insn "*maskir_internal7"
2800   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2801         (compare:CC
2802          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
2803                          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
2804                  (and:SI (not:SI (match_dup 2))
2805                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2806          (const_int 0)))
2807    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2808         (ior:SI (and:SI (match_dup 2) (match_dup 3))
2809                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2810   "TARGET_POWER"
2811   "@
2812    maskir. %0,%3,%2
2813    #"
2814   [(set_attr "type" "compare")
2815    (set_attr "length" "4,8")])
2816
2817 (define_split
2818   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2819         (compare:CC
2820          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
2821                          (match_operand:SI 3 "gpc_reg_operand" ""))
2822                  (and:SI (not:SI (match_dup 2))
2823                          (match_operand:SI 1 "gpc_reg_operand" "")))
2824          (const_int 0)))
2825    (set (match_operand:SI 0 "gpc_reg_operand" "")
2826         (ior:SI (and:SI (match_dup 2) (match_dup 3))
2827                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2828   "TARGET_POWER && reload_completed"
2829   [(set (match_dup 0)
2830         (ior:SI (and:SI (match_dup 2) (match_dup 3))
2831                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2832    (set (match_dup 4)
2833         (compare:CC (match_dup 0)
2834                     (const_int 0)))]
2835   "")
2836
2837 (define_insn "*maskir_internal8"
2838   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
2839         (compare:CC
2840          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
2841                          (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2842                  (and:SI (not:SI (match_dup 2))
2843                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
2844          (const_int 0)))
2845    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2846         (ior:SI (and:SI (match_dup 3) (match_dup 2))
2847                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2848   "TARGET_POWER"
2849   "@
2850    maskir. %0,%3,%2
2851    #"
2852   [(set_attr "type" "compare")
2853    (set_attr "length" "4,8")])
2854
2855 (define_split
2856   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
2857         (compare:CC
2858          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
2859                          (match_operand:SI 2 "gpc_reg_operand" ""))
2860                  (and:SI (not:SI (match_dup 2))
2861                          (match_operand:SI 1 "gpc_reg_operand" "")))
2862          (const_int 0)))
2863    (set (match_operand:SI 0 "gpc_reg_operand" "")
2864         (ior:SI (and:SI (match_dup 3) (match_dup 2))
2865                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
2866   "TARGET_POWER && reload_completed"
2867   [(set (match_dup 0)
2868         (ior:SI (and:SI (match_dup 3) (match_dup 2))
2869                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
2870    (set (match_dup 4)
2871         (compare:CC (match_dup 0)
2872                     (const_int 0)))]
2873   "")
2874 \f
2875 ;; Rotate and shift insns, in all their variants.  These support shifts,
2876 ;; field inserts and extracts, and various combinations thereof.
2877 (define_expand "insv"
2878   [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
2879                        (match_operand:SI 1 "const_int_operand" "")
2880                        (match_operand:SI 2 "const_int_operand" ""))
2881         (match_operand 3 "gpc_reg_operand" ""))]
2882   ""
2883   "
2884 {
2885   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
2886      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
2887      compiler if the address of the structure is taken later.  */
2888   if (GET_CODE (operands[0]) == SUBREG
2889       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
2890     FAIL;
2891
2892   if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
2893     emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
2894   else
2895     emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
2896   DONE;
2897 }")
2898
2899 (define_insn "insvsi"
2900   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2901                          (match_operand:SI 1 "const_int_operand" "i")
2902                          (match_operand:SI 2 "const_int_operand" "i"))
2903         (match_operand:SI 3 "gpc_reg_operand" "r"))]
2904   ""
2905   "*
2906 {
2907   int start = INTVAL (operands[2]) & 31;
2908   int size = INTVAL (operands[1]) & 31;
2909
2910   operands[4] = GEN_INT (32 - start - size);
2911   operands[1] = GEN_INT (start + size - 1);
2912   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2913 }"
2914   [(set_attr "type" "insert_word")])
2915
2916 (define_insn "*insvsi_internal1"
2917   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2918                          (match_operand:SI 1 "const_int_operand" "i")
2919                          (match_operand:SI 2 "const_int_operand" "i"))
2920         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2921                    (match_operand:SI 4 "const_int_operand" "i")))]
2922   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2923   "*
2924 {
2925   int shift = INTVAL (operands[4]) & 31;
2926   int start = INTVAL (operands[2]) & 31;
2927   int size = INTVAL (operands[1]) & 31;
2928
2929   operands[4] = GEN_INT (shift - start - size);
2930   operands[1] = GEN_INT (start + size - 1);
2931   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2932 }"
2933   [(set_attr "type" "insert_word")])
2934
2935 (define_insn "*insvsi_internal2"
2936   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2937                          (match_operand:SI 1 "const_int_operand" "i")
2938                          (match_operand:SI 2 "const_int_operand" "i"))
2939         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2940                      (match_operand:SI 4 "const_int_operand" "i")))]
2941   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2942   "*
2943 {
2944   int shift = INTVAL (operands[4]) & 31;
2945   int start = INTVAL (operands[2]) & 31;
2946   int size = INTVAL (operands[1]) & 31;
2947
2948   operands[4] = GEN_INT (32 - shift - start - size);
2949   operands[1] = GEN_INT (start + size - 1);
2950   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2951 }"
2952   [(set_attr "type" "insert_word")])
2953
2954 (define_insn "*insvsi_internal3"
2955   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2956                          (match_operand:SI 1 "const_int_operand" "i")
2957                          (match_operand:SI 2 "const_int_operand" "i"))
2958         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2959                      (match_operand:SI 4 "const_int_operand" "i")))]
2960   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
2961   "*
2962 {
2963   int shift = INTVAL (operands[4]) & 31;
2964   int start = INTVAL (operands[2]) & 31;
2965   int size = INTVAL (operands[1]) & 31;
2966
2967   operands[4] = GEN_INT (32 - shift - start - size);
2968   operands[1] = GEN_INT (start + size - 1);
2969   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
2970 }"
2971   [(set_attr "type" "insert_word")])
2972
2973 (define_insn "*insvsi_internal4"
2974   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
2975                          (match_operand:SI 1 "const_int_operand" "i")
2976                          (match_operand:SI 2 "const_int_operand" "i"))
2977         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
2978                          (match_operand:SI 4 "const_int_operand" "i")
2979                          (match_operand:SI 5 "const_int_operand" "i")))]
2980   "INTVAL (operands[4]) >= INTVAL (operands[1])"
2981   "*
2982 {
2983   int extract_start = INTVAL (operands[5]) & 31;
2984   int extract_size = INTVAL (operands[4]) & 31;
2985   int insert_start = INTVAL (operands[2]) & 31;
2986   int insert_size = INTVAL (operands[1]) & 31;
2987
2988 /* Align extract field with insert field */
2989   operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
2990   operands[1] = GEN_INT (insert_start + insert_size - 1);
2991   return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
2992 }"
2993   [(set_attr "type" "insert_word")])
2994
2995 ;; combine patterns for rlwimi
2996 (define_insn "*insvsi_internal5"
2997   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2998         (ior:SI (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
2999                         (match_operand:SI 1 "mask_operand" "i"))
3000                 (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3001                                      (match_operand:SI 2 "const_int_operand" "i"))
3002                         (match_operand:SI 5 "mask_operand" "i"))))]
3003   "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3004   "*
3005 {
3006  int me = extract_ME(operands[5]);
3007  int mb = extract_MB(operands[5]);
3008  operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3009  operands[2] = GEN_INT(mb);
3010  operands[1] = GEN_INT(me);
3011  return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3012 }"
3013   [(set_attr "type" "insert_word")])
3014
3015 (define_insn "*insvsi_internal6"
3016   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3017         (ior:SI (and:SI (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3018                                      (match_operand:SI 2 "const_int_operand" "i"))
3019                         (match_operand:SI 5 "mask_operand" "i"))
3020                 (and:SI (match_operand:SI 4 "gpc_reg_operand" "0")
3021                         (match_operand:SI 1 "mask_operand" "i"))))]
3022   "TARGET_POWERPC && INTVAL(operands[1]) == ~INTVAL(operands[5])"
3023   "*
3024 {
3025  int me = extract_ME(operands[5]);
3026  int mb = extract_MB(operands[5]);
3027  operands[4] = GEN_INT(32 - INTVAL(operands[2]));
3028  operands[2] = GEN_INT(mb);
3029  operands[1] = GEN_INT(me);
3030  return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3031 }"
3032   [(set_attr "type" "insert_word")])
3033
3034 (define_insn "insvdi"
3035   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3036                          (match_operand:SI 1 "const_int_operand" "i")
3037                          (match_operand:SI 2 "const_int_operand" "i"))
3038         (match_operand:DI 3 "gpc_reg_operand" "r"))]
3039   "TARGET_POWERPC64"
3040   "*
3041 {
3042   int start = INTVAL (operands[2]) & 63;
3043   int size = INTVAL (operands[1]) & 63;
3044
3045   operands[1] = GEN_INT (64 - start - size);
3046   return \"rldimi %0,%3,%H1,%H2\";
3047 }")
3048
3049 (define_insn "*insvdi_internal2"
3050   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3051                          (match_operand:SI 1 "const_int_operand" "i")
3052                          (match_operand:SI 2 "const_int_operand" "i"))
3053         (ashiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3054                      (match_operand:SI 4 "const_int_operand" "i")))]
3055   "TARGET_POWERPC64
3056    && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3057   "*
3058 {
3059   int shift = INTVAL (operands[4]) & 63;
3060   int start = (INTVAL (operands[2]) & 63) - 32;
3061   int size = INTVAL (operands[1]) & 63;
3062
3063   operands[4] = GEN_INT (64 - shift - start - size);
3064   operands[2] = GEN_INT (start);
3065   operands[1] = GEN_INT (start + size - 1);
3066   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3067 }")
3068
3069 (define_insn "*insvdi_internal3"
3070   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3071                          (match_operand:SI 1 "const_int_operand" "i")
3072                          (match_operand:SI 2 "const_int_operand" "i"))
3073         (lshiftrt:DI (match_operand:DI 3 "gpc_reg_operand" "r")
3074                      (match_operand:SI 4 "const_int_operand" "i")))]
3075   "TARGET_POWERPC64
3076    && insvdi_rshift_rlwimi_p (operands[1], operands[2], operands[4])"
3077   "*
3078 {
3079   int shift = INTVAL (operands[4]) & 63;
3080   int start = (INTVAL (operands[2]) & 63) - 32;
3081   int size = INTVAL (operands[1]) & 63;
3082
3083   operands[4] = GEN_INT (64 - shift - start - size);
3084   operands[2] = GEN_INT (start);
3085   operands[1] = GEN_INT (start + size - 1);
3086   return \"rlwimi %0,%3,%h4,%h2,%h1\";
3087 }")
3088
3089 (define_expand "extzv"
3090   [(set (match_operand 0 "gpc_reg_operand" "")
3091         (zero_extract (match_operand 1 "gpc_reg_operand" "")
3092                        (match_operand:SI 2 "const_int_operand" "")
3093                        (match_operand:SI 3 "const_int_operand" "")))]
3094   ""
3095   "
3096 {
3097   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3098      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3099      compiler if the address of the structure is taken later.  */
3100   if (GET_CODE (operands[0]) == SUBREG
3101       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3102     FAIL;
3103
3104   if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3105     emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3106   else
3107     emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3108   DONE;
3109 }")
3110
3111 (define_insn "extzvsi"
3112   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3113         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3114                          (match_operand:SI 2 "const_int_operand" "i")
3115                          (match_operand:SI 3 "const_int_operand" "i")))]
3116   ""
3117   "*
3118 {
3119   int start = INTVAL (operands[3]) & 31;
3120   int size = INTVAL (operands[2]) & 31;
3121
3122   if (start + size >= 32)
3123     operands[3] = const0_rtx;
3124   else
3125     operands[3] = GEN_INT (start + size);
3126   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3127 }")
3128
3129 (define_insn "*extzvsi_internal1"
3130   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3131         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3132                          (match_operand:SI 2 "const_int_operand" "i,i")
3133                          (match_operand:SI 3 "const_int_operand" "i,i"))
3134                     (const_int 0)))
3135    (clobber (match_scratch:SI 4 "=r,r"))]
3136   ""
3137   "*
3138 {
3139   int start = INTVAL (operands[3]) & 31;
3140   int size = INTVAL (operands[2]) & 31;
3141
3142   /* Force split for non-cc0 compare.  */
3143   if (which_alternative == 1)
3144      return \"#\";
3145
3146   /* If the bit-field being tested fits in the upper or lower half of a
3147      word, it is possible to use andiu. or andil. to test it.  This is
3148      useful because the condition register set-use delay is smaller for
3149      andi[ul]. than for rlinm.  This doesn't work when the starting bit
3150      position is 0 because the LT and GT bits may be set wrong.  */
3151
3152   if ((start > 0 && start + size <= 16) || start >= 16)
3153     {
3154       operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3155                               - (1 << (16 - (start & 15) - size))));
3156       if (start < 16)
3157         return \"{andiu.|andis.} %4,%1,%3\";
3158       else
3159         return \"{andil.|andi.} %4,%1,%3\";
3160     }
3161
3162   if (start + size >= 32)
3163     operands[3] = const0_rtx;
3164   else
3165     operands[3] = GEN_INT (start + size);
3166   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3167 }"
3168   [(set_attr "type" "compare")
3169    (set_attr "length" "4,8")])
3170
3171 (define_split
3172   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3173         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3174                          (match_operand:SI 2 "const_int_operand" "")
3175                          (match_operand:SI 3 "const_int_operand" ""))
3176                     (const_int 0)))
3177    (clobber (match_scratch:SI 4 ""))]
3178   "reload_completed"
3179   [(set (match_dup 4)
3180         (zero_extract:SI (match_dup 1) (match_dup 2)
3181                          (match_dup 3)))
3182    (set (match_dup 0)
3183         (compare:CC (match_dup 4)
3184                     (const_int 0)))]
3185   "")
3186
3187 (define_insn "*extzvsi_internal2"
3188   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3189         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3190                          (match_operand:SI 2 "const_int_operand" "i,i")
3191                          (match_operand:SI 3 "const_int_operand" "i,i"))
3192                     (const_int 0)))
3193    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3194         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3195   ""
3196   "*
3197 {
3198   int start = INTVAL (operands[3]) & 31;
3199   int size = INTVAL (operands[2]) & 31;
3200
3201   /* Force split for non-cc0 compare.  */
3202   if (which_alternative == 1)
3203      return \"#\";
3204
3205   /* Since we are using the output value, we can't ignore any need for
3206      a shift.  The bit-field must end at the LSB.  */
3207   if (start >= 16 && start + size == 32)
3208     {
3209       operands[3] = GEN_INT ((1 << size) - 1);
3210       return \"{andil.|andi.} %0,%1,%3\";
3211     }
3212
3213   if (start + size >= 32)
3214     operands[3] = const0_rtx;
3215   else
3216     operands[3] = GEN_INT (start + size);
3217   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3218 }"
3219   [(set_attr "type" "compare")
3220    (set_attr "length" "4,8")])
3221
3222 (define_split
3223   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3224         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3225                          (match_operand:SI 2 "const_int_operand" "")
3226                          (match_operand:SI 3 "const_int_operand" ""))
3227                     (const_int 0)))
3228    (set (match_operand:SI 0 "gpc_reg_operand" "")
3229         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3230   "reload_completed"
3231   [(set (match_dup 0)
3232         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3233    (set (match_dup 4)
3234         (compare:CC (match_dup 0)
3235                     (const_int 0)))]
3236   "")
3237
3238 (define_insn "extzvdi"
3239   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3240         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3241                          (match_operand:SI 2 "const_int_operand" "i")
3242                          (match_operand:SI 3 "const_int_operand" "i")))]
3243   "TARGET_POWERPC64"
3244   "*
3245 {
3246   int start = INTVAL (operands[3]) & 63;
3247   int size = INTVAL (operands[2]) & 63;
3248
3249   if (start + size >= 64)
3250     operands[3] = const0_rtx;
3251   else
3252     operands[3] = GEN_INT (start + size);
3253   operands[2] = GEN_INT (64 - size);
3254   return \"rldicl %0,%1,%3,%2\";
3255 }")
3256
3257 (define_insn "*extzvdi_internal1"
3258   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3259         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3260                          (match_operand:SI 2 "const_int_operand" "i")
3261                          (match_operand:SI 3 "const_int_operand" "i"))
3262                     (const_int 0)))
3263    (clobber (match_scratch:DI 4 "=r"))]
3264   "TARGET_64BIT"
3265   "*
3266 {
3267   int start = INTVAL (operands[3]) & 63;
3268   int size = INTVAL (operands[2]) & 63;
3269
3270   if (start + size >= 64)
3271     operands[3] = const0_rtx;
3272   else
3273     operands[3] = GEN_INT (start + size);
3274   operands[2] = GEN_INT (64 - size);
3275   return \"rldicl. %4,%1,%3,%2\";
3276 }"
3277   [(set_attr "type" "compare")])
3278
3279 (define_insn "*extzvdi_internal2"
3280   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3281         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3282                          (match_operand:SI 2 "const_int_operand" "i")
3283                          (match_operand:SI 3 "const_int_operand" "i"))
3284                     (const_int 0)))
3285    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3286         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3287   "TARGET_64BIT"
3288   "*
3289 {
3290   int start = INTVAL (operands[3]) & 63;
3291   int size = INTVAL (operands[2]) & 63;
3292
3293   if (start + size >= 64)
3294     operands[3] = const0_rtx;
3295   else
3296     operands[3] = GEN_INT (start + size);
3297   operands[2] = GEN_INT (64 - size);
3298   return \"rldicl. %0,%1,%3,%2\";
3299 }"
3300   [(set_attr "type" "compare")])
3301
3302 (define_insn "rotlsi3"
3303   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3304         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3305                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3306   ""
3307   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3308
3309 (define_insn "*rotlsi3_internal2"
3310   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3311         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3312                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3313                     (const_int 0)))
3314    (clobber (match_scratch:SI 3 "=r,r"))]
3315   ""
3316   "@
3317    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3318    #"
3319   [(set_attr "type" "delayed_compare")
3320    (set_attr "length" "4,8")])
3321
3322 (define_split
3323   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3324         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3325                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3326                     (const_int 0)))
3327    (clobber (match_scratch:SI 3 ""))]
3328   "reload_completed"
3329   [(set (match_dup 3)
3330         (rotate:SI (match_dup 1) (match_dup 2)))
3331    (set (match_dup 0)
3332         (compare:CC (match_dup 3)
3333                     (const_int 0)))]
3334   "")
3335
3336 (define_insn "*rotlsi3_internal3"
3337   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3338         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3339                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3340                     (const_int 0)))
3341    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3342         (rotate:SI (match_dup 1) (match_dup 2)))]
3343   ""
3344   "@
3345    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3346    #"
3347   [(set_attr "type" "delayed_compare")
3348    (set_attr "length" "4,8")])
3349
3350 (define_split
3351   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3352         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3353                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3354                     (const_int 0)))
3355    (set (match_operand:SI 0 "gpc_reg_operand" "")
3356         (rotate:SI (match_dup 1) (match_dup 2)))]
3357   "reload_completed"
3358   [(set (match_dup 0)
3359         (rotate:SI (match_dup 1) (match_dup 2)))
3360    (set (match_dup 3)
3361         (compare:CC (match_dup 0)
3362                     (const_int 0)))]
3363   "")
3364
3365 (define_insn "*rotlsi3_internal4"
3366   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3367         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3368                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
3369                 (match_operand:SI 3 "mask_operand" "n")))]
3370   ""
3371   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
3372
3373 (define_insn "*rotlsi3_internal5"
3374   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3375         (compare:CC (and:SI
3376                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3377                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3378                      (match_operand:SI 3 "mask_operand" "n,n"))
3379                     (const_int 0)))
3380    (clobber (match_scratch:SI 4 "=r,r"))]
3381   ""
3382   "@
3383    {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3384    #"
3385   [(set_attr "type" "delayed_compare")
3386    (set_attr "length" "4,8")])
3387
3388 (define_split
3389   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3390         (compare:CC (and:SI
3391                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3392                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3393                      (match_operand:SI 3 "mask_operand" ""))
3394                     (const_int 0)))
3395    (clobber (match_scratch:SI 4 ""))]
3396   "reload_completed"
3397   [(set (match_dup 4)
3398         (and:SI (rotate:SI (match_dup 1)
3399                                 (match_dup 2))
3400                      (match_dup 3)))
3401    (set (match_dup 0)
3402         (compare:CC (match_dup 4)
3403                     (const_int 0)))]
3404   "")
3405
3406 (define_insn "*rotlsi3_internal6"
3407   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3408         (compare:CC (and:SI
3409                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3410                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3411                      (match_operand:SI 3 "mask_operand" "n,n"))
3412                     (const_int 0)))
3413    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3414         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3415   ""
3416   "@
3417    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3418    #"
3419   [(set_attr "type" "delayed_compare")
3420    (set_attr "length" "4,8")])
3421
3422 (define_split
3423   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3424         (compare:CC (and:SI
3425                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3426                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3427                      (match_operand:SI 3 "mask_operand" ""))
3428                     (const_int 0)))
3429    (set (match_operand:SI 0 "gpc_reg_operand" "")
3430         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3431   "reload_completed"
3432   [(set (match_dup 0)
3433         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3434    (set (match_dup 4)
3435         (compare:CC (match_dup 0)
3436                     (const_int 0)))]
3437   "")
3438
3439 (define_insn "*rotlsi3_internal7"
3440   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3441         (zero_extend:SI
3442          (subreg:QI
3443           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3444                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3445   ""
3446   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
3447
3448 (define_insn "*rotlsi3_internal8"
3449   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3450         (compare:CC (zero_extend:SI
3451                      (subreg:QI
3452                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3453                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3454                     (const_int 0)))
3455    (clobber (match_scratch:SI 3 "=r,r"))]
3456   ""
3457   "@
3458    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3459    #"
3460   [(set_attr "type" "delayed_compare")
3461    (set_attr "length" "4,8")])
3462
3463 (define_split
3464   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3465         (compare:CC (zero_extend:SI
3466                      (subreg:QI
3467                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3468                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3469                     (const_int 0)))
3470    (clobber (match_scratch:SI 3 ""))]
3471   "reload_completed"
3472   [(set (match_dup 3)
3473         (zero_extend:SI (subreg:QI
3474                       (rotate:SI (match_dup 1)
3475                                  (match_dup 2)) 0)))
3476    (set (match_dup 0)
3477         (compare:CC (match_dup 3)
3478                     (const_int 0)))]
3479   "")
3480
3481 (define_insn "*rotlsi3_internal9"
3482   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3483         (compare:CC (zero_extend:SI
3484                      (subreg:QI
3485                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3486                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3487                     (const_int 0)))
3488    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3489         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3490   ""
3491   "@
3492    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3493    #"
3494   [(set_attr "type" "delayed_compare")
3495    (set_attr "length" "4,8")])
3496
3497 (define_split
3498   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3499         (compare:CC (zero_extend:SI
3500                      (subreg:QI
3501                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3502                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3503                     (const_int 0)))
3504    (set (match_operand:SI 0 "gpc_reg_operand" "")
3505         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3506   "reload_completed"
3507   [(set (match_dup 0)
3508         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3509    (set (match_dup 3)
3510         (compare:CC (match_dup 0)
3511                     (const_int 0)))]
3512   "")
3513
3514 (define_insn "*rotlsi3_internal10"
3515   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3516         (zero_extend:SI
3517          (subreg:HI
3518           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3519                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3520   ""
3521   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
3522
3523 (define_insn "*rotlsi3_internal11"
3524   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3525         (compare:CC (zero_extend:SI
3526                      (subreg:HI
3527                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3528                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3529                     (const_int 0)))
3530    (clobber (match_scratch:SI 3 "=r,r"))]
3531   ""
3532   "@
3533    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3534    #"
3535   [(set_attr "type" "delayed_compare")
3536    (set_attr "length" "4,8")])
3537
3538 (define_split
3539   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3540         (compare:CC (zero_extend:SI
3541                      (subreg:HI
3542                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3543                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3544                     (const_int 0)))
3545    (clobber (match_scratch:SI 3 ""))]
3546   "reload_completed"
3547   [(set (match_dup 3)
3548         (zero_extend:SI (subreg:HI
3549                       (rotate:SI (match_dup 1)
3550                                  (match_dup 2)) 0)))
3551    (set (match_dup 0)
3552         (compare:CC (match_dup 3)
3553                     (const_int 0)))]
3554   "")
3555
3556 (define_insn "*rotlsi3_internal12"
3557   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3558         (compare:CC (zero_extend:SI
3559                      (subreg:HI
3560                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3561                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3562                     (const_int 0)))
3563    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3564         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3565   ""
3566   "@
3567    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3568    #"
3569   [(set_attr "type" "delayed_compare")
3570    (set_attr "length" "4,8")])
3571
3572 (define_split
3573   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3574         (compare:CC (zero_extend:SI
3575                      (subreg:HI
3576                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3577                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3578                     (const_int 0)))
3579    (set (match_operand:SI 0 "gpc_reg_operand" "")
3580         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3581   "reload_completed"
3582   [(set (match_dup 0)
3583         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3584    (set (match_dup 3)
3585         (compare:CC (match_dup 0)
3586                     (const_int 0)))]
3587   "")
3588
3589 ;; Note that we use "sle." instead of "sl." so that we can set
3590 ;; SHIFT_COUNT_TRUNCATED.
3591
3592 (define_expand "ashlsi3"
3593   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3594    (use (match_operand:SI 1 "gpc_reg_operand" ""))
3595    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3596   ""
3597   "
3598 {
3599   if (TARGET_POWER)
3600     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3601   else
3602     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
3603   DONE;
3604 }")
3605
3606 (define_insn "ashlsi3_power"
3607   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3608         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3609                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3610    (clobber (match_scratch:SI 3 "=q,X"))]
3611   "TARGET_POWER"
3612   "@
3613    sle %0,%1,%2
3614    {sli|slwi} %0,%1,%h2")
3615
3616 (define_insn "ashlsi3_no_power"
3617   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3618         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3619                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3620   "! TARGET_POWER"
3621   "{sl|slw}%I2 %0,%1,%h2")
3622
3623 (define_insn ""
3624   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3625         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3626                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3627                     (const_int 0)))
3628    (clobber (match_scratch:SI 3 "=r,r,r,r"))
3629    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3630   "TARGET_POWER"
3631   "@
3632    sle. %3,%1,%2
3633    {sli.|slwi.} %3,%1,%h2
3634    #
3635    #"
3636   [(set_attr "type" "delayed_compare")
3637    (set_attr "length" "4,4,8,8")])
3638
3639 (define_split
3640   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3641         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3642                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3643                     (const_int 0)))
3644    (clobber (match_scratch:SI 3 ""))
3645    (clobber (match_scratch:SI 4 ""))]
3646   "TARGET_POWER && reload_completed"
3647   [(parallel [(set (match_dup 3)
3648         (ashift:SI (match_dup 1) (match_dup 2)))
3649    (clobber (match_dup 4))])
3650    (set (match_dup 0)
3651         (compare:CC (match_dup 3)
3652                     (const_int 0)))]
3653   "")
3654
3655 (define_insn ""
3656   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3657         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3658                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3659                     (const_int 0)))
3660    (clobber (match_scratch:SI 3 "=r,r"))]
3661   "! TARGET_POWER && TARGET_32BIT"
3662   "@
3663    {sl|slw}%I2. %3,%1,%h2
3664    #"
3665   [(set_attr "type" "delayed_compare")
3666    (set_attr "length" "4,8")])
3667
3668 (define_split
3669   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3670         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3671                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3672                     (const_int 0)))
3673    (clobber (match_scratch:SI 3 ""))]
3674   "! TARGET_POWER && TARGET_32BIT && reload_completed"
3675   [(set (match_dup 3)
3676         (ashift:SI (match_dup 1) (match_dup 2)))
3677    (set (match_dup 0)
3678         (compare:CC (match_dup 3)
3679                     (const_int 0)))]
3680   "")
3681
3682 (define_insn ""
3683   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3684         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3685                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
3686                     (const_int 0)))
3687    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3688         (ashift:SI (match_dup 1) (match_dup 2)))
3689    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
3690   "TARGET_POWER"
3691   "@
3692    sle. %0,%1,%2
3693    {sli.|slwi.} %0,%1,%h2
3694    #
3695    #"
3696   [(set_attr "type" "delayed_compare")
3697    (set_attr "length" "4,4,8,8")])
3698
3699 (define_split
3700   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3701         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3702                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3703                     (const_int 0)))
3704    (set (match_operand:SI 0 "gpc_reg_operand" "")
3705         (ashift:SI (match_dup 1) (match_dup 2)))
3706    (clobber (match_scratch:SI 4 ""))]
3707   "TARGET_POWER && reload_completed"
3708   [(parallel [(set (match_dup 0)
3709         (ashift:SI (match_dup 1) (match_dup 2)))
3710    (clobber (match_dup 4))])
3711    (set (match_dup 3)
3712         (compare:CC (match_dup 0)
3713                     (const_int 0)))]
3714   "")
3715
3716 (define_insn ""
3717   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3718         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3719                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3720                     (const_int 0)))
3721    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3722         (ashift:SI (match_dup 1) (match_dup 2)))]
3723   "! TARGET_POWER && TARGET_32BIT"
3724   "@
3725    {sl|slw}%I2. %0,%1,%h2
3726    #"
3727   [(set_attr "type" "delayed_compare")
3728    (set_attr "length" "4,8")])
3729
3730 (define_split
3731   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3732         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3733                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3734                     (const_int 0)))
3735    (set (match_operand:SI 0 "gpc_reg_operand" "")
3736         (ashift:SI (match_dup 1) (match_dup 2)))]
3737   "! TARGET_POWER && TARGET_32BIT && reload_completed"
3738   [(set (match_dup 0)
3739         (ashift:SI (match_dup 1) (match_dup 2)))
3740    (set (match_dup 3)
3741         (compare:CC (match_dup 0)
3742                     (const_int 0)))]
3743   "")
3744
3745 (define_insn ""
3746   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3747         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3748                            (match_operand:SI 2 "const_int_operand" "i"))
3749                 (match_operand:SI 3 "mask_operand" "n")))]
3750   "includes_lshift_p (operands[2], operands[3])"
3751   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
3752
3753 (define_insn ""
3754   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3755         (compare:CC
3756          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3757                             (match_operand:SI 2 "const_int_operand" "i,i"))
3758                  (match_operand:SI 3 "mask_operand" "n,n"))
3759          (const_int 0)))
3760    (clobber (match_scratch:SI 4 "=r,r"))]
3761   "includes_lshift_p (operands[2], operands[3])"
3762   "@
3763    {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
3764    #"
3765   [(set_attr "type" "delayed_compare")
3766    (set_attr "length" "4,8")])
3767
3768 (define_split
3769   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3770         (compare:CC
3771          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3772                             (match_operand:SI 2 "const_int_operand" ""))
3773                  (match_operand:SI 3 "mask_operand" ""))
3774          (const_int 0)))
3775    (clobber (match_scratch:SI 4 ""))]
3776   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3777   [(set (match_dup 4)
3778         (and:SI (ashift:SI (match_dup 1) (match_dup 2))
3779                  (match_dup 3)))
3780    (set (match_dup 0)
3781         (compare:CC (match_dup 4)
3782                     (const_int 0)))]
3783   "")
3784
3785 (define_insn ""
3786   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3787         (compare:CC
3788          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3789                             (match_operand:SI 2 "const_int_operand" "i,i"))
3790                  (match_operand:SI 3 "mask_operand" "n,n"))
3791          (const_int 0)))
3792    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3793         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3794   "includes_lshift_p (operands[2], operands[3])"
3795   "@
3796    {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
3797    #"
3798   [(set_attr "type" "delayed_compare")
3799    (set_attr "length" "4,8")])
3800
3801 (define_split
3802   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3803         (compare:CC
3804          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
3805                             (match_operand:SI 2 "const_int_operand" ""))
3806                  (match_operand:SI 3 "mask_operand" ""))
3807          (const_int 0)))
3808    (set (match_operand:SI 0 "gpc_reg_operand" "")
3809         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3810   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
3811   [(set (match_dup 0)
3812         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3813    (set (match_dup 4)
3814         (compare:CC (match_dup 0)
3815                     (const_int 0)))]
3816   "")
3817
3818 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
3819 ;; "sli x,x,0".
3820 (define_expand "lshrsi3"
3821   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3822    (use (match_operand:SI 1 "gpc_reg_operand" ""))
3823    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3824   ""
3825   "
3826 {
3827   if (TARGET_POWER)
3828     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
3829   else
3830     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
3831   DONE;
3832 }")
3833
3834 (define_insn "lshrsi3_power"
3835   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3836         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
3837                      (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
3838    (clobber (match_scratch:SI 3 "=q,X,X"))]
3839   "TARGET_POWER"
3840   "@
3841   sre %0,%1,%2
3842   mr %0,%1
3843   {s%A2i|s%A2wi} %0,%1,%h2")
3844
3845 (define_insn "lshrsi3_no_power"
3846   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3847         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3848                      (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
3849   "! TARGET_POWER"
3850   "@
3851   mr %0,%1
3852   {sr|srw}%I2 %0,%1,%h2")
3853
3854 (define_insn ""
3855   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3856         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3857                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3858                     (const_int 0)))
3859    (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
3860    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3861   "TARGET_POWER"
3862   "@
3863   sre. %3,%1,%2
3864   mr. %1,%1
3865   {s%A2i.|s%A2wi.} %3,%1,%h2
3866   #
3867   #
3868   #"
3869   [(set_attr "type" "delayed_compare")
3870    (set_attr "length" "4,4,4,8,8,8")])
3871
3872 (define_split
3873   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3874         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3875                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
3876                     (const_int 0)))
3877    (clobber (match_scratch:SI 3 ""))
3878    (clobber (match_scratch:SI 4 ""))]
3879   "TARGET_POWER && reload_completed"
3880   [(parallel [(set (match_dup 3)
3881         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3882    (clobber (match_dup 4))])
3883    (set (match_dup 0)
3884         (compare:CC (match_dup 3)
3885                     (const_int 0)))]
3886   "")
3887
3888 (define_insn ""
3889   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
3890         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3891                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3892                     (const_int 0)))
3893    (clobber (match_scratch:SI 3 "=X,r,X,r"))]
3894   "! TARGET_POWER && TARGET_32BIT"
3895   "@
3896    mr. %1,%1
3897    {sr|srw}%I2. %3,%1,%h2
3898    #
3899    #"
3900   [(set_attr "type" "delayed_compare")
3901    (set_attr "length" "4,4,8,8")])
3902
3903 (define_split
3904   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3905         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3906                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
3907                     (const_int 0)))
3908    (clobber (match_scratch:SI 3 ""))]
3909   "! TARGET_POWER && TARGET_32BIT && reload_completed"
3910   [(set (match_dup 3)
3911         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3912    (set (match_dup 0)
3913         (compare:CC (match_dup 3)
3914                     (const_int 0)))]
3915   "")
3916
3917 (define_insn ""
3918   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
3919         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
3920                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
3921                     (const_int 0)))
3922    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
3923         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3924    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
3925   "TARGET_POWER"
3926   "@
3927   sre. %0,%1,%2
3928   mr. %0,%1
3929   {s%A2i.|s%A2wi.} %0,%1,%h2
3930   #
3931   #
3932   #"
3933   [(set_attr "type" "delayed_compare")
3934    (set_attr "length" "4,4,4,8,8,8")])
3935
3936 (define_split
3937   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3938         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3939                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
3940                     (const_int 0)))
3941    (set (match_operand:SI 0 "gpc_reg_operand" "")
3942         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3943    (clobber (match_scratch:SI 4 ""))]
3944   "TARGET_POWER && reload_completed"
3945   [(parallel [(set (match_dup 0)
3946         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3947    (clobber (match_dup 4))])
3948    (set (match_dup 3)
3949         (compare:CC (match_dup 0)
3950                     (const_int 0)))]
3951   "")
3952
3953 (define_insn ""
3954   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
3955         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
3956                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
3957                     (const_int 0)))
3958    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
3959         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3960   "! TARGET_POWER && TARGET_32BIT"
3961   "@
3962    mr. %0,%1
3963    {sr|srw}%I2. %0,%1,%h2
3964    #
3965    #"
3966   [(set_attr "type" "delayed_compare")
3967    (set_attr "length" "4,4,8,8")])
3968
3969 (define_split
3970   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3971         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
3972                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
3973                     (const_int 0)))
3974    (set (match_operand:SI 0 "gpc_reg_operand" "")
3975         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
3976   "! TARGET_POWER && TARGET_32BIT && reload_completed"
3977   [(set (match_dup 0)
3978         (lshiftrt:SI (match_dup 1) (match_dup 2)))
3979    (set (match_dup 3)
3980         (compare:CC (match_dup 0)
3981                     (const_int 0)))]
3982   "")
3983
3984 (define_insn ""
3985   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3986         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3987                              (match_operand:SI 2 "const_int_operand" "i"))
3988                 (match_operand:SI 3 "mask_operand" "n")))]
3989   "includes_rshift_p (operands[2], operands[3])"
3990   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
3991
3992 (define_insn ""
3993   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3994         (compare:CC
3995          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3996                               (match_operand:SI 2 "const_int_operand" "i,i"))
3997                  (match_operand:SI 3 "mask_operand" "n,n"))
3998          (const_int 0)))
3999    (clobber (match_scratch:SI 4 "=r,r"))]
4000   "includes_rshift_p (operands[2], operands[3])"
4001   "@
4002    {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4003    #"
4004   [(set_attr "type" "delayed_compare")
4005    (set_attr "length" "4,8")])
4006
4007 (define_split
4008   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4009         (compare:CC
4010          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4011                               (match_operand:SI 2 "const_int_operand" ""))
4012                  (match_operand:SI 3 "mask_operand" ""))
4013          (const_int 0)))
4014    (clobber (match_scratch:SI 4 ""))]
4015   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4016   [(set (match_dup 4)
4017         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4018                  (match_dup 3)))
4019    (set (match_dup 0)
4020         (compare:CC (match_dup 4)
4021                     (const_int 0)))]
4022   "")
4023
4024 (define_insn ""
4025   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4026         (compare:CC
4027          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4028                               (match_operand:SI 2 "const_int_operand" "i,i"))
4029                  (match_operand:SI 3 "mask_operand" "n,n"))
4030          (const_int 0)))
4031    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4032         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4033   "includes_rshift_p (operands[2], operands[3])"
4034   "@
4035    {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4036    #"
4037   [(set_attr "type" "delayed_compare")
4038    (set_attr "length" "4,8")])
4039
4040 (define_split
4041   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4042         (compare:CC
4043          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4044                               (match_operand:SI 2 "const_int_operand" ""))
4045                  (match_operand:SI 3 "mask_operand" ""))
4046          (const_int 0)))
4047    (set (match_operand:SI 0 "gpc_reg_operand" "")
4048         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4049   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4050   [(set (match_dup 0)
4051         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4052    (set (match_dup 4)
4053         (compare:CC (match_dup 0)
4054                     (const_int 0)))]
4055   "")
4056
4057 (define_insn ""
4058   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4059         (zero_extend:SI
4060          (subreg:QI
4061           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4062                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4063   "includes_rshift_p (operands[2], GEN_INT (255))"
4064   "{rlinm|rlwinm} %0,%1,%s2,0xff")
4065
4066 (define_insn ""
4067   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4068         (compare:CC
4069          (zero_extend:SI
4070           (subreg:QI
4071            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4072                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4073          (const_int 0)))
4074    (clobber (match_scratch:SI 3 "=r,r"))]
4075   "includes_rshift_p (operands[2], GEN_INT (255))"
4076   "@
4077    {rlinm.|rlwinm.} %3,%1,%s2,0xff
4078    #"
4079   [(set_attr "type" "delayed_compare")
4080    (set_attr "length" "4,8")])
4081
4082 (define_split
4083   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4084         (compare:CC
4085          (zero_extend:SI
4086           (subreg:QI
4087            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4088                         (match_operand:SI 2 "const_int_operand" "")) 0))
4089          (const_int 0)))
4090    (clobber (match_scratch:SI 3 ""))]
4091   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4092   [(set (match_dup 3)
4093         (zero_extend:SI (subreg:QI
4094            (lshiftrt:SI (match_dup 1)
4095                         (match_dup 2)) 0)))
4096    (set (match_dup 0)
4097         (compare:CC (match_dup 3)
4098                     (const_int 0)))]
4099   "")
4100
4101 (define_insn ""
4102   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4103         (compare:CC
4104          (zero_extend:SI
4105           (subreg:QI
4106            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4107                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4108          (const_int 0)))
4109    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4110         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4111   "includes_rshift_p (operands[2], GEN_INT (255))"
4112   "@
4113    {rlinm.|rlwinm.} %0,%1,%s2,0xff
4114    #"
4115   [(set_attr "type" "delayed_compare")
4116    (set_attr "length" "4,8")])
4117
4118 (define_split
4119   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4120         (compare:CC
4121          (zero_extend:SI
4122           (subreg:QI
4123            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4124                         (match_operand:SI 2 "const_int_operand" "")) 0))
4125          (const_int 0)))
4126    (set (match_operand:SI 0 "gpc_reg_operand" "")
4127         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4128   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4129   [(set (match_dup 0)
4130         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4131    (set (match_dup 3)
4132         (compare:CC (match_dup 0)
4133                     (const_int 0)))]
4134   "")
4135
4136 (define_insn ""
4137   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4138         (zero_extend:SI
4139          (subreg:HI
4140           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4141                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4142   "includes_rshift_p (operands[2], GEN_INT (65535))"
4143   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4144
4145 (define_insn ""
4146   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4147         (compare:CC
4148          (zero_extend:SI
4149           (subreg:HI
4150            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4151                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4152          (const_int 0)))
4153    (clobber (match_scratch:SI 3 "=r,r"))]
4154   "includes_rshift_p (operands[2], GEN_INT (65535))"
4155   "@
4156    {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4157    #"
4158   [(set_attr "type" "delayed_compare")
4159    (set_attr "length" "4,8")])
4160
4161 (define_split
4162   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4163         (compare:CC
4164          (zero_extend:SI
4165           (subreg:HI
4166            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4167                         (match_operand:SI 2 "const_int_operand" "")) 0))
4168          (const_int 0)))
4169    (clobber (match_scratch:SI 3 ""))]
4170   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4171   [(set (match_dup 3)
4172         (zero_extend:SI (subreg:HI
4173            (lshiftrt:SI (match_dup 1)
4174                         (match_dup 2)) 0)))
4175    (set (match_dup 0)
4176         (compare:CC (match_dup 3)
4177                     (const_int 0)))]
4178   "")
4179
4180 (define_insn ""
4181   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4182         (compare:CC
4183          (zero_extend:SI
4184           (subreg:HI
4185            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4186                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4187          (const_int 0)))
4188    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4189         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4190   "includes_rshift_p (operands[2], GEN_INT (65535))"
4191   "@
4192    {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4193    #"
4194   [(set_attr "type" "delayed_compare")
4195    (set_attr "length" "4,8")])
4196
4197 (define_split
4198   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4199         (compare:CC
4200          (zero_extend:SI
4201           (subreg:HI
4202            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4203                         (match_operand:SI 2 "const_int_operand" "")) 0))
4204          (const_int 0)))
4205    (set (match_operand:SI 0 "gpc_reg_operand" "")
4206         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4207   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4208   [(set (match_dup 0)
4209         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4210    (set (match_dup 3)
4211         (compare:CC (match_dup 0)
4212                     (const_int 0)))]
4213   "")
4214
4215 (define_insn ""
4216   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4217                          (const_int 1)
4218                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4219         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4220                      (const_int 31)))]
4221   "TARGET_POWER"
4222   "rrib %0,%1,%2")
4223
4224 (define_insn ""
4225   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4226                          (const_int 1)
4227                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4228         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4229                      (const_int 31)))]
4230   "TARGET_POWER"
4231   "rrib %0,%1,%2")
4232
4233 (define_insn ""
4234   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4235                          (const_int 1)
4236                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4237         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4238                          (const_int 1)
4239                          (const_int 0)))]
4240   "TARGET_POWER"
4241   "rrib %0,%1,%2")
4242
4243 (define_expand "ashrsi3"
4244   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4245         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4246                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4247   ""
4248   "
4249 {
4250   if (TARGET_POWER)
4251     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4252   else
4253     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4254   DONE;
4255 }")
4256
4257 (define_insn "ashrsi3_power"
4258   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4259         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4260                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4261    (clobber (match_scratch:SI 3 "=q,X"))]
4262   "TARGET_POWER"
4263   "@
4264    srea %0,%1,%2
4265    {srai|srawi} %0,%1,%h2")
4266
4267 (define_insn "ashrsi3_no_power"
4268   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4269         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4270                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4271   "! TARGET_POWER"
4272   "{sra|sraw}%I2 %0,%1,%h2")
4273
4274 (define_insn ""
4275   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4276         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4277                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4278                     (const_int 0)))
4279    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4280    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4281   "TARGET_POWER"
4282   "@
4283    srea. %3,%1,%2
4284    {srai.|srawi.} %3,%1,%h2
4285    #
4286    #"
4287   [(set_attr "type" "delayed_compare")
4288    (set_attr "length" "4,4,8,8")])
4289
4290 (define_split
4291   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4292         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4293                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4294                     (const_int 0)))
4295    (clobber (match_scratch:SI 3 ""))
4296    (clobber (match_scratch:SI 4 ""))]
4297   "TARGET_POWER && reload_completed"
4298   [(parallel [(set (match_dup 3)
4299         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4300    (clobber (match_dup 4))])
4301    (set (match_dup 0)
4302         (compare:CC (match_dup 3)
4303                     (const_int 0)))]
4304   "")
4305
4306 (define_insn ""
4307   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4308         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4309                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4310                     (const_int 0)))
4311    (clobber (match_scratch:SI 3 "=r,r"))]
4312   "! TARGET_POWER"
4313   "@
4314    {sra|sraw}%I2. %3,%1,%h2
4315    #"
4316   [(set_attr "type" "delayed_compare")
4317    (set_attr "length" "4,8")])
4318
4319 (define_split
4320   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4321         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4322                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4323                     (const_int 0)))
4324    (clobber (match_scratch:SI 3 ""))]
4325   "! TARGET_POWER && reload_completed"
4326   [(set (match_dup 3)
4327         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4328    (set (match_dup 0)
4329         (compare:CC (match_dup 3)
4330                     (const_int 0)))]
4331   "")
4332
4333 (define_insn ""
4334   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4335         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4336                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4337                     (const_int 0)))
4338    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4339         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4340    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4341   "TARGET_POWER"
4342   "@
4343    srea. %0,%1,%2
4344    {srai.|srawi.} %0,%1,%h2
4345    #
4346    #"
4347   [(set_attr "type" "delayed_compare")
4348    (set_attr "length" "4,4,8,8")])
4349
4350 (define_split
4351   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4352         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4353                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4354                     (const_int 0)))
4355    (set (match_operand:SI 0 "gpc_reg_operand" "")
4356         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4357    (clobber (match_scratch:SI 4 ""))]
4358   "TARGET_POWER && reload_completed"
4359   [(parallel [(set (match_dup 0)
4360         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4361    (clobber (match_dup 4))])
4362    (set (match_dup 3)
4363         (compare:CC (match_dup 0)
4364                     (const_int 0)))]
4365   "")
4366
4367 (define_insn ""
4368   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4369         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4370                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4371                     (const_int 0)))
4372    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4373         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4374   "! TARGET_POWER"
4375   "@
4376    {sra|sraw}%I2. %0,%1,%h2
4377    #"
4378   [(set_attr "type" "delayed_compare")
4379    (set_attr "length" "4,8")])
4380 \f
4381 (define_split
4382   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4383         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4384                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4385                     (const_int 0)))
4386    (set (match_operand:SI 0 "gpc_reg_operand" "")
4387         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4388   "! TARGET_POWER && reload_completed"
4389   [(set (match_dup 0)
4390         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4391    (set (match_dup 3)
4392         (compare:CC (match_dup 0)
4393                     (const_int 0)))]
4394   "")
4395
4396 ;; Floating-point insns, excluding normal data motion.
4397 ;;
4398 ;; PowerPC has a full set of single-precision floating point instructions.
4399 ;;
4400 ;; For the POWER architecture, we pretend that we have both SFmode and
4401 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
4402 ;; The only conversions we will do will be when storing to memory.  In that
4403 ;; case, we will use the "frsp" instruction before storing.
4404 ;;
4405 ;; Note that when we store into a single-precision memory location, we need to
4406 ;; use the frsp insn first.  If the register being stored isn't dead, we
4407 ;; need a scratch register for the frsp.  But this is difficult when the store
4408 ;; is done by reload.  It is not incorrect to do the frsp on the register in
4409 ;; this case, we just lose precision that we would have otherwise gotten but
4410 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
4411
4412 (define_expand "extendsfdf2"
4413   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4414         (float_extend:DF (match_operand:SF 1 "reg_or_none500mem_operand" "")))]
4415   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4416   "")
4417
4418 (define_insn_and_split "*extendsfdf2_fpr"
4419   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f,f")
4420         (float_extend:DF (match_operand:SF 1 "reg_or_mem_operand" "0,f,m")))]
4421   "TARGET_HARD_FLOAT && TARGET_FPRS"
4422   "@
4423    #
4424    fmr %0,%1
4425    lfs%U1%X1 %0,%1"
4426   "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
4427   [(const_int 0)]
4428 {
4429   emit_note (NOTE_INSN_DELETED);
4430   DONE;
4431 }
4432   [(set_attr "type" "fp,fp,fpload")])
4433
4434 (define_expand "truncdfsf2"
4435   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4436         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "")))]
4437   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4438   "")
4439
4440 (define_insn "*truncdfsf2_fpr"
4441   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4442         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4443   "TARGET_HARD_FLOAT && TARGET_FPRS"
4444   "frsp %0,%1"
4445   [(set_attr "type" "fp")])
4446
4447 (define_insn "aux_truncdfsf2"
4448   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4449         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] UNSPEC_FRSP))]
4450   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4451   "frsp %0,%1"
4452   [(set_attr "type" "fp")])
4453
4454 (define_expand "negsf2"
4455   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4456         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4457   "TARGET_HARD_FLOAT"
4458   "")
4459
4460 (define_insn "*negsf2"
4461   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4462         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4463   "TARGET_HARD_FLOAT && TARGET_FPRS"
4464   "fneg %0,%1"
4465   [(set_attr "type" "fp")])
4466
4467 (define_expand "abssf2"
4468   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4469         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4470   "TARGET_HARD_FLOAT"
4471   "")
4472
4473 (define_insn "*abssf2"
4474   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4475         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4476   "TARGET_HARD_FLOAT && TARGET_FPRS"
4477   "fabs %0,%1"
4478   [(set_attr "type" "fp")])
4479
4480 (define_insn ""
4481   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4482         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
4483   "TARGET_HARD_FLOAT && TARGET_FPRS"
4484   "fnabs %0,%1"
4485   [(set_attr "type" "fp")])
4486
4487 (define_expand "addsf3"
4488   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4489         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4490                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4491   "TARGET_HARD_FLOAT"
4492   "")
4493
4494 (define_insn ""
4495   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4496         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4497                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4498   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4499   "fadds %0,%1,%2"
4500   [(set_attr "type" "fp")])
4501
4502 (define_insn ""
4503   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4504         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4505                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4506   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4507   "{fa|fadd} %0,%1,%2"
4508   [(set_attr "type" "fp")])
4509
4510 (define_expand "subsf3"
4511   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4512         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4513                   (match_operand:SF 2 "gpc_reg_operand" "")))]
4514   "TARGET_HARD_FLOAT"
4515   "")
4516
4517 (define_insn ""
4518   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4519         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4520                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4521   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4522   "fsubs %0,%1,%2"
4523   [(set_attr "type" "fp")])
4524
4525 (define_insn ""
4526   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4527         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4528                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4529   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4530   "{fs|fsub} %0,%1,%2"
4531   [(set_attr "type" "fp")])
4532
4533 (define_expand "mulsf3"
4534   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4535         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4536                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4537   "TARGET_HARD_FLOAT"
4538   "")
4539
4540 (define_insn ""
4541   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4542         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4543                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4544   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4545   "fmuls %0,%1,%2"
4546   [(set_attr "type" "fp")])
4547
4548 (define_insn ""
4549   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4550         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4551                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4552   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4553   "{fm|fmul} %0,%1,%2"
4554   [(set_attr "type" "dmul")])
4555
4556 (define_expand "divsf3"
4557   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4558         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4559                 (match_operand:SF 2 "gpc_reg_operand" "")))]
4560   "TARGET_HARD_FLOAT"
4561   "")
4562
4563 (define_insn ""
4564   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4565         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4566                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4567   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4568   "fdivs %0,%1,%2"
4569   [(set_attr "type" "sdiv")])
4570
4571 (define_insn ""
4572   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4573         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4574                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4575   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
4576   "{fd|fdiv} %0,%1,%2"
4577   [(set_attr "type" "ddiv")])
4578
4579 (define_insn ""
4580   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4581         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4582                           (match_operand:SF 2 "gpc_reg_operand" "f"))
4583                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
4584   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4585   "fmadds %0,%1,%2,%3"
4586   [(set_attr "type" "fp")])
4587
4588 (define_insn ""
4589   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4590         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4591                           (match_operand:SF 2 "gpc_reg_operand" "f"))
4592                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
4593   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4594   "{fma|fmadd} %0,%1,%2,%3"
4595   [(set_attr "type" "dmul")])
4596
4597 (define_insn ""
4598   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4599         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4600                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4601                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
4602   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4603   "fmsubs %0,%1,%2,%3"
4604   [(set_attr "type" "fp")])
4605
4606 (define_insn ""
4607   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4608         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4609                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4610                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
4611   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4612   "{fms|fmsub} %0,%1,%2,%3"
4613   [(set_attr "type" "dmul")])
4614
4615 (define_insn ""
4616   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4617         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4618                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
4619                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4620   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4621    && HONOR_SIGNED_ZEROS (SFmode)"
4622   "fnmadds %0,%1,%2,%3"
4623   [(set_attr "type" "fp")])
4624
4625 (define_insn ""
4626   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4627         (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4628                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4629                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
4630   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4631    && ! HONOR_SIGNED_ZEROS (SFmode)"
4632   "fnmadds %0,%1,%2,%3"
4633   [(set_attr "type" "fp")])
4634
4635 (define_insn ""
4636   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4637         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4638                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
4639                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4640   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4641   "{fnma|fnmadd} %0,%1,%2,%3"
4642   [(set_attr "type" "dmul")])
4643
4644 (define_insn ""
4645   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4646         (minus:SF (mult:SF (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f"))
4647                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4648                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
4649   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4650    && ! HONOR_SIGNED_ZEROS (SFmode)"
4651   "{fnma|fnmadd} %0,%1,%2,%3"
4652   [(set_attr "type" "dmul")])
4653
4654 (define_insn ""
4655   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4656         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4657                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
4658                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4659   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4660    && HONOR_SIGNED_ZEROS (SFmode)"
4661   "fnmsubs %0,%1,%2,%3"
4662   [(set_attr "type" "fp")])
4663
4664 (define_insn ""
4665   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4666         (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4667                   (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4668                            (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4669   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4670    && ! HONOR_SIGNED_ZEROS (SFmode)"
4671   "fnmsubs %0,%1,%2,%3"
4672   [(set_attr "type" "fp")])
4673
4674 (define_insn ""
4675   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4676         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4677                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
4678                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4679   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4680   "{fnms|fnmsub} %0,%1,%2,%3"
4681   [(set_attr "type" "dmul")])
4682
4683 (define_insn ""
4684   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4685         (minus:SF (match_operand:SF 3 "gpc_reg_operand" "f")
4686                   (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4687                            (match_operand:SF 2 "gpc_reg_operand" "f"))))]
4688   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4689    && ! HONOR_SIGNED_ZEROS (SFmode)"
4690   "{fnms|fnmsub} %0,%1,%2,%3"
4691   [(set_attr "type" "fp")])
4692
4693 (define_expand "sqrtsf2"
4694   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4695         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
4696   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
4697   "")
4698
4699 (define_insn ""
4700   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4701         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4702   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4703   "fsqrts %0,%1"
4704   [(set_attr "type" "ssqrt")])
4705
4706 (define_insn ""
4707   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4708         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4709   "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
4710   "fsqrt %0,%1"
4711   [(set_attr "type" "dsqrt")])
4712
4713 (define_expand "copysignsf3"
4714   [(set (match_dup 3)
4715         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))
4716    (set (match_dup 4)
4717         (neg:SF (abs:SF (match_dup 1))))
4718    (set (match_operand:SF 0 "gpc_reg_operand" "")
4719         (if_then_else:SF (ge (match_operand:SF 2 "gpc_reg_operand" "")
4720                              (match_dup 5))
4721                          (match_dup 3)
4722                          (match_dup 4)))]
4723   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
4724    && !HONOR_NANS (SFmode) && !HONOR_SIGNED_ZEROS (SFmode)" 
4725   {
4726      operands[3] = gen_reg_rtx (SFmode);
4727      operands[4] = gen_reg_rtx (SFmode);
4728      operands[5] = CONST0_RTX (SFmode);
4729   })
4730
4731 (define_expand "copysigndf3"
4732   [(set (match_dup 3)
4733         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))
4734    (set (match_dup 4)
4735         (neg:DF (abs:DF (match_dup 1))))
4736    (set (match_operand:DF 0 "gpc_reg_operand" "")
4737         (if_then_else:DF (ge (match_operand:DF 2 "gpc_reg_operand" "")
4738                              (match_dup 5))
4739                          (match_dup 3)
4740                          (match_dup 4)))]
4741   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS
4742    && !HONOR_NANS (DFmode) && !HONOR_SIGNED_ZEROS (DFmode)"
4743   {
4744      operands[3] = gen_reg_rtx (DFmode);
4745      operands[4] = gen_reg_rtx (DFmode);
4746      operands[5] = CONST0_RTX (DFmode);
4747   })
4748
4749 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
4750 ;; fsel instruction and some auxiliary computations.  Then we just have a
4751 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
4752 ;; combine.
4753 (define_expand "smaxsf3"
4754   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4755         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4756                              (match_operand:SF 2 "gpc_reg_operand" ""))
4757                          (match_dup 1)
4758                          (match_dup 2)))]
4759   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4760   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
4761
4762 (define_expand "sminsf3"
4763   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4764         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
4765                              (match_operand:SF 2 "gpc_reg_operand" ""))
4766                          (match_dup 2)
4767                          (match_dup 1)))]
4768   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4769   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
4770
4771 (define_split
4772   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4773         (match_operator:SF 3 "min_max_operator"
4774          [(match_operand:SF 1 "gpc_reg_operand" "")
4775           (match_operand:SF 2 "gpc_reg_operand" "")]))]
4776   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
4777   [(const_int 0)]
4778   "
4779 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
4780                       operands[1], operands[2]);
4781   DONE;
4782 }")
4783
4784 (define_expand "movsicc"
4785    [(set (match_operand:SI 0 "gpc_reg_operand" "")
4786          (if_then_else:SI (match_operand 1 "comparison_operator" "")
4787                           (match_operand:SI 2 "gpc_reg_operand" "")
4788                           (match_operand:SI 3 "gpc_reg_operand" "")))]
4789   "TARGET_ISEL"
4790   "
4791 {
4792   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4793     DONE;
4794   else
4795     FAIL;
4796 }")
4797
4798 ;; We use the BASE_REGS for the isel input operands because, if rA is
4799 ;; 0, the value of 0 is placed in rD upon truth.  Similarly for rB
4800 ;; because we may switch the operands and rB may end up being rA.
4801 ;;
4802 ;; We need 2 patterns: an unsigned and a signed pattern.  We could
4803 ;; leave out the mode in operand 4 and use one pattern, but reload can
4804 ;; change the mode underneath our feet and then gets confused trying
4805 ;; to reload the value.
4806 (define_insn "isel_signed"
4807   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4808         (if_then_else:SI
4809          (match_operator 1 "comparison_operator"
4810                          [(match_operand:CC 4 "cc_reg_operand" "y")
4811                           (const_int 0)])
4812          (match_operand:SI 2 "gpc_reg_operand" "b")
4813          (match_operand:SI 3 "gpc_reg_operand" "b")))]
4814   "TARGET_ISEL"
4815   "*
4816 { return output_isel (operands); }"
4817   [(set_attr "length" "4")])
4818
4819 (define_insn "isel_unsigned"
4820   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4821         (if_then_else:SI
4822          (match_operator 1 "comparison_operator"
4823                          [(match_operand:CCUNS 4 "cc_reg_operand" "y")
4824                           (const_int 0)])
4825          (match_operand:SI 2 "gpc_reg_operand" "b")
4826          (match_operand:SI 3 "gpc_reg_operand" "b")))]
4827   "TARGET_ISEL"
4828   "*
4829 { return output_isel (operands); }"
4830   [(set_attr "length" "4")])
4831
4832 (define_expand "movsfcc"
4833    [(set (match_operand:SF 0 "gpc_reg_operand" "")
4834          (if_then_else:SF (match_operand 1 "comparison_operator" "")
4835                           (match_operand:SF 2 "gpc_reg_operand" "")
4836                           (match_operand:SF 3 "gpc_reg_operand" "")))]
4837   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4838   "
4839 {
4840   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
4841     DONE;
4842   else
4843     FAIL;
4844 }")
4845
4846 (define_insn "*fselsfsf4"
4847   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4848         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
4849                              (match_operand:SF 4 "zero_fp_constant" "F"))
4850                          (match_operand:SF 2 "gpc_reg_operand" "f")
4851                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
4852   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4853   "fsel %0,%1,%2,%3"
4854   [(set_attr "type" "fp")])
4855
4856 (define_insn "*fseldfsf4"
4857   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4858         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
4859                              (match_operand:DF 4 "zero_fp_constant" "F"))
4860                          (match_operand:SF 2 "gpc_reg_operand" "f")
4861                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
4862   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
4863   "fsel %0,%1,%2,%3"
4864   [(set_attr "type" "fp")])
4865
4866 (define_expand "negdf2"
4867   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4868         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
4869   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4870   "")
4871
4872 (define_insn "*negdf2_fpr"
4873   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4874         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4875   "TARGET_HARD_FLOAT && TARGET_FPRS"
4876   "fneg %0,%1"
4877   [(set_attr "type" "fp")])
4878
4879 (define_expand "absdf2"
4880   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4881         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "")))]
4882   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4883   "")
4884
4885 (define_insn "*absdf2_fpr"
4886   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4887         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4888   "TARGET_HARD_FLOAT && TARGET_FPRS"
4889   "fabs %0,%1"
4890   [(set_attr "type" "fp")])
4891
4892 (define_insn "*nabsdf2_fpr"
4893   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4894         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
4895   "TARGET_HARD_FLOAT && TARGET_FPRS"
4896   "fnabs %0,%1"
4897   [(set_attr "type" "fp")])
4898
4899 (define_expand "adddf3"
4900   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4901         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "")
4902                  (match_operand:DF 2 "gpc_reg_operand" "")))]
4903   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4904   "")
4905
4906 (define_insn "*adddf3_fpr"
4907   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4908         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4909                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
4910   "TARGET_HARD_FLOAT && TARGET_FPRS"
4911   "{fa|fadd} %0,%1,%2"
4912   [(set_attr "type" "fp")])
4913
4914 (define_expand "subdf3"
4915   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4916         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "")
4917                   (match_operand:DF 2 "gpc_reg_operand" "")))]
4918   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4919   "")
4920
4921 (define_insn "*subdf3_fpr"
4922   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4923         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4924                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
4925   "TARGET_HARD_FLOAT && TARGET_FPRS"
4926   "{fs|fsub} %0,%1,%2"
4927   [(set_attr "type" "fp")])
4928
4929 (define_expand "muldf3"
4930   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4931         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "")
4932                  (match_operand:DF 2 "gpc_reg_operand" "")))]
4933   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4934   "")
4935
4936 (define_insn "*muldf3_fpr"
4937   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4938         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4939                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
4940   "TARGET_HARD_FLOAT && TARGET_FPRS"
4941   "{fm|fmul} %0,%1,%2"
4942   [(set_attr "type" "dmul")])
4943
4944 (define_expand "divdf3"
4945   [(set (match_operand:DF 0 "gpc_reg_operand" "")
4946         (div:DF (match_operand:DF 1 "gpc_reg_operand" "")
4947                 (match_operand:DF 2 "gpc_reg_operand" "")))]
4948   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
4949   "")
4950
4951 (define_insn "*divdf3_fpr"
4952   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4953         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
4954                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
4955   "TARGET_HARD_FLOAT && TARGET_FPRS"
4956   "{fd|fdiv} %0,%1,%2"
4957   [(set_attr "type" "ddiv")])
4958
4959 (define_insn ""
4960   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4961         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4962                           (match_operand:DF 2 "gpc_reg_operand" "f"))
4963                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
4964   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4965   "{fma|fmadd} %0,%1,%2,%3"
4966   [(set_attr "type" "dmul")])
4967
4968 (define_insn ""
4969   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4970         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4971                            (match_operand:DF 2 "gpc_reg_operand" "f"))
4972                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
4973   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
4974   "{fms|fmsub} %0,%1,%2,%3"
4975   [(set_attr "type" "dmul")])
4976
4977 (define_insn ""
4978   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4979         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
4980                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
4981                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
4982   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4983    && HONOR_SIGNED_ZEROS (DFmode)"
4984   "{fnma|fnmadd} %0,%1,%2,%3"
4985   [(set_attr "type" "dmul")])
4986
4987 (define_insn ""
4988   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4989         (minus:DF (mult:DF (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f"))
4990                            (match_operand:DF 2 "gpc_reg_operand" "f"))
4991                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
4992   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
4993    && ! HONOR_SIGNED_ZEROS (DFmode)"
4994   "{fnma|fnmadd} %0,%1,%2,%3"
4995   [(set_attr "type" "dmul")])
4996
4997 (define_insn ""
4998   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4999         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5000                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
5001                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5002   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5003    && HONOR_SIGNED_ZEROS (DFmode)"
5004   "{fnms|fnmsub} %0,%1,%2,%3"
5005   [(set_attr "type" "dmul")])
5006
5007 (define_insn ""
5008   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5009         (minus:DF (match_operand:DF 3 "gpc_reg_operand" "f")
5010                   (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5011                            (match_operand:DF 2 "gpc_reg_operand" "f"))))]
5012   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD
5013    && ! HONOR_SIGNED_ZEROS (DFmode)"
5014   "{fnms|fnmsub} %0,%1,%2,%3"
5015   [(set_attr "type" "dmul")])
5016
5017 (define_insn "sqrtdf2"
5018   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5019         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5020   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5021   "fsqrt %0,%1"
5022   [(set_attr "type" "dsqrt")])
5023
5024 ;; The conditional move instructions allow us to perform max and min
5025 ;; operations even when
5026
5027 (define_expand "smaxdf3"
5028   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5029         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5030                              (match_operand:DF 2 "gpc_reg_operand" ""))
5031                          (match_dup 1)
5032                          (match_dup 2)))]
5033   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5034   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5035
5036 (define_expand "smindf3"
5037   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5038         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5039                              (match_operand:DF 2 "gpc_reg_operand" ""))
5040                          (match_dup 2)
5041                          (match_dup 1)))]
5042   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5043   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5044
5045 (define_split
5046   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5047         (match_operator:DF 3 "min_max_operator"
5048          [(match_operand:DF 1 "gpc_reg_operand" "")
5049           (match_operand:DF 2 "gpc_reg_operand" "")]))]
5050   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS && !flag_trapping_math"
5051   [(const_int 0)]
5052   "
5053 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]),
5054                       operands[1], operands[2]);
5055   DONE;
5056 }")
5057
5058 (define_expand "movdfcc"
5059    [(set (match_operand:DF 0 "gpc_reg_operand" "")
5060          (if_then_else:DF (match_operand 1 "comparison_operator" "")
5061                           (match_operand:DF 2 "gpc_reg_operand" "")
5062                           (match_operand:DF 3 "gpc_reg_operand" "")))]
5063   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5064   "
5065 {
5066   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5067     DONE;
5068   else
5069     FAIL;
5070 }")
5071
5072 (define_insn "*fseldfdf4"
5073   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5074         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5075                              (match_operand:DF 4 "zero_fp_constant" "F"))
5076                          (match_operand:DF 2 "gpc_reg_operand" "f")
5077                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5078   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5079   "fsel %0,%1,%2,%3"
5080   [(set_attr "type" "fp")])
5081
5082 (define_insn "*fselsfdf4"
5083   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5084         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5085                              (match_operand:SF 4 "zero_fp_constant" "F"))
5086                          (match_operand:DF 2 "gpc_reg_operand" "f")
5087                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5088   "TARGET_PPC_GFXOPT"
5089   "fsel %0,%1,%2,%3"
5090   [(set_attr "type" "fp")])
5091 \f
5092 ;; Conversions to and from floating-point.
5093
5094 (define_expand "fixuns_truncsfsi2"
5095   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5096         (unsigned_fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5097   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5098   "")
5099
5100 (define_expand "fix_truncsfsi2"
5101   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5102         (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5103   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5104   "")
5105
5106 ; For each of these conversions, there is a define_expand, a define_insn
5107 ; with a '#' template, and a define_split (with C code).  The idea is
5108 ; to allow constant folding with the template of the define_insn,
5109 ; then to have the insns split later (between sched1 and final).
5110
5111 (define_expand "floatsidf2"
5112   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5113                    (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5114               (use (match_dup 2))
5115               (use (match_dup 3))
5116               (clobber (match_dup 4))
5117               (clobber (match_dup 5))
5118               (clobber (match_dup 6))])]
5119   "TARGET_HARD_FLOAT && TARGET_FPRS"
5120   "
5121 {
5122   if (TARGET_E500_DOUBLE)
5123     {
5124       emit_insn (gen_spe_floatsidf2 (operands[0], operands[1]));
5125       DONE;
5126     }
5127   if (TARGET_POWERPC64)
5128     {
5129       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5130       rtx t1 = gen_reg_rtx (DImode);
5131       rtx t2 = gen_reg_rtx (DImode);
5132       emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5133       DONE;
5134     }
5135
5136   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5137   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5138   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5139   operands[5] = gen_reg_rtx (DFmode);
5140   operands[6] = gen_reg_rtx (SImode);
5141 }")
5142
5143 (define_insn "*floatsidf2_internal"
5144   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5145         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5146    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5147    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5148    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5149    (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))
5150    (clobber (match_operand:SI 6 "gpc_reg_operand" "=&r"))]
5151   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5152   "#"
5153   [(set_attr "length" "24")])
5154
5155 (define_split
5156   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5157         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5158    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5159    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5160    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5161    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5162    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5163   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5164   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5165         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5166    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5167    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5168    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5169    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5170    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5171   "
5172 {
5173   rtx lowword, highword;
5174   if (GET_CODE (operands[4]) != MEM)
5175     abort();
5176   highword = XEXP (operands[4], 0);
5177   lowword = plus_constant (highword, 4);
5178   if (! WORDS_BIG_ENDIAN)
5179     {
5180       rtx tmp;
5181       tmp = highword; highword = lowword; lowword = tmp;
5182     }
5183
5184   emit_insn (gen_xorsi3 (operands[6], operands[1],
5185                          GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5186   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5187   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5188   emit_move_insn (operands[5], operands[4]);
5189   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5190   DONE;
5191 }")
5192
5193 (define_expand "floatunssisf2"
5194   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5195         (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5196   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5197   "")
5198
5199 (define_expand "floatunssidf2"
5200   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5201                    (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5202               (use (match_dup 2))
5203               (use (match_dup 3))
5204               (clobber (match_dup 4))
5205               (clobber (match_dup 5))])]
5206   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5207   "
5208 {
5209   if (TARGET_E500_DOUBLE)
5210     {
5211       emit_insn (gen_spe_floatunssidf2 (operands[0], operands[1]));
5212       DONE;
5213     }
5214   if (TARGET_POWERPC64)
5215     {
5216       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5217       rtx t1 = gen_reg_rtx (DImode);
5218       rtx t2 = gen_reg_rtx (DImode);
5219       emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5220                                          t1, t2));
5221       DONE;
5222     }
5223
5224   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5225   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5226   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5227   operands[5] = gen_reg_rtx (DFmode);
5228 }")
5229
5230 (define_insn "*floatunssidf2_internal"
5231   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5232         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5233    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5234    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5235    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5236    (clobber (match_operand:DF 5 "gpc_reg_operand" "=&f"))]
5237   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5238   "#"
5239   [(set_attr "length" "20")])
5240
5241 (define_split
5242   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5243         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5244    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5245    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5246    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5247    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5248   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5249   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5250         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5251    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5252    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5253    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5254    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5255   "
5256 {
5257   rtx lowword, highword;
5258   if (GET_CODE (operands[4]) != MEM)
5259     abort();
5260   highword = XEXP (operands[4], 0);
5261   lowword = plus_constant (highword, 4);
5262   if (! WORDS_BIG_ENDIAN)
5263     {
5264       rtx tmp;
5265       tmp = highword; highword = lowword; lowword = tmp;
5266     }
5267
5268   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5269   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5270   emit_move_insn (operands[5], operands[4]);
5271   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5272   DONE;
5273 }")
5274
5275 (define_expand "fix_truncdfsi2"
5276   [(parallel [(set (match_operand:SI 0 "reg_or_mem_operand" "")
5277                    (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5278               (clobber (match_dup 2))
5279               (clobber (match_dup 3))])]
5280   "(TARGET_POWER2 || TARGET_POWERPC)
5281    && TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
5282   "
5283 {
5284   if (TARGET_E500_DOUBLE)
5285     {
5286      emit_insn (gen_spe_fix_truncdfsi2 (operands[0], operands[1]));
5287      DONE;
5288     }
5289   operands[2] = gen_reg_rtx (DImode);
5290   if (TARGET_PPC_GFXOPT)
5291     {
5292       rtx orig_dest = operands[0];
5293       if (GET_CODE (orig_dest) != MEM)
5294         operands[0] = assign_stack_temp (SImode, GET_MODE_SIZE (SImode), 0);
5295       emit_insn (gen_fix_truncdfsi2_internal_gfxopt (operands[0], operands[1],
5296                                                      operands[2]));
5297       if (operands[0] != orig_dest)
5298         emit_move_insn (orig_dest, operands[0]);
5299       DONE;
5300     }
5301   operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5302 }")
5303
5304 (define_insn_and_split "*fix_truncdfsi2_internal"
5305   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5306         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5307    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5308    (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5309   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5310   "#"
5311   "&& 1"
5312   [(pc)]
5313   "
5314 {
5315   rtx lowword;
5316   if (GET_CODE (operands[3]) != MEM)
5317     abort();
5318   lowword = XEXP (operands[3], 0);
5319   if (WORDS_BIG_ENDIAN)
5320     lowword = plus_constant (lowword, 4);
5321
5322   emit_insn (gen_fctiwz (operands[2], operands[1]));
5323   emit_move_insn (operands[3], operands[2]);
5324   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5325   DONE;
5326 }"
5327   [(set_attr "length" "16")])
5328
5329 (define_insn_and_split "fix_truncdfsi2_internal_gfxopt"
5330   [(set (match_operand:SI 0 "memory_operand" "=Z")
5331         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5332    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))]
5333   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS
5334    && TARGET_PPC_GFXOPT"
5335   "#"
5336   "&& 1"
5337   [(pc)]
5338   "
5339 {
5340   emit_insn (gen_fctiwz (operands[2], operands[1]));
5341   emit_insn (gen_stfiwx (operands[0], operands[2]));
5342   DONE;
5343 }"
5344   [(set_attr "length" "16")])
5345
5346 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] UNSPEC_FCTIWZ))
5347 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5348 ; because the first makes it clear that operand 0 is not live
5349 ; before the instruction.
5350 (define_insn "fctiwz"
5351   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
5352         (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))]
5353                    UNSPEC_FCTIWZ))]
5354   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5355   "{fcirz|fctiwz} %0,%1"
5356   [(set_attr "type" "fp")])
5357
5358 ; An UNSPEC is used so we don't have to support SImode in FP registers.
5359 (define_insn "stfiwx"
5360   [(set (match_operand:SI 0 "memory_operand" "=Z")
5361         (unspec:SI [(match_operand:DI 1 "gpc_reg_operand" "f")]
5362                    UNSPEC_STFIWX))]
5363   "TARGET_PPC_GFXOPT"
5364   "stfiwx %1,%y0"
5365   [(set_attr "type" "fpstore")])
5366
5367 (define_expand "floatsisf2"
5368   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5369         (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5370   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5371   "")
5372
5373 (define_insn "floatdidf2"
5374   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5375         (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
5376   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5377   "fcfid %0,%1"
5378   [(set_attr "type" "fp")])
5379
5380 (define_insn_and_split "floatsidf_ppc64"
5381   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5382         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5383    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5384    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5385    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5386   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5387   "#"
5388   "&& 1"
5389   [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5390    (set (match_dup 2) (match_dup 3))
5391    (set (match_dup 4) (match_dup 2))
5392    (set (match_dup 0) (float:DF (match_dup 4)))]
5393   "")
5394
5395 (define_insn_and_split "floatunssidf_ppc64"
5396   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5397         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5398    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5399    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5400    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5401   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5402   "#"
5403   "&& 1"
5404   [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5405    (set (match_dup 2) (match_dup 3))
5406    (set (match_dup 4) (match_dup 2))
5407    (set (match_dup 0) (float:DF (match_dup 4)))]
5408   "")
5409
5410 (define_insn "fix_truncdfdi2"
5411   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5412         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5413   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5414   "fctidz %0,%1"
5415   [(set_attr "type" "fp")])
5416
5417 (define_expand "floatdisf2"
5418   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5419         (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
5420   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5421   "
5422 {
5423   rtx val = operands[1];
5424   if (!flag_unsafe_math_optimizations)
5425     {
5426       rtx label = gen_label_rtx ();
5427       val = gen_reg_rtx (DImode);
5428       emit_insn (gen_floatdisf2_internal2 (val, operands[1], label));
5429       emit_label (label);
5430     }
5431   emit_insn (gen_floatdisf2_internal1 (operands[0], val));
5432   DONE;
5433 }")
5434
5435 ;; This is not IEEE compliant if rounding mode is "round to nearest".
5436 ;; If the DI->DF conversion is inexact, then it's possible to suffer
5437 ;; from double rounding.
5438 (define_insn_and_split "floatdisf2_internal1"
5439   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5440         (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
5441    (clobber (match_scratch:DF 2 "=f"))]
5442   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5443   "#"
5444   "&& reload_completed"
5445   [(set (match_dup 2)
5446         (float:DF (match_dup 1)))
5447    (set (match_dup 0)
5448         (float_truncate:SF (match_dup 2)))]
5449   "")
5450
5451 ;; Twiddles bits to avoid double rounding.
5452 ;; Bits that might be truncated when converting to DFmode are replaced
5453 ;; by a bit that won't be lost at that stage, but is below the SFmode
5454 ;; rounding position.
5455 (define_expand "floatdisf2_internal2"
5456   [(set (match_dup 3) (ashiftrt:DI (match_operand:DI 1 "" "")
5457                                    (const_int 53)))
5458    (parallel [(set (match_operand:DI 0 "" "") (and:DI (match_dup 1)
5459                                                       (const_int 2047)))
5460               (clobber (scratch:CC))])
5461    (set (match_dup 3) (plus:DI (match_dup 3)
5462                                (const_int 1)))
5463    (set (match_dup 0) (plus:DI (match_dup 0)
5464                                (const_int 2047)))
5465    (set (match_dup 4) (compare:CCUNS (match_dup 3)
5466                                      (const_int 3)))
5467    (set (match_dup 0) (ior:DI (match_dup 0)
5468                               (match_dup 1)))
5469    (parallel [(set (match_dup 0) (and:DI (match_dup 0)
5470                                          (const_int -2048)))
5471               (clobber (scratch:CC))])
5472    (set (pc) (if_then_else (geu (match_dup 4) (const_int 0))
5473                            (label_ref (match_operand:DI 2 "" ""))
5474                            (pc)))
5475    (set (match_dup 0) (match_dup 1))]
5476   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5477   "
5478 {
5479   operands[3] = gen_reg_rtx (DImode);
5480   operands[4] = gen_reg_rtx (CCUNSmode);
5481 }")
5482 \f
5483 ;; Define the DImode operations that can be done in a small number
5484 ;; of instructions.  The & constraints are to prevent the register
5485 ;; allocator from allocating registers that overlap with the inputs
5486 ;; (for example, having an input in 7,8 and an output in 6,7).  We
5487 ;; also allow for the output being the same as one of the inputs.
5488
5489 (define_insn "*adddi3_noppc64"
5490   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5491         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5492                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5493   "! TARGET_POWERPC64"
5494   "*
5495 {
5496   if (WORDS_BIG_ENDIAN)
5497     return (GET_CODE (operands[2])) != CONST_INT
5498             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5499             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5500   else
5501     return (GET_CODE (operands[2])) != CONST_INT
5502             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5503             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5504 }"
5505   [(set_attr "type" "two")
5506    (set_attr "length" "8")])
5507
5508 (define_insn "*subdi3_noppc64"
5509   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5510         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5511                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5512   "! TARGET_POWERPC64"
5513   "*
5514 {
5515   if (WORDS_BIG_ENDIAN)
5516     return (GET_CODE (operands[1]) != CONST_INT)
5517             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5518             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5519   else
5520     return (GET_CODE (operands[1]) != CONST_INT)
5521             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5522             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5523 }"
5524   [(set_attr "type" "two")
5525    (set_attr "length" "8")])
5526
5527 (define_insn "*negdi2_noppc64"
5528   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5529         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
5530   "! TARGET_POWERPC64"
5531   "*
5532 {
5533   return (WORDS_BIG_ENDIAN)
5534     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5535     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5536 }"
5537   [(set_attr "type" "two")
5538    (set_attr "length" "8")])
5539
5540 (define_expand "mulsidi3"
5541   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5542         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5543                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5544   "! TARGET_POWERPC64"
5545   "
5546 {
5547   if (! TARGET_POWER && ! TARGET_POWERPC)
5548     {
5549       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5550       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5551       emit_insn (gen_mull_call ());
5552       if (WORDS_BIG_ENDIAN)
5553         emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
5554       else
5555         {
5556           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
5557                           gen_rtx_REG (SImode, 3));
5558           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
5559                           gen_rtx_REG (SImode, 4));
5560         }
5561       DONE;
5562     }
5563   else if (TARGET_POWER)
5564     {
5565       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5566       DONE;
5567     }
5568 }")
5569
5570 (define_insn "mulsidi3_mq"
5571   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5572         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5573                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5574    (clobber (match_scratch:SI 3 "=q"))]
5575   "TARGET_POWER"
5576   "mul %0,%1,%2\;mfmq %L0"
5577   [(set_attr "type" "imul")
5578    (set_attr "length" "8")])
5579
5580 (define_insn "*mulsidi3_no_mq"
5581   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5582         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5583                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5584   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5585   "*
5586 {
5587   return (WORDS_BIG_ENDIAN)
5588     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5589     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5590 }"
5591   [(set_attr "type" "imul")
5592    (set_attr "length" "8")])
5593
5594 (define_split
5595   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5596         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5597                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5598   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5599   [(set (match_dup 3)
5600         (truncate:SI
5601          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5602                                (sign_extend:DI (match_dup 2)))
5603                       (const_int 32))))
5604    (set (match_dup 4)
5605         (mult:SI (match_dup 1)
5606                  (match_dup 2)))]
5607   "
5608 {
5609   int endian = (WORDS_BIG_ENDIAN == 0);
5610   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5611   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5612 }")
5613
5614 (define_expand "umulsidi3"
5615   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5616         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5617                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5618   "TARGET_POWERPC && ! TARGET_POWERPC64"
5619   "
5620 {
5621   if (TARGET_POWER)
5622     {
5623       emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5624       DONE;
5625     }
5626 }")
5627
5628 (define_insn "umulsidi3_mq"
5629   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5630         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5631                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5632    (clobber (match_scratch:SI 3 "=q"))]
5633   "TARGET_POWERPC && TARGET_POWER"
5634   "*
5635 {
5636   return (WORDS_BIG_ENDIAN)
5637     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5638     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5639 }"
5640   [(set_attr "type" "imul")
5641    (set_attr "length" "8")])
5642
5643 (define_insn "*umulsidi3_no_mq"
5644   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5645         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5646                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5647   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5648   "*
5649 {
5650   return (WORDS_BIG_ENDIAN)
5651     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5652     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5653 }"
5654   [(set_attr "type" "imul")
5655    (set_attr "length" "8")])
5656
5657 (define_split
5658   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5659         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5660                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5661   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5662   [(set (match_dup 3)
5663         (truncate:SI
5664          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5665                                (zero_extend:DI (match_dup 2)))
5666                       (const_int 32))))
5667    (set (match_dup 4)
5668         (mult:SI (match_dup 1)
5669                  (match_dup 2)))]
5670   "
5671 {
5672   int endian = (WORDS_BIG_ENDIAN == 0);
5673   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5674   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5675 }")
5676
5677 (define_expand "smulsi3_highpart"
5678   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5679         (truncate:SI
5680          (lshiftrt:DI (mult:DI (sign_extend:DI
5681                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5682                                (sign_extend:DI
5683                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5684                       (const_int 32))))]
5685   ""
5686   "
5687 {
5688   if (! TARGET_POWER && ! TARGET_POWERPC)
5689     {
5690       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5691       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5692       emit_insn (gen_mulh_call ());
5693       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
5694       DONE;
5695     }
5696   else if (TARGET_POWER)
5697     {
5698       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5699       DONE;
5700     }
5701 }")
5702
5703 (define_insn "smulsi3_highpart_mq"
5704   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5705         (truncate:SI
5706          (lshiftrt:DI (mult:DI (sign_extend:DI
5707                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5708                                (sign_extend:DI
5709                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5710                       (const_int 32))))
5711    (clobber (match_scratch:SI 3 "=q"))]
5712   "TARGET_POWER"
5713   "mul %0,%1,%2"
5714   [(set_attr "type" "imul")])
5715
5716 (define_insn "*smulsi3_highpart_no_mq"
5717   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5718         (truncate:SI
5719          (lshiftrt:DI (mult:DI (sign_extend:DI
5720                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5721                                (sign_extend:DI
5722                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5723                       (const_int 32))))]
5724   "TARGET_POWERPC && ! TARGET_POWER"
5725   "mulhw %0,%1,%2"
5726   [(set_attr "type" "imul")])
5727
5728 (define_expand "umulsi3_highpart"
5729   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5730         (truncate:SI
5731          (lshiftrt:DI (mult:DI (zero_extend:DI
5732                                 (match_operand:SI 1 "gpc_reg_operand" ""))
5733                                (zero_extend:DI
5734                                 (match_operand:SI 2 "gpc_reg_operand" "")))
5735                       (const_int 32))))]
5736   "TARGET_POWERPC"
5737   "
5738 {
5739   if (TARGET_POWER)
5740     {
5741       emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5742       DONE;
5743     }
5744 }")
5745
5746 (define_insn "umulsi3_highpart_mq"
5747   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5748         (truncate:SI
5749          (lshiftrt:DI (mult:DI (zero_extend:DI
5750                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5751                                (zero_extend:DI
5752                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5753                       (const_int 32))))
5754    (clobber (match_scratch:SI 3 "=q"))]
5755   "TARGET_POWERPC && TARGET_POWER"
5756   "mulhwu %0,%1,%2"
5757   [(set_attr "type" "imul")])
5758
5759 (define_insn "*umulsi3_highpart_no_mq"
5760   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5761         (truncate:SI
5762          (lshiftrt:DI (mult:DI (zero_extend:DI
5763                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5764                                (zero_extend:DI
5765                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5766                       (const_int 32))))]
5767   "TARGET_POWERPC && ! TARGET_POWER"
5768   "mulhwu %0,%1,%2"
5769   [(set_attr "type" "imul")])
5770
5771 ;; If operands 0 and 2 are in the same register, we have a problem.  But
5772 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
5773 ;; why we have the strange constraints below.
5774 (define_insn "ashldi3_power"
5775   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5776         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5777                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5778    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5779   "TARGET_POWER"
5780   "@
5781    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5782    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5783    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5784    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5785   [(set_attr "length" "8")])
5786
5787 (define_insn "lshrdi3_power"
5788   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5789         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5790                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5791    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5792   "TARGET_POWER"
5793   "@
5794    {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
5795    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5796    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5797    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5798   [(set_attr "length" "8")])
5799
5800 ;; Shift by a variable amount is too complex to be worth open-coding.  We
5801 ;; just handle shifts by constants.
5802 (define_insn "ashrdi3_power"
5803   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5804         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5805                      (match_operand:SI 2 "const_int_operand" "M,i")))
5806    (clobber (match_scratch:SI 3 "=X,q"))]
5807   "TARGET_POWER"
5808   "@
5809    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5810    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5811   [(set_attr "length" "8")])
5812
5813 (define_insn "ashrdi3_no_power"
5814   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5815         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5816                      (match_operand:SI 2 "const_int_operand" "M,i")))]
5817   "TARGET_32BIT && !TARGET_POWERPC64 && !TARGET_POWER && WORDS_BIG_ENDIAN"
5818   "@
5819    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5820    {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5821   [(set_attr "type" "two,three")
5822    (set_attr "length" "8,12")])
5823
5824 (define_insn "*ashrdisi3_noppc64"
5825   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5826         (subreg:SI (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
5827                                 (const_int 32)) 4))]
5828   "TARGET_32BIT && !TARGET_POWERPC64"
5829   "*
5830 {
5831   if (REGNO (operands[0]) == REGNO (operands[1]))
5832     return \"\";
5833   else
5834     return \"mr %0,%1\";
5835 }"
5836    [(set_attr "length" "4")])
5837
5838 \f
5839 ;; PowerPC64 DImode operations.
5840
5841 (define_expand "adddi3"
5842   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5843         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5844                  (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
5845   ""
5846   "
5847 {
5848   if (! TARGET_POWERPC64)
5849     {
5850       if (non_short_cint_operand (operands[2], DImode))
5851         FAIL;
5852     }
5853   else
5854     if (GET_CODE (operands[2]) == CONST_INT
5855         && ! add_operand (operands[2], DImode))
5856       {
5857         rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
5858                    ? operands[0] : gen_reg_rtx (DImode));
5859
5860         HOST_WIDE_INT val = INTVAL (operands[2]);
5861         HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5862         HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5863
5864         if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5865           FAIL;
5866
5867         /* The ordering here is important for the prolog expander.
5868            When space is allocated from the stack, adding 'low' first may
5869            produce a temporary deallocation (which would be bad).  */
5870         emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
5871         emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5872         DONE;
5873       }
5874 }")
5875
5876 ;; Discourage ai/addic because of carry but provide it in an alternative
5877 ;; allowing register zero as source.
5878
5879 (define_insn "*adddi3_internal1"
5880   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5881         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
5882                  (match_operand:DI 2 "add_operand" "r,I,I,L")))]
5883   "TARGET_POWERPC64"
5884   "@
5885    add %0,%1,%2
5886    addi %0,%1,%2
5887    addic %0,%1,%2
5888    addis %0,%1,%v2")
5889
5890 (define_insn "*adddi3_internal2"
5891   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
5892         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5893                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5894                     (const_int 0)))
5895    (clobber (match_scratch:DI 3 "=r,r,r,r"))]
5896   "TARGET_64BIT"
5897   "@
5898    add. %3,%1,%2
5899    addic. %3,%1,%2
5900    #
5901    #"
5902   [(set_attr "type" "fast_compare,compare,compare,compare")
5903    (set_attr "length" "4,4,8,8")])
5904
5905 (define_split
5906   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5907         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5908                              (match_operand:DI 2 "reg_or_short_operand" ""))
5909                     (const_int 0)))
5910    (clobber (match_scratch:DI 3 ""))]
5911   "TARGET_POWERPC64 && reload_completed"
5912   [(set (match_dup 3)
5913         (plus:DI (match_dup 1) (match_dup 2)))
5914    (set (match_dup 0)
5915         (compare:CC (match_dup 3)
5916                     (const_int 0)))]
5917   "")
5918
5919 (define_insn "*adddi3_internal3"
5920   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5921         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5922                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5923                     (const_int 0)))
5924    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
5925         (plus:DI (match_dup 1) (match_dup 2)))]
5926   "TARGET_64BIT"
5927   "@
5928    add. %0,%1,%2
5929    addic. %0,%1,%2
5930    #
5931    #"
5932   [(set_attr "type" "fast_compare,compare,compare,compare")
5933    (set_attr "length" "4,4,8,8")])
5934
5935 (define_split
5936   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5937         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5938                              (match_operand:DI 2 "reg_or_short_operand" ""))
5939                     (const_int 0)))
5940    (set (match_operand:DI 0 "gpc_reg_operand" "")
5941         (plus:DI (match_dup 1) (match_dup 2)))]
5942   "TARGET_POWERPC64 && reload_completed"
5943   [(set (match_dup 0)
5944         (plus:DI (match_dup 1) (match_dup 2)))
5945    (set (match_dup 3)
5946         (compare:CC (match_dup 0)
5947                     (const_int 0)))]
5948   "")
5949
5950 ;; Split an add that we can't do in one insn into two insns, each of which
5951 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
5952 ;; add should be last in case the result gets used in an address.
5953
5954 (define_split
5955   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5956         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5957                  (match_operand:DI 2 "non_add_cint_operand" "")))]
5958   "TARGET_POWERPC64"
5959   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
5960    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5961 "
5962 {
5963   HOST_WIDE_INT val = INTVAL (operands[2]);
5964   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5965   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5966
5967   operands[4] = GEN_INT (low);
5968   if (CONST_OK_FOR_LETTER_P (rest, 'L'))
5969     operands[3] = GEN_INT (rest);
5970   else if (! no_new_pseudos)
5971     {
5972       operands[3] = gen_reg_rtx (DImode);
5973       emit_move_insn (operands[3], operands[2]);
5974       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
5975       DONE;
5976     }
5977   else
5978     FAIL;
5979 }")
5980
5981 (define_insn "one_cmpldi2"
5982   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5983         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5984   "TARGET_POWERPC64"
5985   "nor %0,%1,%1")
5986
5987 (define_insn ""
5988   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5989         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5990                     (const_int 0)))
5991    (clobber (match_scratch:DI 2 "=r,r"))]
5992   "TARGET_64BIT"
5993   "@
5994    nor. %2,%1,%1
5995    #"
5996   [(set_attr "type" "compare")
5997    (set_attr "length" "4,8")])
5998
5999 (define_split
6000   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6001         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6002                     (const_int 0)))
6003    (clobber (match_scratch:DI 2 ""))]
6004   "TARGET_POWERPC64 && reload_completed"
6005   [(set (match_dup 2)
6006         (not:DI (match_dup 1)))
6007    (set (match_dup 0)
6008         (compare:CC (match_dup 2)
6009                     (const_int 0)))]
6010   "")
6011
6012 (define_insn ""
6013   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6014         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6015                     (const_int 0)))
6016    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6017         (not:DI (match_dup 1)))]
6018   "TARGET_64BIT"
6019   "@
6020    nor. %0,%1,%1
6021    #"
6022   [(set_attr "type" "compare")
6023    (set_attr "length" "4,8")])
6024
6025 (define_split
6026   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6027         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6028                     (const_int 0)))
6029    (set (match_operand:DI 0 "gpc_reg_operand" "")
6030         (not:DI (match_dup 1)))]
6031   "TARGET_POWERPC64 && reload_completed"
6032   [(set (match_dup 0)
6033         (not:DI (match_dup 1)))
6034    (set (match_dup 2)
6035         (compare:CC (match_dup 0)
6036                     (const_int 0)))]
6037   "")
6038
6039 (define_insn ""
6040   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6041         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
6042                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
6043   "TARGET_POWERPC64"
6044   "@
6045    subf %0,%2,%1
6046    subfic %0,%2,%1")
6047
6048 (define_insn ""
6049   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6050         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6051                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6052                     (const_int 0)))
6053    (clobber (match_scratch:DI 3 "=r,r"))]
6054   "TARGET_64BIT"
6055   "@
6056    subf. %3,%2,%1
6057    #"
6058   [(set_attr "type" "fast_compare")
6059    (set_attr "length" "4,8")])
6060
6061 (define_split
6062   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6063         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6064                               (match_operand:DI 2 "gpc_reg_operand" ""))
6065                     (const_int 0)))
6066    (clobber (match_scratch:DI 3 ""))]
6067   "TARGET_POWERPC64 && reload_completed"
6068   [(set (match_dup 3)
6069         (minus:DI (match_dup 1) (match_dup 2)))
6070    (set (match_dup 0)
6071         (compare:CC (match_dup 3)
6072                     (const_int 0)))]
6073   "")
6074
6075 (define_insn ""
6076   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6077         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6078                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6079                     (const_int 0)))
6080    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6081         (minus:DI (match_dup 1) (match_dup 2)))]
6082   "TARGET_64BIT"
6083   "@
6084    subf. %0,%2,%1
6085    #"
6086   [(set_attr "type" "fast_compare")
6087    (set_attr "length" "4,8")])
6088
6089 (define_split
6090   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6091         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6092                               (match_operand:DI 2 "gpc_reg_operand" ""))
6093                     (const_int 0)))
6094    (set (match_operand:DI 0 "gpc_reg_operand" "")
6095         (minus:DI (match_dup 1) (match_dup 2)))]
6096   "TARGET_POWERPC64 && reload_completed"
6097   [(set (match_dup 0)
6098         (minus:DI (match_dup 1) (match_dup 2)))
6099    (set (match_dup 3)
6100         (compare:CC (match_dup 0)
6101                     (const_int 0)))]
6102   "")
6103
6104 (define_expand "subdi3"
6105   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6106         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
6107                   (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
6108   ""
6109   "
6110 {
6111   if (GET_CODE (operands[2]) == CONST_INT)
6112     {
6113       emit_insn (gen_adddi3 (operands[0], operands[1],
6114                              negate_rtx (DImode, operands[2])));
6115       DONE;
6116     }
6117 }")
6118
6119 (define_insn_and_split "absdi2"
6120   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6121         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
6122    (clobber (match_scratch:DI 2 "=&r,&r"))]
6123   "TARGET_POWERPC64"
6124   "#"
6125   "&& reload_completed"
6126   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6127    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6128    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
6129   "")
6130
6131 (define_insn_and_split "*nabsdi2"
6132   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6133         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
6134    (clobber (match_scratch:DI 2 "=&r,&r"))]
6135   "TARGET_POWERPC64"
6136   "#"
6137   "&& reload_completed"
6138   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6139    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6140    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
6141   "")
6142
6143 (define_expand "negdi2"
6144   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6145         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
6146   ""
6147   "")
6148
6149 (define_insn ""
6150   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6151         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6152   "TARGET_POWERPC64"
6153   "neg %0,%1")
6154
6155 (define_insn ""
6156   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6157         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6158                     (const_int 0)))
6159    (clobber (match_scratch:DI 2 "=r,r"))]
6160   "TARGET_64BIT"
6161   "@
6162    neg. %2,%1
6163    #"
6164   [(set_attr "type" "fast_compare")
6165    (set_attr "length" "4,8")])
6166
6167 (define_split
6168   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6169         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6170                     (const_int 0)))
6171    (clobber (match_scratch:DI 2 ""))]
6172   "TARGET_POWERPC64 && reload_completed"
6173   [(set (match_dup 2)
6174         (neg:DI (match_dup 1)))
6175    (set (match_dup 0)
6176         (compare:CC (match_dup 2)
6177                     (const_int 0)))]
6178   "")
6179
6180 (define_insn ""
6181   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6182         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6183                     (const_int 0)))
6184    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6185         (neg:DI (match_dup 1)))]
6186   "TARGET_64BIT"
6187   "@
6188    neg. %0,%1
6189    #"
6190   [(set_attr "type" "fast_compare")
6191    (set_attr "length" "4,8")])
6192
6193 (define_split
6194   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6195         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6196                     (const_int 0)))
6197    (set (match_operand:DI 0 "gpc_reg_operand" "")
6198         (neg:DI (match_dup 1)))]
6199   "TARGET_POWERPC64 && reload_completed"
6200   [(set (match_dup 0)
6201         (neg:DI (match_dup 1)))
6202    (set (match_dup 2)
6203         (compare:CC (match_dup 0)
6204                     (const_int 0)))]
6205   "")
6206
6207 (define_insn "clzdi2"
6208   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6209         (clz:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6210   "TARGET_POWERPC64"
6211   "cntlzd %0,%1")
6212
6213 (define_expand "ctzdi2"
6214   [(set (match_dup 2)
6215         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6216    (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6217                                          (match_dup 2)))
6218               (clobber (scratch:CC))])
6219    (set (match_dup 4) (clz:DI (match_dup 3)))
6220    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
6221         (minus:DI (const_int 63) (match_dup 4)))]
6222   "TARGET_POWERPC64"
6223   {
6224      operands[2] = gen_reg_rtx (DImode);
6225      operands[3] = gen_reg_rtx (DImode);
6226      operands[4] = gen_reg_rtx (DImode);
6227   })
6228
6229 (define_expand "ffsdi2"
6230   [(set (match_dup 2)
6231         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
6232    (parallel [(set (match_dup 3) (and:DI (match_dup 1)
6233                                          (match_dup 2)))
6234               (clobber (scratch:CC))])
6235    (set (match_dup 4) (clz:DI (match_dup 3)))
6236    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
6237         (minus:DI (const_int 64) (match_dup 4)))]
6238   "TARGET_POWERPC64"
6239   {
6240      operands[2] = gen_reg_rtx (DImode);
6241      operands[3] = gen_reg_rtx (DImode);
6242      operands[4] = gen_reg_rtx (DImode);
6243   })
6244
6245 (define_insn "muldi3"
6246   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6247         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6248                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6249   "TARGET_POWERPC64"
6250   "mulld %0,%1,%2"
6251    [(set_attr "type" "lmul")])
6252
6253 (define_insn "*muldi3_internal1"
6254   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6255         (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6256                              (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6257                     (const_int 0)))
6258    (clobber (match_scratch:DI 3 "=r,r"))]
6259   "TARGET_POWERPC64"
6260   "@
6261    mulld. %3,%1,%2
6262    #"
6263   [(set_attr "type" "lmul_compare")
6264    (set_attr "length" "4,8")])
6265
6266 (define_split
6267   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6268         (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6269                              (match_operand:DI 2 "gpc_reg_operand" ""))
6270                     (const_int 0)))
6271    (clobber (match_scratch:DI 3 ""))]
6272   "TARGET_POWERPC64 && reload_completed"
6273   [(set (match_dup 3)
6274         (mult:DI (match_dup 1) (match_dup 2)))
6275    (set (match_dup 0)
6276         (compare:CC (match_dup 3)
6277                     (const_int 0)))]
6278   "")
6279
6280 (define_insn "*muldi3_internal2"
6281   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6282         (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r")
6283                              (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6284                     (const_int 0)))
6285    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6286         (mult:DI (match_dup 1) (match_dup 2)))]
6287   "TARGET_POWERPC64"
6288   "@
6289    mulld. %0,%1,%2
6290    #"
6291   [(set_attr "type" "lmul_compare")
6292    (set_attr "length" "4,8")])
6293
6294 (define_split
6295   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6296         (compare:CC (mult:DI (match_operand:DI 1 "gpc_reg_operand" "")
6297                              (match_operand:DI 2 "gpc_reg_operand" ""))
6298                     (const_int 0)))
6299    (set (match_operand:DI 0 "gpc_reg_operand" "")
6300         (mult:DI (match_dup 1) (match_dup 2)))]
6301   "TARGET_POWERPC64 && reload_completed"
6302   [(set (match_dup 0)
6303         (mult:DI (match_dup 1) (match_dup 2)))
6304    (set (match_dup 3)
6305         (compare:CC (match_dup 0)
6306                     (const_int 0)))]
6307   "")
6308
6309 (define_insn "smuldi3_highpart"
6310   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6311         (truncate:DI
6312          (lshiftrt:TI (mult:TI (sign_extend:TI
6313                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6314                                (sign_extend:TI
6315                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6316                       (const_int 64))))]
6317   "TARGET_POWERPC64"
6318   "mulhd %0,%1,%2"
6319   [(set_attr "type" "lmul")])
6320
6321 (define_insn "umuldi3_highpart"
6322   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6323         (truncate:DI
6324          (lshiftrt:TI (mult:TI (zero_extend:TI
6325                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6326                                (zero_extend:TI
6327                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6328                       (const_int 64))))]
6329   "TARGET_POWERPC64"
6330   "mulhdu %0,%1,%2"
6331   [(set_attr "type" "lmul")])
6332
6333 (define_expand "divdi3"
6334   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6335         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6336                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6337   "TARGET_POWERPC64"
6338   "
6339 {
6340   if (GET_CODE (operands[2]) == CONST_INT
6341       && INTVAL (operands[2]) > 0
6342       && exact_log2 (INTVAL (operands[2])) >= 0)
6343     ;
6344   else
6345     operands[2] = force_reg (DImode, operands[2]);
6346 }")
6347
6348 (define_expand "moddi3"
6349   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6350    (use (match_operand:DI 1 "gpc_reg_operand" ""))
6351    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6352   "TARGET_POWERPC64"
6353   "
6354 {
6355   int i;
6356   rtx temp1;
6357   rtx temp2;
6358
6359   if (GET_CODE (operands[2]) != CONST_INT
6360       || INTVAL (operands[2]) <= 0
6361       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
6362     FAIL;
6363
6364   temp1 = gen_reg_rtx (DImode);
6365   temp2 = gen_reg_rtx (DImode);
6366
6367   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6368   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6369   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6370   DONE;
6371 }")
6372
6373 (define_insn ""
6374   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6375         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6376                 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6377   "TARGET_POWERPC64"
6378   "sradi %0,%1,%p2\;addze %0,%0"
6379   [(set_attr "type" "two")
6380    (set_attr "length" "8")])
6381
6382 (define_insn ""
6383   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6384         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6385                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6386                     (const_int 0)))
6387    (clobber (match_scratch:DI 3 "=r,r"))]
6388   "TARGET_64BIT"
6389   "@
6390    sradi %3,%1,%p2\;addze. %3,%3
6391    #"
6392   [(set_attr "type" "compare")
6393    (set_attr "length" "8,12")])
6394
6395 (define_split
6396   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6397         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6398                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6399                     (const_int 0)))
6400    (clobber (match_scratch:DI 3 ""))]
6401   "TARGET_POWERPC64 && reload_completed"
6402   [(set (match_dup 3)
6403         (div:DI (match_dup 1) (match_dup 2)))
6404    (set (match_dup 0)
6405         (compare:CC (match_dup 3)
6406                     (const_int 0)))]
6407   "")
6408
6409 (define_insn ""
6410   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6411         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6412                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6413                     (const_int 0)))
6414    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6415         (div:DI (match_dup 1) (match_dup 2)))]
6416   "TARGET_64BIT"
6417   "@
6418    sradi %0,%1,%p2\;addze. %0,%0
6419    #"
6420   [(set_attr "type" "compare")
6421    (set_attr "length" "8,12")])
6422
6423 (define_split
6424   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6425         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6426                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6427                     (const_int 0)))
6428    (set (match_operand:DI 0 "gpc_reg_operand" "")
6429         (div:DI (match_dup 1) (match_dup 2)))]
6430   "TARGET_POWERPC64 && reload_completed"
6431   [(set (match_dup 0)
6432         (div:DI (match_dup 1) (match_dup 2)))
6433    (set (match_dup 3)
6434         (compare:CC (match_dup 0)
6435                     (const_int 0)))]
6436   "")
6437
6438 (define_insn ""
6439   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6440         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6441                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6442   "TARGET_POWERPC64"
6443   "divd %0,%1,%2"
6444   [(set_attr "type" "ldiv")])
6445
6446 (define_insn "udivdi3"
6447   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6448         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6449                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6450   "TARGET_POWERPC64"
6451   "divdu %0,%1,%2"
6452   [(set_attr "type" "ldiv")])
6453
6454 (define_insn "rotldi3"
6455   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6456         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6457                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6458   "TARGET_POWERPC64"
6459   "rld%I2cl %0,%1,%H2,0")
6460
6461 (define_insn "*rotldi3_internal2"
6462   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6463         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6464                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6465                     (const_int 0)))
6466    (clobber (match_scratch:DI 3 "=r,r"))]
6467   "TARGET_64BIT"
6468   "@
6469    rld%I2cl. %3,%1,%H2,0
6470    #"
6471   [(set_attr "type" "delayed_compare")
6472    (set_attr "length" "4,8")])
6473
6474 (define_split
6475   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6476         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6477                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6478                     (const_int 0)))
6479    (clobber (match_scratch:DI 3 ""))]
6480   "TARGET_POWERPC64 && reload_completed"
6481   [(set (match_dup 3)
6482         (rotate:DI (match_dup 1) (match_dup 2)))
6483    (set (match_dup 0)
6484         (compare:CC (match_dup 3)
6485                     (const_int 0)))]
6486   "")
6487
6488 (define_insn "*rotldi3_internal3"
6489   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6490         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6491                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6492                     (const_int 0)))
6493    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6494         (rotate:DI (match_dup 1) (match_dup 2)))]
6495   "TARGET_64BIT"
6496   "@
6497    rld%I2cl. %0,%1,%H2,0
6498    #"
6499   [(set_attr "type" "delayed_compare")
6500    (set_attr "length" "4,8")])
6501
6502 (define_split
6503   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6504         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6505                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6506                     (const_int 0)))
6507    (set (match_operand:DI 0 "gpc_reg_operand" "")
6508         (rotate:DI (match_dup 1) (match_dup 2)))]
6509   "TARGET_POWERPC64 && reload_completed"
6510   [(set (match_dup 0)
6511         (rotate:DI (match_dup 1) (match_dup 2)))
6512    (set (match_dup 3)
6513         (compare:CC (match_dup 0)
6514                     (const_int 0)))]
6515   "")
6516
6517 (define_insn "*rotldi3_internal4"
6518   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6519         (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6520                            (match_operand:DI 2 "reg_or_cint_operand" "ri"))
6521                 (match_operand:DI 3 "mask64_operand" "n")))]
6522   "TARGET_POWERPC64"
6523   "rld%I2c%B3 %0,%1,%H2,%S3")
6524
6525 (define_insn "*rotldi3_internal5"
6526   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6527         (compare:CC (and:DI
6528                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6529                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6530                      (match_operand:DI 3 "mask64_operand" "n,n"))
6531                     (const_int 0)))
6532    (clobber (match_scratch:DI 4 "=r,r"))]
6533   "TARGET_64BIT"
6534   "@
6535    rld%I2c%B3. %4,%1,%H2,%S3
6536    #"
6537   [(set_attr "type" "delayed_compare")
6538    (set_attr "length" "4,8")])
6539
6540 (define_split
6541   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6542         (compare:CC (and:DI
6543                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6544                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6545                      (match_operand:DI 3 "mask64_operand" ""))
6546                     (const_int 0)))
6547    (clobber (match_scratch:DI 4 ""))]
6548   "TARGET_POWERPC64 && reload_completed"
6549   [(set (match_dup 4)
6550         (and:DI (rotate:DI (match_dup 1)
6551                                 (match_dup 2))
6552                      (match_dup 3)))
6553    (set (match_dup 0)
6554         (compare:CC (match_dup 4)
6555                     (const_int 0)))]
6556   "")
6557
6558 (define_insn "*rotldi3_internal6"
6559   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6560         (compare:CC (and:DI
6561                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6562                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6563                      (match_operand:DI 3 "mask64_operand" "n,n"))
6564                     (const_int 0)))
6565    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6566         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6567   "TARGET_64BIT"
6568   "@
6569    rld%I2c%B3. %0,%1,%H2,%S3
6570    #"
6571   [(set_attr "type" "delayed_compare")
6572    (set_attr "length" "4,8")])
6573
6574 (define_split
6575   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6576         (compare:CC (and:DI
6577                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6578                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6579                      (match_operand:DI 3 "mask64_operand" ""))
6580                     (const_int 0)))
6581    (set (match_operand:DI 0 "gpc_reg_operand" "")
6582         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6583   "TARGET_POWERPC64 && reload_completed"
6584   [(set (match_dup 0)
6585         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6586    (set (match_dup 4)
6587         (compare:CC (match_dup 0)
6588                     (const_int 0)))]
6589   "")
6590
6591 (define_insn "*rotldi3_internal7"
6592   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6593         (zero_extend:DI
6594          (subreg:QI
6595           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6596                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6597   "TARGET_POWERPC64"
6598   "rld%I2cl %0,%1,%H2,56")
6599
6600 (define_insn "*rotldi3_internal8"
6601   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6602         (compare:CC (zero_extend:DI
6603                      (subreg:QI
6604                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6605                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6606                     (const_int 0)))
6607    (clobber (match_scratch:DI 3 "=r,r"))]
6608   "TARGET_64BIT"
6609   "@
6610    rld%I2cl. %3,%1,%H2,56
6611    #"
6612   [(set_attr "type" "delayed_compare")
6613    (set_attr "length" "4,8")])
6614
6615 (define_split
6616   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6617         (compare:CC (zero_extend:DI
6618                      (subreg:QI
6619                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6620                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6621                     (const_int 0)))
6622    (clobber (match_scratch:DI 3 ""))]
6623   "TARGET_POWERPC64 && reload_completed"
6624   [(set (match_dup 3)
6625         (zero_extend:DI (subreg:QI
6626                       (rotate:DI (match_dup 1)
6627                                  (match_dup 2)) 0)))
6628    (set (match_dup 0)
6629         (compare:CC (match_dup 3)
6630                     (const_int 0)))]
6631   "")
6632
6633 (define_insn "*rotldi3_internal9"
6634   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6635         (compare:CC (zero_extend:DI
6636                      (subreg:QI
6637                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6638                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6639                     (const_int 0)))
6640    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6641         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6642   "TARGET_64BIT"
6643   "@
6644    rld%I2cl. %0,%1,%H2,56
6645    #"
6646   [(set_attr "type" "delayed_compare")
6647    (set_attr "length" "4,8")])
6648
6649 (define_split
6650   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6651         (compare:CC (zero_extend:DI
6652                      (subreg:QI
6653                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6654                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6655                     (const_int 0)))
6656    (set (match_operand:DI 0 "gpc_reg_operand" "")
6657         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6658   "TARGET_POWERPC64 && reload_completed"
6659   [(set (match_dup 0)
6660         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6661    (set (match_dup 3)
6662         (compare:CC (match_dup 0)
6663                     (const_int 0)))]
6664   "")
6665
6666 (define_insn "*rotldi3_internal10"
6667   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6668         (zero_extend:DI
6669          (subreg:HI
6670           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6671                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6672   "TARGET_POWERPC64"
6673   "rld%I2cl %0,%1,%H2,48")
6674
6675 (define_insn "*rotldi3_internal11"
6676   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6677         (compare:CC (zero_extend:DI
6678                      (subreg:HI
6679                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6680                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6681                     (const_int 0)))
6682    (clobber (match_scratch:DI 3 "=r,r"))]
6683   "TARGET_64BIT"
6684   "@
6685    rld%I2cl. %3,%1,%H2,48
6686    #"
6687   [(set_attr "type" "delayed_compare")
6688    (set_attr "length" "4,8")])
6689
6690 (define_split
6691   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6692         (compare:CC (zero_extend:DI
6693                      (subreg:HI
6694                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6695                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6696                     (const_int 0)))
6697    (clobber (match_scratch:DI 3 ""))]
6698   "TARGET_POWERPC64 && reload_completed"
6699   [(set (match_dup 3)
6700         (zero_extend:DI (subreg:HI
6701                       (rotate:DI (match_dup 1)
6702                                  (match_dup 2)) 0)))
6703    (set (match_dup 0)
6704         (compare:CC (match_dup 3)
6705                     (const_int 0)))]
6706   "")
6707
6708 (define_insn "*rotldi3_internal12"
6709   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6710         (compare:CC (zero_extend:DI
6711                      (subreg:HI
6712                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6713                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6714                     (const_int 0)))
6715    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6716         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6717   "TARGET_64BIT"
6718   "@
6719    rld%I2cl. %0,%1,%H2,48
6720    #"
6721   [(set_attr "type" "delayed_compare")
6722    (set_attr "length" "4,8")])
6723
6724 (define_split
6725   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6726         (compare:CC (zero_extend:DI
6727                      (subreg:HI
6728                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6729                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6730                     (const_int 0)))
6731    (set (match_operand:DI 0 "gpc_reg_operand" "")
6732         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6733   "TARGET_POWERPC64 && reload_completed"
6734   [(set (match_dup 0)
6735         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6736    (set (match_dup 3)
6737         (compare:CC (match_dup 0)
6738                     (const_int 0)))]
6739   "")
6740
6741 (define_insn "*rotldi3_internal13"
6742   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6743         (zero_extend:DI
6744          (subreg:SI
6745           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6746                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6747   "TARGET_POWERPC64"
6748   "rld%I2cl %0,%1,%H2,32")
6749
6750 (define_insn "*rotldi3_internal14"
6751   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6752         (compare:CC (zero_extend:DI
6753                      (subreg:SI
6754                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6755                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6756                     (const_int 0)))
6757    (clobber (match_scratch:DI 3 "=r,r"))]
6758   "TARGET_64BIT"
6759   "@
6760    rld%I2cl. %3,%1,%H2,32
6761    #"
6762   [(set_attr "type" "delayed_compare")
6763    (set_attr "length" "4,8")])
6764
6765 (define_split
6766   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6767         (compare:CC (zero_extend:DI
6768                      (subreg:SI
6769                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6770                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6771                     (const_int 0)))
6772    (clobber (match_scratch:DI 3 ""))]
6773   "TARGET_POWERPC64 && reload_completed"
6774   [(set (match_dup 3)
6775         (zero_extend:DI (subreg:SI
6776                       (rotate:DI (match_dup 1)
6777                                  (match_dup 2)) 0)))
6778    (set (match_dup 0)
6779         (compare:CC (match_dup 3)
6780                     (const_int 0)))]
6781   "")
6782
6783 (define_insn "*rotldi3_internal15"
6784   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6785         (compare:CC (zero_extend:DI
6786                      (subreg:SI
6787                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6788                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6789                     (const_int 0)))
6790    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6791         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6792   "TARGET_64BIT"
6793   "@
6794    rld%I2cl. %0,%1,%H2,32
6795    #"
6796   [(set_attr "type" "delayed_compare")
6797    (set_attr "length" "4,8")])
6798
6799 (define_split
6800   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6801         (compare:CC (zero_extend:DI
6802                      (subreg:SI
6803                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6804                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6805                     (const_int 0)))
6806    (set (match_operand:DI 0 "gpc_reg_operand" "")
6807         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6808   "TARGET_POWERPC64 && reload_completed"
6809   [(set (match_dup 0)
6810         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6811    (set (match_dup 3)
6812         (compare:CC (match_dup 0)
6813                     (const_int 0)))]
6814   "")
6815
6816 (define_expand "ashldi3"
6817   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6818         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6819                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
6820   "TARGET_POWERPC64 || TARGET_POWER"
6821   "
6822 {
6823   if (TARGET_POWERPC64)
6824     ;
6825   else if (TARGET_POWER)
6826     {
6827       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6828       DONE;
6829     }
6830   else
6831     FAIL;
6832 }")
6833
6834 (define_insn "*ashldi3_internal1"
6835   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6836         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6837                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6838   "TARGET_POWERPC64"
6839   "sld%I2 %0,%1,%H2")
6840
6841 (define_insn "*ashldi3_internal2"
6842   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6843         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6844                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6845                     (const_int 0)))
6846    (clobber (match_scratch:DI 3 "=r,r"))]
6847   "TARGET_64BIT"
6848   "@
6849    sld%I2. %3,%1,%H2
6850    #"
6851   [(set_attr "type" "delayed_compare")
6852    (set_attr "length" "4,8")])
6853
6854 (define_split
6855   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6856         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6857                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6858                     (const_int 0)))
6859    (clobber (match_scratch:DI 3 ""))]
6860   "TARGET_POWERPC64 && reload_completed"
6861   [(set (match_dup 3)
6862         (ashift:DI (match_dup 1) (match_dup 2)))
6863    (set (match_dup 0)
6864         (compare:CC (match_dup 3)
6865                     (const_int 0)))]
6866   "")
6867
6868 (define_insn "*ashldi3_internal3"
6869   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6870         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6871                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6872                     (const_int 0)))
6873    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6874         (ashift:DI (match_dup 1) (match_dup 2)))]
6875   "TARGET_64BIT"
6876   "@
6877    sld%I2. %0,%1,%H2
6878    #"
6879   [(set_attr "type" "delayed_compare")
6880    (set_attr "length" "4,8")])
6881
6882 (define_split
6883   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6884         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6885                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6886                     (const_int 0)))
6887    (set (match_operand:DI 0 "gpc_reg_operand" "")
6888         (ashift:DI (match_dup 1) (match_dup 2)))]
6889   "TARGET_POWERPC64 && reload_completed"
6890   [(set (match_dup 0)
6891         (ashift:DI (match_dup 1) (match_dup 2)))
6892    (set (match_dup 3)
6893         (compare:CC (match_dup 0)
6894                     (const_int 0)))]
6895   "")
6896
6897 (define_insn "*ashldi3_internal4"
6898   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6899         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6900                            (match_operand:SI 2 "const_int_operand" "i"))
6901                 (match_operand:DI 3 "const_int_operand" "n")))]
6902   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6903   "rldic %0,%1,%H2,%W3")
6904
6905 (define_insn "ashldi3_internal5"
6906   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6907         (compare:CC
6908          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6909                             (match_operand:SI 2 "const_int_operand" "i,i"))
6910                  (match_operand:DI 3 "const_int_operand" "n,n"))
6911          (const_int 0)))
6912    (clobber (match_scratch:DI 4 "=r,r"))]
6913   "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6914   "@
6915    rldic. %4,%1,%H2,%W3
6916    #"
6917   [(set_attr "type" "delayed_compare")
6918    (set_attr "length" "4,8")])
6919
6920 (define_split
6921   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6922         (compare:CC
6923          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6924                             (match_operand:SI 2 "const_int_operand" ""))
6925                  (match_operand:DI 3 "const_int_operand" ""))
6926          (const_int 0)))
6927    (clobber (match_scratch:DI 4 ""))]
6928   "TARGET_POWERPC64 && reload_completed
6929    && includes_rldic_lshift_p (operands[2], operands[3])"
6930   [(set (match_dup 4)
6931         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6932                 (match_dup 3)))
6933    (set (match_dup 0)
6934         (compare:CC (match_dup 4)
6935                     (const_int 0)))]
6936   "")
6937
6938 (define_insn "*ashldi3_internal6"
6939   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6940         (compare:CC
6941          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6942                             (match_operand:SI 2 "const_int_operand" "i,i"))
6943                     (match_operand:DI 3 "const_int_operand" "n,n"))
6944          (const_int 0)))
6945    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6946         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6947   "TARGET_64BIT && includes_rldic_lshift_p (operands[2], operands[3])"
6948   "@
6949    rldic. %0,%1,%H2,%W3
6950    #"
6951   [(set_attr "type" "delayed_compare")
6952    (set_attr "length" "4,8")])
6953
6954 (define_split
6955   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6956         (compare:CC
6957          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6958                             (match_operand:SI 2 "const_int_operand" ""))
6959                  (match_operand:DI 3 "const_int_operand" ""))
6960          (const_int 0)))
6961    (set (match_operand:DI 0 "gpc_reg_operand" "")
6962         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6963   "TARGET_POWERPC64 && reload_completed
6964    && includes_rldic_lshift_p (operands[2], operands[3])"
6965   [(set (match_dup 0)
6966         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6967                 (match_dup 3)))
6968    (set (match_dup 4)
6969         (compare:CC (match_dup 0)
6970                     (const_int 0)))]
6971   "")
6972
6973 (define_insn "*ashldi3_internal7"
6974   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6975         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6976                            (match_operand:SI 2 "const_int_operand" "i"))
6977                 (match_operand:DI 3 "mask64_operand" "n")))]
6978   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6979   "rldicr %0,%1,%H2,%S3")
6980
6981 (define_insn "ashldi3_internal8"
6982   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6983         (compare:CC
6984          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6985                             (match_operand:SI 2 "const_int_operand" "i,i"))
6986                  (match_operand:DI 3 "mask64_operand" "n,n"))
6987          (const_int 0)))
6988    (clobber (match_scratch:DI 4 "=r,r"))]
6989   "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
6990   "@
6991    rldicr. %4,%1,%H2,%S3
6992    #"
6993   [(set_attr "type" "delayed_compare")
6994    (set_attr "length" "4,8")])
6995
6996 (define_split
6997   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6998         (compare:CC
6999          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7000                             (match_operand:SI 2 "const_int_operand" ""))
7001                  (match_operand:DI 3 "mask64_operand" ""))
7002          (const_int 0)))
7003    (clobber (match_scratch:DI 4 ""))]
7004   "TARGET_POWERPC64 && reload_completed
7005    && includes_rldicr_lshift_p (operands[2], operands[3])"
7006   [(set (match_dup 4)
7007         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7008                 (match_dup 3)))
7009    (set (match_dup 0)
7010         (compare:CC (match_dup 4)
7011                     (const_int 0)))]
7012   "")
7013
7014 (define_insn "*ashldi3_internal9"
7015   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7016         (compare:CC
7017          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7018                             (match_operand:SI 2 "const_int_operand" "i,i"))
7019                     (match_operand:DI 3 "mask64_operand" "n,n"))
7020          (const_int 0)))
7021    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7022         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7023   "TARGET_64BIT && includes_rldicr_lshift_p (operands[2], operands[3])"
7024   "@
7025    rldicr. %0,%1,%H2,%S3
7026    #"
7027   [(set_attr "type" "delayed_compare")
7028    (set_attr "length" "4,8")])
7029
7030 (define_split
7031   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7032         (compare:CC
7033          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7034                             (match_operand:SI 2 "const_int_operand" ""))
7035                  (match_operand:DI 3 "mask64_operand" ""))
7036          (const_int 0)))
7037    (set (match_operand:DI 0 "gpc_reg_operand" "")
7038         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7039   "TARGET_POWERPC64 && reload_completed
7040    && includes_rldicr_lshift_p (operands[2], operands[3])"
7041   [(set (match_dup 0)
7042         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7043                 (match_dup 3)))
7044    (set (match_dup 4)
7045         (compare:CC (match_dup 0)
7046                     (const_int 0)))]
7047   "")
7048
7049 (define_expand "lshrdi3"
7050   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7051         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7052                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7053   "TARGET_POWERPC64 || TARGET_POWER"
7054   "
7055 {
7056   if (TARGET_POWERPC64)
7057     ;
7058   else if (TARGET_POWER)
7059     {
7060       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
7061       DONE;
7062     }
7063   else
7064     FAIL;
7065 }")
7066
7067 (define_insn "*lshrdi3_internal1"
7068   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7069         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7070                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7071   "TARGET_POWERPC64"
7072   "srd%I2 %0,%1,%H2")
7073
7074 (define_insn "*lshrdi3_internal2"
7075   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7076         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7077                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7078                     (const_int 0)))
7079    (clobber (match_scratch:DI 3 "=r,r"))]
7080   "TARGET_64BIT "
7081   "@
7082    srd%I2. %3,%1,%H2
7083    #"
7084   [(set_attr "type" "delayed_compare")
7085    (set_attr "length" "4,8")])
7086
7087 (define_split
7088   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7089         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7090                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7091                     (const_int 0)))
7092    (clobber (match_scratch:DI 3 ""))]
7093   "TARGET_POWERPC64 && reload_completed"
7094   [(set (match_dup 3)
7095         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7096    (set (match_dup 0)
7097         (compare:CC (match_dup 3)
7098                     (const_int 0)))]
7099   "")
7100
7101 (define_insn "*lshrdi3_internal3"
7102   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7103         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7104                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7105                     (const_int 0)))
7106    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7107         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7108   "TARGET_64BIT"
7109   "@
7110    srd%I2. %0,%1,%H2
7111    #"
7112   [(set_attr "type" "delayed_compare")
7113    (set_attr "length" "4,8")])
7114
7115 (define_split
7116   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7117         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7118                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7119                     (const_int 0)))
7120    (set (match_operand:DI 0 "gpc_reg_operand" "")
7121         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7122   "TARGET_POWERPC64 && reload_completed"
7123   [(set (match_dup 0)
7124         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7125    (set (match_dup 3)
7126         (compare:CC (match_dup 0)
7127                     (const_int 0)))]
7128   "")
7129
7130 (define_expand "ashrdi3"
7131   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7132         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7133                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7134   "WORDS_BIG_ENDIAN"
7135   "
7136 {
7137   if (TARGET_POWERPC64)
7138     ;
7139   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7140     {
7141       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7142       DONE;
7143     }
7144   else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT
7145            && WORDS_BIG_ENDIAN)
7146     {
7147       emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7148       DONE;
7149     }
7150   else
7151     FAIL;
7152 }")
7153
7154 (define_insn "*ashrdi3_internal1"
7155   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7156         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7157                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7158   "TARGET_POWERPC64"
7159   "srad%I2 %0,%1,%H2")
7160
7161 (define_insn "*ashrdi3_internal2"
7162   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7163         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7164                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7165                     (const_int 0)))
7166    (clobber (match_scratch:DI 3 "=r,r"))]
7167   "TARGET_64BIT"
7168   "@
7169    srad%I2. %3,%1,%H2
7170    #"
7171   [(set_attr "type" "delayed_compare")
7172    (set_attr "length" "4,8")])
7173
7174 (define_split
7175   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7176         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7177                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7178                     (const_int 0)))
7179    (clobber (match_scratch:DI 3 ""))]
7180   "TARGET_POWERPC64 && reload_completed"
7181   [(set (match_dup 3)
7182         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7183    (set (match_dup 0)
7184         (compare:CC (match_dup 3)
7185                     (const_int 0)))]
7186   "")
7187
7188 (define_insn "*ashrdi3_internal3"
7189   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7190         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7191                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7192                     (const_int 0)))
7193    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7194         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7195   "TARGET_64BIT"
7196   "@
7197    srad%I2. %0,%1,%H2
7198    #"
7199   [(set_attr "type" "delayed_compare")
7200    (set_attr "length" "4,8")])
7201
7202 (define_split
7203   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7204         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7205                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7206                     (const_int 0)))
7207    (set (match_operand:DI 0 "gpc_reg_operand" "")
7208         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7209   "TARGET_POWERPC64 && reload_completed"
7210   [(set (match_dup 0)
7211         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7212    (set (match_dup 3)
7213         (compare:CC (match_dup 0)
7214                     (const_int 0)))]
7215   "")
7216
7217 (define_insn "anddi3"
7218   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
7219         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r")
7220                 (match_operand:DI 2 "and64_2_operand" "?r,S,T,K,J,t")))
7221    (clobber (match_scratch:CC 3 "=X,X,X,x,x,X"))]
7222   "TARGET_POWERPC64"
7223   "@
7224    and %0,%1,%2
7225    rldic%B2 %0,%1,0,%S2
7226    rlwinm %0,%1,0,%m2,%M2
7227    andi. %0,%1,%b2
7228    andis. %0,%1,%u2
7229    #"
7230   [(set_attr "type" "*,*,*,compare,compare,*")
7231    (set_attr "length" "4,4,4,4,4,8")])
7232
7233 (define_split
7234   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7235         (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7236                 (match_operand:DI 2 "mask64_2_operand" "")))
7237    (clobber (match_scratch:CC 3 ""))]
7238   "TARGET_POWERPC64
7239     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7240     && !mask64_operand (operands[2], DImode)"
7241   [(set (match_dup 0)
7242         (and:DI (rotate:DI (match_dup 1)
7243                            (match_dup 4))
7244                 (match_dup 5)))
7245    (set (match_dup 0)
7246         (and:DI (rotate:DI (match_dup 0)
7247                            (match_dup 6))
7248                 (match_dup 7)))]
7249 {
7250   build_mask64_2_operands (operands[2], &operands[4]);
7251 })
7252
7253 (define_insn "*anddi3_internal2"
7254   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7255         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7256                             (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7257                     (const_int 0)))
7258    (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
7259    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7260   "TARGET_64BIT"
7261   "@
7262    and. %3,%1,%2
7263    rldic%B2. %3,%1,0,%S2
7264    andi. %3,%1,%b2
7265    andis. %3,%1,%u2
7266    #
7267    #
7268    #
7269    #
7270    #
7271    #"
7272   [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7273    (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7274
7275 (define_split
7276   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7277         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7278                             (match_operand:DI 2 "and64_operand" ""))
7279                     (const_int 0)))
7280    (clobber (match_scratch:DI 3 ""))
7281    (clobber (match_scratch:CC 4 ""))]
7282   "TARGET_POWERPC64 && reload_completed"
7283   [(parallel [(set (match_dup 3)
7284                    (and:DI (match_dup 1)
7285                            (match_dup 2)))
7286               (clobber (match_dup 4))])
7287    (set (match_dup 0)
7288         (compare:CC (match_dup 3)
7289                     (const_int 0)))]
7290   "")
7291
7292 (define_split
7293   [(set (match_operand:CC 0 "cc_reg_operand" "")
7294         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7295                             (match_operand:DI 2 "mask64_2_operand" ""))
7296                     (const_int 0)))
7297    (clobber (match_scratch:DI 3 ""))
7298    (clobber (match_scratch:CC 4 ""))]
7299   "TARGET_POWERPC64 && reload_completed
7300     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7301     && !mask64_operand (operands[2], DImode)"
7302   [(set (match_dup 3)
7303         (and:DI (rotate:DI (match_dup 1)
7304                            (match_dup 5))
7305                 (match_dup 6)))
7306    (parallel [(set (match_dup 0)
7307                    (compare:CC (and:DI (rotate:DI (match_dup 3)
7308                                                   (match_dup 7))
7309                                        (match_dup 8))
7310                                (const_int 0)))
7311               (clobber (match_dup 3))])]
7312   "
7313 {
7314   build_mask64_2_operands (operands[2], &operands[5]);
7315 }")
7316
7317 (define_insn "*anddi3_internal3"
7318   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7319         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7320                             (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7321                     (const_int 0)))
7322    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
7323         (and:DI (match_dup 1) (match_dup 2)))
7324    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7325   "TARGET_64BIT"
7326   "@
7327    and. %0,%1,%2
7328    rldic%B2. %0,%1,0,%S2
7329    andi. %0,%1,%b2
7330    andis. %0,%1,%u2
7331    #
7332    #
7333    #
7334    #
7335    #
7336    #"
7337   [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7338    (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7339
7340 (define_split
7341   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7342         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7343                             (match_operand:DI 2 "and64_operand" ""))
7344                     (const_int 0)))
7345    (set (match_operand:DI 0 "gpc_reg_operand" "")
7346         (and:DI (match_dup 1) (match_dup 2)))
7347    (clobber (match_scratch:CC 4 ""))]
7348   "TARGET_POWERPC64 && reload_completed"
7349   [(parallel [(set (match_dup 0)
7350                     (and:DI (match_dup 1) (match_dup 2)))
7351                (clobber (match_dup 4))])
7352    (set (match_dup 3)
7353         (compare:CC (match_dup 0)
7354                     (const_int 0)))]
7355   "")
7356
7357 (define_split
7358   [(set (match_operand:CC 3 "cc_reg_operand" "")
7359         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7360                             (match_operand:DI 2 "mask64_2_operand" ""))
7361                     (const_int 0)))
7362    (set (match_operand:DI 0 "gpc_reg_operand" "")
7363         (and:DI (match_dup 1) (match_dup 2)))
7364    (clobber (match_scratch:CC 4 ""))]
7365   "TARGET_POWERPC64 && reload_completed
7366     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7367     && !mask64_operand (operands[2], DImode)"
7368   [(set (match_dup 0)
7369         (and:DI (rotate:DI (match_dup 1)
7370                            (match_dup 5))
7371                 (match_dup 6)))
7372    (parallel [(set (match_dup 3)
7373                    (compare:CC (and:DI (rotate:DI (match_dup 0)
7374                                                   (match_dup 7))
7375                                        (match_dup 8))
7376                                (const_int 0)))
7377               (set (match_dup 0)
7378                    (and:DI (rotate:DI (match_dup 0)
7379                                       (match_dup 7))
7380                            (match_dup 8)))])]
7381   "
7382 {
7383   build_mask64_2_operands (operands[2], &operands[5]);
7384 }")
7385
7386 (define_expand "iordi3"
7387   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7388         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7389                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7390   "TARGET_POWERPC64"
7391   "
7392 {
7393   if (non_logical_cint_operand (operands[2], DImode))
7394     {
7395       HOST_WIDE_INT value;
7396       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7397                  ? operands[0] : gen_reg_rtx (DImode));
7398
7399       if (GET_CODE (operands[2]) == CONST_INT)
7400         {
7401           value = INTVAL (operands[2]);
7402           emit_insn (gen_iordi3 (tmp, operands[1],
7403                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7404         }
7405       else
7406         {
7407           value = CONST_DOUBLE_LOW (operands[2]);
7408           emit_insn (gen_iordi3 (tmp, operands[1],
7409                                  immed_double_const (value
7410                                                      & (~ (HOST_WIDE_INT) 0xffff),
7411                                                      0, DImode)));
7412         }
7413
7414       emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7415       DONE;
7416     }
7417 }")
7418
7419 (define_expand "xordi3"
7420   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7421         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7422                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7423   "TARGET_POWERPC64"
7424   "
7425 {
7426   if (non_logical_cint_operand (operands[2], DImode))
7427     {
7428       HOST_WIDE_INT value;
7429       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7430                  ? operands[0] : gen_reg_rtx (DImode));
7431
7432       if (GET_CODE (operands[2]) == CONST_INT)
7433         {
7434           value = INTVAL (operands[2]);
7435           emit_insn (gen_xordi3 (tmp, operands[1],
7436                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7437         }
7438       else
7439         {
7440           value = CONST_DOUBLE_LOW (operands[2]);
7441           emit_insn (gen_xordi3 (tmp, operands[1],
7442                                  immed_double_const (value
7443                                                      & (~ (HOST_WIDE_INT) 0xffff),
7444                                                      0, DImode)));
7445         }
7446
7447       emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7448       DONE;
7449     }
7450 }")
7451
7452 (define_insn "*booldi3_internal1"
7453   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7454         (match_operator:DI 3 "boolean_or_operator"
7455          [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7456           (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7457   "TARGET_POWERPC64"
7458   "@
7459    %q3 %0,%1,%2
7460    %q3i %0,%1,%b2
7461    %q3is %0,%1,%u2")
7462
7463 (define_insn "*booldi3_internal2"
7464   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7465         (compare:CC (match_operator:DI 4 "boolean_or_operator"
7466          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7467           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7468          (const_int 0)))
7469    (clobber (match_scratch:DI 3 "=r,r"))]
7470   "TARGET_64BIT"
7471   "@
7472    %q4. %3,%1,%2
7473    #"
7474   [(set_attr "type" "compare")
7475    (set_attr "length" "4,8")])
7476
7477 (define_split
7478   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7479         (compare:CC (match_operator:DI 4 "boolean_operator"
7480          [(match_operand:DI 1 "gpc_reg_operand" "")
7481           (match_operand:DI 2 "gpc_reg_operand" "")])
7482          (const_int 0)))
7483    (clobber (match_scratch:DI 3 ""))]
7484   "TARGET_POWERPC64 && reload_completed"
7485   [(set (match_dup 3) (match_dup 4))
7486    (set (match_dup 0)
7487         (compare:CC (match_dup 3)
7488                     (const_int 0)))]
7489   "")
7490
7491 (define_insn "*booldi3_internal3"
7492   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7493         (compare:CC (match_operator:DI 4 "boolean_operator"
7494          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7495           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7496          (const_int 0)))
7497    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7498         (match_dup 4))]
7499   "TARGET_64BIT"
7500   "@
7501    %q4. %0,%1,%2
7502    #"
7503   [(set_attr "type" "compare")
7504    (set_attr "length" "4,8")])
7505
7506 (define_split
7507   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7508         (compare:CC (match_operator:DI 4 "boolean_operator"
7509          [(match_operand:DI 1 "gpc_reg_operand" "")
7510           (match_operand:DI 2 "gpc_reg_operand" "")])
7511          (const_int 0)))
7512    (set (match_operand:DI 0 "gpc_reg_operand" "")
7513         (match_dup 4))]
7514   "TARGET_POWERPC64 && reload_completed"
7515   [(set (match_dup 0) (match_dup 4))
7516    (set (match_dup 3)
7517         (compare:CC (match_dup 0)
7518                     (const_int 0)))]
7519   "")
7520
7521 ;; Split a logical operation that we can't do in one insn into two insns,
7522 ;; each of which does one 16-bit part.  This is used by combine.
7523
7524 (define_split
7525   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7526         (match_operator:DI 3 "boolean_or_operator"
7527          [(match_operand:DI 1 "gpc_reg_operand" "")
7528           (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7529   "TARGET_POWERPC64"
7530   [(set (match_dup 0) (match_dup 4))
7531    (set (match_dup 0) (match_dup 5))]
7532 "
7533 {
7534   rtx i3,i4;
7535
7536   if (GET_CODE (operands[2]) == CONST_DOUBLE)
7537     {
7538       HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7539       i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7540                                         0, DImode);
7541       i4 = GEN_INT (value & 0xffff);
7542     }
7543   else
7544     {
7545       i3 = GEN_INT (INTVAL (operands[2])
7546                              & (~ (HOST_WIDE_INT) 0xffff));
7547       i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7548     }
7549   operands[4] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7550                                 operands[1], i3);
7551   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), DImode,
7552                                 operands[0], i4);
7553 }")
7554
7555 (define_insn "*boolcdi3_internal1"
7556   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7557         (match_operator:DI 3 "boolean_operator"
7558          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7559           (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7560   "TARGET_POWERPC64"
7561   "%q3 %0,%2,%1")
7562
7563 (define_insn "*boolcdi3_internal2"
7564   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7565         (compare:CC (match_operator:DI 4 "boolean_operator"
7566          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7567           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7568          (const_int 0)))
7569    (clobber (match_scratch:DI 3 "=r,r"))]
7570   "TARGET_64BIT"
7571   "@
7572    %q4. %3,%2,%1
7573    #"
7574   [(set_attr "type" "compare")
7575    (set_attr "length" "4,8")])
7576
7577 (define_split
7578   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7579         (compare:CC (match_operator:DI 4 "boolean_operator"
7580          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7581           (match_operand:DI 2 "gpc_reg_operand" "")])
7582          (const_int 0)))
7583    (clobber (match_scratch:DI 3 ""))]
7584   "TARGET_POWERPC64 && reload_completed"
7585   [(set (match_dup 3) (match_dup 4))
7586    (set (match_dup 0)
7587         (compare:CC (match_dup 3)
7588                     (const_int 0)))]
7589   "")
7590
7591 (define_insn "*boolcdi3_internal3"
7592   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7593         (compare:CC (match_operator:DI 4 "boolean_operator"
7594          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7595           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7596          (const_int 0)))
7597    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7598         (match_dup 4))]
7599   "TARGET_64BIT"
7600   "@
7601    %q4. %0,%2,%1
7602    #"
7603   [(set_attr "type" "compare")
7604    (set_attr "length" "4,8")])
7605
7606 (define_split
7607   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7608         (compare:CC (match_operator:DI 4 "boolean_operator"
7609          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7610           (match_operand:DI 2 "gpc_reg_operand" "")])
7611          (const_int 0)))
7612    (set (match_operand:DI 0 "gpc_reg_operand" "")
7613         (match_dup 4))]
7614   "TARGET_POWERPC64 && reload_completed"
7615   [(set (match_dup 0) (match_dup 4))
7616    (set (match_dup 3)
7617         (compare:CC (match_dup 0)
7618                     (const_int 0)))]
7619   "")
7620
7621 (define_insn "*boolccdi3_internal1"
7622   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7623         (match_operator:DI 3 "boolean_operator"
7624          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7625           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7626   "TARGET_POWERPC64"
7627   "%q3 %0,%1,%2")
7628
7629 (define_insn "*boolccdi3_internal2"
7630   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7631         (compare:CC (match_operator:DI 4 "boolean_operator"
7632          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7633           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7634          (const_int 0)))
7635    (clobber (match_scratch:DI 3 "=r,r"))]
7636   "TARGET_64BIT"
7637   "@
7638    %q4. %3,%1,%2
7639    #"
7640   [(set_attr "type" "compare")
7641    (set_attr "length" "4,8")])
7642
7643 (define_split
7644   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7645         (compare:CC (match_operator:DI 4 "boolean_operator"
7646          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7647           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7648          (const_int 0)))
7649    (clobber (match_scratch:DI 3 ""))]
7650   "TARGET_POWERPC64 && reload_completed"
7651   [(set (match_dup 3) (match_dup 4))
7652    (set (match_dup 0)
7653         (compare:CC (match_dup 3)
7654                     (const_int 0)))]
7655   "")
7656
7657 (define_insn "*boolccdi3_internal3"
7658   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7659         (compare:CC (match_operator:DI 4 "boolean_operator"
7660          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7661           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7662          (const_int 0)))
7663    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7664         (match_dup 4))]
7665   "TARGET_64BIT"
7666   "@
7667    %q4. %0,%1,%2
7668    #"
7669   [(set_attr "type" "compare")
7670    (set_attr "length" "4,8")])
7671
7672 (define_split
7673   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7674         (compare:CC (match_operator:DI 4 "boolean_operator"
7675          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7676           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7677          (const_int 0)))
7678    (set (match_operand:DI 0 "gpc_reg_operand" "")
7679         (match_dup 4))]
7680   "TARGET_POWERPC64 && reload_completed"
7681   [(set (match_dup 0) (match_dup 4))
7682    (set (match_dup 3)
7683         (compare:CC (match_dup 0)
7684                     (const_int 0)))]
7685   "")
7686 \f
7687 ;; Now define ways of moving data around.
7688
7689 ;; Elf specific ways of loading addresses for non-PIC code.
7690 ;; The output of this could be r0, but we make a very strong
7691 ;; preference for a base register because it will usually
7692 ;; be needed there.
7693 (define_insn "elf_high"
7694   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7695         (high:SI (match_operand 1 "" "")))]
7696   "TARGET_ELF && ! TARGET_64BIT"
7697   "{liu|lis} %0,%1@ha")
7698
7699 (define_insn "elf_low"
7700   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7701         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7702                    (match_operand 2 "" "")))]
7703    "TARGET_ELF && ! TARGET_64BIT"
7704    "@
7705     {cal|la} %0,%2@l(%1)
7706     {ai|addic} %0,%1,%K2")
7707
7708
7709 ;; Set up a register with a value from the GOT table
7710
7711 (define_expand "movsi_got"
7712   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7713         (unspec:SI [(match_operand:SI 1 "got_operand" "")
7714                     (match_dup 2)] UNSPEC_MOVSI_GOT))]
7715   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7716   "
7717 {
7718   if (GET_CODE (operands[1]) == CONST)
7719     {
7720       rtx offset = const0_rtx;
7721       HOST_WIDE_INT value;
7722
7723       operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7724       value = INTVAL (offset);
7725       if (value != 0)
7726         {
7727           rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7728           emit_insn (gen_movsi_got (tmp, operands[1]));
7729           emit_insn (gen_addsi3 (operands[0], tmp, offset));
7730           DONE;
7731         }
7732     }
7733
7734   operands[2] = rs6000_got_register (operands[1]);
7735 }")
7736
7737 (define_insn "*movsi_got_internal"
7738   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7739         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7740                     (match_operand:SI 2 "gpc_reg_operand" "b")]
7741                    UNSPEC_MOVSI_GOT))]
7742   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7743   "{l|lwz} %0,%a1@got(%2)"
7744   [(set_attr "type" "load")])
7745
7746 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7747 ;; didn't get allocated to a hard register.
7748 (define_split
7749   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7750         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7751                     (match_operand:SI 2 "memory_operand" "")]
7752                    UNSPEC_MOVSI_GOT))]
7753   "DEFAULT_ABI == ABI_V4
7754     && flag_pic == 1
7755     && (reload_in_progress || reload_completed)"
7756   [(set (match_dup 0) (match_dup 2))
7757    (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)]
7758                                  UNSPEC_MOVSI_GOT))]
7759   "")
7760
7761 ;; For SI, we special-case integers that can't be loaded in one insn.  We
7762 ;; do the load 16-bits at a time.  We could do this by loading from memory,
7763 ;; and this is even supposed to be faster, but it is simpler not to get
7764 ;; integers in the TOC.
7765 (define_expand "movsi"
7766   [(set (match_operand:SI 0 "general_operand" "")
7767         (match_operand:SI 1 "any_operand" ""))]
7768   ""
7769   "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
7770
7771 (define_insn "movsi_low"
7772   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7773         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7774                            (match_operand 2 "" ""))))]
7775   "TARGET_MACHO && ! TARGET_64BIT"
7776   "{l|lwz} %0,lo16(%2)(%1)"
7777   [(set_attr "type" "load")
7778    (set_attr "length" "4")])
7779
7780 (define_insn "*movsi_internal1"
7781   [(set (match_operand:SI 0 "rs6000_nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7782         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7783   "gpc_reg_operand (operands[0], SImode)
7784    || gpc_reg_operand (operands[1], SImode)"
7785   "@
7786    mr %0,%1
7787    {cal|la} %0,%a1
7788    {l%U1%X1|lwz%U1%X1} %0,%1
7789    {st%U0%X0|stw%U0%X0} %1,%0
7790    {lil|li} %0,%1
7791    {liu|lis} %0,%v1
7792    #
7793    {cal|la} %0,%a1
7794    mf%1 %0
7795    mt%0 %1
7796    mt%0 %1
7797    mt%0 %1
7798    {cror 0,0,0|nop}"
7799   [(set_attr "type" "*,*,load,store,*,*,*,*,mfjmpr,*,mtjmpr,*,*")
7800    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7801
7802 ;; Split a load of a large constant into the appropriate two-insn
7803 ;; sequence.
7804
7805 (define_split
7806   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7807         (match_operand:SI 1 "const_int_operand" ""))]
7808   "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7809    && (INTVAL (operands[1]) & 0xffff) != 0"
7810   [(set (match_dup 0)
7811         (match_dup 2))
7812    (set (match_dup 0)
7813         (ior:SI (match_dup 0)
7814                 (match_dup 3)))]
7815   "
7816 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
7817
7818   if (tem == operands[0])
7819     DONE;
7820   else
7821     FAIL;
7822 }")
7823
7824 (define_insn "*movsi_internal2"
7825   [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
7826         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "0,r,r")
7827                     (const_int 0)))
7828    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
7829   "TARGET_32BIT"
7830   "@
7831    {cmpi|cmpwi} %2,%0,0
7832    mr. %0,%1
7833    #"
7834   [(set_attr "type" "cmp,compare,cmp")
7835    (set_attr "length" "4,4,8")])
7836
7837 (define_split
7838   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7839         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7840                     (const_int 0)))
7841    (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
7842   "TARGET_32BIT && reload_completed"
7843   [(set (match_dup 0) (match_dup 1))
7844    (set (match_dup 2)
7845         (compare:CC (match_dup 0)
7846                     (const_int 0)))]
7847   "")
7848 \f
7849 (define_expand "movhi"
7850   [(set (match_operand:HI 0 "general_operand" "")
7851         (match_operand:HI 1 "any_operand" ""))]
7852   ""
7853   "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
7854
7855 (define_insn "*movhi_internal"
7856   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7857         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7858   "gpc_reg_operand (operands[0], HImode)
7859    || gpc_reg_operand (operands[1], HImode)"
7860   "@
7861    mr %0,%1
7862    lhz%U1%X1 %0,%1
7863    sth%U0%X0 %1,%0
7864    {lil|li} %0,%w1
7865    mf%1 %0
7866    mt%0 %1
7867    mt%0 %1
7868    {cror 0,0,0|nop}"
7869   [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7870
7871 (define_expand "movqi"
7872   [(set (match_operand:QI 0 "general_operand" "")
7873         (match_operand:QI 1 "any_operand" ""))]
7874   ""
7875   "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
7876
7877 (define_insn "*movqi_internal"
7878   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7879         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7880   "gpc_reg_operand (operands[0], QImode)
7881    || gpc_reg_operand (operands[1], QImode)"
7882   "@
7883    mr %0,%1
7884    lbz%U1%X1 %0,%1
7885    stb%U0%X0 %1,%0
7886    {lil|li} %0,%1
7887    mf%1 %0
7888    mt%0 %1
7889    mt%0 %1
7890    {cror 0,0,0|nop}"
7891   [(set_attr "type" "*,load,store,*,mfjmpr,*,mtjmpr,*")])
7892 \f
7893 ;; Here is how to move condition codes around.  When we store CC data in
7894 ;; an integer register or memory, we store just the high-order 4 bits.
7895 ;; This lets us not shift in the most common case of CR0.
7896 (define_expand "movcc"
7897   [(set (match_operand:CC 0 "nonimmediate_operand" "")
7898         (match_operand:CC 1 "nonimmediate_operand" ""))]
7899   ""
7900   "")
7901
7902 (define_insn "*movcc_internal1"
7903   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,?y,r,r,r,r,q,cl,r,m")
7904         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,h,r,r,m,r"))]
7905   "register_operand (operands[0], CCmode)
7906    || register_operand (operands[1], CCmode)"
7907   "@
7908    mcrf %0,%1
7909    mtcrf 128,%1
7910    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7911    mfcr %0%Q1
7912    mfcr %0%Q1\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7913    mr %0,%1
7914    mf%1 %0
7915    mt%0 %1
7916    mt%0 %1
7917    {l%U1%X1|lwz%U1%X1} %0,%1
7918    {st%U0%U1|stw%U0%U1} %1,%0"
7919   [(set (attr "type")
7920      (cond [(eq_attr "alternative" "0")
7921                 (const_string "cr_logical")
7922             (eq_attr "alternative" "1,2")
7923                 (const_string "mtcr")
7924             (eq_attr "alternative" "5,7")
7925                 (const_string "integer")
7926             (eq_attr "alternative" "6")
7927                 (const_string "mfjmpr")
7928             (eq_attr "alternative" "8")
7929                 (const_string "mtjmpr")
7930             (eq_attr "alternative" "9")
7931                 (const_string "load")
7932             (eq_attr "alternative" "10")
7933                 (const_string "store")
7934             (ne (symbol_ref "TARGET_MFCRF") (const_int 0))
7935                 (const_string "mfcrf")
7936            ]
7937         (const_string "mfcr")))
7938    (set_attr "length" "4,4,12,4,8,4,4,4,4,4,4")])
7939 \f
7940 ;; For floating-point, we normally deal with the floating-point registers
7941 ;; unless -msoft-float is used.  The sole exception is that parameter passing
7942 ;; can produce floating-point values in fixed-point registers.  Unless the
7943 ;; value is a simple constant or already in memory, we deal with this by
7944 ;; allocating memory and copying the value explicitly via that memory location.
7945 (define_expand "movsf"
7946   [(set (match_operand:SF 0 "nonimmediate_operand" "")
7947         (match_operand:SF 1 "any_operand" ""))]
7948   ""
7949   "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7950
7951 (define_split
7952   [(set (match_operand:SF 0 "gpc_reg_operand" "")
7953         (match_operand:SF 1 "const_double_operand" ""))]
7954   "reload_completed
7955    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7956        || (GET_CODE (operands[0]) == SUBREG
7957            && GET_CODE (SUBREG_REG (operands[0])) == REG
7958            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7959   [(set (match_dup 2) (match_dup 3))]
7960   "
7961 {
7962   long l;
7963   REAL_VALUE_TYPE rv;
7964
7965   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7966   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7967
7968   if (! TARGET_POWERPC64)
7969     operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7970   else
7971     operands[2] = gen_lowpart (SImode, operands[0]);
7972
7973   operands[3] = gen_int_mode (l, SImode);
7974 }")
7975
7976 (define_insn "*movsf_hardfloat"
7977   [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!cl,!q,!r,!h,!r,!r")
7978         (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,r,r,h,0,G,Fn"))]
7979   "(gpc_reg_operand (operands[0], SFmode)
7980    || gpc_reg_operand (operands[1], SFmode))
7981    && (TARGET_HARD_FLOAT && TARGET_FPRS)"
7982   "@
7983    mr %0,%1
7984    {l%U1%X1|lwz%U1%X1} %0,%1
7985    {st%U0%X0|stw%U0%X0} %1,%0
7986    fmr %0,%1
7987    lfs%U1%X1 %0,%1
7988    stfs%U0%X0 %1,%0
7989    mt%0 %1
7990    mt%0 %1
7991    mf%1 %0
7992    {cror 0,0,0|nop}
7993    #
7994    #"
7995   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,mtjmpr,*,*,*,*")
7996    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,4,8")])
7997
7998 (define_insn "*movsf_softfloat"
7999   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,cl,q,r,r,m,r,r,r,r,r,*h")
8000         (match_operand:SF 1 "input_operand" "r,r,r,h,m,r,I,L,R,G,Fn,0"))]
8001   "(gpc_reg_operand (operands[0], SFmode)
8002    || gpc_reg_operand (operands[1], SFmode))
8003    && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
8004   "@
8005    mr %0,%1
8006    mt%0 %1
8007    mt%0 %1
8008    mf%1 %0
8009    {l%U1%X1|lwz%U1%X1} %0,%1
8010    {st%U0%X0|stw%U0%X0} %1,%0
8011    {lil|li} %0,%1
8012    {liu|lis} %0,%v1
8013    {cal|la} %0,%a1
8014    #
8015    #
8016    {cror 0,0,0|nop}"
8017   [(set_attr "type" "*,mtjmpr,*,*,load,store,*,*,*,*,*,*")
8018    (set_attr "length" "4,4,4,4,4,4,4,4,4,4,8,4")])
8019
8020 \f
8021 (define_expand "movdf"
8022   [(set (match_operand:DF 0 "nonimmediate_operand" "")
8023         (match_operand:DF 1 "any_operand" ""))]
8024   ""
8025   "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
8026
8027 (define_split
8028   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8029         (match_operand:DF 1 "const_int_operand" ""))]
8030   "! TARGET_POWERPC64 && reload_completed
8031    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8032        || (GET_CODE (operands[0]) == SUBREG
8033            && GET_CODE (SUBREG_REG (operands[0])) == REG
8034            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8035   [(set (match_dup 2) (match_dup 4))
8036    (set (match_dup 3) (match_dup 1))]
8037   "
8038 {
8039   int endian = (WORDS_BIG_ENDIAN == 0);
8040   HOST_WIDE_INT value = INTVAL (operands[1]);
8041
8042   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8043   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8044 #if HOST_BITS_PER_WIDE_INT == 32
8045   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8046 #else
8047   operands[4] = GEN_INT (value >> 32);
8048   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8049 #endif
8050 }")
8051
8052 (define_split
8053   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8054         (match_operand:DF 1 "const_double_operand" ""))]
8055   "! TARGET_POWERPC64 && reload_completed
8056    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8057        || (GET_CODE (operands[0]) == SUBREG
8058            && GET_CODE (SUBREG_REG (operands[0])) == REG
8059            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8060   [(set (match_dup 2) (match_dup 4))
8061    (set (match_dup 3) (match_dup 5))]
8062   "
8063 {
8064   int endian = (WORDS_BIG_ENDIAN == 0);
8065   long l[2];
8066   REAL_VALUE_TYPE rv;
8067
8068   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8069   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8070
8071   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8072   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8073   operands[4] = gen_int_mode (l[endian], SImode);
8074   operands[5] = gen_int_mode (l[1 - endian], SImode);
8075 }")
8076
8077 (define_split
8078   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8079         (match_operand:DF 1 "easy_fp_constant" ""))]
8080   "TARGET_POWERPC64 && reload_completed
8081    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8082        || (GET_CODE (operands[0]) == SUBREG
8083            && GET_CODE (SUBREG_REG (operands[0])) == REG
8084            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8085   [(set (match_dup 2) (match_dup 3))]
8086   "
8087 {
8088   int endian = (WORDS_BIG_ENDIAN == 0);
8089   long l[2];
8090   REAL_VALUE_TYPE rv;
8091 #if HOST_BITS_PER_WIDE_INT >= 64
8092   HOST_WIDE_INT val;
8093 #endif
8094
8095   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8096   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8097
8098   operands[2] = gen_lowpart (DImode, operands[0]);
8099   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
8100 #if HOST_BITS_PER_WIDE_INT >= 64
8101   val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32
8102          | ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
8103
8104   operands[3] = gen_int_mode (val, DImode);
8105 #else
8106   operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
8107 #endif
8108 }")
8109
8110 ;; Don't have reload use general registers to load a constant.  First,
8111 ;; it might not work if the output operand is the equivalent of
8112 ;; a non-offsettable memref, but also it is less efficient than loading
8113 ;; the constant into an FP register, since it will probably be used there.
8114 ;; The "??" is a kludge until we can figure out a more reasonable way
8115 ;; of handling these non-offsettable values.
8116 (define_insn "*movdf_hardfloat32"
8117   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,f,f,m,!r,!r,!r")
8118         (match_operand:DF 1 "input_operand" "r,m,r,f,m,f,G,H,F"))]
8119   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8120    && (gpc_reg_operand (operands[0], DFmode)
8121        || gpc_reg_operand (operands[1], DFmode))"
8122   "*
8123 {
8124   switch (which_alternative)
8125     {
8126     default:
8127       abort ();
8128     case 0:
8129       /* We normally copy the low-numbered register first.  However, if
8130          the first register operand 0 is the same as the second register
8131          of operand 1, we must copy in the opposite order.  */
8132       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8133         return \"mr %L0,%L1\;mr %0,%1\";
8134       else
8135         return \"mr %0,%1\;mr %L0,%L1\";
8136     case 1:
8137       if (GET_CODE (operands[1]) == MEM
8138           && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[1], 0),
8139                         reload_completed || reload_in_progress)
8140               || GET_CODE (XEXP (operands[1], 0)) == REG
8141               || GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8142                   || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
8143               || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC))
8144         {
8145           /* If the low-address word is used in the address, we must load
8146              it last.  Otherwise, load it first.  Note that we cannot have
8147              auto-increment in that case since the address register is
8148              known to be dead.  */
8149           if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8150                                  operands[1], 0))
8151             return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8152           else
8153             return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8154         }
8155       else
8156         {
8157           rtx addreg;
8158
8159           addreg = find_addr_reg (XEXP (operands[1], 0));
8160           if (refers_to_regno_p (REGNO (operands[0]),
8161                                  REGNO (operands[0]) + 1,
8162                                  operands[1], 0))
8163             {
8164               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8165               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8166               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8167               return \"{lx|lwzx} %0,%1\";
8168             }
8169           else
8170             {
8171               output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
8172               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8173               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8174               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8175               return \"\";
8176             }
8177         }
8178     case 2:
8179       if (GET_CODE (operands[0]) == MEM
8180           && (rs6000_legitimate_offset_address_p (DFmode, XEXP (operands[0], 0),
8181                     reload_completed || reload_in_progress)
8182               || GET_CODE (XEXP (operands[0], 0)) == REG
8183               || GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8184                   || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8185               || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC))
8186         return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8187       else
8188         {
8189           rtx addreg;
8190
8191           addreg = find_addr_reg (XEXP (operands[0], 0));
8192           output_asm_insn (\"{stx|stwx} %1,%0\", operands);
8193           output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8194           output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
8195           output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8196           return \"\";
8197         }
8198     case 3:
8199       return \"fmr %0,%1\";
8200     case 4:
8201       return \"lfd%U1%X1 %0,%1\";
8202     case 5:
8203       return \"stfd%U0%X0 %1,%0\";
8204     case 6:
8205     case 7:
8206     case 8:
8207       return \"#\";
8208     }
8209 }"
8210   [(set_attr "type" "two,load,store,fp,fpload,fpstore,*,*,*")
8211    (set_attr "length" "8,16,16,4,4,4,8,12,16")])
8212
8213 (define_insn "*movdf_softfloat32"
8214   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8215         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8216   "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || TARGET_E500_SINGLE)
8217    && (gpc_reg_operand (operands[0], DFmode)
8218        || gpc_reg_operand (operands[1], DFmode))"
8219   "*
8220 {
8221   switch (which_alternative)
8222     {
8223     default:
8224       abort ();
8225     case 0:
8226       /* We normally copy the low-numbered register first.  However, if
8227          the first register operand 0 is the same as the second register of
8228          operand 1, we must copy in the opposite order.  */
8229       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8230         return \"mr %L0,%L1\;mr %0,%1\";
8231       else
8232         return \"mr %0,%1\;mr %L0,%L1\";
8233     case 1:
8234       /* If the low-address word is used in the address, we must load
8235          it last.  Otherwise, load it first.  Note that we cannot have
8236          auto-increment in that case since the address register is
8237          known to be dead.  */
8238       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8239                              operands[1], 0))
8240         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8241       else
8242         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8243     case 2:
8244       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8245     case 3:
8246     case 4:
8247     case 5:
8248       return \"#\";
8249     }
8250 }"
8251   [(set_attr "type" "two,load,store,*,*,*")
8252    (set_attr "length" "8,8,8,8,12,16")])
8253
8254 ; ld/std require word-aligned displacements -> 'Y' constraint.
8255 ; List Y->r and r->Y before r->r for reload.
8256 (define_insn "*movdf_hardfloat64"
8257   [(set (match_operand:DF 0 "nonimmediate_operand" "=Y,r,!r,f,f,m,!cl,!r,!h,!r,!r,!r")
8258         (match_operand:DF 1 "input_operand" "r,Y,r,f,m,f,r,h,0,G,H,F"))]
8259   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8260    && (gpc_reg_operand (operands[0], DFmode)
8261        || gpc_reg_operand (operands[1], DFmode))"
8262   "@
8263    std%U0%X0 %1,%0
8264    ld%U1%X1 %0,%1
8265    mr %0,%1
8266    fmr %0,%1
8267    lfd%U1%X1 %0,%1
8268    stfd%U0%X0 %1,%0
8269    mt%0 %1
8270    mf%1 %0
8271    {cror 0,0,0|nop}
8272    #
8273    #
8274    #"
8275   [(set_attr "type" "*,load,store,fp,fpload,fpstore,mtjmpr,*,*,*,*,*")
8276    (set_attr "length" "4,4,4,4,4,4,4,4,4,8,12,16")])
8277
8278 (define_insn "*movdf_softfloat64"
8279   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,Y,r,cl,r,r,r,r,*h")
8280         (match_operand:DF 1 "input_operand" "Y,r,r,r,h,G,H,F,0"))]
8281   "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8282    && (gpc_reg_operand (operands[0], DFmode)
8283        || gpc_reg_operand (operands[1], DFmode))"
8284   "@
8285    ld%U1%X1 %0,%1
8286    std%U0%X0 %1,%0
8287    mr %0,%1
8288    mt%0 %1
8289    mf%1 %0
8290    #
8291    #
8292    #
8293    {cror 0,0,0|nop}"
8294   [(set_attr "type" "load,store,*,*,*,*,*,*,*")
8295    (set_attr "length" "4,4,4,4,4,8,12,16,4")])
8296 \f
8297 (define_expand "movtf"
8298   [(set (match_operand:TF 0 "general_operand" "")
8299         (match_operand:TF 1 "any_operand" ""))]
8300   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8301    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8302   "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8303
8304 ; It's important to list the o->f and f->o moves before f->f because
8305 ; otherwise reload, given m->f, will try to pick f->f and reload it,
8306 ; which doesn't make progress.  Likewise r->Y must be before r->r.
8307 (define_insn_and_split "*movtf_internal"
8308   [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,f,r,Y,r")
8309         (match_operand:TF 1 "input_operand"         "f,o,f,YGHF,r,r"))]
8310   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8311    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128
8312    && (gpc_reg_operand (operands[0], TFmode)
8313        || gpc_reg_operand (operands[1], TFmode))"
8314   "#"
8315   "&& reload_completed"
8316   [(pc)]
8317 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; }
8318   [(set_attr "length" "8,8,8,20,20,16")])
8319
8320 (define_expand "extenddftf2"
8321   [(parallel [(set (match_operand:TF 0 "nonimmediate_operand" "")
8322                    (float_extend:TF (match_operand:DF 1 "input_operand" "")))
8323               (use (match_dup 2))])]
8324   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8325    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8326 {
8327   operands[2] = CONST0_RTX (DFmode);
8328 })
8329
8330 (define_insn_and_split "*extenddftf2_internal"
8331   [(set (match_operand:TF 0 "nonimmediate_operand" "=o,f,&f,r")
8332        (float_extend:TF (match_operand:DF 1 "input_operand" "fr,mf,mf,rmGHF")))
8333    (use (match_operand:DF 2 "zero_reg_mem_operand" "rf,m,f,n"))]
8334   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8335    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8336   "#"
8337   "&& reload_completed"
8338   [(pc)]
8339 {
8340   const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8341   const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8342   emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word),
8343                   operands[1]);
8344   emit_move_insn (simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word),
8345                   operands[2]);
8346   DONE;
8347 })
8348
8349 (define_expand "extendsftf2"
8350   [(set (match_operand:TF 0 "nonimmediate_operand" "")
8351         (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "")))]
8352   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8353    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8354 {
8355   rtx tmp = gen_reg_rtx (DFmode);
8356   emit_insn (gen_extendsfdf2 (tmp, operands[1]));
8357   emit_insn (gen_extenddftf2 (operands[0], tmp));
8358   DONE;
8359 })
8360
8361 (define_expand "trunctfdf2"
8362   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8363         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))]
8364   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8365    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8366   "")
8367
8368 (define_insn_and_split "trunctfdf2_internal1"
8369   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,?f")
8370         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "0,f")))]
8371   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
8372    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8373   "@
8374    #
8375    fmr %0,%1"
8376   "&& reload_completed && REGNO (operands[0]) == REGNO (operands[1])"
8377   [(const_int 0)]
8378 {
8379   emit_note (NOTE_INSN_DELETED);
8380   DONE;
8381 }
8382   [(set_attr "type" "fp")])
8383
8384 (define_insn "trunctfdf2_internal2"
8385   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8386         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8387   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
8388    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8389   "fadd %0,%1,%L1"
8390   [(set_attr "type" "fp")])
8391
8392 (define_insn_and_split "trunctfsf2"
8393   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8394         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8395    (clobber (match_scratch:DF 2 "=f"))]
8396   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8397    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8398   "#"
8399   "&& reload_completed"
8400   [(set (match_dup 2)
8401         (float_truncate:DF (match_dup 1)))
8402    (set (match_dup 0)
8403         (float_truncate:SF (match_dup 2)))]
8404   "")
8405
8406 (define_expand "floatsitf2"
8407   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8408         (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))]
8409   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8410    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8411 {
8412   rtx tmp = gen_reg_rtx (DFmode);
8413   expand_float (tmp, operands[1], false);
8414   emit_insn (gen_extenddftf2 (operands[0], tmp));
8415   DONE;
8416 })
8417
8418 ; fadd, but rounding towards zero.
8419 ; This is probably not the optimal code sequence.
8420 (define_insn "fix_trunc_helper"
8421   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8422         (unspec:DF [(match_operand:TF 1 "gpc_reg_operand" "f")]
8423                    UNSPEC_FIX_TRUNC_TF))
8424    (clobber (match_operand:DF 2 "gpc_reg_operand" "=&f"))]
8425   "TARGET_HARD_FLOAT && TARGET_FPRS"
8426   "mffs %2\n\tmtfsb1 31\n\tmtfsb0 30\n\tfadd %0,%1,%L1\n\tmtfsf 1,%2"
8427   [(set_attr "type" "fp")
8428    (set_attr "length" "20")])
8429
8430 (define_expand "fix_trunctfsi2"
8431   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
8432                    (fix:SI (match_operand:TF 1 "gpc_reg_operand" "")))
8433               (clobber (match_dup 2))
8434               (clobber (match_dup 3))
8435               (clobber (match_dup 4))
8436               (clobber (match_dup 5))])]
8437   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8438    && (TARGET_POWER2 || TARGET_POWERPC)
8439    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8440 {
8441   operands[2] = gen_reg_rtx (DFmode);
8442   operands[3] = gen_reg_rtx (DFmode);
8443   operands[4] = gen_reg_rtx (DImode);
8444   operands[5] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
8445 })
8446
8447 (define_insn_and_split "*fix_trunctfsi2_internal"
8448   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8449         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))
8450    (clobber (match_operand:DF 2 "gpc_reg_operand" "=f"))
8451    (clobber (match_operand:DF 3 "gpc_reg_operand" "=&f"))
8452    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))
8453    (clobber (match_operand:DI 5 "memory_operand" "=o"))]
8454   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8455    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8456   "#"
8457   "&& reload_completed"
8458   [(pc)]
8459 {
8460   rtx lowword;
8461   emit_insn (gen_fix_trunc_helper (operands[2], operands[1], operands[3]));
8462
8463   if (GET_CODE (operands[5]) != MEM)
8464     abort();
8465   lowword = XEXP (operands[5], 0);
8466   if (WORDS_BIG_ENDIAN)
8467     lowword = plus_constant (lowword, 4);
8468
8469   emit_insn (gen_fctiwz (operands[4], operands[2]));
8470   emit_move_insn (operands[5], operands[4]);
8471   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
8472   DONE;
8473 })
8474
8475 (define_insn "negtf2"
8476   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8477         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8478   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8479    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8480   "*
8481 {
8482   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8483     return \"fneg %L0,%L1\;fneg %0,%1\";
8484   else
8485     return \"fneg %0,%1\;fneg %L0,%L1\";
8486 }"
8487   [(set_attr "type" "fp")
8488    (set_attr "length" "8")])
8489
8490 (define_expand "abstf2"
8491   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8492         (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8493   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8494    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8495   "
8496 {
8497   rtx label = gen_label_rtx ();
8498   emit_insn (gen_abstf2_internal (operands[0], operands[1], label));
8499   emit_label (label);
8500   DONE;
8501 }")
8502
8503 (define_expand "abstf2_internal"
8504   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8505         (match_operand:TF 1 "gpc_reg_operand" "f"))
8506    (set (match_dup 3) (match_dup 5))
8507    (set (match_dup 5) (abs:DF (match_dup 5)))
8508    (set (match_dup 4) (compare:CCFP (match_dup 3) (match_dup 5)))
8509    (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
8510                            (label_ref (match_operand 2 "" ""))
8511                            (pc)))
8512    (set (match_dup 6) (neg:DF (match_dup 6)))]
8513   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
8514    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8515   "
8516 {
8517   const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
8518   const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
8519   operands[3] = gen_reg_rtx (DFmode);
8520   operands[4] = gen_reg_rtx (CCFPmode);
8521   operands[5] = simplify_gen_subreg (DFmode, operands[0], TFmode, hi_word);
8522   operands[6] = simplify_gen_subreg (DFmode, operands[0], TFmode, lo_word);
8523 }")
8524 \f
8525 ;; Next come the multi-word integer load and store and the load and store
8526 ;; multiple insns.
8527 (define_expand "movdi"
8528   [(set (match_operand:DI 0 "general_operand" "")
8529         (match_operand:DI 1 "any_operand" ""))]
8530   ""
8531   "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
8532
8533 ; List r->r after r->"o<>", otherwise reload will try to reload a
8534 ; non-offsettable address by using r->r which won't make progress.
8535 (define_insn "*movdi_internal32"
8536   [(set (match_operand:DI 0 "nonimmediate_operand" "=o<>,r,r,*f,*f,m,r")
8537         (match_operand:DI 1 "input_operand" "r,r,m,f,m,f,IJKnGHF"))]
8538   "! TARGET_POWERPC64
8539    && (gpc_reg_operand (operands[0], DImode)
8540        || gpc_reg_operand (operands[1], DImode))"
8541   "@
8542    #
8543    #
8544    #
8545    fmr %0,%1
8546    lfd%U1%X1 %0,%1
8547    stfd%U0%X0 %1,%0
8548    #"
8549   [(set_attr "type" "load,*,store,fp,fpload,fpstore,*")])
8550
8551 (define_split
8552   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8553         (match_operand:DI 1 "const_int_operand" ""))]
8554   "! TARGET_POWERPC64 && reload_completed"
8555   [(set (match_dup 2) (match_dup 4))
8556    (set (match_dup 3) (match_dup 1))]
8557   "
8558 {
8559   HOST_WIDE_INT value = INTVAL (operands[1]);
8560   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8561                                        DImode);
8562   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8563                                        DImode);
8564 #if HOST_BITS_PER_WIDE_INT == 32
8565   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8566 #else
8567   operands[4] = GEN_INT (value >> 32);
8568   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8569 #endif
8570 }")
8571
8572 (define_split
8573   [(set (match_operand:DI 0 "nonimmediate_operand" "")
8574         (match_operand:DI 1 "input_operand" ""))]
8575   "reload_completed && !TARGET_POWERPC64
8576    && gpr_or_gpr_p (operands[0], operands[1])"
8577   [(pc)]
8578 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8579
8580 (define_insn "*movdi_internal64"
8581   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,*f,*f,m,r,*h,*h")
8582         (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
8583   "TARGET_POWERPC64
8584    && (gpc_reg_operand (operands[0], DImode)
8585        || gpc_reg_operand (operands[1], DImode))"
8586   "@
8587    mr %0,%1
8588    ld%U1%X1 %0,%1
8589    std%U0%X0 %1,%0
8590    li %0,%1
8591    lis %0,%v1
8592    #
8593    {cal|la} %0,%a1
8594    fmr %0,%1
8595    lfd%U1%X1 %0,%1
8596    stfd%U0%X0 %1,%0
8597    mf%1 %0
8598    mt%0 %1
8599    {cror 0,0,0|nop}"
8600   [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,mfjmpr,mtjmpr,*")
8601    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8602
8603 ;; immediate value valid for a single instruction hiding in a const_double
8604 (define_insn ""
8605   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8606         (match_operand:DI 1 "const_double_operand" "F"))]
8607   "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8608    && GET_CODE (operands[1]) == CONST_DOUBLE
8609    && num_insns_constant (operands[1], DImode) == 1"
8610   "*
8611 {
8612   return ((unsigned HOST_WIDE_INT)
8613           (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8614          ? \"li %0,%1\" : \"lis %0,%v1\";
8615 }")
8616
8617 ;; Generate all one-bits and clear left or right.
8618 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8619 (define_split
8620   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8621         (match_operand:DI 1 "mask64_operand" ""))]
8622   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8623   [(set (match_dup 0) (const_int -1))
8624    (set (match_dup 0)
8625         (and:DI (rotate:DI (match_dup 0)
8626                            (const_int 0))
8627                 (match_dup 1)))]
8628   "")
8629
8630 ;; Split a load of a large constant into the appropriate five-instruction
8631 ;; sequence.  Handle anything in a constant number of insns.
8632 ;; When non-easy constants can go in the TOC, this should use
8633 ;; easy_fp_constant predicate.
8634 (define_split
8635   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8636         (match_operand:DI 1 "const_int_operand" ""))]
8637   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8638   [(set (match_dup 0) (match_dup 2))
8639    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8640   "
8641 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8642
8643   if (tem == operands[0])
8644     DONE;
8645   else
8646     FAIL;
8647 }")
8648
8649 (define_split
8650   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8651         (match_operand:DI 1 "const_double_operand" ""))]
8652   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8653   [(set (match_dup 0) (match_dup 2))
8654    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8655   "
8656 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8657
8658   if (tem == operands[0])
8659     DONE;
8660   else
8661     FAIL;
8662 }")
8663
8664 (define_insn "*movdi_internal2"
8665   [(set (match_operand:CC 2 "cc_reg_operand" "=y,x,?y")
8666         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "0,r,r")
8667                     (const_int 0)))
8668    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r") (match_dup 1))]
8669   "TARGET_64BIT"
8670   "@
8671    cmpdi %2,%0,0
8672    mr. %0,%1
8673    #"
8674   [(set_attr "type" "cmp,compare,cmp")
8675    (set_attr "length" "4,4,8")])
8676
8677 (define_split
8678   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8679         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8680                     (const_int 0)))
8681    (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8682   "TARGET_POWERPC64 && reload_completed"
8683   [(set (match_dup 0) (match_dup 1))
8684    (set (match_dup 2)
8685         (compare:CC (match_dup 0)
8686                     (const_int 0)))]
8687   "")
8688 \f
8689 ;; TImode is similar, except that we usually want to compute the address into
8690 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
8691 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8692 (define_expand "movti"
8693   [(parallel [(set (match_operand:TI 0 "general_operand" "")
8694                    (match_operand:TI 1 "general_operand" ""))
8695               (clobber (scratch:SI))])]
8696   ""
8697   "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
8698
8699 ;; We say that MQ is clobbered in the last alternative because the first
8700 ;; alternative would never get used otherwise since it would need a reload
8701 ;; while the 2nd alternative would not.  We put memory cases first so they
8702 ;; are preferred.  Otherwise, we'd try to reload the output instead of
8703 ;; giving the SCRATCH mq.
8704
8705 (define_insn "*movti_power"
8706   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r,r")
8707         (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))
8708    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X,X"))]
8709   "TARGET_POWER && ! TARGET_POWERPC64
8710    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8711   "*
8712 {
8713   switch (which_alternative)
8714     {
8715     default:
8716       abort ();
8717
8718     case 0:
8719       if (TARGET_STRING)
8720         return \"{stsi|stswi} %1,%P0,16\";
8721     case 1:
8722     case 2:
8723       return \"#\";
8724     case 3:
8725       /* If the address is not used in the output, we can use lsi.  Otherwise,
8726          fall through to generating four loads.  */
8727       if (TARGET_STRING
8728           && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8729         return \"{lsi|lswi} %0,%P1,16\";
8730       /* ... fall through ...  */
8731     case 4:
8732     case 5:
8733       return \"#\";
8734     }
8735 }"
8736   [(set_attr "type" "store,store,*,load,load,*")])
8737
8738 (define_insn "*movti_string"
8739   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,o<>,????r,????r,????r,r")
8740         (match_operand:TI 1 "input_operand" "r,r,r,Q,m,n"))]
8741   "! TARGET_POWER && ! TARGET_POWERPC64
8742    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8743   "*
8744 {
8745   switch (which_alternative)
8746     {
8747     default:
8748       abort ();
8749     case 0:
8750       if (TARGET_STRING)
8751         return \"{stsi|stswi} %1,%P0,16\";
8752     case 1:
8753     case 2:
8754       return \"#\";
8755     case 3:
8756       /* If the address is not used in the output, we can use lsi.  Otherwise,
8757          fall through to generating four loads.  */
8758       if (TARGET_STRING
8759           && ! reg_overlap_mentioned_p (operands[0], operands[1]))
8760         return \"{lsi|lswi} %0,%P1,16\";
8761       /* ... fall through ...  */
8762     case 4:
8763     case 5:
8764       return \"#\";
8765     }
8766 }"
8767   [(set_attr "type" "store,store,*,load,load,*")])
8768
8769 (define_insn "*movti_ppc64"
8770   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,o<>,r")
8771         (match_operand:TI 1 "input_operand" "r,r,m"))]
8772   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8773    || gpc_reg_operand (operands[1], TImode))"
8774   "#"
8775   [(set_attr "type" "*,load,store")])
8776
8777 (define_split
8778   [(set (match_operand:TI 0 "gpc_reg_operand" "")
8779         (match_operand:TI 1 "const_double_operand" ""))]
8780   "TARGET_POWERPC64"
8781   [(set (match_dup 2) (match_dup 4))
8782    (set (match_dup 3) (match_dup 5))]
8783   "
8784 {
8785   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8786                                        TImode);
8787   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8788                                        TImode);
8789   if (GET_CODE (operands[1]) == CONST_DOUBLE)
8790     {
8791       operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8792       operands[5] = GEN_INT (CONST_DOUBLE_LOW (operands[1]));
8793     }
8794   else if (GET_CODE (operands[1]) == CONST_INT)
8795     {
8796       operands[4] = GEN_INT (- (INTVAL (operands[1]) < 0));
8797       operands[5] = operands[1];
8798     }
8799   else
8800     FAIL;
8801 }")
8802
8803 (define_split
8804   [(set (match_operand:TI 0 "nonimmediate_operand" "")
8805         (match_operand:TI 1 "input_operand" ""))]
8806   "reload_completed
8807    && gpr_or_gpr_p (operands[0], operands[1])"
8808   [(pc)]
8809 { rs6000_split_multireg_move (operands[0], operands[1]); DONE; })
8810 \f
8811 (define_expand "load_multiple"
8812   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8813                           (match_operand:SI 1 "" ""))
8814                      (use (match_operand:SI 2 "" ""))])]
8815   "TARGET_STRING && !TARGET_POWERPC64"
8816   "
8817 {
8818   int regno;
8819   int count;
8820   rtx op1;
8821   int i;
8822
8823   /* Support only loading a constant number of fixed-point registers from
8824      memory and only bother with this if more than two; the machine
8825      doesn't support more than eight.  */
8826   if (GET_CODE (operands[2]) != CONST_INT
8827       || INTVAL (operands[2]) <= 2
8828       || INTVAL (operands[2]) > 8
8829       || GET_CODE (operands[1]) != MEM
8830       || GET_CODE (operands[0]) != REG
8831       || REGNO (operands[0]) >= 32)
8832     FAIL;
8833
8834   count = INTVAL (operands[2]);
8835   regno = REGNO (operands[0]);
8836
8837   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8838   op1 = replace_equiv_address (operands[1],
8839                                force_reg (SImode, XEXP (operands[1], 0)));
8840
8841   for (i = 0; i < count; i++)
8842     XVECEXP (operands[3], 0, i)
8843       = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8844                      adjust_address_nv (op1, SImode, i * 4));
8845 }")
8846
8847 (define_insn "*ldmsi8"
8848   [(match_parallel 0 "load_multiple_operation"
8849     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8850           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8851      (set (match_operand:SI 3 "gpc_reg_operand" "")
8852           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8853      (set (match_operand:SI 4 "gpc_reg_operand" "")
8854           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8855      (set (match_operand:SI 5 "gpc_reg_operand" "")
8856           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8857      (set (match_operand:SI 6 "gpc_reg_operand" "")
8858           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8859      (set (match_operand:SI 7 "gpc_reg_operand" "")
8860           (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8861      (set (match_operand:SI 8 "gpc_reg_operand" "")
8862           (mem:SI (plus:SI (match_dup 1) (const_int 24))))
8863      (set (match_operand:SI 9 "gpc_reg_operand" "")
8864           (mem:SI (plus:SI (match_dup 1) (const_int 28))))])]
8865   "TARGET_STRING && XVECLEN (operands[0], 0) == 8"
8866   "*
8867 { return rs6000_output_load_multiple (operands); }"
8868   [(set_attr "type" "load")
8869    (set_attr "length" "32")])
8870
8871 (define_insn "*ldmsi7"
8872   [(match_parallel 0 "load_multiple_operation"
8873     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8874           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8875      (set (match_operand:SI 3 "gpc_reg_operand" "")
8876           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8877      (set (match_operand:SI 4 "gpc_reg_operand" "")
8878           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8879      (set (match_operand:SI 5 "gpc_reg_operand" "")
8880           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8881      (set (match_operand:SI 6 "gpc_reg_operand" "")
8882           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8883      (set (match_operand:SI 7 "gpc_reg_operand" "")
8884           (mem:SI (plus:SI (match_dup 1) (const_int 20))))
8885      (set (match_operand:SI 8 "gpc_reg_operand" "")
8886           (mem:SI (plus:SI (match_dup 1) (const_int 24))))])]
8887   "TARGET_STRING && XVECLEN (operands[0], 0) == 7"
8888   "*
8889 { return rs6000_output_load_multiple (operands); }"
8890   [(set_attr "type" "load")
8891    (set_attr "length" "32")])
8892
8893 (define_insn "*ldmsi6"
8894   [(match_parallel 0 "load_multiple_operation"
8895     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8896           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8897      (set (match_operand:SI 3 "gpc_reg_operand" "")
8898           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8899      (set (match_operand:SI 4 "gpc_reg_operand" "")
8900           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8901      (set (match_operand:SI 5 "gpc_reg_operand" "")
8902           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8903      (set (match_operand:SI 6 "gpc_reg_operand" "")
8904           (mem:SI (plus:SI (match_dup 1) (const_int 16))))
8905      (set (match_operand:SI 7 "gpc_reg_operand" "")
8906           (mem:SI (plus:SI (match_dup 1) (const_int 20))))])]
8907   "TARGET_STRING && XVECLEN (operands[0], 0) == 6"
8908   "*
8909 { return rs6000_output_load_multiple (operands); }"
8910   [(set_attr "type" "load")
8911    (set_attr "length" "32")])
8912
8913 (define_insn "*ldmsi5"
8914   [(match_parallel 0 "load_multiple_operation"
8915     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8916           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8917      (set (match_operand:SI 3 "gpc_reg_operand" "")
8918           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8919      (set (match_operand:SI 4 "gpc_reg_operand" "")
8920           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8921      (set (match_operand:SI 5 "gpc_reg_operand" "")
8922           (mem:SI (plus:SI (match_dup 1) (const_int 12))))
8923      (set (match_operand:SI 6 "gpc_reg_operand" "")
8924           (mem:SI (plus:SI (match_dup 1) (const_int 16))))])]
8925   "TARGET_STRING && XVECLEN (operands[0], 0) == 5"
8926   "*
8927 { return rs6000_output_load_multiple (operands); }"
8928   [(set_attr "type" "load")
8929    (set_attr "length" "32")])
8930
8931 (define_insn "*ldmsi4"
8932   [(match_parallel 0 "load_multiple_operation"
8933     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8934           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8935      (set (match_operand:SI 3 "gpc_reg_operand" "")
8936           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8937      (set (match_operand:SI 4 "gpc_reg_operand" "")
8938           (mem:SI (plus:SI (match_dup 1) (const_int 8))))
8939      (set (match_operand:SI 5 "gpc_reg_operand" "")
8940           (mem:SI (plus:SI (match_dup 1) (const_int 12))))])]
8941   "TARGET_STRING && XVECLEN (operands[0], 0) == 4"
8942   "*
8943 { return rs6000_output_load_multiple (operands); }"
8944   [(set_attr "type" "load")
8945    (set_attr "length" "32")])
8946
8947 (define_insn "*ldmsi3"
8948   [(match_parallel 0 "load_multiple_operation"
8949     [(set (match_operand:SI 2 "gpc_reg_operand" "")
8950           (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
8951      (set (match_operand:SI 3 "gpc_reg_operand" "")
8952           (mem:SI (plus:SI (match_dup 1) (const_int 4))))
8953      (set (match_operand:SI 4 "gpc_reg_operand" "")
8954           (mem:SI (plus:SI (match_dup 1) (const_int 8))))])]
8955   "TARGET_STRING && XVECLEN (operands[0], 0) == 3"
8956   "*
8957 { return rs6000_output_load_multiple (operands); }"
8958   [(set_attr "type" "load")
8959    (set_attr "length" "32")])
8960
8961 (define_expand "store_multiple"
8962   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8963                           (match_operand:SI 1 "" ""))
8964                      (clobber (scratch:SI))
8965                      (use (match_operand:SI 2 "" ""))])]
8966   "TARGET_STRING && !TARGET_POWERPC64"
8967   "
8968 {
8969   int regno;
8970   int count;
8971   rtx to;
8972   rtx op0;
8973   int i;
8974
8975   /* Support only storing a constant number of fixed-point registers to
8976      memory and only bother with this if more than two; the machine
8977      doesn't support more than eight.  */
8978   if (GET_CODE (operands[2]) != CONST_INT
8979       || INTVAL (operands[2]) <= 2
8980       || INTVAL (operands[2]) > 8
8981       || GET_CODE (operands[0]) != MEM
8982       || GET_CODE (operands[1]) != REG
8983       || REGNO (operands[1]) >= 32)
8984     FAIL;
8985
8986   count = INTVAL (operands[2]);
8987   regno = REGNO (operands[1]);
8988
8989   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8990   to = force_reg (SImode, XEXP (operands[0], 0));
8991   op0 = replace_equiv_address (operands[0], to);
8992
8993   XVECEXP (operands[3], 0, 0)
8994     = gen_rtx_SET (VOIDmode, adjust_address_nv (op0, SImode, 0), operands[1]);
8995   XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8996                                                  gen_rtx_SCRATCH (SImode));
8997
8998   for (i = 1; i < count; i++)
8999     XVECEXP (operands[3], 0, i + 1)
9000       = gen_rtx_SET (VOIDmode,
9001                      adjust_address_nv (op0, SImode, i * 4),
9002                      gen_rtx_REG (SImode, regno + i));
9003 }")
9004
9005 (define_insn "*store_multiple_power"
9006   [(match_parallel 0 "store_multiple_operation"
9007                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
9008                          (match_operand:SI 2 "gpc_reg_operand" "r"))
9009                     (clobber (match_scratch:SI 3 "=q"))])]
9010   "TARGET_STRING && TARGET_POWER"
9011   "{stsi|stswi} %2,%P1,%O0"
9012   [(set_attr "type" "store")])
9013
9014 (define_insn "*stmsi8"
9015   [(match_parallel 0 "store_multiple_operation"
9016     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9017           (match_operand:SI 2 "gpc_reg_operand" "r"))
9018      (clobber (match_scratch:SI 3 "X"))
9019      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9020           (match_operand:SI 4 "gpc_reg_operand" "r"))
9021      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9022           (match_operand:SI 5 "gpc_reg_operand" "r"))
9023      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9024           (match_operand:SI 6 "gpc_reg_operand" "r"))
9025      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9026           (match_operand:SI 7 "gpc_reg_operand" "r"))
9027      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9028           (match_operand:SI 8 "gpc_reg_operand" "r"))
9029      (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9030           (match_operand:SI 9 "gpc_reg_operand" "r"))
9031      (set (mem:SI (plus:SI (match_dup 1) (const_int 28)))
9032           (match_operand:SI 10 "gpc_reg_operand" "r"))])]
9033   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 9"
9034   "{stsi|stswi} %2,%1,%O0"
9035   [(set_attr "type" "store")])
9036
9037 (define_insn "*stmsi7"
9038   [(match_parallel 0 "store_multiple_operation"
9039     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9040           (match_operand:SI 2 "gpc_reg_operand" "r"))
9041      (clobber (match_scratch:SI 3 "X"))
9042      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9043           (match_operand:SI 4 "gpc_reg_operand" "r"))
9044      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9045           (match_operand:SI 5 "gpc_reg_operand" "r"))
9046      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9047           (match_operand:SI 6 "gpc_reg_operand" "r"))
9048      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9049           (match_operand:SI 7 "gpc_reg_operand" "r"))
9050      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9051           (match_operand:SI 8 "gpc_reg_operand" "r"))
9052      (set (mem:SI (plus:SI (match_dup 1) (const_int 24)))
9053           (match_operand:SI 9 "gpc_reg_operand" "r"))])]
9054   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 8"
9055   "{stsi|stswi} %2,%1,%O0"
9056   [(set_attr "type" "store")])
9057
9058 (define_insn "*stmsi6"
9059   [(match_parallel 0 "store_multiple_operation"
9060     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9061           (match_operand:SI 2 "gpc_reg_operand" "r"))
9062      (clobber (match_scratch:SI 3 "X"))
9063      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9064           (match_operand:SI 4 "gpc_reg_operand" "r"))
9065      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9066           (match_operand:SI 5 "gpc_reg_operand" "r"))
9067      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9068           (match_operand:SI 6 "gpc_reg_operand" "r"))
9069      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9070           (match_operand:SI 7 "gpc_reg_operand" "r"))
9071      (set (mem:SI (plus:SI (match_dup 1) (const_int 20)))
9072           (match_operand:SI 8 "gpc_reg_operand" "r"))])]
9073   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 7"
9074   "{stsi|stswi} %2,%1,%O0"
9075   [(set_attr "type" "store")])
9076
9077 (define_insn "*stmsi5"
9078   [(match_parallel 0 "store_multiple_operation"
9079     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9080           (match_operand:SI 2 "gpc_reg_operand" "r"))
9081      (clobber (match_scratch:SI 3 "X"))
9082      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9083           (match_operand:SI 4 "gpc_reg_operand" "r"))
9084      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9085           (match_operand:SI 5 "gpc_reg_operand" "r"))
9086      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9087           (match_operand:SI 6 "gpc_reg_operand" "r"))
9088      (set (mem:SI (plus:SI (match_dup 1) (const_int 16)))
9089           (match_operand:SI 7 "gpc_reg_operand" "r"))])]
9090   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 6"
9091   "{stsi|stswi} %2,%1,%O0"
9092   [(set_attr "type" "store")])
9093
9094 (define_insn "*stmsi4"
9095   [(match_parallel 0 "store_multiple_operation"
9096     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9097           (match_operand:SI 2 "gpc_reg_operand" "r"))
9098      (clobber (match_scratch:SI 3 "X"))
9099      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9100           (match_operand:SI 4 "gpc_reg_operand" "r"))
9101      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9102           (match_operand:SI 5 "gpc_reg_operand" "r"))
9103      (set (mem:SI (plus:SI (match_dup 1) (const_int 12)))
9104           (match_operand:SI 6 "gpc_reg_operand" "r"))])]
9105   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 5"
9106   "{stsi|stswi} %2,%1,%O0"
9107   [(set_attr "type" "store")])
9108
9109 (define_insn "*stmsi3"
9110   [(match_parallel 0 "store_multiple_operation"
9111     [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9112           (match_operand:SI 2 "gpc_reg_operand" "r"))
9113      (clobber (match_scratch:SI 3 "X"))
9114      (set (mem:SI (plus:SI (match_dup 1) (const_int 4)))
9115           (match_operand:SI 4 "gpc_reg_operand" "r"))
9116      (set (mem:SI (plus:SI (match_dup 1) (const_int 8)))
9117           (match_operand:SI 5 "gpc_reg_operand" "r"))])]
9118   "TARGET_STRING && !TARGET_POWER && XVECLEN (operands[0], 0) == 4"
9119   "{stsi|stswi} %2,%1,%O0"
9120   [(set_attr "type" "store")])
9121 \f
9122 (define_expand "clrmemsi"
9123   [(parallel [(set (match_operand:BLK 0 "" "")
9124                    (const_int 0))
9125               (use (match_operand:SI 1 "" ""))
9126               (use (match_operand:SI 2 "" ""))])]
9127   ""
9128   "
9129 {
9130   if (expand_block_clear (operands))
9131     DONE;
9132   else
9133     FAIL;
9134 }")
9135
9136 ;; String/block move insn.
9137 ;; Argument 0 is the destination
9138 ;; Argument 1 is the source
9139 ;; Argument 2 is the length
9140 ;; Argument 3 is the alignment
9141
9142 (define_expand "movmemsi"
9143   [(parallel [(set (match_operand:BLK 0 "" "")
9144                    (match_operand:BLK 1 "" ""))
9145               (use (match_operand:SI 2 "" ""))
9146               (use (match_operand:SI 3 "" ""))])]
9147   ""
9148   "
9149 {
9150   if (expand_block_move (operands))
9151     DONE;
9152   else
9153     FAIL;
9154 }")
9155
9156 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
9157 ;; register allocator doesn't have a clue about allocating 8 word registers.
9158 ;; rD/rS = r5 is preferred, efficient form.
9159 (define_expand "movmemsi_8reg"
9160   [(parallel [(set (match_operand 0 "" "")
9161                    (match_operand 1 "" ""))
9162               (use (match_operand 2 "" ""))
9163               (use (match_operand 3 "" ""))
9164               (clobber (reg:SI  5))
9165               (clobber (reg:SI  6))
9166               (clobber (reg:SI  7))
9167               (clobber (reg:SI  8))
9168               (clobber (reg:SI  9))
9169               (clobber (reg:SI 10))
9170               (clobber (reg:SI 11))
9171               (clobber (reg:SI 12))
9172               (clobber (match_scratch:SI 4 ""))])]
9173   "TARGET_STRING"
9174   "")
9175
9176 (define_insn ""
9177   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9178         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9179    (use (match_operand:SI 2 "immediate_operand" "i"))
9180    (use (match_operand:SI 3 "immediate_operand" "i"))
9181    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9182    (clobber (reg:SI  6))
9183    (clobber (reg:SI  7))
9184    (clobber (reg:SI  8))
9185    (clobber (reg:SI  9))
9186    (clobber (reg:SI 10))
9187    (clobber (reg:SI 11))
9188    (clobber (reg:SI 12))
9189    (clobber (match_scratch:SI 5 "=q"))]
9190   "TARGET_STRING && TARGET_POWER
9191    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9192        || INTVAL (operands[2]) == 0)
9193    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9194    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9195    && REGNO (operands[4]) == 5"
9196   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9197   [(set_attr "type" "load")
9198    (set_attr "length" "8")])
9199
9200 (define_insn ""
9201   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9202         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9203    (use (match_operand:SI 2 "immediate_operand" "i"))
9204    (use (match_operand:SI 3 "immediate_operand" "i"))
9205    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9206    (clobber (reg:SI  6))
9207    (clobber (reg:SI  7))
9208    (clobber (reg:SI  8))
9209    (clobber (reg:SI  9))
9210    (clobber (reg:SI 10))
9211    (clobber (reg:SI 11))
9212    (clobber (reg:SI 12))
9213    (clobber (match_scratch:SI 5 "X"))]
9214   "TARGET_STRING && ! TARGET_POWER
9215    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9216        || INTVAL (operands[2]) == 0)
9217    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9218    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9219    && REGNO (operands[4]) == 5"
9220   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9221   [(set_attr "type" "load")
9222    (set_attr "length" "8")])
9223
9224 (define_insn ""
9225   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9226         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9227    (use (match_operand:SI 2 "immediate_operand" "i"))
9228    (use (match_operand:SI 3 "immediate_operand" "i"))
9229    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9230    (clobber (reg:SI  6))
9231    (clobber (reg:SI  7))
9232    (clobber (reg:SI  8))
9233    (clobber (reg:SI  9))
9234    (clobber (reg:SI 10))
9235    (clobber (reg:SI 11))
9236    (clobber (reg:SI 12))
9237    (clobber (match_scratch:SI 5 "X"))]
9238   "TARGET_STRING && TARGET_POWERPC64
9239    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9240        || INTVAL (operands[2]) == 0)
9241    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9242    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9243    && REGNO (operands[4]) == 5"
9244   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9245   [(set_attr "type" "load")
9246    (set_attr "length" "8")])
9247
9248 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
9249 ;; register allocator doesn't have a clue about allocating 6 word registers.
9250 ;; rD/rS = r5 is preferred, efficient form.
9251 (define_expand "movmemsi_6reg"
9252   [(parallel [(set (match_operand 0 "" "")
9253                    (match_operand 1 "" ""))
9254               (use (match_operand 2 "" ""))
9255               (use (match_operand 3 "" ""))
9256               (clobber (reg:SI  5))
9257               (clobber (reg:SI  6))
9258               (clobber (reg:SI  7))
9259               (clobber (reg:SI  8))
9260               (clobber (reg:SI  9))
9261               (clobber (reg:SI 10))
9262               (clobber (match_scratch:SI 4 ""))])]
9263   "TARGET_STRING"
9264   "")
9265
9266 (define_insn ""
9267   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9268         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9269    (use (match_operand:SI 2 "immediate_operand" "i"))
9270    (use (match_operand:SI 3 "immediate_operand" "i"))
9271    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9272    (clobber (reg:SI  6))
9273    (clobber (reg:SI  7))
9274    (clobber (reg:SI  8))
9275    (clobber (reg:SI  9))
9276    (clobber (reg:SI 10))
9277    (clobber (match_scratch:SI 5 "=q"))]
9278   "TARGET_STRING && TARGET_POWER
9279    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
9280    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9281    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9282    && REGNO (operands[4]) == 5"
9283   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9284   [(set_attr "type" "load")
9285    (set_attr "length" "8")])
9286
9287 (define_insn ""
9288   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9289         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9290    (use (match_operand:SI 2 "immediate_operand" "i"))
9291    (use (match_operand:SI 3 "immediate_operand" "i"))
9292    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9293    (clobber (reg:SI  6))
9294    (clobber (reg:SI  7))
9295    (clobber (reg:SI  8))
9296    (clobber (reg:SI  9))
9297    (clobber (reg:SI 10))
9298    (clobber (match_scratch:SI 5 "X"))]
9299   "TARGET_STRING && ! TARGET_POWER
9300    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9301    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9302    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9303    && REGNO (operands[4]) == 5"
9304   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9305   [(set_attr "type" "load")
9306    (set_attr "length" "8")])
9307
9308 (define_insn ""
9309   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9310         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9311    (use (match_operand:SI 2 "immediate_operand" "i"))
9312    (use (match_operand:SI 3 "immediate_operand" "i"))
9313    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9314    (clobber (reg:SI  6))
9315    (clobber (reg:SI  7))
9316    (clobber (reg:SI  8))
9317    (clobber (reg:SI  9))
9318    (clobber (reg:SI 10))
9319    (clobber (match_scratch:SI 5 "X"))]
9320   "TARGET_STRING && TARGET_POWERPC64
9321    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9322    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9323    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9324    && REGNO (operands[4]) == 5"
9325   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9326   [(set_attr "type" "load")
9327    (set_attr "length" "8")])
9328
9329 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9330 ;; problems with TImode.
9331 ;; rD/rS = r5 is preferred, efficient form.
9332 (define_expand "movmemsi_4reg"
9333   [(parallel [(set (match_operand 0 "" "")
9334                    (match_operand 1 "" ""))
9335               (use (match_operand 2 "" ""))
9336               (use (match_operand 3 "" ""))
9337               (clobber (reg:SI 5))
9338               (clobber (reg:SI 6))
9339               (clobber (reg:SI 7))
9340               (clobber (reg:SI 8))
9341               (clobber (match_scratch:SI 4 ""))])]
9342   "TARGET_STRING"
9343   "")
9344
9345 (define_insn ""
9346   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9347         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9348    (use (match_operand:SI 2 "immediate_operand" "i"))
9349    (use (match_operand:SI 3 "immediate_operand" "i"))
9350    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9351    (clobber (reg:SI 6))
9352    (clobber (reg:SI 7))
9353    (clobber (reg:SI 8))
9354    (clobber (match_scratch:SI 5 "=q"))]
9355   "TARGET_STRING && TARGET_POWER
9356    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9357    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9358    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9359    && REGNO (operands[4]) == 5"
9360   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9361   [(set_attr "type" "load")
9362    (set_attr "length" "8")])
9363
9364 (define_insn ""
9365   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9366         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9367    (use (match_operand:SI 2 "immediate_operand" "i"))
9368    (use (match_operand:SI 3 "immediate_operand" "i"))
9369    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9370    (clobber (reg:SI 6))
9371    (clobber (reg:SI 7))
9372    (clobber (reg:SI 8))
9373    (clobber (match_scratch:SI 5 "X"))]
9374   "TARGET_STRING && ! TARGET_POWER
9375    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9376    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9377    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9378    && REGNO (operands[4]) == 5"
9379   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9380   [(set_attr "type" "load")
9381    (set_attr "length" "8")])
9382
9383 (define_insn ""
9384   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9385         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9386    (use (match_operand:SI 2 "immediate_operand" "i"))
9387    (use (match_operand:SI 3 "immediate_operand" "i"))
9388    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9389    (clobber (reg:SI 6))
9390    (clobber (reg:SI 7))
9391    (clobber (reg:SI 8))
9392    (clobber (match_scratch:SI 5 "X"))]
9393   "TARGET_STRING && TARGET_POWERPC64
9394    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9395    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9396    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9397    && REGNO (operands[4]) == 5"
9398   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9399   [(set_attr "type" "load")
9400    (set_attr "length" "8")])
9401
9402 ;; Move up to 8 bytes at a time.
9403 (define_expand "movmemsi_2reg"
9404   [(parallel [(set (match_operand 0 "" "")
9405                    (match_operand 1 "" ""))
9406               (use (match_operand 2 "" ""))
9407               (use (match_operand 3 "" ""))
9408               (clobber (match_scratch:DI 4 ""))
9409               (clobber (match_scratch:SI 5 ""))])]
9410   "TARGET_STRING && ! TARGET_POWERPC64"
9411   "")
9412
9413 (define_insn ""
9414   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9415         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9416    (use (match_operand:SI 2 "immediate_operand" "i"))
9417    (use (match_operand:SI 3 "immediate_operand" "i"))
9418    (clobber (match_scratch:DI 4 "=&r"))
9419    (clobber (match_scratch:SI 5 "=q"))]
9420   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9421    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9422   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9423   [(set_attr "type" "load")
9424    (set_attr "length" "8")])
9425
9426 (define_insn ""
9427   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9428         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9429    (use (match_operand:SI 2 "immediate_operand" "i"))
9430    (use (match_operand:SI 3 "immediate_operand" "i"))
9431    (clobber (match_scratch:DI 4 "=&r"))
9432    (clobber (match_scratch:SI 5 "X"))]
9433   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9434    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9435   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9436   [(set_attr "type" "load")
9437    (set_attr "length" "8")])
9438
9439 ;; Move up to 4 bytes at a time.
9440 (define_expand "movmemsi_1reg"
9441   [(parallel [(set (match_operand 0 "" "")
9442                    (match_operand 1 "" ""))
9443               (use (match_operand 2 "" ""))
9444               (use (match_operand 3 "" ""))
9445               (clobber (match_scratch:SI 4 ""))
9446               (clobber (match_scratch:SI 5 ""))])]
9447   "TARGET_STRING"
9448   "")
9449
9450 (define_insn ""
9451   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9452         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9453    (use (match_operand:SI 2 "immediate_operand" "i"))
9454    (use (match_operand:SI 3 "immediate_operand" "i"))
9455    (clobber (match_scratch:SI 4 "=&r"))
9456    (clobber (match_scratch:SI 5 "=q"))]
9457   "TARGET_STRING && TARGET_POWER
9458    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9459   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9460   [(set_attr "type" "load")
9461    (set_attr "length" "8")])
9462
9463 (define_insn ""
9464   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9465         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9466    (use (match_operand:SI 2 "immediate_operand" "i"))
9467    (use (match_operand:SI 3 "immediate_operand" "i"))
9468    (clobber (match_scratch:SI 4 "=&r"))
9469    (clobber (match_scratch:SI 5 "X"))]
9470   "TARGET_STRING && ! TARGET_POWER
9471    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9472   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9473   [(set_attr "type" "load")
9474    (set_attr "length" "8")])
9475
9476 (define_insn ""
9477   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9478         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9479    (use (match_operand:SI 2 "immediate_operand" "i"))
9480    (use (match_operand:SI 3 "immediate_operand" "i"))
9481    (clobber (match_scratch:SI 4 "=&r"))
9482    (clobber (match_scratch:SI 5 "X"))]
9483   "TARGET_STRING && TARGET_POWERPC64
9484    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9485   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9486   [(set_attr "type" "load")
9487    (set_attr "length" "8")])
9488
9489 \f
9490 ;; Define insns that do load or store with update.  Some of these we can
9491 ;; get by using pre-decrement or pre-increment, but the hardware can also
9492 ;; do cases where the increment is not the size of the object.
9493 ;;
9494 ;; In all these cases, we use operands 0 and 1 for the register being
9495 ;; incremented because those are the operands that local-alloc will
9496 ;; tie and these are the pair most likely to be tieable (and the ones
9497 ;; that will benefit the most).
9498
9499 (define_insn "*movdi_update1"
9500   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9501         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9502                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9503    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9504         (plus:DI (match_dup 1) (match_dup 2)))]
9505   "TARGET_POWERPC64 && TARGET_UPDATE"
9506   "@
9507    ldux %3,%0,%2
9508    ldu %3,%2(%0)"
9509   [(set_attr "type" "load_ux,load_u")])
9510
9511 (define_insn "movdi_<mode>_update"
9512   [(set (mem:DI (plus:P (match_operand:P 1 "gpc_reg_operand" "0,0")
9513                          (match_operand:P 2 "reg_or_aligned_short_operand" "r,I")))
9514         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9515    (set (match_operand:P 0 "gpc_reg_operand" "=b,b")
9516         (plus:P (match_dup 1) (match_dup 2)))]
9517   "TARGET_POWERPC64 && TARGET_UPDATE"
9518   "@
9519    stdux %3,%0,%2
9520    stdu %3,%2(%0)"
9521   [(set_attr "type" "store_ux,store_u")])
9522
9523 (define_insn "*movsi_update1"
9524   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9525         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9526                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9527    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9528         (plus:SI (match_dup 1) (match_dup 2)))]
9529   "TARGET_UPDATE"
9530   "@
9531    {lux|lwzux} %3,%0,%2
9532    {lu|lwzu} %3,%2(%0)"
9533   [(set_attr "type" "load_ux,load_u")])
9534
9535 (define_insn "*movsi_update2"
9536   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9537         (sign_extend:DI
9538          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9539                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
9540    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9541         (plus:DI (match_dup 1) (match_dup 2)))]
9542   "TARGET_POWERPC64"
9543   "lwaux %3,%0,%2"
9544   [(set_attr "type" "load_ext_ux")])
9545
9546 (define_insn "movsi_update"
9547   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9548                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9549         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9550    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9551         (plus:SI (match_dup 1) (match_dup 2)))]
9552   "TARGET_UPDATE"
9553   "@
9554    {stux|stwux} %3,%0,%2
9555    {stu|stwu} %3,%2(%0)"
9556   [(set_attr "type" "store_ux,store_u")])
9557
9558 (define_insn "*movhi_update1"
9559   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9560         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9561                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9562    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9563         (plus:SI (match_dup 1) (match_dup 2)))]
9564   "TARGET_UPDATE"
9565   "@
9566    lhzux %3,%0,%2
9567    lhzu %3,%2(%0)"
9568   [(set_attr "type" "load_ux,load_u")])
9569
9570 (define_insn "*movhi_update2"
9571   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9572         (zero_extend:SI
9573          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9574                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9575    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9576         (plus:SI (match_dup 1) (match_dup 2)))]
9577   "TARGET_UPDATE"
9578   "@
9579    lhzux %3,%0,%2
9580    lhzu %3,%2(%0)"
9581   [(set_attr "type" "load_ux,load_u")])
9582
9583 (define_insn "*movhi_update3"
9584   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9585         (sign_extend:SI
9586          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9587                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9588    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9589         (plus:SI (match_dup 1) (match_dup 2)))]
9590   "TARGET_UPDATE"
9591   "@
9592    lhaux %3,%0,%2
9593    lhau %3,%2(%0)"
9594   [(set_attr "type" "load_ext_ux,load_ext_u")])
9595
9596 (define_insn "*movhi_update4"
9597   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9598                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9599         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9600    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9601         (plus:SI (match_dup 1) (match_dup 2)))]
9602   "TARGET_UPDATE"
9603   "@
9604    sthux %3,%0,%2
9605    sthu %3,%2(%0)"
9606   [(set_attr "type" "store_ux,store_u")])
9607
9608 (define_insn "*movqi_update1"
9609   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9610         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9611                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9612    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9613         (plus:SI (match_dup 1) (match_dup 2)))]
9614   "TARGET_UPDATE"
9615   "@
9616    lbzux %3,%0,%2
9617    lbzu %3,%2(%0)"
9618   [(set_attr "type" "load_ux,load_u")])
9619
9620 (define_insn "*movqi_update2"
9621   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9622         (zero_extend:SI
9623          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9624                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9625    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9626         (plus:SI (match_dup 1) (match_dup 2)))]
9627   "TARGET_UPDATE"
9628   "@
9629    lbzux %3,%0,%2
9630    lbzu %3,%2(%0)"
9631   [(set_attr "type" "load_ux,load_u")])
9632
9633 (define_insn "*movqi_update3"
9634   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9635                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9636         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9637    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9638         (plus:SI (match_dup 1) (match_dup 2)))]
9639   "TARGET_UPDATE"
9640   "@
9641    stbux %3,%0,%2
9642    stbu %3,%2(%0)"
9643   [(set_attr "type" "store_ux,store_u")])
9644
9645 (define_insn "*movsf_update1"
9646   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9647         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9648                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9649    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9650         (plus:SI (match_dup 1) (match_dup 2)))]
9651   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9652   "@
9653    lfsux %3,%0,%2
9654    lfsu %3,%2(%0)"
9655   [(set_attr "type" "fpload_ux,fpload_u")])
9656
9657 (define_insn "*movsf_update2"
9658   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9659                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9660         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9661    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9662         (plus:SI (match_dup 1) (match_dup 2)))]
9663   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9664   "@
9665    stfsux %3,%0,%2
9666    stfsu %3,%2(%0)"
9667   [(set_attr "type" "fpstore_ux,fpstore_u")])
9668
9669 (define_insn "*movsf_update3"
9670   [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9671         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9672                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9673    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9674         (plus:SI (match_dup 1) (match_dup 2)))]
9675   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9676   "@
9677    {lux|lwzux} %3,%0,%2
9678    {lu|lwzu} %3,%2(%0)"
9679   [(set_attr "type" "load_ux,load_u")])
9680
9681 (define_insn "*movsf_update4"
9682   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9683                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9684         (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9685    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9686         (plus:SI (match_dup 1) (match_dup 2)))]
9687   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9688   "@
9689    {stux|stwux} %3,%0,%2
9690    {stu|stwu} %3,%2(%0)"
9691   [(set_attr "type" "store_ux,store_u")])
9692
9693 (define_insn "*movdf_update1"
9694   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9695         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9696                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9697    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9698         (plus:SI (match_dup 1) (match_dup 2)))]
9699   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9700   "@
9701    lfdux %3,%0,%2
9702    lfdu %3,%2(%0)"
9703   [(set_attr "type" "fpload_ux,fpload_u")])
9704
9705 (define_insn "*movdf_update2"
9706   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9707                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9708         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9709    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9710         (plus:SI (match_dup 1) (match_dup 2)))]
9711   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9712   "@
9713    stfdux %3,%0,%2
9714    stfdu %3,%2(%0)"
9715   [(set_attr "type" "fpstore_ux,fpstore_u")])
9716
9717 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9718
9719 (define_insn "*lfq_power2"
9720   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
9721         (match_operand:TF 1 "memory_operand" ""))]
9722   "TARGET_POWER2
9723    && TARGET_HARD_FLOAT && TARGET_FPRS"
9724    "lfq%U1%X1 %0,%1")
9725
9726 (define_peephole2
9727   [(set (match_operand:DF 0 "gpc_reg_operand" "")
9728         (match_operand:DF 1 "memory_operand" ""))
9729    (set (match_operand:DF 2 "gpc_reg_operand" "")
9730         (match_operand:DF 3 "memory_operand" ""))]
9731   "TARGET_POWER2
9732    && TARGET_HARD_FLOAT && TARGET_FPRS
9733    && registers_ok_for_quad_peep (operands[0], operands[2])
9734    && mems_ok_for_quad_peep (operands[1], operands[3])"
9735   [(set (match_dup 0)
9736         (match_dup 1))]
9737   "operands[1] = widen_memory_access (operands[1], TFmode, 0);
9738    operands[0] = gen_rtx_REG (TFmode, REGNO (operands[0]));")
9739
9740 (define_insn "*stfq_power2"
9741   [(set (match_operand:TF 0 "memory_operand" "")
9742         (match_operand:TF 1 "gpc_reg_operand" "f"))]
9743   "TARGET_POWER2
9744    && TARGET_HARD_FLOAT && TARGET_FPRS"
9745   "stfq%U0%X0 %1,%0")
9746
9747
9748 (define_peephole2
9749   [(set (match_operand:DF 0 "memory_operand" "")
9750         (match_operand:DF 1 "gpc_reg_operand" ""))
9751    (set (match_operand:DF 2 "memory_operand" "")
9752         (match_operand:DF 3 "gpc_reg_operand" ""))]
9753   "TARGET_POWER2
9754    && TARGET_HARD_FLOAT && TARGET_FPRS
9755    && registers_ok_for_quad_peep (operands[1], operands[3])
9756    && mems_ok_for_quad_peep (operands[0], operands[2])"
9757   [(set (match_dup 0)
9758         (match_dup 1))]
9759   "operands[0] = widen_memory_access (operands[0], TFmode, 0);
9760    operands[1] = gen_rtx_REG (TFmode, REGNO (operands[1]));")
9761
9762 ;; after inserting conditional returns we can sometimes have
9763 ;; unnecessary register moves.  Unfortunately we cannot have a
9764 ;; modeless peephole here, because some single SImode sets have early
9765 ;; clobber outputs.  Although those sets expand to multi-ppc-insn
9766 ;; sequences, using get_attr_length here will smash the operands
9767 ;; array.  Neither is there an early_cobbler_p predicate.
9768 (define_peephole2
9769   [(set (match_operand:DF 0 "gpc_reg_operand" "")
9770         (match_operand:DF 1 "any_operand" ""))
9771    (set (match_operand:DF 2 "gpc_reg_operand" "")
9772         (match_dup 0))]
9773   "peep2_reg_dead_p (2, operands[0])"
9774   [(set (match_dup 2) (match_dup 1))])
9775
9776 (define_peephole2
9777   [(set (match_operand:SF 0 "gpc_reg_operand" "")
9778         (match_operand:SF 1 "any_operand" ""))
9779    (set (match_operand:SF 2 "gpc_reg_operand" "")
9780         (match_dup 0))]
9781   "peep2_reg_dead_p (2, operands[0])"
9782   [(set (match_dup 2) (match_dup 1))])
9783
9784 \f
9785 ;; TLS support.
9786
9787 ;; "b" output constraint here and on tls_ld to support tls linker optimization.
9788 (define_insn "tls_gd_32"
9789   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9790         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9791                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9792                    UNSPEC_TLSGD))]
9793   "HAVE_AS_TLS && !TARGET_64BIT"
9794   "addi %0,%1,%2@got@tlsgd")
9795
9796 (define_insn "tls_gd_64"
9797   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9798         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9799                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9800                    UNSPEC_TLSGD))]
9801   "HAVE_AS_TLS && TARGET_64BIT"
9802   "addi %0,%1,%2@got@tlsgd")
9803
9804 (define_insn "tls_ld_32"
9805   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9806         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")]
9807                    UNSPEC_TLSLD))]
9808   "HAVE_AS_TLS && !TARGET_64BIT"
9809   "addi %0,%1,%&@got@tlsld")
9810
9811 (define_insn "tls_ld_64"
9812   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9813         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")]
9814                    UNSPEC_TLSLD))]
9815   "HAVE_AS_TLS && TARGET_64BIT"
9816   "addi %0,%1,%&@got@tlsld")
9817
9818 (define_insn "tls_dtprel_32"
9819   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9820         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9821                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9822                    UNSPEC_TLSDTPREL))]
9823   "HAVE_AS_TLS && !TARGET_64BIT"
9824   "addi %0,%1,%2@dtprel")
9825
9826 (define_insn "tls_dtprel_64"
9827   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9828         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9829                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9830                    UNSPEC_TLSDTPREL))]
9831   "HAVE_AS_TLS && TARGET_64BIT"
9832   "addi %0,%1,%2@dtprel")
9833
9834 (define_insn "tls_dtprel_ha_32"
9835   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9836         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9837                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9838                    UNSPEC_TLSDTPRELHA))]
9839   "HAVE_AS_TLS && !TARGET_64BIT"
9840   "addis %0,%1,%2@dtprel@ha")
9841
9842 (define_insn "tls_dtprel_ha_64"
9843   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9844         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9845                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9846                    UNSPEC_TLSDTPRELHA))]
9847   "HAVE_AS_TLS && TARGET_64BIT"
9848   "addis %0,%1,%2@dtprel@ha")
9849
9850 (define_insn "tls_dtprel_lo_32"
9851   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9852         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9853                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9854                    UNSPEC_TLSDTPRELLO))]
9855   "HAVE_AS_TLS && !TARGET_64BIT"
9856   "addi %0,%1,%2@dtprel@l")
9857
9858 (define_insn "tls_dtprel_lo_64"
9859   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9860         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9861                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9862                    UNSPEC_TLSDTPRELLO))]
9863   "HAVE_AS_TLS && TARGET_64BIT"
9864   "addi %0,%1,%2@dtprel@l")
9865
9866 (define_insn "tls_got_dtprel_32"
9867   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9868         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9869                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9870                    UNSPEC_TLSGOTDTPREL))]
9871   "HAVE_AS_TLS && !TARGET_64BIT"
9872   "lwz %0,%2@got@dtprel(%1)")
9873
9874 (define_insn "tls_got_dtprel_64"
9875   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9876         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9877                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9878                    UNSPEC_TLSGOTDTPREL))]
9879   "HAVE_AS_TLS && TARGET_64BIT"
9880   "ld %0,%2@got@dtprel(%1)")
9881
9882 (define_insn "tls_tprel_32"
9883   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9884         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9885                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9886                    UNSPEC_TLSTPREL))]
9887   "HAVE_AS_TLS && !TARGET_64BIT"
9888   "addi %0,%1,%2@tprel")
9889
9890 (define_insn "tls_tprel_64"
9891   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9892         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9893                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9894                    UNSPEC_TLSTPREL))]
9895   "HAVE_AS_TLS && TARGET_64BIT"
9896   "addi %0,%1,%2@tprel")
9897
9898 (define_insn "tls_tprel_ha_32"
9899   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9900         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9901                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9902                    UNSPEC_TLSTPRELHA))]
9903   "HAVE_AS_TLS && !TARGET_64BIT"
9904   "addis %0,%1,%2@tprel@ha")
9905
9906 (define_insn "tls_tprel_ha_64"
9907   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9908         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9909                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9910                    UNSPEC_TLSTPRELHA))]
9911   "HAVE_AS_TLS && TARGET_64BIT"
9912   "addis %0,%1,%2@tprel@ha")
9913
9914 (define_insn "tls_tprel_lo_32"
9915   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9916         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9917                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9918                    UNSPEC_TLSTPRELLO))]
9919   "HAVE_AS_TLS && !TARGET_64BIT"
9920   "addi %0,%1,%2@tprel@l")
9921
9922 (define_insn "tls_tprel_lo_64"
9923   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9924         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9925                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9926                    UNSPEC_TLSTPRELLO))]
9927   "HAVE_AS_TLS && TARGET_64BIT"
9928   "addi %0,%1,%2@tprel@l")
9929
9930 ;; "b" output constraint here and on tls_tls input to support linker tls
9931 ;; optimization.  The linker may edit the instructions emitted by a
9932 ;; tls_got_tprel/tls_tls pair to addis,addi.
9933 (define_insn "tls_got_tprel_32"
9934   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
9935         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9936                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9937                    UNSPEC_TLSGOTTPREL))]
9938   "HAVE_AS_TLS && !TARGET_64BIT"
9939   "lwz %0,%2@got@tprel(%1)")
9940
9941 (define_insn "tls_got_tprel_64"
9942   [(set (match_operand:DI 0 "gpc_reg_operand" "=b")
9943         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9944                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9945                    UNSPEC_TLSGOTTPREL))]
9946   "HAVE_AS_TLS && TARGET_64BIT"
9947   "ld %0,%2@got@tprel(%1)")
9948
9949 (define_insn "tls_tls_32"
9950   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9951         (unspec:SI [(match_operand:SI 1 "gpc_reg_operand" "b")
9952                     (match_operand:SI 2 "rs6000_tls_symbol_ref" "")]
9953                    UNSPEC_TLSTLS))]
9954   "HAVE_AS_TLS && !TARGET_64BIT"
9955   "add %0,%1,%2@tls")
9956
9957 (define_insn "tls_tls_64"
9958   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9959         (unspec:DI [(match_operand:DI 1 "gpc_reg_operand" "b")
9960                     (match_operand:DI 2 "rs6000_tls_symbol_ref" "")]
9961                    UNSPEC_TLSTLS))]
9962   "HAVE_AS_TLS && TARGET_64BIT"
9963   "add %0,%1,%2@tls")
9964 \f
9965 ;; Next come insns related to the calling sequence.
9966 ;;
9967 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9968 ;; We move the back-chain and decrement the stack pointer.
9969
9970 (define_expand "allocate_stack"
9971   [(set (match_operand 0 "gpc_reg_operand" "=r")
9972         (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9973    (set (reg 1)
9974         (minus (reg 1) (match_dup 1)))]
9975   ""
9976   "
9977 { rtx chain = gen_reg_rtx (Pmode);
9978   rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9979   rtx neg_op0;
9980
9981   emit_move_insn (chain, stack_bot);
9982
9983   /* Check stack bounds if necessary.  */
9984   if (current_function_limit_stack)
9985     {
9986       rtx available;
9987       available = expand_binop (Pmode, sub_optab,
9988                                 stack_pointer_rtx, stack_limit_rtx,
9989                                 NULL_RTX, 1, OPTAB_WIDEN);
9990       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9991     }
9992
9993   if (GET_CODE (operands[1]) != CONST_INT
9994       || INTVAL (operands[1]) < -32767
9995       || INTVAL (operands[1]) > 32768)
9996     {
9997       neg_op0 = gen_reg_rtx (Pmode);
9998       if (TARGET_32BIT)
9999         emit_insn (gen_negsi2 (neg_op0, operands[1]));
10000       else
10001         emit_insn (gen_negdi2 (neg_op0, operands[1]));
10002     }
10003   else
10004     neg_op0 = GEN_INT (- INTVAL (operands[1]));
10005
10006   if (TARGET_UPDATE)
10007     emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_di_update))
10008                 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
10009
10010   else
10011     {
10012       emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
10013                  (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
10014       emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
10015     }
10016
10017   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10018   DONE;
10019 }")
10020
10021 ;; These patterns say how to save and restore the stack pointer.  We need not
10022 ;; save the stack pointer at function level since we are careful to
10023 ;; preserve the backchain.  At block level, we have to restore the backchain
10024 ;; when we restore the stack pointer.
10025 ;;
10026 ;; For nonlocal gotos, we must save both the stack pointer and its
10027 ;; backchain and restore both.  Note that in the nonlocal case, the
10028 ;; save area is a memory location.
10029
10030 (define_expand "save_stack_function"
10031   [(match_operand 0 "any_operand" "")
10032    (match_operand 1 "any_operand" "")]
10033   ""
10034   "DONE;")
10035
10036 (define_expand "restore_stack_function"
10037   [(match_operand 0 "any_operand" "")
10038    (match_operand 1 "any_operand" "")]
10039   ""
10040   "DONE;")
10041
10042 (define_expand "restore_stack_block"
10043   [(use (match_operand 0 "register_operand" ""))
10044    (set (match_dup 2) (match_dup 3))
10045    (set (match_dup 0) (match_operand 1 "register_operand" ""))
10046    (set (match_dup 3) (match_dup 2))]
10047   ""
10048   "
10049 {
10050   operands[2] = gen_reg_rtx (Pmode);
10051   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
10052 }")
10053
10054 (define_expand "save_stack_nonlocal"
10055   [(match_operand 0 "memory_operand" "")
10056    (match_operand 1 "register_operand" "")]
10057   ""
10058   "
10059 {
10060   rtx temp = gen_reg_rtx (Pmode);
10061   int units_per_word = (TARGET_32BIT) ? 4 : 8;
10062
10063   /* Copy the backchain to the first word, sp to the second.  */
10064   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
10065   emit_move_insn (adjust_address_nv (operands[0], Pmode, 0), temp);
10066   emit_move_insn (adjust_address_nv (operands[0], Pmode, units_per_word),
10067                   operands[1]);
10068   DONE;
10069 }")
10070
10071 (define_expand "restore_stack_nonlocal"
10072   [(match_operand 0 "register_operand" "")
10073    (match_operand 1 "memory_operand" "")]
10074   ""
10075   "
10076 {
10077   rtx temp = gen_reg_rtx (Pmode);
10078   int units_per_word = (TARGET_32BIT) ? 4 : 8;
10079
10080   /* Restore the backchain from the first word, sp from the second.  */
10081   emit_move_insn (temp,
10082                   adjust_address_nv (operands[1], Pmode, 0));
10083   emit_move_insn (operands[0],
10084                   adjust_address_nv (operands[1], Pmode, units_per_word));
10085   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
10086   DONE;
10087 }")
10088 \f
10089 ;; TOC register handling.
10090
10091 ;; Code to initialize the TOC register...
10092
10093 (define_insn "load_toc_aix_si"
10094   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10095                    (unspec:SI [(const_int 0)] UNSPEC_TOC))
10096               (use (reg:SI 2))])]
10097   "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
10098   "*
10099 {
10100   char buf[30];
10101   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10102   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10103   operands[2] = gen_rtx_REG (Pmode, 2);
10104   return \"{l|lwz} %0,%1(%2)\";
10105 }"
10106   [(set_attr "type" "load")])
10107
10108 (define_insn "load_toc_aix_di"
10109   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10110                    (unspec:DI [(const_int 0)] UNSPEC_TOC))
10111               (use (reg:DI 2))])]
10112   "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
10113   "*
10114 {
10115   char buf[30];
10116 #ifdef TARGET_RELOCATABLE
10117   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10118                                !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10119 #else
10120   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10121 #endif
10122   if (TARGET_ELF)
10123     strcat (buf, \"@toc\");
10124   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10125   operands[2] = gen_rtx_REG (Pmode, 2);
10126   return \"ld %0,%1(%2)\";
10127 }"
10128   [(set_attr "type" "load")])
10129
10130 (define_insn "load_toc_v4_pic_si"
10131   [(set (match_operand:SI 0 "register_operand" "=l")
10132         (unspec:SI [(const_int 0)] UNSPEC_TOC))]
10133   "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10134   "bl _GLOBAL_OFFSET_TABLE_@local-4"
10135   [(set_attr "type" "branch")
10136    (set_attr "length" "4")])
10137
10138 (define_insn "load_toc_v4_PIC_1"
10139   [(set (match_operand:SI 0 "register_operand" "=l")
10140         (match_operand:SI 1 "immediate_operand" "s"))
10141    (use (unspec [(match_dup 1)] UNSPEC_TOC))]
10142   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10143   "bcl 20,31,%1\\n%1:"
10144   [(set_attr "type" "branch")
10145    (set_attr "length" "4")])
10146
10147 (define_insn "load_toc_v4_PIC_1b"
10148   [(set (match_operand:SI 0 "register_operand" "=l")
10149         (match_operand:SI 1 "immediate_operand" "s"))
10150    (use (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")]
10151                 UNSPEC_TOCPTR))]
10152   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10153   "bcl 20,31,%1+4\\n%1:\\n\\t.long %2-%1"
10154   [(set_attr "type" "branch")
10155    (set_attr "length" "8")])
10156
10157 (define_insn "load_toc_v4_PIC_2"
10158   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10159         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
10160                    (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10161                              (match_operand:SI 3 "immediate_operand" "s")))))]
10162   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10163   "{l|lwz} %0,%2-%3(%1)"
10164   [(set_attr "type" "load")])
10165
10166
10167 ;; If the TOC is shared over a translation unit, as happens with all
10168 ;; the kinds of PIC that we support, we need to restore the TOC
10169 ;; pointer only when jumping over units of translation.
10170 ;; On Darwin, we need to reload the picbase.
10171
10172 (define_expand "builtin_setjmp_receiver"
10173   [(use (label_ref (match_operand 0 "" "")))]
10174   "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10175    || (TARGET_TOC && TARGET_MINIMAL_TOC)
10176    || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10177   "
10178 {
10179 #if TARGET_MACHO
10180   if (DEFAULT_ABI == ABI_DARWIN)
10181     {
10182       const char *picbase = machopic_function_base_name ();
10183       rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (picbase));
10184       rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10185       rtx tmplabrtx;
10186       char tmplab[20];
10187
10188       ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10189                                   CODE_LABEL_NUMBER (operands[0]));
10190       tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (tmplab));
10191
10192       emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
10193       emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10194     }
10195   else
10196 #endif
10197     rs6000_emit_load_toc_table (FALSE);
10198   DONE;
10199 }")
10200 \f
10201 ;; A function pointer under AIX is a pointer to a data area whose first word
10202 ;; contains the actual address of the function, whose second word contains a
10203 ;; pointer to its TOC, and whose third word contains a value to place in the
10204 ;; static chain register (r11).  Note that if we load the static chain, our
10205 ;; "trampoline" need not have any executable code.
10206
10207 (define_expand "call_indirect_aix32"
10208   [(set (match_dup 2)
10209         (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10210    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10211         (reg:SI 2))
10212    (set (reg:SI 2)
10213         (mem:SI (plus:SI (match_dup 0)
10214                          (const_int 4))))
10215    (set (reg:SI 11)
10216         (mem:SI (plus:SI (match_dup 0)
10217                          (const_int 8))))
10218    (parallel [(call (mem:SI (match_dup 2))
10219                     (match_operand 1 "" ""))
10220               (use (reg:SI 2))
10221               (use (reg:SI 11))
10222               (set (reg:SI 2)
10223                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10224               (clobber (scratch:SI))])]
10225   "TARGET_32BIT"
10226   "
10227 { operands[2] = gen_reg_rtx (SImode); }")
10228
10229 (define_expand "call_indirect_aix64"
10230   [(set (match_dup 2)
10231         (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10232    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10233         (reg:DI 2))
10234    (set (reg:DI 2)
10235         (mem:DI (plus:DI (match_dup 0)
10236                          (const_int 8))))
10237    (set (reg:DI 11)
10238         (mem:DI (plus:DI (match_dup 0)
10239                          (const_int 16))))
10240    (parallel [(call (mem:SI (match_dup 2))
10241                     (match_operand 1 "" ""))
10242               (use (reg:DI 2))
10243               (use (reg:DI 11))
10244               (set (reg:DI 2)
10245                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10246               (clobber (scratch:SI))])]
10247   "TARGET_64BIT"
10248   "
10249 { operands[2] = gen_reg_rtx (DImode); }")
10250
10251 (define_expand "call_value_indirect_aix32"
10252   [(set (match_dup 3)
10253         (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10254    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10255         (reg:SI 2))
10256    (set (reg:SI 2)
10257         (mem:SI (plus:SI (match_dup 1)
10258                          (const_int 4))))
10259    (set (reg:SI 11)
10260         (mem:SI (plus:SI (match_dup 1)
10261                          (const_int 8))))
10262    (parallel [(set (match_operand 0 "" "")
10263                    (call (mem:SI (match_dup 3))
10264                          (match_operand 2 "" "")))
10265               (use (reg:SI 2))
10266               (use (reg:SI 11))
10267               (set (reg:SI 2)
10268                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10269               (clobber (scratch:SI))])]
10270   "TARGET_32BIT"
10271   "
10272 { operands[3] = gen_reg_rtx (SImode); }")
10273
10274 (define_expand "call_value_indirect_aix64"
10275   [(set (match_dup 3)
10276         (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10277    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10278         (reg:DI 2))
10279    (set (reg:DI 2)
10280         (mem:DI (plus:DI (match_dup 1)
10281                          (const_int 8))))
10282    (set (reg:DI 11)
10283         (mem:DI (plus:DI (match_dup 1)
10284                          (const_int 16))))
10285    (parallel [(set (match_operand 0 "" "")
10286                    (call (mem:SI (match_dup 3))
10287                          (match_operand 2 "" "")))
10288               (use (reg:DI 2))
10289               (use (reg:DI 11))
10290               (set (reg:DI 2)
10291                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10292               (clobber (scratch:SI))])]
10293   "TARGET_64BIT"
10294   "
10295 { operands[3] = gen_reg_rtx (DImode); }")
10296
10297 ;; Now the definitions for the call and call_value insns
10298 (define_expand "call"
10299   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10300                     (match_operand 1 "" ""))
10301               (use (match_operand 2 "" ""))
10302               (clobber (scratch:SI))])]
10303   ""
10304   "
10305 {
10306 #if TARGET_MACHO
10307   if (MACHOPIC_INDIRECT)
10308     operands[0] = machopic_indirect_call_target (operands[0]);
10309 #endif
10310
10311   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10312     abort ();
10313
10314   operands[0] = XEXP (operands[0], 0);
10315
10316   if (GET_CODE (operands[0]) != SYMBOL_REF
10317       || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[0]))
10318       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[2]) & CALL_LONG) != 0))
10319     {
10320       if (INTVAL (operands[2]) & CALL_LONG)
10321         operands[0] = rs6000_longcall_ref (operands[0]);
10322
10323       if (DEFAULT_ABI == ABI_V4
10324           || DEFAULT_ABI == ABI_DARWIN)
10325         operands[0] = force_reg (Pmode, operands[0]);
10326
10327       else if (DEFAULT_ABI == ABI_AIX)
10328         {
10329           /* AIX function pointers are really pointers to a three word
10330              area.  */
10331           emit_call_insn (TARGET_32BIT
10332                           ? gen_call_indirect_aix32 (force_reg (SImode,
10333                                                                 operands[0]),
10334                                                      operands[1])
10335                           : gen_call_indirect_aix64 (force_reg (DImode,
10336                                                                 operands[0]),
10337                                                      operands[1]));
10338           DONE;
10339         }
10340       else
10341         abort ();
10342     }
10343 }")
10344
10345 (define_expand "call_value"
10346   [(parallel [(set (match_operand 0 "" "")
10347                    (call (mem:SI (match_operand 1 "address_operand" ""))
10348                          (match_operand 2 "" "")))
10349               (use (match_operand 3 "" ""))
10350               (clobber (scratch:SI))])]
10351   ""
10352   "
10353 {
10354 #if TARGET_MACHO
10355   if (MACHOPIC_INDIRECT)
10356     operands[1] = machopic_indirect_call_target (operands[1]);
10357 #endif
10358
10359   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10360     abort ();
10361
10362   operands[1] = XEXP (operands[1], 0);
10363
10364   if (GET_CODE (operands[1]) != SYMBOL_REF
10365       || (DEFAULT_ABI == ABI_AIX && !SYMBOL_REF_FUNCTION_P (operands[1]))
10366       || (DEFAULT_ABI != ABI_DARWIN && (INTVAL (operands[3]) & CALL_LONG) != 0))
10367     {
10368       if (INTVAL (operands[3]) & CALL_LONG)
10369         operands[1] = rs6000_longcall_ref (operands[1]);
10370
10371       if (DEFAULT_ABI == ABI_V4
10372           || DEFAULT_ABI == ABI_DARWIN)
10373         operands[1] = force_reg (Pmode, operands[1]);
10374
10375       else if (DEFAULT_ABI == ABI_AIX)
10376         {
10377           /* AIX function pointers are really pointers to a three word
10378              area.  */
10379           emit_call_insn (TARGET_32BIT
10380                           ? gen_call_value_indirect_aix32 (operands[0],
10381                                                            force_reg (SImode,
10382                                                                       operands[1]),
10383                                                            operands[2])
10384                           : gen_call_value_indirect_aix64 (operands[0],
10385                                                            force_reg (DImode,
10386                                                                       operands[1]),
10387                                                            operands[2]));
10388           DONE;
10389         }
10390       else
10391         abort ();
10392     }
10393 }")
10394
10395 ;; Call to function in current module.  No TOC pointer reload needed.
10396 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10397 ;; either the function was not prototyped, or it was prototyped as a
10398 ;; variable argument function.  It is > 0 if FP registers were passed
10399 ;; and < 0 if they were not.
10400
10401 (define_insn "*call_local32"
10402   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10403          (match_operand 1 "" "g,g"))
10404    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10405    (clobber (match_scratch:SI 3 "=l,l"))]
10406   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10407   "*
10408 {
10409   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10410     output_asm_insn (\"crxor 6,6,6\", operands);
10411
10412   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10413     output_asm_insn (\"creqv 6,6,6\", operands);
10414
10415   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10416 }"
10417   [(set_attr "type" "branch")
10418    (set_attr "length" "4,8")])
10419
10420 (define_insn "*call_local64"
10421   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10422          (match_operand 1 "" "g,g"))
10423    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10424    (clobber (match_scratch:SI 3 "=l,l"))]
10425   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10426   "*
10427 {
10428   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10429     output_asm_insn (\"crxor 6,6,6\", operands);
10430
10431   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10432     output_asm_insn (\"creqv 6,6,6\", operands);
10433
10434   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10435 }"
10436   [(set_attr "type" "branch")
10437    (set_attr "length" "4,8")])
10438
10439 (define_insn "*call_value_local32"
10440   [(set (match_operand 0 "" "")
10441         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10442               (match_operand 2 "" "g,g")))
10443    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10444    (clobber (match_scratch:SI 4 "=l,l"))]
10445   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10446   "*
10447 {
10448   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10449     output_asm_insn (\"crxor 6,6,6\", operands);
10450
10451   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10452     output_asm_insn (\"creqv 6,6,6\", operands);
10453
10454   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10455 }"
10456   [(set_attr "type" "branch")
10457    (set_attr "length" "4,8")])
10458
10459
10460 (define_insn "*call_value_local64"
10461   [(set (match_operand 0 "" "")
10462         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10463               (match_operand 2 "" "g,g")))
10464    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10465    (clobber (match_scratch:SI 4 "=l,l"))]
10466   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10467   "*
10468 {
10469   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10470     output_asm_insn (\"crxor 6,6,6\", operands);
10471
10472   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10473     output_asm_insn (\"creqv 6,6,6\", operands);
10474
10475   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10476 }"
10477   [(set_attr "type" "branch")
10478    (set_attr "length" "4,8")])
10479
10480 ;; Call to function which may be in another module.  Restore the TOC
10481 ;; pointer (r2) after the call unless this is System V.
10482 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10483 ;; either the function was not prototyped, or it was prototyped as a
10484 ;; variable argument function.  It is > 0 if FP registers were passed
10485 ;; and < 0 if they were not.
10486
10487 (define_insn "*call_indirect_nonlocal_aix32"
10488   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10489          (match_operand 1 "" "g"))
10490    (use (reg:SI 2))
10491    (use (reg:SI 11))
10492    (set (reg:SI 2)
10493         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10494    (clobber (match_scratch:SI 2 "=l"))]
10495   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10496   "b%T0l\;{l|lwz} 2,20(1)"
10497   [(set_attr "type" "jmpreg")
10498    (set_attr "length" "8")])
10499
10500 (define_insn "*call_nonlocal_aix32"
10501   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10502          (match_operand 1 "" "g"))
10503    (use (match_operand:SI 2 "immediate_operand" "O"))
10504    (clobber (match_scratch:SI 3 "=l"))]
10505   "TARGET_32BIT
10506    && DEFAULT_ABI == ABI_AIX
10507    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10508   "bl %z0\;%."
10509   [(set_attr "type" "branch")
10510    (set_attr "length" "8")])
10511
10512 (define_insn "*call_indirect_nonlocal_aix64"
10513   [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10514          (match_operand 1 "" "g"))
10515    (use (reg:DI 2))
10516    (use (reg:DI 11))
10517    (set (reg:DI 2)
10518         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10519    (clobber (match_scratch:SI 2 "=l"))]
10520   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10521   "b%T0l\;ld 2,40(1)"
10522   [(set_attr "type" "jmpreg")
10523    (set_attr "length" "8")])
10524
10525 (define_insn "*call_nonlocal_aix64"
10526   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10527          (match_operand 1 "" "g"))
10528    (use (match_operand:SI 2 "immediate_operand" "O"))
10529    (clobber (match_scratch:SI 3 "=l"))]
10530   "TARGET_64BIT
10531    && DEFAULT_ABI == ABI_AIX
10532    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10533   "bl %z0\;%."
10534   [(set_attr "type" "branch")
10535    (set_attr "length" "8")])
10536
10537 (define_insn "*call_value_indirect_nonlocal_aix32"
10538   [(set (match_operand 0 "" "")
10539         (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10540               (match_operand 2 "" "g")))
10541    (use (reg:SI 2))
10542    (use (reg:SI 11))
10543    (set (reg:SI 2)
10544         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10545    (clobber (match_scratch:SI 3 "=l"))]
10546   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10547   "b%T1l\;{l|lwz} 2,20(1)"
10548   [(set_attr "type" "jmpreg")
10549    (set_attr "length" "8")])
10550
10551 (define_insn "*call_value_nonlocal_aix32"
10552   [(set (match_operand 0 "" "")
10553         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10554               (match_operand 2 "" "g")))
10555    (use (match_operand:SI 3 "immediate_operand" "O"))
10556    (clobber (match_scratch:SI 4 "=l"))]
10557   "TARGET_32BIT
10558    && DEFAULT_ABI == ABI_AIX
10559    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10560   "bl %z1\;%."
10561   [(set_attr "type" "branch")
10562    (set_attr "length" "8")])
10563
10564 (define_insn "*call_value_indirect_nonlocal_aix64"
10565   [(set (match_operand 0 "" "")
10566         (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10567               (match_operand 2 "" "g")))
10568    (use (reg:DI 2))
10569    (use (reg:DI 11))
10570    (set (reg:DI 2)
10571         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10572    (clobber (match_scratch:SI 3 "=l"))]
10573   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10574   "b%T1l\;ld 2,40(1)"
10575   [(set_attr "type" "jmpreg")
10576    (set_attr "length" "8")])
10577
10578 (define_insn "*call_value_nonlocal_aix64"
10579   [(set (match_operand 0 "" "")
10580         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10581               (match_operand 2 "" "g")))
10582    (use (match_operand:SI 3 "immediate_operand" "O"))
10583    (clobber (match_scratch:SI 4 "=l"))]
10584   "TARGET_64BIT
10585    && DEFAULT_ABI == ABI_AIX
10586    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10587   "bl %z1\;%."
10588   [(set_attr "type" "branch")
10589    (set_attr "length" "8")])
10590
10591 ;; A function pointer under System V is just a normal pointer
10592 ;; operands[0] is the function pointer
10593 ;; operands[1] is the stack size to clean up
10594 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10595 ;; which indicates how to set cr1
10596
10597 (define_insn "*call_indirect_nonlocal_sysv"
10598   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10599          (match_operand 1 "" "g,g"))
10600    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10601    (clobber (match_scratch:SI 3 "=l,l"))]
10602   "DEFAULT_ABI == ABI_V4
10603    || DEFAULT_ABI == ABI_DARWIN"
10604 {
10605   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10606     output_asm_insn ("crxor 6,6,6", operands);
10607
10608   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10609     output_asm_insn ("creqv 6,6,6", operands);
10610
10611   return "b%T0l";
10612 }
10613   [(set_attr "type" "jmpreg,jmpreg")
10614    (set_attr "length" "4,8")])
10615
10616 (define_insn "*call_nonlocal_sysv"
10617   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10618          (match_operand 1 "" "g,g"))
10619    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10620    (clobber (match_scratch:SI 3 "=l,l"))]
10621   "(DEFAULT_ABI == ABI_DARWIN
10622    || (DEFAULT_ABI == ABI_V4
10623        && (INTVAL (operands[2]) & CALL_LONG) == 0))"
10624 {
10625   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10626     output_asm_insn ("crxor 6,6,6", operands);
10627
10628   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10629     output_asm_insn ("creqv 6,6,6", operands);
10630
10631 #if TARGET_MACHO
10632   return output_call(insn, operands, 0, 2);
10633 #else
10634   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
10635 #endif
10636 }
10637   [(set_attr "type" "branch,branch")
10638    (set_attr "length" "4,8")])
10639
10640 (define_insn "*call_value_indirect_nonlocal_sysv"
10641   [(set (match_operand 0 "" "")
10642         (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10643               (match_operand 2 "" "g,g")))
10644    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10645    (clobber (match_scratch:SI 4 "=l,l"))]
10646   "DEFAULT_ABI == ABI_V4
10647    || DEFAULT_ABI == ABI_DARWIN"
10648 {
10649   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10650     output_asm_insn ("crxor 6,6,6", operands);
10651
10652   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10653     output_asm_insn ("creqv 6,6,6", operands);
10654
10655   return "b%T1l";
10656 }
10657   [(set_attr "type" "jmpreg,jmpreg")
10658    (set_attr "length" "4,8")])
10659
10660 (define_insn "*call_value_nonlocal_sysv"
10661   [(set (match_operand 0 "" "")
10662         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10663               (match_operand 2 "" "g,g")))
10664    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10665    (clobber (match_scratch:SI 4 "=l,l"))]
10666   "(DEFAULT_ABI == ABI_DARWIN
10667    || (DEFAULT_ABI == ABI_V4
10668        && (INTVAL (operands[3]) & CALL_LONG) == 0))"
10669 {
10670   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10671     output_asm_insn ("crxor 6,6,6", operands);
10672
10673   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10674     output_asm_insn ("creqv 6,6,6", operands);
10675
10676 #if TARGET_MACHO
10677   return output_call(insn, operands, 1, 3);
10678 #else
10679   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
10680 #endif
10681 }
10682   [(set_attr "type" "branch,branch")
10683    (set_attr "length" "4,8")])
10684
10685 ;; Call subroutine returning any type.
10686 (define_expand "untyped_call"
10687   [(parallel [(call (match_operand 0 "" "")
10688                     (const_int 0))
10689               (match_operand 1 "" "")
10690               (match_operand 2 "" "")])]
10691   ""
10692   "
10693 {
10694   int i;
10695
10696   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10697
10698   for (i = 0; i < XVECLEN (operands[2], 0); i++)
10699     {
10700       rtx set = XVECEXP (operands[2], 0, i);
10701       emit_move_insn (SET_DEST (set), SET_SRC (set));
10702     }
10703
10704   /* The optimizer does not know that the call sets the function value
10705      registers we stored in the result block.  We avoid problems by
10706      claiming that all hard registers are used and clobbered at this
10707      point.  */
10708   emit_insn (gen_blockage ());
10709
10710   DONE;
10711 }")
10712
10713 ;; sibling call patterns
10714 (define_expand "sibcall"
10715   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10716                     (match_operand 1 "" ""))
10717               (use (match_operand 2 "" ""))
10718               (use (match_operand 3 "" ""))
10719               (return)])]
10720   ""
10721   "
10722 {
10723 #if TARGET_MACHO
10724   if (MACHOPIC_INDIRECT)
10725     operands[0] = machopic_indirect_call_target (operands[0]);
10726 #endif
10727
10728   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10729     abort ();
10730
10731   operands[0] = XEXP (operands[0], 0);
10732   operands[3] = gen_reg_rtx (SImode);
10733
10734 }")
10735
10736 ;; this and similar patterns must be marked as using LR, otherwise
10737 ;; dataflow will try to delete the store into it.  This is true
10738 ;; even when the actual reg to jump to is in CTR, when LR was
10739 ;; saved and restored around the PIC-setting BCL.
10740 (define_insn "*sibcall_local32"
10741   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10742          (match_operand 1 "" "g,g"))
10743    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10744    (use (match_operand:SI 3 "register_operand" "l,l"))
10745    (return)]
10746   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10747   "*
10748 {
10749   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10750     output_asm_insn (\"crxor 6,6,6\", operands);
10751
10752   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10753     output_asm_insn (\"creqv 6,6,6\", operands);
10754
10755   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10756 }"
10757   [(set_attr "type" "branch")
10758    (set_attr "length" "4,8")])
10759
10760 (define_insn "*sibcall_local64"
10761   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10762          (match_operand 1 "" "g,g"))
10763    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10764    (use (match_operand:SI 3 "register_operand" "l,l"))
10765    (return)]
10766   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10767   "*
10768 {
10769   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10770     output_asm_insn (\"crxor 6,6,6\", operands);
10771
10772   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10773     output_asm_insn (\"creqv 6,6,6\", operands);
10774
10775   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10776 }"
10777   [(set_attr "type" "branch")
10778    (set_attr "length" "4,8")])
10779
10780 (define_insn "*sibcall_value_local32"
10781   [(set (match_operand 0 "" "")
10782         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10783               (match_operand 2 "" "g,g")))
10784    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10785    (use (match_operand:SI 4 "register_operand" "l,l"))
10786    (return)]
10787   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10788   "*
10789 {
10790   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10791     output_asm_insn (\"crxor 6,6,6\", operands);
10792
10793   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10794     output_asm_insn (\"creqv 6,6,6\", operands);
10795
10796   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10797 }"
10798   [(set_attr "type" "branch")
10799    (set_attr "length" "4,8")])
10800
10801
10802 (define_insn "*sibcall_value_local64"
10803   [(set (match_operand 0 "" "")
10804         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10805               (match_operand 2 "" "g,g")))
10806    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10807    (use (match_operand:SI 4 "register_operand" "l,l"))
10808    (return)]
10809   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10810   "*
10811 {
10812   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10813     output_asm_insn (\"crxor 6,6,6\", operands);
10814
10815   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10816     output_asm_insn (\"creqv 6,6,6\", operands);
10817
10818   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10819 }"
10820   [(set_attr "type" "branch")
10821    (set_attr "length" "4,8")])
10822
10823 (define_insn "*sibcall_nonlocal_aix32"
10824   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10825          (match_operand 1 "" "g"))
10826    (use (match_operand:SI 2 "immediate_operand" "O"))
10827    (use (match_operand:SI 3 "register_operand" "l"))
10828    (return)]
10829   "TARGET_32BIT
10830    && DEFAULT_ABI == ABI_AIX
10831    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10832   "b %z0"
10833   [(set_attr "type" "branch")
10834    (set_attr "length" "4")])
10835
10836 (define_insn "*sibcall_nonlocal_aix64"
10837   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10838          (match_operand 1 "" "g"))
10839    (use (match_operand:SI 2 "immediate_operand" "O"))
10840    (use (match_operand:SI 3 "register_operand" "l"))
10841    (return)]
10842   "TARGET_64BIT
10843    && DEFAULT_ABI == ABI_AIX
10844    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10845   "b %z0"
10846   [(set_attr "type" "branch")
10847    (set_attr "length" "4")])
10848
10849 (define_insn "*sibcall_value_nonlocal_aix32"
10850   [(set (match_operand 0 "" "")
10851         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10852               (match_operand 2 "" "g")))
10853    (use (match_operand:SI 3 "immediate_operand" "O"))
10854    (use (match_operand:SI 4 "register_operand" "l"))
10855    (return)]
10856   "TARGET_32BIT
10857    && DEFAULT_ABI == ABI_AIX
10858    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10859   "b %z1"
10860   [(set_attr "type" "branch")
10861    (set_attr "length" "4")])
10862
10863 (define_insn "*sibcall_value_nonlocal_aix64"
10864   [(set (match_operand 0 "" "")
10865         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10866               (match_operand 2 "" "g")))
10867    (use (match_operand:SI 3 "immediate_operand" "O"))
10868    (use (match_operand:SI 4 "register_operand" "l"))
10869    (return)]
10870   "TARGET_64BIT
10871    && DEFAULT_ABI == ABI_AIX
10872    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10873   "b %z1"
10874   [(set_attr "type" "branch")
10875    (set_attr "length" "4")])
10876
10877 (define_insn "*sibcall_nonlocal_sysv"
10878   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10879          (match_operand 1 "" ""))
10880    (use (match_operand 2 "immediate_operand" "O,n"))
10881    (use (match_operand:SI 3 "register_operand" "l,l"))
10882    (return)]
10883   "(DEFAULT_ABI == ABI_DARWIN
10884      || DEFAULT_ABI == ABI_V4)
10885    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10886   "*
10887 {
10888   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10889     output_asm_insn (\"crxor 6,6,6\", operands);
10890
10891   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10892     output_asm_insn (\"creqv 6,6,6\", operands);
10893
10894   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@plt\" : \"b %z0\";
10895 }"
10896   [(set_attr "type" "branch,branch")
10897    (set_attr "length" "4,8")])
10898
10899 (define_expand "sibcall_value"
10900   [(parallel [(set (match_operand 0 "register_operand" "")
10901                 (call (mem:SI (match_operand 1 "address_operand" ""))
10902                       (match_operand 2 "" "")))
10903               (use (match_operand 3 "" ""))
10904               (use (match_operand 4 "" ""))
10905               (return)])]
10906   ""
10907   "
10908 {
10909 #if TARGET_MACHO
10910   if (MACHOPIC_INDIRECT)
10911     operands[1] = machopic_indirect_call_target (operands[1]);
10912 #endif
10913
10914   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10915     abort ();
10916
10917   operands[1] = XEXP (operands[1], 0);
10918   operands[4] = gen_reg_rtx (SImode);
10919
10920 }")
10921
10922 (define_insn "*sibcall_value_nonlocal_sysv"
10923   [(set (match_operand 0 "" "")
10924         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10925               (match_operand 2 "" "")))
10926    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10927    (use (match_operand:SI 4 "register_operand" "l,l"))
10928    (return)]
10929   "(DEFAULT_ABI == ABI_DARWIN
10930        || DEFAULT_ABI == ABI_V4)
10931    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10932   "*
10933 {
10934   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10935     output_asm_insn (\"crxor 6,6,6\", operands);
10936
10937   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10938     output_asm_insn (\"creqv 6,6,6\", operands);
10939
10940   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@plt\" : \"b %z1\";
10941 }"
10942   [(set_attr "type" "branch,branch")
10943    (set_attr "length" "4,8")])
10944
10945 (define_expand "sibcall_epilogue"
10946   [(use (const_int 0))]
10947   "TARGET_SCHED_PROLOG"
10948   "
10949 {
10950       rs6000_emit_epilogue (TRUE);
10951       DONE;
10952 }")
10953
10954 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10955 ;; all of memory.  This blocks insns from being moved across this point.
10956
10957 (define_insn "blockage"
10958   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCK)]
10959   ""
10960   "")
10961 \f
10962 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
10963 ;; signed & unsigned, and one type of branch.
10964 ;;
10965 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10966 ;; insns, and branches.  We store the operands of compares until we see
10967 ;; how it is used.
10968 (define_expand "cmpsi"
10969   [(set (cc0)
10970         (compare (match_operand:SI 0 "gpc_reg_operand" "")
10971                  (match_operand:SI 1 "reg_or_short_operand" "")))]
10972   ""
10973   "
10974 {
10975   /* Take care of the possibility that operands[1] might be negative but
10976      this might be a logical operation.  That insn doesn't exist.  */
10977   if (GET_CODE (operands[1]) == CONST_INT
10978       && INTVAL (operands[1]) < 0)
10979     operands[1] = force_reg (SImode, operands[1]);
10980
10981   rs6000_compare_op0 = operands[0];
10982   rs6000_compare_op1 = operands[1];
10983   rs6000_compare_fp_p = 0;
10984   DONE;
10985 }")
10986
10987 (define_expand "cmpdi"
10988   [(set (cc0)
10989         (compare (match_operand:DI 0 "gpc_reg_operand" "")
10990                  (match_operand:DI 1 "reg_or_short_operand" "")))]
10991   "TARGET_POWERPC64"
10992   "
10993 {
10994   /* Take care of the possibility that operands[1] might be negative but
10995      this might be a logical operation.  That insn doesn't exist.  */
10996   if (GET_CODE (operands[1]) == CONST_INT
10997       && INTVAL (operands[1]) < 0)
10998     operands[1] = force_reg (DImode, operands[1]);
10999
11000   rs6000_compare_op0 = operands[0];
11001   rs6000_compare_op1 = operands[1];
11002   rs6000_compare_fp_p = 0;
11003   DONE;
11004 }")
11005
11006 (define_expand "cmpsf"
11007   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
11008                        (match_operand:SF 1 "gpc_reg_operand" "")))]
11009   "TARGET_HARD_FLOAT"
11010   "
11011 {
11012   rs6000_compare_op0 = operands[0];
11013   rs6000_compare_op1 = operands[1];
11014   rs6000_compare_fp_p = 1;
11015   DONE;
11016 }")
11017
11018 (define_expand "cmpdf"
11019   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
11020                        (match_operand:DF 1 "gpc_reg_operand" "")))]
11021   "TARGET_HARD_FLOAT && (TARGET_FPRS || TARGET_E500_DOUBLE)"
11022   "
11023 {
11024   rs6000_compare_op0 = operands[0];
11025   rs6000_compare_op1 = operands[1];
11026   rs6000_compare_fp_p = 1;
11027   DONE;
11028 }")
11029
11030 (define_expand "cmptf"
11031   [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
11032                        (match_operand:TF 1 "gpc_reg_operand" "")))]
11033   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN)
11034    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11035   "
11036 {
11037   rs6000_compare_op0 = operands[0];
11038   rs6000_compare_op1 = operands[1];
11039   rs6000_compare_fp_p = 1;
11040   DONE;
11041 }")
11042
11043 (define_expand "beq"
11044   [(use (match_operand 0 "" ""))]
11045   ""
11046   "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
11047
11048 (define_expand "bne"
11049   [(use (match_operand 0 "" ""))]
11050   ""
11051   "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
11052
11053 (define_expand "bge"
11054   [(use (match_operand 0 "" ""))]
11055   ""
11056   "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
11057
11058 (define_expand "bgt"
11059   [(use (match_operand 0 "" ""))]
11060   ""
11061   "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
11062
11063 (define_expand "ble"
11064   [(use (match_operand 0 "" ""))]
11065   ""
11066   "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
11067
11068 (define_expand "blt"
11069   [(use (match_operand 0 "" ""))]
11070   ""
11071   "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
11072
11073 (define_expand "bgeu"
11074   [(use (match_operand 0 "" ""))]
11075   ""
11076   "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
11077
11078 (define_expand "bgtu"
11079   [(use (match_operand 0 "" ""))]
11080   ""
11081   "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
11082
11083 (define_expand "bleu"
11084   [(use (match_operand 0 "" ""))]
11085   ""
11086   "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
11087
11088 (define_expand "bltu"
11089   [(use (match_operand 0 "" ""))]
11090   ""
11091   "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
11092
11093 (define_expand "bunordered"
11094   [(use (match_operand 0 "" ""))]
11095   "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
11096   "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
11097
11098 (define_expand "bordered"
11099   [(use (match_operand 0 "" ""))]
11100   "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
11101   "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
11102
11103 (define_expand "buneq"
11104   [(use (match_operand 0 "" ""))]
11105   ""
11106   "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
11107
11108 (define_expand "bunge"
11109   [(use (match_operand 0 "" ""))]
11110   ""
11111   "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
11112
11113 (define_expand "bungt"
11114   [(use (match_operand 0 "" ""))]
11115   ""
11116   "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
11117
11118 (define_expand "bunle"
11119   [(use (match_operand 0 "" ""))]
11120   ""
11121   "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
11122
11123 (define_expand "bunlt"
11124   [(use (match_operand 0 "" ""))]
11125   ""
11126   "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
11127
11128 (define_expand "bltgt"
11129   [(use (match_operand 0 "" ""))]
11130   ""
11131   "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
11132
11133 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11134 ;; For SEQ, likewise, except that comparisons with zero should be done
11135 ;; with an scc insns.  However, due to the order that combine see the
11136 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
11137 ;; the cases we don't want to handle.
11138 (define_expand "seq"
11139   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11140   ""
11141   "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
11142
11143 (define_expand "sne"
11144   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11145   ""
11146   "
11147 {
11148   if (! rs6000_compare_fp_p)
11149     FAIL;
11150
11151   rs6000_emit_sCOND (NE, operands[0]);
11152   DONE;
11153 }")
11154
11155 ;; A >= 0 is best done the portable way for A an integer.
11156 (define_expand "sge"
11157   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11158   ""
11159   "
11160 {
11161   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11162     FAIL;
11163
11164   rs6000_emit_sCOND (GE, operands[0]);
11165   DONE;
11166 }")
11167
11168 ;; A > 0 is best done using the portable sequence, so fail in that case.
11169 (define_expand "sgt"
11170   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11171   ""
11172   "
11173 {
11174   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11175     FAIL;
11176
11177   rs6000_emit_sCOND (GT, operands[0]);
11178   DONE;
11179 }")
11180
11181 ;; A <= 0 is best done the portable way for A an integer.
11182 (define_expand "sle"
11183   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11184   ""
11185   "
11186 {
11187   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11188     FAIL;
11189
11190   rs6000_emit_sCOND (LE, operands[0]);
11191   DONE;
11192 }")
11193
11194 ;; A < 0 is best done in the portable way for A an integer.
11195 (define_expand "slt"
11196   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11197   ""
11198   "
11199 {
11200   if (! rs6000_compare_fp_p && rs6000_compare_op1 == const0_rtx)
11201     FAIL;
11202
11203   rs6000_emit_sCOND (LT, operands[0]);
11204   DONE;
11205 }")
11206
11207 (define_expand "sgeu"
11208   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11209   ""
11210   "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11211
11212 (define_expand "sgtu"
11213   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11214   ""
11215   "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
11216
11217 (define_expand "sleu"
11218   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11219   ""
11220   "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11221
11222 (define_expand "sltu"
11223   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11224   ""
11225   "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
11226
11227 (define_expand "sunordered"
11228   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11229   "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
11230   "{ rs6000_emit_sCOND (UNORDERED, operands[0]); DONE; }")
11231
11232 (define_expand "sordered"
11233   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11234   "! (TARGET_HARD_FLOAT && TARGET_E500 && !TARGET_FPRS)"
11235   "{ rs6000_emit_sCOND (ORDERED, operands[0]); DONE; }")
11236
11237 (define_expand "suneq"
11238   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11239   ""
11240   "{ rs6000_emit_sCOND (UNEQ, operands[0]); DONE; }")
11241
11242 (define_expand "sunge"
11243   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11244   ""
11245   "{ rs6000_emit_sCOND (UNGE, operands[0]); DONE; }")
11246
11247 (define_expand "sungt"
11248   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11249   ""
11250   "{ rs6000_emit_sCOND (UNGT, operands[0]); DONE; }")
11251
11252 (define_expand "sunle"
11253   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11254   ""
11255   "{ rs6000_emit_sCOND (UNLE, operands[0]); DONE; }")
11256
11257 (define_expand "sunlt"
11258   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11259   ""
11260   "{ rs6000_emit_sCOND (UNLT, operands[0]); DONE; }")
11261
11262 (define_expand "sltgt"
11263   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11264   ""
11265   "{ rs6000_emit_sCOND (LTGT, operands[0]); DONE; }")
11266
11267 \f
11268 ;; Here are the actual compare insns.
11269 (define_insn "*cmpsi_internal1"
11270   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11271         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11272                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11273   ""
11274   "{cmp%I2|cmpw%I2} %0,%1,%2"
11275   [(set_attr "type" "cmp")])
11276
11277 (define_insn "*cmpdi_internal1"
11278   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11279         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
11280                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11281   "TARGET_POWERPC64"
11282   "cmpd%I2 %0,%1,%2"
11283   [(set_attr "type" "cmp")])
11284
11285 ;; If we are comparing a register for equality with a large constant,
11286 ;; we can do this with an XOR followed by a compare.  But we need a scratch
11287 ;; register for the result of the XOR.
11288
11289 (define_split
11290   [(set (match_operand:CC 0 "cc_reg_operand" "")
11291         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11292                     (match_operand:SI 2 "non_short_cint_operand" "")))
11293    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
11294   "find_single_use (operands[0], insn, 0)
11295    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
11296        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
11297   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
11298    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
11299   "
11300 {
11301   /* Get the constant we are comparing against, C,  and see what it looks like
11302      sign-extended to 16 bits.  Then see what constant could be XOR'ed
11303      with C to get the sign-extended value.  */
11304
11305   HOST_WIDE_INT c = INTVAL (operands[2]);
11306   HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11307   HOST_WIDE_INT xorv = c ^ sextc;
11308
11309   operands[4] = GEN_INT (xorv);
11310   operands[5] = GEN_INT (sextc);
11311 }")
11312
11313 (define_insn "*cmpsi_internal2"
11314   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11315         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11316                        (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11317   ""
11318   "{cmpl%I2|cmplw%I2} %0,%1,%b2"
11319   [(set_attr "type" "cmp")])
11320
11321 (define_insn "*cmpdi_internal2"
11322   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11323         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11324                        (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11325   ""
11326   "cmpld%I2 %0,%1,%b2"
11327   [(set_attr "type" "cmp")])
11328
11329 ;; The following two insns don't exist as single insns, but if we provide
11330 ;; them, we can swap an add and compare, which will enable us to overlap more
11331 ;; of the required delay between a compare and branch.  We generate code for
11332 ;; them by splitting.
11333
11334 (define_insn ""
11335   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11336         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11337                     (match_operand:SI 2 "short_cint_operand" "i")))
11338    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11339         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11340   ""
11341   "#"
11342   [(set_attr "length" "8")])
11343
11344 (define_insn ""
11345   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11346         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11347                        (match_operand:SI 2 "u_short_cint_operand" "i")))
11348    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11349         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11350   ""
11351   "#"
11352   [(set_attr "length" "8")])
11353
11354 (define_split
11355   [(set (match_operand:CC 3 "cc_reg_operand" "")
11356         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11357                     (match_operand:SI 2 "short_cint_operand" "")))
11358    (set (match_operand:SI 0 "gpc_reg_operand" "")
11359         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11360   ""
11361   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11362    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11363
11364 (define_split
11365   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11366         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11367                        (match_operand:SI 2 "u_short_cint_operand" "")))
11368    (set (match_operand:SI 0 "gpc_reg_operand" "")
11369         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11370   ""
11371   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11372    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11373
11374 (define_insn "*cmpsf_internal1"
11375   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11376         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11377                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
11378   "TARGET_HARD_FLOAT && TARGET_FPRS"
11379   "fcmpu %0,%1,%2"
11380   [(set_attr "type" "fpcompare")])
11381
11382 (define_insn "*cmpdf_internal1"
11383   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11384         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11385                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
11386   "TARGET_HARD_FLOAT && TARGET_FPRS"
11387   "fcmpu %0,%1,%2"
11388   [(set_attr "type" "fpcompare")])
11389
11390 ;; Only need to compare second words if first words equal
11391 (define_insn "*cmptf_internal1"
11392   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11393         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11394                       (match_operand:TF 2 "gpc_reg_operand" "f")))]
11395   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && !TARGET_XL_COMPAT
11396    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11397   "fcmpu %0,%1,%2\;bne %0,$+8\;fcmpu %0,%L1,%L2"
11398   [(set_attr "type" "fpcompare")
11399    (set_attr "length" "12")])
11400
11401 (define_insn_and_split "*cmptf_internal2"
11402   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11403         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11404                       (match_operand:TF 2 "gpc_reg_operand" "f")))
11405     (clobber (match_scratch:DF 3 "=f"))
11406     (clobber (match_scratch:DF 4 "=f"))
11407     (clobber (match_scratch:DF 5 "=f"))
11408     (clobber (match_scratch:DF 6 "=f"))
11409     (clobber (match_scratch:DF 7 "=f"))
11410     (clobber (match_scratch:DF 8 "=f"))
11411     (clobber (match_scratch:DF 9 "=f"))
11412     (clobber (match_scratch:DF 10 "=f"))]
11413   "(DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN) && TARGET_XL_COMPAT
11414    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11415   "#"
11416   "&& reload_completed"
11417   [(set (match_dup 3) (match_dup 13))
11418    (set (match_dup 4) (match_dup 14))
11419    (set (match_dup 9) (abs:DF (match_dup 5)))
11420    (set (match_dup 0) (compare:CCFP (match_dup 9) (match_dup 3)))
11421    (set (pc) (if_then_else (ne (match_dup 0) (const_int 0))
11422                            (label_ref (match_dup 11))
11423                            (pc)))
11424    (set (match_dup 0) (compare:CCFP (match_dup 5) (match_dup 7)))
11425    (set (pc) (label_ref (match_dup 12)))
11426    (match_dup 11)
11427    (set (match_dup 10) (minus:DF (match_dup 5) (match_dup 7)))
11428    (set (match_dup 9) (minus:DF (match_dup 6) (match_dup 8)))
11429    (set (match_dup 9) (plus:DF (match_dup 10) (match_dup 9)))
11430    (set (match_dup 0) (compare:CCFP (match_dup 7) (match_dup 4)))
11431    (match_dup 12)]
11432 {
11433   REAL_VALUE_TYPE rv;
11434   const int lo_word = FLOAT_WORDS_BIG_ENDIAN ? GET_MODE_SIZE (DFmode) : 0;
11435   const int hi_word = FLOAT_WORDS_BIG_ENDIAN ? 0 : GET_MODE_SIZE (DFmode);
11436
11437   operands[5] = simplify_gen_subreg (DFmode, operands[1], TFmode, hi_word);
11438   operands[6] = simplify_gen_subreg (DFmode, operands[1], TFmode, lo_word);
11439   operands[7] = simplify_gen_subreg (DFmode, operands[2], TFmode, hi_word);
11440   operands[8] = simplify_gen_subreg (DFmode, operands[2], TFmode, lo_word);
11441   operands[11] = gen_label_rtx ();
11442   operands[12] = gen_label_rtx ();
11443   real_inf (&rv);
11444   operands[13] = force_const_mem (DFmode,
11445                                   CONST_DOUBLE_FROM_REAL_VALUE (rv, DFmode));
11446   operands[14] = force_const_mem (DFmode,
11447                                   CONST_DOUBLE_FROM_REAL_VALUE (dconst0,
11448                                                                 DFmode));
11449   if (TARGET_TOC)
11450     {
11451       operands[13] = gen_const_mem (DFmode,
11452                                     create_TOC_reference (XEXP (operands[13], 0)));
11453       operands[14] = gen_const_mem (DFmode,
11454                                     create_TOC_reference (XEXP (operands[14], 0)));
11455       set_mem_alias_set (operands[13], get_TOC_alias_set ());
11456       set_mem_alias_set (operands[14], get_TOC_alias_set ());
11457     }
11458 })
11459 \f
11460 ;; Now we have the scc insns.  We can do some combinations because of the
11461 ;; way the machine works.
11462 ;;
11463 ;; Note that this is probably faster if we can put an insn between the
11464 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
11465 ;; cases the insns below which don't use an intermediate CR field will
11466 ;; be used instead.
11467 (define_insn ""
11468   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11469         (match_operator:SI 1 "scc_comparison_operator"
11470                            [(match_operand 2 "cc_reg_operand" "y")
11471                             (const_int 0)]))]
11472   ""
11473   "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11474   [(set (attr "type")
11475      (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11476                 (const_string "mfcrf")
11477            ]
11478         (const_string "mfcr")))
11479    (set_attr "length" "8")])
11480
11481 ;; Same as above, but get the GT bit.
11482 (define_insn "move_from_CR_gt_bit"
11483   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11484         (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_GT))]
11485   "TARGET_E500"
11486   "mfcr %0\;{rlinm|rlwinm} %0,%0,%D1,31,31"
11487   [(set_attr "type" "mfcr")
11488    (set_attr "length" "8")])
11489
11490 ;; Same as above, but get the OV/ORDERED bit.
11491 (define_insn "move_from_CR_ov_bit"
11492   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11493         (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] UNSPEC_MV_CR_OV))]
11494   "TARGET_ISEL"
11495   "mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
11496   [(set_attr "type" "mfcr")
11497    (set_attr "length" "8")])
11498
11499 (define_insn ""
11500   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11501         (match_operator:DI 1 "scc_comparison_operator"
11502                            [(match_operand 2 "cc_reg_operand" "y")
11503                             (const_int 0)]))]
11504   "TARGET_POWERPC64"
11505   "mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%J1,1"
11506   [(set (attr "type")
11507      (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11508                 (const_string "mfcrf")
11509            ]
11510         (const_string "mfcr")))
11511    (set_attr "length" "8")])
11512
11513 (define_insn ""
11514   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11515         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11516                                        [(match_operand 2 "cc_reg_operand" "y,y")
11517                                         (const_int 0)])
11518                     (const_int 0)))
11519    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11520         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11521   "TARGET_32BIT"
11522   "@
11523    mfcr %3%Q2\;{rlinm.|rlwinm.} %3,%3,%J1,1
11524    #"
11525   [(set_attr "type" "delayed_compare")
11526    (set_attr "length" "8,16")])
11527
11528 (define_split
11529   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11530         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11531                                        [(match_operand 2 "cc_reg_operand" "")
11532                                         (const_int 0)])
11533                     (const_int 0)))
11534    (set (match_operand:SI 3 "gpc_reg_operand" "")
11535         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11536   "TARGET_32BIT && reload_completed"
11537   [(set (match_dup 3)
11538         (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11539    (set (match_dup 0)
11540         (compare:CC (match_dup 3)
11541                     (const_int 0)))]
11542   "")
11543
11544 (define_insn ""
11545   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11546         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11547                                       [(match_operand 2 "cc_reg_operand" "y")
11548                                        (const_int 0)])
11549                    (match_operand:SI 3 "const_int_operand" "n")))]
11550   ""
11551   "*
11552 {
11553   int is_bit = ccr_bit (operands[1], 1);
11554   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11555   int count;
11556
11557   if (is_bit >= put_bit)
11558     count = is_bit - put_bit;
11559   else
11560     count = 32 - (put_bit - is_bit);
11561
11562   operands[4] = GEN_INT (count);
11563   operands[5] = GEN_INT (put_bit);
11564
11565   return \"mfcr %0%Q2\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
11566 }"
11567   [(set (attr "type")
11568      (cond [(ne (symbol_ref "TARGET_MFCRF") (const_int 0))
11569                 (const_string "mfcrf")
11570            ]
11571         (const_string "mfcr")))
11572    (set_attr "length" "8")])
11573
11574 (define_insn ""
11575   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11576         (compare:CC
11577          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11578                                        [(match_operand 2 "cc_reg_operand" "y,y")
11579                                         (const_int 0)])
11580                     (match_operand:SI 3 "const_int_operand" "n,n"))
11581          (const_int 0)))
11582    (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11583         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11584                    (match_dup 3)))]
11585   ""
11586   "*
11587 {
11588   int is_bit = ccr_bit (operands[1], 1);
11589   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11590   int count;
11591
11592   /* Force split for non-cc0 compare.  */
11593   if (which_alternative == 1)
11594      return \"#\";
11595
11596   if (is_bit >= put_bit)
11597     count = is_bit - put_bit;
11598   else
11599     count = 32 - (put_bit - is_bit);
11600
11601   operands[5] = GEN_INT (count);
11602   operands[6] = GEN_INT (put_bit);
11603
11604   return \"mfcr %4%Q2\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
11605 }"
11606   [(set_attr "type" "delayed_compare")
11607    (set_attr "length" "8,16")])
11608
11609 (define_split
11610   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11611         (compare:CC
11612          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11613                                        [(match_operand 2 "cc_reg_operand" "")
11614                                         (const_int 0)])
11615                     (match_operand:SI 3 "const_int_operand" ""))
11616          (const_int 0)))
11617    (set (match_operand:SI 4 "gpc_reg_operand" "")
11618         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11619                    (match_dup 3)))]
11620   "reload_completed"
11621   [(set (match_dup 4)
11622         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11623                    (match_dup 3)))
11624    (set (match_dup 0)
11625         (compare:CC (match_dup 4)
11626                     (const_int 0)))]
11627   "")
11628
11629 ;; There is a 3 cycle delay between consecutive mfcr instructions
11630 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11631
11632 (define_peephole
11633   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11634         (match_operator:SI 1 "scc_comparison_operator"
11635                            [(match_operand 2 "cc_reg_operand" "y")
11636                             (const_int 0)]))
11637    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11638         (match_operator:SI 4 "scc_comparison_operator"
11639                            [(match_operand 5 "cc_reg_operand" "y")
11640                             (const_int 0)]))]
11641   "REGNO (operands[2]) != REGNO (operands[5])"
11642   "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11643   [(set_attr "type" "mfcr")
11644    (set_attr "length" "12")])
11645
11646 (define_peephole
11647   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11648         (match_operator:DI 1 "scc_comparison_operator"
11649                            [(match_operand 2 "cc_reg_operand" "y")
11650                             (const_int 0)]))
11651    (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11652         (match_operator:DI 4 "scc_comparison_operator"
11653                            [(match_operand 5 "cc_reg_operand" "y")
11654                             (const_int 0)]))]
11655   "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11656   "mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11657   [(set_attr "type" "mfcr")
11658    (set_attr "length" "12")])
11659
11660 ;; There are some scc insns that can be done directly, without a compare.
11661 ;; These are faster because they don't involve the communications between
11662 ;; the FXU and branch units.   In fact, we will be replacing all of the
11663 ;; integer scc insns here or in the portable methods in emit_store_flag.
11664 ;;
11665 ;; Also support (neg (scc ..)) since that construct is used to replace
11666 ;; branches, (plus (scc ..) ..) since that construct is common and
11667 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11668 ;; cases where it is no more expensive than (neg (scc ..)).
11669
11670 ;; Have reload force a constant into a register for the simple insns that
11671 ;; otherwise won't accept constants.  We do this because it is faster than
11672 ;; the cmp/mfcr sequence we would otherwise generate.
11673
11674 (define_insn ""
11675   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11676         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11677                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
11678    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
11679   "TARGET_32BIT"
11680   "@
11681    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11682    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
11683    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11684    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11685    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
11686   [(set_attr "type" "three,two,three,three,three")
11687    (set_attr "length" "12,8,12,12,12")])
11688
11689 (define_insn ""
11690   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
11691         (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
11692                (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
11693    (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
11694   "TARGET_64BIT"
11695   "@
11696    xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
11697    subfic %3,%1,0\;adde %0,%3,%1
11698    xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
11699    xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
11700    subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
11701   [(set_attr "type" "three,two,three,three,three")
11702    (set_attr "length" "12,8,12,12,12")])
11703
11704 (define_insn ""
11705   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11706         (compare:CC
11707          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11708                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11709          (const_int 0)))
11710    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11711         (eq:SI (match_dup 1) (match_dup 2)))
11712    (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11713   "TARGET_32BIT"
11714   "@
11715    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11716    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
11717    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11718    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11719    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11720    #
11721    #
11722    #
11723    #
11724    #"
11725   [(set_attr "type" "compare")
11726    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11727
11728 (define_split
11729   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11730         (compare:CC
11731          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11732                 (match_operand:SI 2 "reg_or_cint_operand" ""))
11733          (const_int 0)))
11734    (set (match_operand:SI 0 "gpc_reg_operand" "")
11735         (eq:SI (match_dup 1) (match_dup 2)))
11736    (clobber (match_scratch:SI 3 ""))]
11737   "TARGET_32BIT && reload_completed"
11738   [(parallel [(set (match_dup 0)
11739         (eq:SI (match_dup 1) (match_dup 2)))
11740    (clobber (match_dup 3))])
11741    (set (match_dup 4)
11742         (compare:CC (match_dup 0)
11743                     (const_int 0)))]
11744   "")
11745
11746 (define_insn ""
11747   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11748         (compare:CC
11749          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11750                 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
11751          (const_int 0)))
11752    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11753         (eq:DI (match_dup 1) (match_dup 2)))
11754    (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11755   "TARGET_64BIT"
11756   "@
11757    xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11758    subfic %3,%1,0\;adde. %0,%3,%1
11759    xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
11760    xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
11761    subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11762    #
11763    #
11764    #
11765    #
11766    #"
11767   [(set_attr "type" "compare")
11768    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11769
11770 (define_split
11771   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11772         (compare:CC
11773          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11774                 (match_operand:DI 2 "reg_or_cint_operand" ""))
11775          (const_int 0)))
11776    (set (match_operand:DI 0 "gpc_reg_operand" "")
11777         (eq:DI (match_dup 1) (match_dup 2)))
11778    (clobber (match_scratch:DI 3 ""))]
11779   "TARGET_64BIT && reload_completed"
11780   [(parallel [(set (match_dup 0)
11781         (eq:DI (match_dup 1) (match_dup 2)))
11782    (clobber (match_dup 3))])
11783    (set (match_dup 4)
11784         (compare:CC (match_dup 0)
11785                     (const_int 0)))]
11786   "")
11787
11788 ;; We have insns of the form shown by the first define_insn below.  If
11789 ;; there is something inside the comparison operation, we must split it.
11790 (define_split
11791   [(set (match_operand:SI 0 "gpc_reg_operand" "")
11792         (plus:SI (match_operator 1 "comparison_operator"
11793                                  [(match_operand:SI 2 "" "")
11794                                   (match_operand:SI 3
11795                                                     "reg_or_cint_operand" "")])
11796                  (match_operand:SI 4 "gpc_reg_operand" "")))
11797    (clobber (match_operand:SI 5 "register_operand" ""))]
11798   "! gpc_reg_operand (operands[2], SImode)"
11799   [(set (match_dup 5) (match_dup 2))
11800    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11801                                (match_dup 4)))])
11802
11803 (define_insn ""
11804   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11805         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11806                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
11807                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11808   "TARGET_32BIT"
11809   "@
11810    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11811    {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11812    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11813    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11814    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11815   [(set_attr "type" "three,two,three,three,three")
11816    (set_attr "length" "12,8,12,12,12")])
11817
11818 (define_insn ""
11819   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11820         (compare:CC
11821          (plus:SI
11822           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11823                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11824           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11825          (const_int 0)))
11826    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11827   "TARGET_32BIT"
11828   "@
11829    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11830    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11831    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11832    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11833    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11834    #
11835    #
11836    #
11837    #
11838    #"
11839   [(set_attr "type" "compare")
11840    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11841
11842 (define_split
11843   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11844         (compare:CC
11845          (plus:SI
11846           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11847                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11848           (match_operand:SI 3 "gpc_reg_operand" ""))
11849          (const_int 0)))
11850    (clobber (match_scratch:SI 4 ""))]
11851   "TARGET_32BIT && reload_completed"
11852   [(set (match_dup 4)
11853         (plus:SI (eq:SI (match_dup 1)
11854                  (match_dup 2))
11855           (match_dup 3)))
11856    (set (match_dup 0)
11857         (compare:CC (match_dup 4)
11858                     (const_int 0)))]
11859   "")
11860
11861 (define_insn ""
11862   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11863         (compare:CC
11864          (plus:SI
11865           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11866                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11867           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11868          (const_int 0)))
11869    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11870         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11871   "TARGET_32BIT"
11872   "@
11873    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11874    {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11875    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11876    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11877    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11878    #
11879    #
11880    #
11881    #
11882    #"
11883   [(set_attr "type" "compare")
11884    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11885
11886 (define_split
11887   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11888         (compare:CC
11889          (plus:SI
11890           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11891                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11892           (match_operand:SI 3 "gpc_reg_operand" ""))
11893          (const_int 0)))
11894    (set (match_operand:SI 0 "gpc_reg_operand" "")
11895         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11896   "TARGET_32BIT && reload_completed"
11897   [(set (match_dup 0)
11898         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11899    (set (match_dup 4)
11900         (compare:CC (match_dup 0)
11901                     (const_int 0)))]
11902   "")
11903
11904 (define_insn ""
11905   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11906         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11907                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
11908   "TARGET_32BIT"
11909   "@
11910    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11911    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11912    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11913    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11914    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
11915    [(set_attr "type" "three,two,three,three,three")
11916     (set_attr "length" "12,8,12,12,12")])
11917
11918 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
11919 ;; since it nabs/sr is just as fast.
11920 (define_insn "*ne0"
11921   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11922         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11923                      (const_int 31)))
11924    (clobber (match_scratch:SI 2 "=&r"))]
11925   "! TARGET_POWER && TARGET_32BIT && !TARGET_ISEL"
11926   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11927   [(set_attr "type" "two")
11928    (set_attr "length" "8")])
11929
11930 (define_insn ""
11931   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11932         (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11933                      (const_int 63)))
11934    (clobber (match_scratch:DI 2 "=&r"))]
11935   "TARGET_64BIT"
11936   "addic %2,%1,-1\;subfe %0,%2,%1"
11937   [(set_attr "type" "two")
11938    (set_attr "length" "8")])
11939
11940 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11941 (define_insn ""
11942   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11943         (plus:SI (lshiftrt:SI
11944                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11945                   (const_int 31))
11946                  (match_operand:SI 2 "gpc_reg_operand" "r")))
11947    (clobber (match_scratch:SI 3 "=&r"))]
11948   "TARGET_32BIT"
11949   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11950   [(set_attr "type" "two")
11951    (set_attr "length" "8")])
11952
11953 (define_insn ""
11954   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11955         (plus:DI (lshiftrt:DI
11956                   (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11957                   (const_int 63))
11958                  (match_operand:DI 2 "gpc_reg_operand" "r")))
11959    (clobber (match_scratch:DI 3 "=&r"))]
11960   "TARGET_64BIT"
11961   "addic %3,%1,-1\;addze %0,%2"
11962   [(set_attr "type" "two")
11963    (set_attr "length" "8")])
11964
11965 (define_insn ""
11966   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11967         (compare:CC
11968          (plus:SI (lshiftrt:SI
11969                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11970                    (const_int 31))
11971                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11972          (const_int 0)))
11973    (clobber (match_scratch:SI 3 "=&r,&r"))
11974    (clobber (match_scratch:SI 4 "=X,&r"))]
11975   "TARGET_32BIT"
11976   "@
11977    {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11978    #"
11979   [(set_attr "type" "compare")
11980    (set_attr "length" "8,12")])
11981
11982 (define_split
11983   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11984         (compare:CC
11985          (plus:SI (lshiftrt:SI
11986                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11987                    (const_int 31))
11988                   (match_operand:SI 2 "gpc_reg_operand" ""))
11989          (const_int 0)))
11990    (clobber (match_scratch:SI 3 ""))
11991    (clobber (match_scratch:SI 4 ""))]
11992   "TARGET_32BIT && reload_completed"
11993   [(parallel [(set (match_dup 3)
11994                    (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11995                                          (const_int 31))
11996                             (match_dup 2)))
11997               (clobber (match_dup 4))])
11998    (set (match_dup 0)
11999         (compare:CC (match_dup 3)
12000                     (const_int 0)))]
12001   "")
12002
12003 (define_insn ""
12004   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12005         (compare:CC
12006          (plus:DI (lshiftrt:DI
12007                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
12008                    (const_int 63))
12009                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12010          (const_int 0)))
12011    (clobber (match_scratch:DI 3 "=&r,&r"))]
12012   "TARGET_64BIT"
12013   "@
12014    addic %3,%1,-1\;addze. %3,%2
12015    #"
12016   [(set_attr "type" "compare")
12017    (set_attr "length" "8,12")])
12018
12019 (define_split
12020   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12021         (compare:CC
12022          (plus:DI (lshiftrt:DI
12023                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12024                    (const_int 63))
12025                   (match_operand:DI 2 "gpc_reg_operand" ""))
12026          (const_int 0)))
12027    (clobber (match_scratch:DI 3 ""))]
12028   "TARGET_64BIT && reload_completed"
12029   [(set (match_dup 3)
12030         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
12031                    (const_int 63))
12032                   (match_dup 2)))
12033    (set (match_dup 0)
12034         (compare:CC (match_dup 3)
12035                     (const_int 0)))]
12036   "")
12037
12038 (define_insn ""
12039   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12040         (compare:CC
12041          (plus:SI (lshiftrt:SI
12042                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
12043                    (const_int 31))
12044                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12045          (const_int 0)))
12046    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12047         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12048                  (match_dup 2)))
12049    (clobber (match_scratch:SI 3 "=&r,&r"))]
12050   "TARGET_32BIT"
12051   "@
12052    {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
12053    #"
12054   [(set_attr "type" "compare")
12055    (set_attr "length" "8,12")])
12056
12057 (define_split
12058   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12059         (compare:CC
12060          (plus:SI (lshiftrt:SI
12061                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12062                    (const_int 31))
12063                   (match_operand:SI 2 "gpc_reg_operand" ""))
12064          (const_int 0)))
12065    (set (match_operand:SI 0 "gpc_reg_operand" "")
12066         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12067                  (match_dup 2)))
12068    (clobber (match_scratch:SI 3 ""))]
12069   "TARGET_32BIT && reload_completed"
12070   [(parallel [(set (match_dup 0)
12071         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12072                  (match_dup 2)))
12073    (clobber (match_dup 3))])
12074    (set (match_dup 4)
12075         (compare:CC (match_dup 0)
12076                     (const_int 0)))]
12077   "")
12078
12079 (define_insn ""
12080   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12081         (compare:CC
12082          (plus:DI (lshiftrt:DI
12083                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
12084                    (const_int 63))
12085                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12086          (const_int 0)))
12087    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12088         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12089                  (match_dup 2)))
12090    (clobber (match_scratch:DI 3 "=&r,&r"))]
12091   "TARGET_64BIT"
12092   "@
12093    addic %3,%1,-1\;addze. %0,%2
12094    #"
12095   [(set_attr "type" "compare")
12096    (set_attr "length" "8,12")])
12097
12098 (define_split
12099   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12100         (compare:CC
12101          (plus:DI (lshiftrt:DI
12102                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12103                    (const_int 63))
12104                   (match_operand:DI 2 "gpc_reg_operand" ""))
12105          (const_int 0)))
12106    (set (match_operand:DI 0 "gpc_reg_operand" "")
12107         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12108                  (match_dup 2)))
12109    (clobber (match_scratch:DI 3 ""))]
12110   "TARGET_64BIT && reload_completed"
12111   [(parallel [(set (match_dup 0)
12112         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12113                  (match_dup 2)))
12114    (clobber (match_dup 3))])
12115    (set (match_dup 4)
12116         (compare:CC (match_dup 0)
12117                     (const_int 0)))]
12118   "")
12119
12120 (define_insn ""
12121   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12122         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12123                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12124    (clobber (match_scratch:SI 3 "=r,X"))]
12125   "TARGET_POWER"
12126   "@
12127    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
12128    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
12129   [(set_attr "length" "12")])
12130
12131 (define_insn ""
12132   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12133         (compare:CC
12134          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12135                 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12136          (const_int 0)))
12137    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12138         (le:SI (match_dup 1) (match_dup 2)))
12139    (clobber (match_scratch:SI 3 "=r,X,r,X"))]
12140   "TARGET_POWER"
12141   "@
12142    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12143    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12144    #
12145    #"
12146   [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12147    (set_attr "length" "12,12,16,16")])
12148
12149 (define_split
12150   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12151         (compare:CC
12152          (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12153                 (match_operand:SI 2 "reg_or_short_operand" ""))
12154          (const_int 0)))
12155    (set (match_operand:SI 0 "gpc_reg_operand" "")
12156         (le:SI (match_dup 1) (match_dup 2)))
12157    (clobber (match_scratch:SI 3 ""))]
12158   "TARGET_POWER && reload_completed"
12159   [(parallel [(set (match_dup 0)
12160         (le:SI (match_dup 1) (match_dup 2)))
12161    (clobber (match_dup 3))])
12162    (set (match_dup 4)
12163         (compare:CC (match_dup 0)
12164                     (const_int 0)))]
12165   "")
12166
12167 (define_insn ""
12168   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12169         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12170                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
12171                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12172   "TARGET_POWER"
12173   "@
12174    doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12175    {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
12176   [(set_attr "length" "12")])
12177
12178 (define_insn ""
12179   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12180         (compare:CC
12181          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12182                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12183                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12184          (const_int 0)))
12185    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12186   "TARGET_POWER"
12187   "@
12188    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12189    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12190    #
12191    #"
12192   [(set_attr "type" "compare")
12193    (set_attr "length" "12,12,16,16")])
12194
12195 (define_split
12196   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12197         (compare:CC
12198          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12199                          (match_operand:SI 2 "reg_or_short_operand" ""))
12200                   (match_operand:SI 3 "gpc_reg_operand" ""))
12201          (const_int 0)))
12202    (clobber (match_scratch:SI 4 ""))]
12203   "TARGET_POWER && reload_completed"
12204   [(set (match_dup 4)
12205         (plus:SI (le:SI (match_dup 1) (match_dup 2))
12206                  (match_dup 3)))
12207    (set (match_dup 0)
12208         (compare:CC (match_dup 4)
12209                     (const_int 0)))]
12210   "")
12211
12212 (define_insn ""
12213   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12214         (compare:CC
12215          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12216                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12217                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12218          (const_int 0)))
12219    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12220         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12221   "TARGET_POWER"
12222   "@
12223    doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12224    {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
12225    #
12226    #"
12227   [(set_attr "type" "compare")
12228    (set_attr "length" "12,12,16,16")])
12229
12230 (define_split
12231   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12232         (compare:CC
12233          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12234                          (match_operand:SI 2 "reg_or_short_operand" ""))
12235                   (match_operand:SI 3 "gpc_reg_operand" ""))
12236          (const_int 0)))
12237    (set (match_operand:SI 0 "gpc_reg_operand" "")
12238         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12239   "TARGET_POWER && reload_completed"
12240   [(set (match_dup 0)
12241         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12242    (set (match_dup 4)
12243         (compare:CC (match_dup 0)
12244                     (const_int 0)))]
12245   "")
12246
12247 (define_insn ""
12248   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12249         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12250                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
12251   "TARGET_POWER"
12252   "@
12253    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12254    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
12255   [(set_attr "length" "12")])
12256
12257 (define_insn ""
12258   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12259         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12260                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12261   "TARGET_32BIT"
12262   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12263   [(set_attr "type" "three")
12264    (set_attr "length" "12")])
12265
12266 (define_insn ""
12267   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12268         (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12269                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
12270   "TARGET_64BIT"
12271   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12272   [(set_attr "type" "three")
12273    (set_attr "length" "12")])
12274
12275 (define_insn ""
12276   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12277         (compare:CC
12278          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12279                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
12280          (const_int 0)))
12281    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12282         (leu:DI (match_dup 1) (match_dup 2)))]
12283   "TARGET_64BIT"
12284   "@
12285    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12286    #"
12287   [(set_attr "type" "compare")
12288    (set_attr "length" "12,16")])
12289
12290 (define_split
12291   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12292         (compare:CC
12293          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12294                  (match_operand:DI 2 "reg_or_short_operand" ""))
12295          (const_int 0)))
12296    (set (match_operand:DI 0 "gpc_reg_operand" "")
12297         (leu:DI (match_dup 1) (match_dup 2)))]
12298   "TARGET_64BIT && reload_completed"
12299   [(set (match_dup 0)
12300         (leu:DI (match_dup 1) (match_dup 2)))
12301    (set (match_dup 3)
12302         (compare:CC (match_dup 0)
12303                     (const_int 0)))]
12304   "")
12305
12306 (define_insn ""
12307   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12308         (compare:CC
12309          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12310                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12311          (const_int 0)))
12312    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12313         (leu:SI (match_dup 1) (match_dup 2)))]
12314   "TARGET_32BIT"
12315   "@
12316    {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12317    #"
12318   [(set_attr "type" "compare")
12319    (set_attr "length" "12,16")])
12320
12321 (define_split
12322   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12323         (compare:CC
12324          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12325                  (match_operand:SI 2 "reg_or_short_operand" ""))
12326          (const_int 0)))
12327    (set (match_operand:SI 0 "gpc_reg_operand" "")
12328         (leu:SI (match_dup 1) (match_dup 2)))]
12329   "TARGET_32BIT && reload_completed"
12330   [(set (match_dup 0)
12331         (leu:SI (match_dup 1) (match_dup 2)))
12332    (set (match_dup 3)
12333         (compare:CC (match_dup 0)
12334                     (const_int 0)))]
12335   "")
12336
12337 (define_insn ""
12338   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12339         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12340                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
12341                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12342   "TARGET_32BIT"
12343   "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
12344   [(set_attr "type" "two")
12345    (set_attr "length" "8")])
12346
12347 (define_insn ""
12348   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12349         (compare:CC
12350          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12351                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12352                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12353          (const_int 0)))
12354    (clobber (match_scratch:SI 4 "=&r,&r"))]
12355   "TARGET_32BIT"
12356   "@
12357    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12358    #"
12359   [(set_attr "type" "compare")
12360    (set_attr "length" "8,12")])
12361
12362 (define_split
12363   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12364         (compare:CC
12365          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12366                           (match_operand:SI 2 "reg_or_short_operand" ""))
12367                   (match_operand:SI 3 "gpc_reg_operand" ""))
12368          (const_int 0)))
12369    (clobber (match_scratch:SI 4 ""))]
12370   "TARGET_32BIT && reload_completed"
12371   [(set (match_dup 4)
12372         (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12373                   (match_dup 3)))
12374    (set (match_dup 0)
12375         (compare:CC (match_dup 4)
12376                     (const_int 0)))]
12377   "")
12378
12379 (define_insn ""
12380   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12381         (compare:CC
12382          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12383                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12384                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12385          (const_int 0)))
12386    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12387         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12388   "TARGET_32BIT"
12389   "@
12390    {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
12391    #"
12392   [(set_attr "type" "compare")
12393    (set_attr "length" "8,12")])
12394
12395 (define_split
12396   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12397         (compare:CC
12398          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12399                           (match_operand:SI 2 "reg_or_short_operand" ""))
12400                   (match_operand:SI 3 "gpc_reg_operand" ""))
12401          (const_int 0)))
12402    (set (match_operand:SI 0 "gpc_reg_operand" "")
12403         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12404   "TARGET_32BIT && reload_completed"
12405   [(set (match_dup 0)
12406         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12407    (set (match_dup 4)
12408         (compare:CC (match_dup 0)
12409                     (const_int 0)))]
12410   "")
12411
12412 (define_insn ""
12413   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12414         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12415                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12416   "TARGET_32BIT"
12417   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
12418    [(set_attr "type" "three")
12419     (set_attr "length" "12")])
12420
12421 (define_insn ""
12422   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12423         (and:SI (neg:SI
12424                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12425                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
12426                 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12427   "TARGET_32BIT"
12428   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12429   [(set_attr "type" "three")
12430    (set_attr "length" "12")])
12431
12432 (define_insn ""
12433   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12434         (compare:CC
12435          (and:SI (neg:SI
12436                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12437                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12438                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12439          (const_int 0)))
12440    (clobber (match_scratch:SI 4 "=&r,&r"))]
12441   "TARGET_32BIT"
12442   "@
12443    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12444    #"
12445   [(set_attr "type" "compare")
12446    (set_attr "length" "12,16")])
12447
12448 (define_split
12449   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12450         (compare:CC
12451          (and:SI (neg:SI
12452                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12453                           (match_operand:SI 2 "reg_or_short_operand" "")))
12454                  (match_operand:SI 3 "gpc_reg_operand" ""))
12455          (const_int 0)))
12456    (clobber (match_scratch:SI 4 ""))]
12457   "TARGET_32BIT && reload_completed"
12458   [(set (match_dup 4)
12459         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12460                 (match_dup 3)))
12461    (set (match_dup 0)
12462         (compare:CC (match_dup 4)
12463                     (const_int 0)))]
12464   "")
12465
12466 (define_insn ""
12467   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12468         (compare:CC
12469          (and:SI (neg:SI
12470                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12471                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12472                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12473          (const_int 0)))
12474    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12475         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12476   "TARGET_32BIT"
12477   "@
12478    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12479    #"
12480   [(set_attr "type" "compare")
12481    (set_attr "length" "12,16")])
12482
12483 (define_split
12484   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12485         (compare:CC
12486          (and:SI (neg:SI
12487                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12488                           (match_operand:SI 2 "reg_or_short_operand" "")))
12489                  (match_operand:SI 3 "gpc_reg_operand" ""))
12490          (const_int 0)))
12491    (set (match_operand:SI 0 "gpc_reg_operand" "")
12492         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12493   "TARGET_32BIT && reload_completed"
12494   [(set (match_dup 0)
12495         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12496                 (match_dup 3)))
12497    (set (match_dup 4)
12498         (compare:CC (match_dup 0)
12499                     (const_int 0)))]
12500   "")
12501
12502 (define_insn ""
12503   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12504         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12505                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12506   "TARGET_POWER"
12507   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12508    [(set_attr "length" "12")])
12509
12510 (define_insn ""
12511   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12512         (compare:CC
12513          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12514                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12515          (const_int 0)))
12516    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12517         (lt:SI (match_dup 1) (match_dup 2)))]
12518   "TARGET_POWER"
12519   "@
12520    doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12521    #"
12522   [(set_attr "type" "delayed_compare")
12523    (set_attr "length" "12,16")])
12524
12525 (define_split
12526   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12527         (compare:CC
12528          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12529                 (match_operand:SI 2 "reg_or_short_operand" ""))
12530          (const_int 0)))
12531    (set (match_operand:SI 0 "gpc_reg_operand" "")
12532         (lt:SI (match_dup 1) (match_dup 2)))]
12533   "TARGET_POWER && reload_completed"
12534   [(set (match_dup 0)
12535         (lt:SI (match_dup 1) (match_dup 2)))
12536    (set (match_dup 3)
12537         (compare:CC (match_dup 0)
12538                     (const_int 0)))]
12539   "")
12540
12541 (define_insn ""
12542   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12543         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12544                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
12545                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12546   "TARGET_POWER"
12547   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
12548   [(set_attr "length" "12")])
12549
12550 (define_insn ""
12551   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12552         (compare:CC
12553          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12554                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12555                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12556          (const_int 0)))
12557    (clobber (match_scratch:SI 4 "=&r,&r"))]
12558   "TARGET_POWER"
12559   "@
12560    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12561    #"
12562   [(set_attr "type" "compare")
12563    (set_attr "length" "12,16")])
12564
12565 (define_split
12566   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12567         (compare:CC
12568          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12569                          (match_operand:SI 2 "reg_or_short_operand" ""))
12570                   (match_operand:SI 3 "gpc_reg_operand" ""))
12571          (const_int 0)))
12572    (clobber (match_scratch:SI 4 ""))]
12573   "TARGET_POWER && reload_completed"
12574   [(set (match_dup 4)
12575         (plus:SI (lt:SI (match_dup 1) (match_dup 2))
12576                  (match_dup 3)))
12577    (set (match_dup 0)
12578         (compare:CC (match_dup 4)
12579                     (const_int 0)))]
12580   "")
12581
12582 (define_insn ""
12583   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12584         (compare:CC
12585          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12586                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12587                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12588          (const_int 0)))
12589    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12590         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12591   "TARGET_POWER"
12592   "@
12593    doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12594    #"
12595   [(set_attr "type" "compare")
12596    (set_attr "length" "12,16")])
12597
12598 (define_split
12599   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12600         (compare:CC
12601          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12602                          (match_operand:SI 2 "reg_or_short_operand" ""))
12603                   (match_operand:SI 3 "gpc_reg_operand" ""))
12604          (const_int 0)))
12605    (set (match_operand:SI 0 "gpc_reg_operand" "")
12606         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12607   "TARGET_POWER && reload_completed"
12608   [(set (match_dup 0)
12609         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12610    (set (match_dup 4)
12611         (compare:CC (match_dup 0)
12612                     (const_int 0)))]
12613   "")
12614
12615 (define_insn ""
12616   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12617         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12618                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12619   "TARGET_POWER"
12620   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12621   [(set_attr "length" "12")])
12622
12623 (define_insn_and_split ""
12624   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12625         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12626                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12627   "TARGET_32BIT"
12628   "#"
12629   "TARGET_32BIT"
12630   [(set (match_dup 0) (neg:SI (ltu:SI (match_dup 1) (match_dup 2))))
12631    (set (match_dup 0) (neg:SI (match_dup 0)))]
12632   "")
12633
12634 (define_insn_and_split ""
12635   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12636         (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12637                 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
12638   "TARGET_64BIT"
12639   "#"
12640   "TARGET_64BIT"
12641   [(set (match_dup 0) (neg:DI (ltu:DI (match_dup 1) (match_dup 2))))
12642    (set (match_dup 0) (neg:DI (match_dup 0)))]
12643   "")
12644
12645 (define_insn ""
12646   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12647         (compare:CC
12648          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12649                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12650          (const_int 0)))
12651    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12652         (ltu:SI (match_dup 1) (match_dup 2)))]
12653   "TARGET_32BIT"
12654   "@
12655    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12656    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12657    #
12658    #"
12659   [(set_attr "type" "compare")
12660    (set_attr "length" "12,12,16,16")])
12661
12662 (define_split
12663   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12664         (compare:CC
12665          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12666                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12667          (const_int 0)))
12668    (set (match_operand:SI 0 "gpc_reg_operand" "")
12669         (ltu:SI (match_dup 1) (match_dup 2)))]
12670   "TARGET_32BIT && reload_completed"
12671   [(set (match_dup 0)
12672         (ltu:SI (match_dup 1) (match_dup 2)))
12673    (set (match_dup 3)
12674         (compare:CC (match_dup 0)
12675                     (const_int 0)))]
12676   "")
12677
12678 (define_insn_and_split ""
12679   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
12680         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12681                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12682                  (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
12683   "TARGET_32BIT"
12684   "#"
12685   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12686   [(set (match_dup 0) (neg:SI (ltu:SI (match_dup 1) (match_dup 2))))
12687    (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 0)))]
12688   "")
12689
12690 (define_insn_and_split ""
12691   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
12692         (plus:DI (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12693                          (match_operand:DI 2 "reg_or_neg_short_operand" "r,P"))
12694                  (match_operand:DI 3 "reg_or_short_operand" "rI,rI")))]
12695   "TARGET_64BIT"
12696   "#"
12697   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
12698   [(set (match_dup 0) (neg:DI (ltu:DI (match_dup 1) (match_dup 2))))
12699    (set (match_dup 0) (minus:DI (match_dup 3) (match_dup 0)))]
12700   "")
12701
12702 (define_insn ""
12703   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12704         (compare:CC
12705          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12706                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12707                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12708          (const_int 0)))
12709    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12710   "TARGET_32BIT"
12711   "@
12712    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
12713    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
12714    #
12715    #"
12716   [(set_attr "type" "compare")
12717    (set_attr "length" "12,12,16,16")])
12718
12719 (define_split
12720   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12721         (compare:CC
12722          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12723                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12724                   (match_operand:SI 3 "gpc_reg_operand" ""))
12725          (const_int 0)))
12726    (clobber (match_scratch:SI 4 ""))]
12727   "TARGET_32BIT && reload_completed"
12728   [(set (match_dup 4)
12729         (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
12730                  (match_dup 3)))
12731    (set (match_dup 0)
12732         (compare:CC (match_dup 4)
12733                     (const_int 0)))]
12734   "")
12735
12736 (define_insn ""
12737   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12738         (compare:CC
12739          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12740                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12741                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12742          (const_int 0)))
12743    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12744         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12745   "TARGET_32BIT"
12746   "@
12747    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
12748    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
12749    #
12750    #"
12751   [(set_attr "type" "compare")
12752    (set_attr "length" "12,12,16,16")])
12753
12754 (define_split
12755   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12756         (compare:CC
12757          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12758                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12759                   (match_operand:SI 3 "gpc_reg_operand" ""))
12760          (const_int 0)))
12761    (set (match_operand:SI 0 "gpc_reg_operand" "")
12762         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12763   "TARGET_32BIT && reload_completed"
12764   [(set (match_dup 0)
12765         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12766    (set (match_dup 4)
12767         (compare:CC (match_dup 0)
12768                     (const_int 0)))]
12769   "")
12770
12771 (define_insn ""
12772   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12773         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12774                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
12775   "TARGET_32BIT"
12776   "@
12777    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12778    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12779   [(set_attr "type" "two")
12780    (set_attr "length" "8")])
12781
12782 (define_insn ""
12783   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12784         (neg:DI (ltu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12785                         (match_operand:DI 2 "reg_or_neg_short_operand" "r,P"))))]
12786   "TARGET_64BIT"
12787   "@
12788    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12789    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12790   [(set_attr "type" "two")
12791    (set_attr "length" "8")])
12792
12793 (define_insn ""
12794   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12795         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12796                (match_operand:SI 2 "reg_or_short_operand" "rI")))
12797    (clobber (match_scratch:SI 3 "=r"))]
12798   "TARGET_POWER"
12799   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12800    [(set_attr "length" "12")])
12801
12802 (define_insn ""
12803   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12804         (compare:CC
12805          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12806                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12807          (const_int 0)))
12808    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12809         (ge:SI (match_dup 1) (match_dup 2)))
12810    (clobber (match_scratch:SI 3 "=r,r"))]
12811   "TARGET_POWER"
12812   "@
12813    doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12814    #"
12815   [(set_attr "type" "compare")
12816    (set_attr "length" "12,16")])
12817
12818 (define_split
12819   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12820         (compare:CC
12821          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12822                 (match_operand:SI 2 "reg_or_short_operand" ""))
12823          (const_int 0)))
12824    (set (match_operand:SI 0 "gpc_reg_operand" "")
12825         (ge:SI (match_dup 1) (match_dup 2)))
12826    (clobber (match_scratch:SI 3 ""))]
12827   "TARGET_POWER && reload_completed"
12828   [(parallel [(set (match_dup 0)
12829                    (ge:SI (match_dup 1) (match_dup 2)))
12830               (clobber (match_dup 3))])
12831    (set (match_dup 4)
12832         (compare:CC (match_dup 0)
12833                     (const_int 0)))]
12834   "")
12835
12836 (define_insn ""
12837   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12838         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12839                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
12840                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12841   "TARGET_POWER"
12842   "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12843   [(set_attr "length" "12")])
12844
12845 (define_insn ""
12846   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12847         (compare:CC
12848          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12849                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12850                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12851          (const_int 0)))
12852    (clobber (match_scratch:SI 4 "=&r,&r"))]
12853   "TARGET_POWER"
12854   "@
12855    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12856    #"
12857   [(set_attr "type" "compare")
12858    (set_attr "length" "12,16")])
12859
12860 (define_split
12861   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12862         (compare:CC
12863          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12864                          (match_operand:SI 2 "reg_or_short_operand" ""))
12865                   (match_operand:SI 3 "gpc_reg_operand" ""))
12866          (const_int 0)))
12867    (clobber (match_scratch:SI 4 ""))]
12868   "TARGET_POWER && reload_completed"
12869   [(set (match_dup 4)
12870         (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12871                  (match_dup 3)))
12872    (set (match_dup 0)
12873         (compare:CC (match_dup 4)
12874                     (const_int 0)))]
12875   "")
12876
12877 (define_insn ""
12878   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12879         (compare:CC
12880          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12881                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12882                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12883          (const_int 0)))
12884    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12885         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12886   "TARGET_POWER"
12887   "@
12888    doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12889    #"
12890   [(set_attr "type" "compare")
12891    (set_attr "length" "12,16")])
12892
12893 (define_split
12894   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12895         (compare:CC
12896          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12897                          (match_operand:SI 2 "reg_or_short_operand" ""))
12898                   (match_operand:SI 3 "gpc_reg_operand" ""))
12899          (const_int 0)))
12900    (set (match_operand:SI 0 "gpc_reg_operand" "")
12901         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12902   "TARGET_POWER && reload_completed"
12903   [(set (match_dup 0)
12904         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12905    (set (match_dup 4)
12906         (compare:CC (match_dup 0)
12907                     (const_int 0)))]
12908   "")
12909
12910 (define_insn ""
12911   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12912         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12913                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12914   "TARGET_POWER"
12915   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12916   [(set_attr "length" "12")])
12917
12918 (define_insn ""
12919   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12920         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12921                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12922   "TARGET_32BIT"
12923   "@
12924    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12925    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12926   [(set_attr "type" "three")
12927    (set_attr "length" "12")])
12928
12929 (define_insn ""
12930   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12931         (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12932                 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
12933   "TARGET_64BIT"
12934   "@
12935    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12936    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12937   [(set_attr "type" "three")
12938    (set_attr "length" "12")])
12939
12940 (define_insn ""
12941   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12942         (compare:CC
12943          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12944                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12945          (const_int 0)))
12946    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12947         (geu:SI (match_dup 1) (match_dup 2)))]
12948   "TARGET_32BIT"
12949   "@
12950    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12951    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12952    #
12953    #"
12954   [(set_attr "type" "compare")
12955    (set_attr "length" "12,12,16,16")])
12956
12957 (define_split
12958   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12959         (compare:CC
12960          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12961                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12962          (const_int 0)))
12963    (set (match_operand:SI 0 "gpc_reg_operand" "")
12964         (geu:SI (match_dup 1) (match_dup 2)))]
12965   "TARGET_32BIT && reload_completed"
12966   [(set (match_dup 0)
12967         (geu:SI (match_dup 1) (match_dup 2)))
12968    (set (match_dup 3)
12969         (compare:CC (match_dup 0)
12970                     (const_int 0)))]
12971   "")
12972
12973 (define_insn ""
12974   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12975         (compare:CC
12976          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12977                  (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12978          (const_int 0)))
12979    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12980         (geu:DI (match_dup 1) (match_dup 2)))]
12981   "TARGET_64BIT"
12982   "@
12983    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12984    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12985    #
12986    #"
12987   [(set_attr "type" "compare")
12988    (set_attr "length" "12,12,16,16")])
12989
12990 (define_split
12991   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12992         (compare:CC
12993          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12994                  (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12995          (const_int 0)))
12996    (set (match_operand:DI 0 "gpc_reg_operand" "")
12997         (geu:DI (match_dup 1) (match_dup 2)))]
12998   "TARGET_64BIT && reload_completed"
12999   [(set (match_dup 0)
13000         (geu:DI (match_dup 1) (match_dup 2)))
13001    (set (match_dup 3)
13002         (compare:CC (match_dup 0)
13003                     (const_int 0)))]
13004   "")
13005
13006 (define_insn ""
13007   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13008         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13009                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
13010                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
13011   "TARGET_32BIT"
13012   "@
13013    {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
13014    {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
13015   [(set_attr "type" "two")
13016    (set_attr "length" "8")])
13017
13018 (define_insn ""
13019   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13020         (compare:CC
13021          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13022                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13023                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13024          (const_int 0)))
13025    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13026   "TARGET_32BIT"
13027   "@
13028    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
13029    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
13030    #
13031    #"
13032   [(set_attr "type" "compare")
13033    (set_attr "length" "8,8,12,12")])
13034
13035 (define_split
13036   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13037         (compare:CC
13038          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13039                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13040                   (match_operand:SI 3 "gpc_reg_operand" ""))
13041          (const_int 0)))
13042    (clobber (match_scratch:SI 4 ""))]
13043   "TARGET_32BIT && reload_completed"
13044   [(set (match_dup 4)
13045         (plus:SI (geu:SI (match_dup 1) (match_dup 2))
13046                   (match_dup 3)))
13047    (set (match_dup 0)
13048         (compare:CC (match_dup 4)
13049                     (const_int 0)))]
13050   "")
13051
13052 (define_insn ""
13053   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13054         (compare:CC
13055          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13056                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
13057                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13058          (const_int 0)))
13059    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13060         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13061   "TARGET_32BIT"
13062   "@
13063    {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
13064    {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
13065    #
13066    #"
13067   [(set_attr "type" "compare")
13068    (set_attr "length" "8,8,12,12")])
13069
13070 (define_split
13071   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13072         (compare:CC
13073          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13074                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
13075                   (match_operand:SI 3 "gpc_reg_operand" ""))
13076          (const_int 0)))
13077    (set (match_operand:SI 0 "gpc_reg_operand" "")
13078         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13079   "TARGET_32BIT && reload_completed"
13080   [(set (match_dup 0)
13081         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13082    (set (match_dup 4)
13083         (compare:CC (match_dup 0)
13084                     (const_int 0)))]
13085   "")
13086
13087 (define_insn ""
13088   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13089         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13090                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
13091   "TARGET_32BIT"
13092   "@
13093    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
13094    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
13095   [(set_attr "type" "three")
13096    (set_attr "length" "12")])
13097
13098 (define_insn ""
13099   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13100         (and:SI (neg:SI
13101                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13102                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
13103                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
13104   "TARGET_32BIT"
13105   "@
13106    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
13107    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
13108   [(set_attr "type" "three")
13109    (set_attr "length" "12")])
13110
13111 (define_insn ""
13112   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13113         (compare:CC
13114          (and:SI (neg:SI
13115                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13116                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13117                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13118          (const_int 0)))
13119    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13120   "TARGET_32BIT"
13121   "@
13122    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13123    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13124    #
13125    #"
13126   [(set_attr "type" "compare")
13127    (set_attr "length" "12,12,16,16")])
13128
13129 (define_split
13130   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13131         (compare:CC
13132          (and:SI (neg:SI
13133                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13134                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13135                  (match_operand:SI 3 "gpc_reg_operand" ""))
13136          (const_int 0)))
13137    (clobber (match_scratch:SI 4 ""))]
13138   "TARGET_32BIT && reload_completed"
13139   [(set (match_dup 4)
13140         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
13141                 (match_dup 3)))
13142    (set (match_dup 0)
13143         (compare:CC (match_dup 4)
13144                     (const_int 0)))]
13145   "")
13146
13147 (define_insn ""
13148   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13149         (compare:CC
13150          (and:SI (neg:SI
13151                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13152                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13153                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13154          (const_int 0)))
13155    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13156         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13157   "TARGET_32BIT"
13158   "@
13159    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13160    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13161    #
13162    #"
13163   [(set_attr "type" "compare")
13164    (set_attr "length" "12,12,16,16")])
13165
13166 (define_split
13167   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13168         (compare:CC
13169          (and:SI (neg:SI
13170                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13171                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13172                  (match_operand:SI 3 "gpc_reg_operand" ""))
13173          (const_int 0)))
13174    (set (match_operand:SI 0 "gpc_reg_operand" "")
13175         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13176   "TARGET_32BIT && reload_completed"
13177   [(set (match_dup 0)
13178         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
13179    (set (match_dup 4)
13180         (compare:CC (match_dup 0)
13181                     (const_int 0)))]
13182   "")
13183
13184 (define_insn ""
13185   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13186         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13187                (const_int 0)))]
13188   "TARGET_32BIT"
13189   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
13190   [(set_attr "type" "three")
13191    (set_attr "length" "12")])
13192
13193 (define_insn ""
13194   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13195         (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13196                (const_int 0)))]
13197   "TARGET_64BIT"
13198   "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
13199   [(set_attr "type" "three")
13200    (set_attr "length" "12")])
13201
13202 (define_insn ""
13203   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
13204         (compare:CC
13205          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13206                 (const_int 0))
13207          (const_int 0)))
13208    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13209         (gt:SI (match_dup 1) (const_int 0)))]
13210   "TARGET_32BIT"
13211   "@
13212    {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
13213    #"
13214   [(set_attr "type" "delayed_compare")
13215    (set_attr "length" "12,16")])
13216
13217 (define_split
13218   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13219         (compare:CC
13220          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13221                 (const_int 0))
13222          (const_int 0)))
13223    (set (match_operand:SI 0 "gpc_reg_operand" "")
13224         (gt:SI (match_dup 1) (const_int 0)))]
13225   "TARGET_32BIT && reload_completed"
13226   [(set (match_dup 0)
13227         (gt:SI (match_dup 1) (const_int 0)))
13228    (set (match_dup 2)
13229         (compare:CC (match_dup 0)
13230                     (const_int 0)))]
13231   "")
13232
13233 (define_insn ""
13234   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
13235         (compare:CC
13236          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13237                 (const_int 0))
13238          (const_int 0)))
13239    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
13240         (gt:DI (match_dup 1) (const_int 0)))]
13241   "TARGET_64BIT"
13242   "@
13243    subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
13244    #"
13245   [(set_attr "type" "delayed_compare")
13246    (set_attr "length" "12,16")])
13247
13248 (define_split
13249   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13250         (compare:CC
13251          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13252                 (const_int 0))
13253          (const_int 0)))
13254    (set (match_operand:DI 0 "gpc_reg_operand" "")
13255         (gt:DI (match_dup 1) (const_int 0)))]
13256   "TARGET_64BIT && reload_completed"
13257   [(set (match_dup 0)
13258         (gt:DI (match_dup 1) (const_int 0)))
13259    (set (match_dup 2)
13260         (compare:CC (match_dup 0)
13261                     (const_int 0)))]
13262   "")
13263
13264 (define_insn ""
13265   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13266         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13267                (match_operand:SI 2 "reg_or_short_operand" "r")))]
13268   "TARGET_POWER"
13269   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
13270   [(set_attr "length" "12")])
13271
13272 (define_insn ""
13273   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13274         (compare:CC
13275          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13276                 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13277          (const_int 0)))
13278    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13279         (gt:SI (match_dup 1) (match_dup 2)))]
13280   "TARGET_POWER"
13281   "@
13282    doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13283    #"
13284   [(set_attr "type" "delayed_compare")
13285    (set_attr "length" "12,16")])
13286
13287 (define_split
13288   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13289         (compare:CC
13290          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13291                 (match_operand:SI 2 "reg_or_short_operand" ""))
13292          (const_int 0)))
13293    (set (match_operand:SI 0 "gpc_reg_operand" "")
13294         (gt:SI (match_dup 1) (match_dup 2)))]
13295   "TARGET_POWER && reload_completed"
13296   [(set (match_dup 0)
13297         (gt:SI (match_dup 1) (match_dup 2)))
13298    (set (match_dup 3)
13299         (compare:CC (match_dup 0)
13300                     (const_int 0)))]
13301   "")
13302
13303 (define_insn ""
13304   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13305         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13306                         (const_int 0))
13307                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
13308   "TARGET_32BIT"
13309   "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
13310   [(set_attr "type" "three")
13311    (set_attr "length" "12")])
13312
13313 (define_insn ""
13314   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
13315         (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13316                         (const_int 0))
13317                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
13318   "TARGET_64BIT"
13319   "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
13320   [(set_attr "type" "three")
13321    (set_attr "length" "12")])
13322
13323 (define_insn ""
13324   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13325         (compare:CC
13326          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13327                          (const_int 0))
13328                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13329          (const_int 0)))
13330    (clobber (match_scratch:SI 3 "=&r,&r"))]
13331   "TARGET_32BIT"
13332   "@
13333    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13334    #"
13335   [(set_attr "type" "compare")
13336    (set_attr "length" "12,16")])
13337
13338 (define_split
13339   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13340         (compare:CC
13341          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13342                          (const_int 0))
13343                   (match_operand:SI 2 "gpc_reg_operand" ""))
13344          (const_int 0)))
13345    (clobber (match_scratch:SI 3 ""))]
13346   "TARGET_32BIT && reload_completed"
13347   [(set (match_dup 3)
13348         (plus:SI (gt:SI (match_dup 1) (const_int 0))
13349                   (match_dup 2)))
13350    (set (match_dup 0)
13351         (compare:CC (match_dup 3)
13352                     (const_int 0)))]
13353   "")
13354
13355 (define_insn ""
13356   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13357         (compare:CC
13358          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13359                          (const_int 0))
13360                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13361          (const_int 0)))
13362    (clobber (match_scratch:DI 3 "=&r,&r"))]
13363   "TARGET_64BIT"
13364   "@
13365    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13366    #"
13367   [(set_attr "type" "compare")
13368    (set_attr "length" "12,16")])
13369
13370 (define_split
13371   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13372         (compare:CC
13373          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13374                          (const_int 0))
13375                   (match_operand:DI 2 "gpc_reg_operand" ""))
13376          (const_int 0)))
13377    (clobber (match_scratch:DI 3 ""))]
13378   "TARGET_64BIT && reload_completed"
13379   [(set (match_dup 3)
13380         (plus:DI (gt:DI (match_dup 1) (const_int 0))
13381                  (match_dup 2)))
13382    (set (match_dup 0)
13383         (compare:CC (match_dup 3)
13384                     (const_int 0)))]
13385   "")
13386
13387 (define_insn ""
13388   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13389         (compare:CC
13390          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13391                          (const_int 0))
13392                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13393          (const_int 0)))
13394    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13395         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13396   "TARGET_32BIT"
13397   "@
13398    {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
13399    #"
13400   [(set_attr "type" "compare")
13401    (set_attr "length" "12,16")])
13402
13403 (define_split
13404   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13405         (compare:CC
13406          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13407                          (const_int 0))
13408                   (match_operand:SI 2 "gpc_reg_operand" ""))
13409          (const_int 0)))
13410    (set (match_operand:SI 0 "gpc_reg_operand" "")
13411         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13412   "TARGET_32BIT && reload_completed"
13413   [(set (match_dup 0)
13414         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
13415    (set (match_dup 3)
13416         (compare:CC (match_dup 0)
13417                     (const_int 0)))]
13418   "")
13419
13420 (define_insn ""
13421   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13422         (compare:CC
13423          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13424                          (const_int 0))
13425                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13426          (const_int 0)))
13427    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13428         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13429   "TARGET_64BIT"
13430   "@
13431    addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
13432    #"
13433   [(set_attr "type" "compare")
13434    (set_attr "length" "12,16")])
13435
13436 (define_split
13437   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13438         (compare:CC
13439          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13440                          (const_int 0))
13441                   (match_operand:DI 2 "gpc_reg_operand" ""))
13442          (const_int 0)))
13443    (set (match_operand:DI 0 "gpc_reg_operand" "")
13444         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13445   "TARGET_64BIT && reload_completed"
13446   [(set (match_dup 0)
13447         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
13448    (set (match_dup 3)
13449         (compare:CC (match_dup 0)
13450                     (const_int 0)))]
13451   "")
13452
13453 (define_insn ""
13454   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13455         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13456                         (match_operand:SI 2 "reg_or_short_operand" "r"))
13457                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
13458   "TARGET_POWER"
13459   "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
13460   [(set_attr "length" "12")])
13461
13462 (define_insn ""
13463   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13464         (compare:CC
13465          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13466                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13467                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13468          (const_int 0)))
13469    (clobber (match_scratch:SI 4 "=&r,&r"))]
13470   "TARGET_POWER"
13471   "@
13472    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13473    #"
13474   [(set_attr "type" "compare")
13475    (set_attr "length" "12,16")])
13476
13477 (define_split
13478   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13479         (compare:CC
13480          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13481                          (match_operand:SI 2 "reg_or_short_operand" ""))
13482                   (match_operand:SI 3 "gpc_reg_operand" ""))
13483          (const_int 0)))
13484    (clobber (match_scratch:SI 4 ""))]
13485   "TARGET_POWER && reload_completed"
13486   [(set (match_dup 4)
13487         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13488    (set (match_dup 0)
13489         (compare:CC (match_dup 4)
13490                     (const_int 0)))]
13491   "")
13492
13493 (define_insn ""
13494   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13495         (compare:CC
13496          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13497                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13498                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13499          (const_int 0)))
13500    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13501         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13502   "TARGET_POWER"
13503   "@
13504    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
13505    #"
13506   [(set_attr "type" "compare")
13507    (set_attr "length" "12,16")])
13508
13509 (define_split
13510   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13511         (compare:CC
13512          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13513                          (match_operand:SI 2 "reg_or_short_operand" ""))
13514                   (match_operand:SI 3 "gpc_reg_operand" ""))
13515          (const_int 0)))
13516    (set (match_operand:SI 0 "gpc_reg_operand" "")
13517         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13518   "TARGET_POWER && reload_completed"
13519   [(set (match_dup 0)
13520         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13521    (set (match_dup 4)
13522         (compare:CC (match_dup 0)
13523                     (const_int 0)))]
13524   "")
13525
13526 (define_insn ""
13527   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13528         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13529                        (const_int 0))))]
13530   "TARGET_32BIT"
13531   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
13532   [(set_attr "type" "three")
13533    (set_attr "length" "12")])
13534
13535 (define_insn ""
13536   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13537         (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13538                        (const_int 0))))]
13539   "TARGET_64BIT"
13540   "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
13541   [(set_attr "type" "three")
13542    (set_attr "length" "12")])
13543
13544 (define_insn ""
13545   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13546         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13547                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
13548   "TARGET_POWER"
13549   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
13550   [(set_attr "length" "12")])
13551
13552 (define_insn_and_split ""
13553   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13554         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13555                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
13556   "TARGET_32BIT"
13557   "#"
13558   "TARGET_32BIT"
13559   [(set (match_dup 0) (neg:SI (gtu:SI (match_dup 1) (match_dup 2))))
13560    (set (match_dup 0) (neg:SI (match_dup 0)))]
13561   "")
13562
13563 (define_insn_and_split ""
13564   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13565         (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13566                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
13567   "TARGET_64BIT"
13568   "#"
13569   "TARGET_64BIT"
13570   [(set (match_dup 0) (neg:DI (gtu:DI (match_dup 1) (match_dup 2))))
13571    (set (match_dup 0) (neg:DI (match_dup 0)))]
13572   "")
13573
13574 (define_insn ""
13575   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13576         (compare:CC
13577          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13578                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13579          (const_int 0)))
13580    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13581         (gtu:SI (match_dup 1) (match_dup 2)))]
13582   "TARGET_32BIT"
13583   "@
13584    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
13585    #"
13586   [(set_attr "type" "compare")
13587    (set_attr "length" "12,16")])
13588
13589 (define_split
13590   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13591         (compare:CC
13592          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13593                  (match_operand:SI 2 "reg_or_short_operand" ""))
13594          (const_int 0)))
13595    (set (match_operand:SI 0 "gpc_reg_operand" "")
13596         (gtu:SI (match_dup 1) (match_dup 2)))]
13597   "TARGET_32BIT && reload_completed"
13598   [(set (match_dup 0)
13599         (gtu:SI (match_dup 1) (match_dup 2)))
13600    (set (match_dup 3)
13601         (compare:CC (match_dup 0)
13602                     (const_int 0)))]
13603   "")
13604
13605 (define_insn ""
13606   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13607         (compare:CC
13608          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13609                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
13610          (const_int 0)))
13611    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
13612         (gtu:DI (match_dup 1) (match_dup 2)))]
13613   "TARGET_64BIT"
13614   "@
13615    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
13616    #"
13617   [(set_attr "type" "compare")
13618    (set_attr "length" "12,16")])
13619
13620 (define_split
13621   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13622         (compare:CC
13623          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13624                  (match_operand:DI 2 "reg_or_short_operand" ""))
13625          (const_int 0)))
13626    (set (match_operand:DI 0 "gpc_reg_operand" "")
13627         (gtu:DI (match_dup 1) (match_dup 2)))]
13628   "TARGET_64BIT && reload_completed"
13629   [(set (match_dup 0)
13630         (gtu:DI (match_dup 1) (match_dup 2)))
13631    (set (match_dup 3)
13632         (compare:CC (match_dup 0)
13633                     (const_int 0)))]
13634   "")
13635
13636 (define_insn_and_split ""
13637   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13638         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13639                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
13640                  (match_operand:SI 3 "reg_or_short_operand" "rI")))]
13641   "TARGET_32BIT"
13642   "#"
13643   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13644   [(set (match_dup 0) (neg:SI (gtu:SI (match_dup 1) (match_dup 2))))
13645    (set (match_dup 0) (minus:SI (match_dup 3) (match_dup 0)))]
13646   "")
13647
13648 (define_insn_and_split ""
13649   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
13650         (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13651                          (match_operand:DI 2 "reg_or_short_operand" "rI"))
13652                  (match_operand:DI 3 "reg_or_short_operand" "rI")))]
13653   "TARGET_64BIT"
13654   "#"
13655   "&& !reg_overlap_mentioned_p (operands[0], operands[3])"
13656   [(set (match_dup 0) (neg:DI (gtu:DI (match_dup 1) (match_dup 2))))
13657    (set (match_dup 0) (minus:DI (match_dup 3) (match_dup 0)))]
13658   "")
13659
13660 (define_insn ""
13661   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13662         (compare:CC
13663          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13664                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13665                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13666          (const_int 0)))
13667    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13668   "TARGET_32BIT"
13669   "@
13670    {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
13671    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subf.} %4,%4,%3
13672    #
13673    #"
13674   [(set_attr "type" "compare")
13675    (set_attr "length" "8,12,12,16")])
13676
13677 (define_split
13678   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13679         (compare:CC
13680          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13681                           (match_operand:SI 2 "reg_or_short_operand" ""))
13682                   (match_operand:SI 3 "gpc_reg_operand" ""))
13683          (const_int 0)))
13684    (clobber (match_scratch:SI 4 ""))]
13685   "TARGET_32BIT && reload_completed"
13686   [(set (match_dup 4)
13687         (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
13688                  (match_dup 3)))
13689    (set (match_dup 0)
13690         (compare:CC (match_dup 4)
13691                     (const_int 0)))]
13692   "")
13693
13694 (define_insn ""
13695   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13696         (compare:CC
13697          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13698                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13699                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13700          (const_int 0)))
13701    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
13702   "TARGET_64BIT"
13703   "@
13704    addic %4,%1,%k2\;addze. %4,%3
13705    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subf. %4,%4,%3
13706    #
13707    #"
13708   [(set_attr "type" "compare")
13709    (set_attr "length" "8,12,12,16")])
13710
13711 (define_split
13712   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13713         (compare:CC
13714          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13715                           (match_operand:DI 2 "reg_or_short_operand" ""))
13716                   (match_operand:DI 3 "gpc_reg_operand" ""))
13717          (const_int 0)))
13718    (clobber (match_scratch:DI 4 ""))]
13719   "TARGET_64BIT && reload_completed"
13720   [(set (match_dup 4)
13721         (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
13722                   (match_dup 3)))
13723    (set (match_dup 0)
13724         (compare:CC (match_dup 4)
13725                     (const_int 0)))]
13726   "")
13727
13728 (define_insn ""
13729   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13730         (compare:CC
13731          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13732                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13733                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13734          (const_int 0)))
13735    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13736         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13737   "TARGET_32BIT"
13738   "@
13739    {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
13740    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subf.} %0,%0,%3
13741    #
13742    #"
13743   [(set_attr "type" "compare")
13744    (set_attr "length" "8,12,12,16")])
13745
13746 (define_split
13747   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13748         (compare:CC
13749          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13750                           (match_operand:SI 2 "reg_or_short_operand" ""))
13751                   (match_operand:SI 3 "gpc_reg_operand" ""))
13752          (const_int 0)))
13753    (set (match_operand:SI 0 "gpc_reg_operand" "")
13754         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13755   "TARGET_32BIT && reload_completed"
13756   [(set (match_dup 0)
13757         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13758    (set (match_dup 4)
13759         (compare:CC (match_dup 0)
13760                     (const_int 0)))]
13761   "")
13762
13763 (define_insn ""
13764   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13765         (compare:CC
13766          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13767                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13768                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13769          (const_int 0)))
13770    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13771         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13772   "TARGET_64BIT"
13773   "@
13774    addic %0,%1,%k2\;addze. %0,%3
13775    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf. %0,%0,%3
13776    #
13777    #"
13778   [(set_attr "type" "compare")
13779    (set_attr "length" "8,12,12,16")])
13780
13781 (define_split
13782   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13783         (compare:CC
13784          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13785                           (match_operand:DI 2 "reg_or_short_operand" ""))
13786                   (match_operand:DI 3 "gpc_reg_operand" ""))
13787          (const_int 0)))
13788    (set (match_operand:DI 0 "gpc_reg_operand" "")
13789         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13790   "TARGET_64BIT && reload_completed"
13791   [(set (match_dup 0)
13792         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13793    (set (match_dup 4)
13794         (compare:CC (match_dup 0)
13795                     (const_int 0)))]
13796   "")
13797
13798 (define_insn ""
13799   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13800         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13801                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13802   "TARGET_32BIT"
13803   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
13804   [(set_attr "type" "two")
13805    (set_attr "length" "8")])
13806
13807 (define_insn ""
13808   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13809         (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13810                         (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
13811   "TARGET_64BIT"
13812   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13813   [(set_attr "type" "two")
13814    (set_attr "length" "8")])
13815 \f
13816 ;; Define both directions of branch and return.  If we need a reload
13817 ;; register, we'd rather use CR0 since it is much easier to copy a
13818 ;; register CC value to there.
13819
13820 (define_insn ""
13821   [(set (pc)
13822         (if_then_else (match_operator 1 "branch_comparison_operator"
13823                                       [(match_operand 2
13824                                                       "cc_reg_operand" "y")
13825                                        (const_int 0)])
13826                       (label_ref (match_operand 0 "" ""))
13827                       (pc)))]
13828   ""
13829   "*
13830 {
13831   return output_cbranch (operands[1], \"%l0\", 0, insn);
13832 }"
13833   [(set_attr "type" "branch")])
13834
13835 (define_insn ""
13836   [(set (pc)
13837         (if_then_else (match_operator 0 "branch_comparison_operator"
13838                                       [(match_operand 1
13839                                                       "cc_reg_operand" "y")
13840                                        (const_int 0)])
13841                       (return)
13842                       (pc)))]
13843   "direct_return ()"
13844   "*
13845 {
13846   return output_cbranch (operands[0], NULL, 0, insn);
13847 }"
13848   [(set_attr "type" "branch")
13849    (set_attr "length" "4")])
13850
13851 (define_insn ""
13852   [(set (pc)
13853         (if_then_else (match_operator 1 "branch_comparison_operator"
13854                                       [(match_operand 2
13855                                                       "cc_reg_operand" "y")
13856                                        (const_int 0)])
13857                       (pc)
13858                       (label_ref (match_operand 0 "" ""))))]
13859   ""
13860   "*
13861 {
13862   return output_cbranch (operands[1], \"%l0\", 1, insn);
13863 }"
13864   [(set_attr "type" "branch")])
13865
13866 (define_insn ""
13867   [(set (pc)
13868         (if_then_else (match_operator 0 "branch_comparison_operator"
13869                                       [(match_operand 1
13870                                                       "cc_reg_operand" "y")
13871                                        (const_int 0)])
13872                       (pc)
13873                       (return)))]
13874   "direct_return ()"
13875   "*
13876 {
13877   return output_cbranch (operands[0], NULL, 1, insn);
13878 }"
13879   [(set_attr "type" "branch")
13880    (set_attr "length" "4")])
13881
13882 ;; Logic on condition register values.
13883
13884 ; This pattern matches things like
13885 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13886 ;                                          (eq:SI (reg:CCFP 68) (const_int 0)))
13887 ;                                  (const_int 1)))
13888 ; which are generated by the branch logic.
13889 ; Prefer destructive operations where BT = BB (for crXX BT,BA,BB)
13890
13891 (define_insn "*cceq_ior_compare"
13892   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13893         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13894                         [(match_operator:SI 2
13895                                       "branch_positive_comparison_operator"
13896                                       [(match_operand 3
13897                                                       "cc_reg_operand" "y,y")
13898                                        (const_int 0)])
13899                          (match_operator:SI 4
13900                                       "branch_positive_comparison_operator"
13901                                       [(match_operand 5
13902                                                       "cc_reg_operand" "0,y")
13903                                        (const_int 0)])])
13904                       (const_int 1)))]
13905   ""
13906   "cr%q1 %E0,%j2,%j4"
13907   [(set_attr "type" "cr_logical,delayed_cr")])
13908
13909 ; Why is the constant -1 here, but 1 in the previous pattern?
13910 ; Because ~1 has all but the low bit set.
13911 (define_insn ""
13912   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13913         (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13914                         [(not:SI (match_operator:SI 2
13915                                       "branch_positive_comparison_operator"
13916                                       [(match_operand 3
13917                                                       "cc_reg_operand" "y,y")
13918                                        (const_int 0)]))
13919                          (match_operator:SI 4
13920                                 "branch_positive_comparison_operator"
13921                                 [(match_operand 5
13922                                                 "cc_reg_operand" "0,y")
13923                                  (const_int 0)])])
13924                       (const_int -1)))]
13925   ""
13926   "cr%q1 %E0,%j2,%j4"
13927   [(set_attr "type" "cr_logical,delayed_cr")])
13928
13929 (define_insn "*cceq_rev_compare"
13930   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y,?y")
13931         (compare:CCEQ (match_operator:SI 1
13932                                       "branch_positive_comparison_operator"
13933                                       [(match_operand 2
13934                                                       "cc_reg_operand" "0,y")
13935                                        (const_int 0)])
13936                       (const_int 0)))]
13937   ""
13938   "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
13939   [(set_attr "type" "cr_logical,delayed_cr")])
13940
13941 ;; If we are comparing the result of two comparisons, this can be done
13942 ;; using creqv or crxor.
13943
13944 (define_insn_and_split ""
13945   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13946         (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13947                               [(match_operand 2 "cc_reg_operand" "y")
13948                                (const_int 0)])
13949                       (match_operator 3 "branch_comparison_operator"
13950                               [(match_operand 4 "cc_reg_operand" "y")
13951                                (const_int 0)])))]
13952   ""
13953   "#"
13954   ""
13955   [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13956                                     (match_dup 5)))]
13957   "
13958 {
13959   int positive_1, positive_2;
13960
13961   positive_1 = branch_positive_comparison_operator (operands[1],
13962                                                     GET_MODE (operands[1]));
13963   positive_2 = branch_positive_comparison_operator (operands[3],
13964                                                     GET_MODE (operands[3]));
13965
13966   if (! positive_1)
13967     operands[1] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[2]),
13968                                                             GET_CODE (operands[1])),
13969                                   SImode,
13970                                   operands[2], const0_rtx);
13971   else if (GET_MODE (operands[1]) != SImode)
13972     operands[1] = gen_rtx_fmt_ee (GET_CODE (operands[1]), SImode,
13973                                   operands[2], const0_rtx);
13974
13975   if (! positive_2)
13976     operands[3] = gen_rtx_fmt_ee (rs6000_reverse_condition (GET_MODE (operands[4]),
13977                                                             GET_CODE (operands[3])),
13978                                   SImode,
13979                                   operands[4], const0_rtx);
13980   else if (GET_MODE (operands[3]) != SImode)
13981     operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[3]), SImode,
13982                                   operands[4], const0_rtx);
13983
13984   if (positive_1 == positive_2)
13985     {
13986       operands[1] = gen_rtx_NOT (SImode, operands[1]);
13987       operands[5] = constm1_rtx;
13988     }
13989   else
13990     {
13991       operands[5] = const1_rtx;
13992     }
13993 }")
13994
13995 ;; Unconditional branch and return.
13996
13997 (define_insn "jump"
13998   [(set (pc)
13999         (label_ref (match_operand 0 "" "")))]
14000   ""
14001   "b %l0"
14002   [(set_attr "type" "branch")])
14003
14004 (define_insn "return"
14005   [(return)]
14006   "direct_return ()"
14007   "{br|blr}"
14008   [(set_attr "type" "jmpreg")])
14009
14010 (define_expand "indirect_jump"
14011   [(set (pc) (match_operand 0 "register_operand" ""))]
14012   ""
14013   "
14014 {
14015   if (TARGET_32BIT)
14016     emit_jump_insn (gen_indirect_jumpsi (operands[0]));
14017   else
14018     emit_jump_insn (gen_indirect_jumpdi (operands[0]));
14019   DONE;
14020 }")
14021
14022 (define_insn "indirect_jumpsi"
14023   [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
14024   "TARGET_32BIT"
14025   "@
14026    bctr
14027    {br|blr}"
14028   [(set_attr "type" "jmpreg")])
14029
14030 (define_insn "indirect_jumpdi"
14031   [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
14032   "TARGET_64BIT"
14033   "@
14034    bctr
14035    blr"
14036   [(set_attr "type" "jmpreg")])
14037
14038 ;; Table jump for switch statements:
14039 (define_expand "tablejump"
14040   [(use (match_operand 0 "" ""))
14041    (use (label_ref (match_operand 1 "" "")))]
14042   ""
14043   "
14044 {
14045   if (TARGET_32BIT)
14046     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
14047   else
14048     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
14049   DONE;
14050 }")
14051
14052 (define_expand "tablejumpsi"
14053   [(set (match_dup 3)
14054         (plus:SI (match_operand:SI 0 "" "")
14055                  (match_dup 2)))
14056    (parallel [(set (pc) (match_dup 3))
14057               (use (label_ref (match_operand 1 "" "")))])]
14058   "TARGET_32BIT"
14059   "
14060 { operands[0] = force_reg (SImode, operands[0]);
14061   operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
14062   operands[3] = gen_reg_rtx (SImode);
14063 }")
14064
14065 (define_expand "tablejumpdi"
14066   [(set (match_dup 4)
14067         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
14068    (set (match_dup 3)
14069         (plus:DI (match_dup 4)
14070                  (match_dup 2)))
14071    (parallel [(set (pc) (match_dup 3))
14072               (use (label_ref (match_operand 1 "" "")))])]
14073   "TARGET_64BIT"
14074   "
14075 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
14076   operands[3] = gen_reg_rtx (DImode);
14077   operands[4] = gen_reg_rtx (DImode);
14078 }")
14079
14080 (define_insn ""
14081   [(set (pc)
14082         (match_operand:SI 0 "register_operand" "c,*l"))
14083    (use (label_ref (match_operand 1 "" "")))]
14084   "TARGET_32BIT"
14085   "@
14086    bctr
14087    {br|blr}"
14088   [(set_attr "type" "jmpreg")])
14089
14090 (define_insn ""
14091   [(set (pc)
14092         (match_operand:DI 0 "register_operand" "c,*l"))
14093    (use (label_ref (match_operand 1 "" "")))]
14094   "TARGET_64BIT"
14095   "@
14096    bctr
14097    blr"
14098   [(set_attr "type" "jmpreg")])
14099
14100 (define_insn "nop"
14101   [(const_int 0)]
14102   ""
14103   "{cror 0,0,0|nop}")
14104 \f
14105 ;; Define the subtract-one-and-jump insns, starting with the template
14106 ;; so loop.c knows what to generate.
14107
14108 (define_expand "doloop_end"
14109   [(use (match_operand 0 "" ""))        ; loop pseudo
14110    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
14111    (use (match_operand 2 "" ""))        ; max iterations
14112    (use (match_operand 3 "" ""))        ; loop level
14113    (use (match_operand 4 "" ""))]       ; label
14114   ""
14115   "
14116 {
14117   /* Only use this on innermost loops.  */
14118   if (INTVAL (operands[3]) > 1)
14119     FAIL;
14120   if (TARGET_64BIT)
14121     {
14122       if (GET_MODE (operands[0]) != DImode)
14123         FAIL;
14124       emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
14125     }
14126   else
14127     {
14128       if (GET_MODE (operands[0]) != SImode)
14129         FAIL;
14130       emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
14131     }
14132   DONE;
14133 }")
14134
14135 (define_expand "ctrsi"
14136   [(parallel [(set (pc)
14137                    (if_then_else (ne (match_operand:SI 0 "register_operand" "")
14138                                      (const_int 1))
14139                                  (label_ref (match_operand 1 "" ""))
14140                                  (pc)))
14141               (set (match_dup 0)
14142                    (plus:SI (match_dup 0)
14143                             (const_int -1)))
14144               (clobber (match_scratch:CC 2 ""))
14145               (clobber (match_scratch:SI 3 ""))])]
14146   "TARGET_32BIT"
14147   "")
14148
14149 (define_expand "ctrdi"
14150   [(parallel [(set (pc)
14151                    (if_then_else (ne (match_operand:DI 0 "register_operand" "")
14152                                      (const_int 1))
14153                                  (label_ref (match_operand 1 "" ""))
14154                                  (pc)))
14155               (set (match_dup 0)
14156                    (plus:DI (match_dup 0)
14157                             (const_int -1)))
14158               (clobber (match_scratch:CC 2 ""))
14159               (clobber (match_scratch:DI 3 ""))])]
14160   "TARGET_64BIT"
14161   "")
14162
14163 ;; We need to be able to do this for any operand, including MEM, or we
14164 ;; will cause reload to blow up since we don't allow output reloads on
14165 ;; JUMP_INSNs.
14166 ;; For the length attribute to be calculated correctly, the
14167 ;; label MUST be operand 0.
14168
14169 (define_insn "*ctrsi_internal1"
14170   [(set (pc)
14171         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
14172                           (const_int 1))
14173                       (label_ref (match_operand 0 "" ""))
14174                       (pc)))
14175    (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14176         (plus:SI (match_dup 1)
14177                  (const_int -1)))
14178    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14179    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
14180   "TARGET_32BIT"
14181   "*
14182 {
14183   if (which_alternative != 0)
14184     return \"#\";
14185   else if (get_attr_length (insn) == 4)
14186     return \"{bdn|bdnz} %l0\";
14187   else
14188     return \"bdz $+8\;b %l0\";
14189 }"
14190   [(set_attr "type" "branch")
14191    (set_attr "length" "*,12,16,16")])
14192
14193 (define_insn "*ctrsi_internal2"
14194   [(set (pc)
14195         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
14196                           (const_int 1))
14197                       (pc)
14198                       (label_ref (match_operand 0 "" ""))))
14199    (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14200         (plus:SI (match_dup 1)
14201                  (const_int -1)))
14202    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14203    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
14204   "TARGET_32BIT"
14205   "*
14206 {
14207   if (which_alternative != 0)
14208     return \"#\";
14209   else if (get_attr_length (insn) == 4)
14210     return \"bdz %l0\";
14211   else
14212     return \"{bdn|bdnz} $+8\;b %l0\";
14213 }"
14214   [(set_attr "type" "branch")
14215    (set_attr "length" "*,12,16,16")])
14216
14217 (define_insn "*ctrdi_internal1"
14218   [(set (pc)
14219         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
14220                           (const_int 1))
14221                       (label_ref (match_operand 0 "" ""))
14222                       (pc)))
14223    (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
14224         (plus:DI (match_dup 1)
14225                  (const_int -1)))
14226    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14227    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
14228   "TARGET_64BIT"
14229   "*
14230 {
14231   if (which_alternative != 0)
14232     return \"#\";
14233   else if (get_attr_length (insn) == 4)
14234     return \"{bdn|bdnz} %l0\";
14235   else
14236     return \"bdz $+8\;b %l0\";
14237 }"
14238   [(set_attr "type" "branch")
14239    (set_attr "length" "*,12,16,16")])
14240
14241 (define_insn "*ctrdi_internal2"
14242   [(set (pc)
14243         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
14244                           (const_int 1))
14245                       (pc)
14246                       (label_ref (match_operand 0 "" ""))))
14247    (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
14248         (plus:DI (match_dup 1)
14249                  (const_int -1)))
14250    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14251    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
14252   "TARGET_64BIT"
14253   "*
14254 {
14255   if (which_alternative != 0)
14256     return \"#\";
14257   else if (get_attr_length (insn) == 4)
14258     return \"bdz %l0\";
14259   else
14260     return \"{bdn|bdnz} $+8\;b %l0\";
14261 }"
14262   [(set_attr "type" "branch")
14263    (set_attr "length" "*,12,16,16")])
14264
14265 ;; Similar but use EQ
14266
14267 (define_insn "*ctrsi_internal5"
14268   [(set (pc)
14269         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
14270                           (const_int 1))
14271                       (label_ref (match_operand 0 "" ""))
14272                       (pc)))
14273    (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14274         (plus:SI (match_dup 1)
14275                  (const_int -1)))
14276    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14277    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
14278   "TARGET_32BIT"
14279   "*
14280 {
14281   if (which_alternative != 0)
14282     return \"#\";
14283   else if (get_attr_length (insn) == 4)
14284     return \"bdz %l0\";
14285   else
14286     return \"{bdn|bdnz} $+8\;b %l0\";
14287 }"
14288   [(set_attr "type" "branch")
14289    (set_attr "length" "*,12,16,16")])
14290
14291 (define_insn "*ctrsi_internal6"
14292   [(set (pc)
14293         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r,*r")
14294                           (const_int 1))
14295                       (pc)
14296                       (label_ref (match_operand 0 "" ""))))
14297    (set (match_operand:SI 2 "nonimmediate_operand" "=1,*r,m,*q*c*l")
14298         (plus:SI (match_dup 1)
14299                  (const_int -1)))
14300    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14301    (clobber (match_scratch:SI 4 "=X,X,&r,r"))]
14302   "TARGET_32BIT"
14303   "*
14304 {
14305   if (which_alternative != 0)
14306     return \"#\";
14307   else if (get_attr_length (insn) == 4)
14308     return \"{bdn|bdnz} %l0\";
14309   else
14310     return \"bdz $+8\;b %l0\";
14311 }"
14312   [(set_attr "type" "branch")
14313    (set_attr "length" "*,12,16,16")])
14314
14315 (define_insn "*ctrdi_internal5"
14316   [(set (pc)
14317         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
14318                           (const_int 1))
14319                       (label_ref (match_operand 0 "" ""))
14320                       (pc)))
14321    (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
14322         (plus:DI (match_dup 1)
14323                  (const_int -1)))
14324    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14325    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
14326   "TARGET_64BIT"
14327   "*
14328 {
14329   if (which_alternative != 0)
14330     return \"#\";
14331   else if (get_attr_length (insn) == 4)
14332     return \"bdz %l0\";
14333   else
14334     return \"{bdn|bdnz} $+8\;b %l0\";
14335 }"
14336   [(set_attr "type" "branch")
14337    (set_attr "length" "*,12,16,16")])
14338
14339 (define_insn "*ctrdi_internal6"
14340   [(set (pc)
14341         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,*r")
14342                           (const_int 1))
14343                       (pc)
14344                       (label_ref (match_operand 0 "" ""))))
14345    (set (match_operand:DI 2 "nonimmediate_operand" "=1,*r,m,*c*l")
14346         (plus:DI (match_dup 1)
14347                  (const_int -1)))
14348    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
14349    (clobber (match_scratch:DI 4 "=X,X,&r,r"))]
14350   "TARGET_64BIT"
14351   "*
14352 {
14353   if (which_alternative != 0)
14354     return \"#\";
14355   else if (get_attr_length (insn) == 4)
14356     return \"{bdn|bdnz} %l0\";
14357   else
14358     return \"bdz $+8\;b %l0\";
14359 }"
14360   [(set_attr "type" "branch")
14361    (set_attr "length" "*,12,16,16")])
14362
14363 ;; Now the splitters if we could not allocate the CTR register
14364
14365 (define_split
14366   [(set (pc)
14367         (if_then_else (match_operator 2 "comparison_operator"
14368                                       [(match_operand:SI 1 "gpc_reg_operand" "")
14369                                        (const_int 1)])
14370                       (match_operand 5 "" "")
14371                       (match_operand 6 "" "")))
14372    (set (match_operand:SI 0 "gpc_reg_operand" "")
14373         (plus:SI (match_dup 1)
14374                  (const_int -1)))
14375    (clobber (match_scratch:CC 3 ""))
14376    (clobber (match_scratch:SI 4 ""))]
14377   "TARGET_32BIT && reload_completed"
14378   [(parallel [(set (match_dup 3)
14379                    (compare:CC (plus:SI (match_dup 1)
14380                                         (const_int -1))
14381                                (const_int 0)))
14382               (set (match_dup 0)
14383                    (plus:SI (match_dup 1)
14384                             (const_int -1)))])
14385    (set (pc) (if_then_else (match_dup 7)
14386                            (match_dup 5)
14387                            (match_dup 6)))]
14388   "
14389 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14390                                 operands[3], const0_rtx); }")
14391
14392 (define_split
14393   [(set (pc)
14394         (if_then_else (match_operator 2 "comparison_operator"
14395                                       [(match_operand:SI 1 "gpc_reg_operand" "")
14396                                        (const_int 1)])
14397                       (match_operand 5 "" "")
14398                       (match_operand 6 "" "")))
14399    (set (match_operand:SI 0 "nonimmediate_operand" "")
14400         (plus:SI (match_dup 1) (const_int -1)))
14401    (clobber (match_scratch:CC 3 ""))
14402    (clobber (match_scratch:SI 4 ""))]
14403   "TARGET_32BIT && reload_completed
14404    && ! gpc_reg_operand (operands[0], SImode)"
14405   [(parallel [(set (match_dup 3)
14406                    (compare:CC (plus:SI (match_dup 1)
14407                                         (const_int -1))
14408                                (const_int 0)))
14409               (set (match_dup 4)
14410                    (plus:SI (match_dup 1)
14411                             (const_int -1)))])
14412    (set (match_dup 0)
14413         (match_dup 4))
14414    (set (pc) (if_then_else (match_dup 7)
14415                            (match_dup 5)
14416                            (match_dup 6)))]
14417   "
14418 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14419                                 operands[3], const0_rtx); }")
14420 (define_split
14421   [(set (pc)
14422         (if_then_else (match_operator 2 "comparison_operator"
14423                                       [(match_operand:DI 1 "gpc_reg_operand" "")
14424                                        (const_int 1)])
14425                       (match_operand 5 "" "")
14426                       (match_operand 6 "" "")))
14427    (set (match_operand:DI 0 "gpc_reg_operand" "")
14428         (plus:DI (match_dup 1)
14429                  (const_int -1)))
14430    (clobber (match_scratch:CC 3 ""))
14431    (clobber (match_scratch:DI 4 ""))]
14432   "TARGET_64BIT && reload_completed"
14433   [(parallel [(set (match_dup 3)
14434                    (compare:CC (plus:DI (match_dup 1)
14435                                         (const_int -1))
14436                                (const_int 0)))
14437               (set (match_dup 0)
14438                    (plus:DI (match_dup 1)
14439                             (const_int -1)))])
14440    (set (pc) (if_then_else (match_dup 7)
14441                            (match_dup 5)
14442                            (match_dup 6)))]
14443   "
14444 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14445                                 operands[3], const0_rtx); }")
14446
14447 (define_split
14448   [(set (pc)
14449         (if_then_else (match_operator 2 "comparison_operator"
14450                                       [(match_operand:DI 1 "gpc_reg_operand" "")
14451                                        (const_int 1)])
14452                       (match_operand 5 "" "")
14453                       (match_operand 6 "" "")))
14454    (set (match_operand:DI 0 "nonimmediate_operand" "")
14455         (plus:DI (match_dup 1) (const_int -1)))
14456    (clobber (match_scratch:CC 3 ""))
14457    (clobber (match_scratch:DI 4 ""))]
14458   "TARGET_64BIT && reload_completed
14459    && ! gpc_reg_operand (operands[0], DImode)"
14460   [(parallel [(set (match_dup 3)
14461                    (compare:CC (plus:DI (match_dup 1)
14462                                         (const_int -1))
14463                                (const_int 0)))
14464               (set (match_dup 4)
14465                    (plus:DI (match_dup 1)
14466                             (const_int -1)))])
14467    (set (match_dup 0)
14468         (match_dup 4))
14469    (set (pc) (if_then_else (match_dup 7)
14470                            (match_dup 5)
14471                            (match_dup 6)))]
14472   "
14473 { operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[2]), VOIDmode,
14474                                 operands[3], const0_rtx); }")
14475 \f
14476 (define_insn "trap"
14477   [(trap_if (const_int 1) (const_int 0))]
14478   ""
14479   "{t 31,0,0|trap}")
14480
14481 (define_expand "conditional_trap"
14482   [(trap_if (match_operator 0 "trap_comparison_operator"
14483                             [(match_dup 2) (match_dup 3)])
14484             (match_operand 1 "const_int_operand" ""))]
14485   ""
14486   "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14487    operands[2] = rs6000_compare_op0;
14488    operands[3] = rs6000_compare_op1;")
14489
14490 (define_insn ""
14491   [(trap_if (match_operator 0 "trap_comparison_operator"
14492                             [(match_operand:SI 1 "register_operand" "r")
14493                              (match_operand:SI 2 "reg_or_short_operand" "rI")])
14494             (const_int 0))]
14495   ""
14496   "{t|tw}%V0%I2 %1,%2")
14497
14498 (define_insn ""
14499   [(trap_if (match_operator 0 "trap_comparison_operator"
14500                             [(match_operand:DI 1 "register_operand" "r")
14501                              (match_operand:DI 2 "reg_or_short_operand" "rI")])
14502             (const_int 0))]
14503   "TARGET_POWERPC64"
14504   "td%V0%I2 %1,%2")
14505 \f
14506 ;; Insns related to generating the function prologue and epilogue.
14507
14508 (define_expand "prologue"
14509   [(use (const_int 0))]
14510   "TARGET_SCHED_PROLOG"
14511   "
14512 {
14513       rs6000_emit_prologue ();
14514       DONE;
14515 }")
14516
14517 (define_insn "*movesi_from_cr_one"
14518   [(match_parallel 0 "mfcr_operation"
14519                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14520                          (unspec:SI [(match_operand:CC 2 "cc_reg_operand" "y")
14521                                      (match_operand 3 "immediate_operand" "n")]
14522                           UNSPEC_MOVESI_FROM_CR))])]
14523   "TARGET_MFCRF"
14524   "*
14525 {
14526   int mask = 0;
14527   int i;
14528   for (i = 0; i < XVECLEN (operands[0], 0); i++)
14529   {
14530     mask = INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14531     operands[4] = GEN_INT (mask);
14532     output_asm_insn (\"mfcr %1,%4\", operands);
14533   }
14534   return \"\";
14535 }"
14536   [(set_attr "type" "mfcrf")])
14537
14538 (define_insn "movesi_from_cr"
14539   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
14540         (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71)
14541                     (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)]
14542                    UNSPEC_MOVESI_FROM_CR))]
14543   ""
14544   "mfcr %0"
14545   [(set_attr "type" "mfcr")])
14546
14547 (define_insn "*stmw"
14548   [(match_parallel 0 "stmw_operation"
14549                    [(set (match_operand:SI 1 "memory_operand" "=m")
14550                          (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14551   "TARGET_MULTIPLE"
14552   "{stm|stmw} %2,%1")
14553
14554 (define_insn "*save_fpregs_si"
14555   [(match_parallel 0 "any_parallel_operand"
14556                    [(clobber (match_operand:SI 1 "register_operand" "=l"))
14557                     (use (match_operand:SI 2 "call_operand" "s"))
14558                     (set (match_operand:DF 3 "memory_operand" "=m")
14559                          (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14560   "TARGET_32BIT"
14561   "bl %z2"
14562   [(set_attr "type" "branch")
14563    (set_attr "length" "4")])
14564
14565 (define_insn "*save_fpregs_di"
14566   [(match_parallel 0 "any_parallel_operand"
14567                    [(clobber (match_operand:DI 1 "register_operand" "=l"))
14568                     (use (match_operand:DI 2 "call_operand" "s"))
14569                     (set (match_operand:DF 3 "memory_operand" "=m")
14570                          (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14571   "TARGET_64BIT"
14572   "bl %z2"
14573   [(set_attr "type" "branch")
14574    (set_attr "length" "4")])
14575
14576 ; These are to explain that changes to the stack pointer should
14577 ; not be moved over stores to stack memory.
14578 (define_insn "stack_tie"
14579   [(set (match_operand:BLK 0 "memory_operand" "+m")
14580         (unspec:BLK [(match_dup 0)] UNSPEC_TIE))]
14581   ""
14582   ""
14583   [(set_attr "length" "0")])
14584
14585
14586 (define_expand "epilogue"
14587   [(use (const_int 0))]
14588   "TARGET_SCHED_PROLOG"
14589   "
14590 {
14591       rs6000_emit_epilogue (FALSE);
14592       DONE;
14593 }")
14594
14595 ; On some processors, doing the mtcrf one CC register at a time is
14596 ; faster (like on the 604e).  On others, doing them all at once is
14597 ; faster; for instance, on the 601 and 750.
14598
14599 (define_expand "movsi_to_cr_one"
14600   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14601         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14602                     (match_dup 2)] UNSPEC_MOVESI_TO_CR))]
14603   ""
14604   "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
14605
14606 (define_insn "*movsi_to_cr"
14607   [(match_parallel 0 "mtcrf_operation"
14608                    [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14609                          (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14610                                      (match_operand 3 "immediate_operand" "n")]
14611                                     UNSPEC_MOVESI_TO_CR))])]
14612  ""
14613  "*
14614 {
14615   int mask = 0;
14616   int i;
14617   for (i = 0; i < XVECLEN (operands[0], 0); i++)
14618     mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14619   operands[4] = GEN_INT (mask);
14620   return \"mtcrf %4,%2\";
14621 }"
14622   [(set_attr "type" "mtcr")])
14623
14624 (define_insn "*mtcrfsi"
14625   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14626         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14627                     (match_operand 2 "immediate_operand" "n")]
14628                    UNSPEC_MOVESI_TO_CR))]
14629   "GET_CODE (operands[0]) == REG
14630    && CR_REGNO_P (REGNO (operands[0]))
14631    && GET_CODE (operands[2]) == CONST_INT
14632    && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14633   "mtcrf %R0,%1"
14634   [(set_attr "type" "mtcr")])
14635
14636 ; The load-multiple instructions have similar properties.
14637 ; Note that "load_multiple" is a name known to the machine-independent
14638 ; code that actually corresponds to the powerpc load-string.
14639
14640 (define_insn "*lmw"
14641   [(match_parallel 0 "lmw_operation"
14642                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14643                          (match_operand:SI 2 "memory_operand" "m"))])]
14644   "TARGET_MULTIPLE"
14645   "{lm|lmw} %1,%2")
14646
14647 (define_insn "*return_internal_si"
14648   [(return)
14649    (use (match_operand:SI 0 "register_operand" "lc"))]
14650   "TARGET_32BIT"
14651   "b%T0"
14652   [(set_attr "type" "jmpreg")])
14653
14654 (define_insn "*return_internal_di"
14655   [(return)
14656    (use (match_operand:DI 0 "register_operand" "lc"))]
14657   "TARGET_64BIT"
14658   "b%T0"
14659   [(set_attr "type" "jmpreg")])
14660
14661 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14662 ; stuff was in GCC.  Oh, and "any_parallel_operand" is a bit flexible...
14663
14664 (define_insn "*return_and_restore_fpregs_si"
14665  [(match_parallel 0 "any_parallel_operand"
14666                   [(return)
14667                    (use (match_operand:SI 1 "register_operand" "l"))
14668                    (use (match_operand:SI 2 "call_operand" "s"))
14669                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14670                         (match_operand:DF 4 "memory_operand" "m"))])]
14671  "TARGET_32BIT"
14672  "b %z2")
14673
14674 (define_insn "*return_and_restore_fpregs_di"
14675  [(match_parallel 0 "any_parallel_operand"
14676                   [(return)
14677                    (use (match_operand:DI 1 "register_operand" "l"))
14678                    (use (match_operand:DI 2 "call_operand" "s"))
14679                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14680                         (match_operand:DF 4 "memory_operand" "m"))])]
14681  "TARGET_64BIT"
14682  "b %z2")
14683
14684 ; This is used in compiling the unwind routines.
14685 (define_expand "eh_return"
14686   [(use (match_operand 0 "general_operand" ""))]
14687   ""
14688   "
14689 {
14690   if (TARGET_32BIT)
14691     emit_insn (gen_eh_set_lr_si (operands[0]));
14692   else
14693     emit_insn (gen_eh_set_lr_di (operands[0]));
14694   DONE;
14695 }")
14696
14697 ; We can't expand this before we know where the link register is stored.
14698 (define_insn "eh_set_lr_si"
14699   [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")]
14700                     UNSPECV_EH_RR)
14701    (clobber (match_scratch:SI 1 "=&b"))]
14702   "TARGET_32BIT"
14703   "#")
14704
14705 (define_insn "eh_set_lr_di"
14706   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
14707                     UNSPECV_EH_RR)
14708    (clobber (match_scratch:DI 1 "=&b"))]
14709   "TARGET_64BIT"
14710   "#")
14711
14712 (define_split
14713   [(unspec_volatile [(match_operand 0 "register_operand" "")] UNSPECV_EH_RR)
14714    (clobber (match_scratch 1 ""))]
14715   "reload_completed"
14716   [(const_int 0)]
14717   "
14718 {
14719   rs6000_emit_eh_reg_restore (operands[0], operands[1]);
14720   DONE;
14721 }")
14722
14723 (define_insn "prefetch"
14724   [(prefetch (match_operand:V4SI 0 "address_operand" "p")
14725              (match_operand:SI 1 "const_int_operand" "n")
14726              (match_operand:SI 2 "const_int_operand" "n"))]
14727   "TARGET_POWERPC"
14728   "*
14729 {
14730   if (GET_CODE (operands[0]) == REG)
14731     return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14732   return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14733 }"
14734   [(set_attr "type" "load")])
14735
14736 (include "altivec.md")
14737 (include "spe.md")