OSDN Git Service

* config/elfos.h: Follow spelling conventions.
[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 Free Software Foundation, Inc.
4 ;; Contributed by Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
5
6 ;; This file is part of GNU CC.
7
8 ;; GNU CC is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
11 ;; any later version.
12
13 ;; GNU CC is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU CC; see the file COPYING.  If not, write to
20 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
21 ;; Boston, MA 02111-1307, USA.
22
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
24
25 ;; `unspec' values used in rs6000.md:
26 ;; Number       Use
27 ;; 0            frsp for POWER machines
28 ;; 0/v          blockage
29 ;; 5            used to tie the stack contents and the stack pointer
30 ;; 6            address of a word pointing to the TOC
31 ;; 7            address of the TOC (more-or-less)
32 ;; 8            movsi_got
33 ;; 9/v          eh_reg_restore
34 ;; 10           fctiwz
35 ;; 15           load_macho_picbase
36 ;; 16           macho_correct_pic
37 ;; 19           movesi_from_cr
38 ;; 20           movesi_to_cr
39 \f
40 ;; Define an insn type attribute.  This is used in function unit delay
41 ;; computations.
42 (define_attr "type" "integer,load,store,fpload,fpstore,vecload,vecstore,imul,imul2,imul3,lmul,idiv,ldiv,branch,compare,cr_logical,delayed_compare,fpcompare,mtjmpr,fp,dmul,sdiv,ddiv,ssqrt,dsqrt,jmpreg,vecsimple,veccomplex,veccmp,vecperm,vecfloat,altivec"
43   (const_string "integer"))
44
45 ;; Length (in bytes).
46 ; '(pc)' in the following doesn't include the instruction itself; it is 
47 ; calculated as if the instruction had zero size.
48 (define_attr "length" ""
49   (if_then_else (eq_attr "type" "branch")
50                 (if_then_else (and (ge (minus (match_dup 0) (pc))
51                                        (const_int -32768))
52                                    (lt (minus (match_dup 0) (pc))
53                                        (const_int 32764)))
54                               (const_int 4)
55                               (const_int 8))
56                 (const_int 4)))
57
58 ;; Processor type -- this attribute must exactly match the processor_type
59 ;; enumeration in rs6000.h.
60
61 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,ppc8540,power4"
62   (const (symbol_ref "rs6000_cpu_attr")))
63
64 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
65 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
66
67 ; Load/Store Unit -- pure PowerPC only
68 ; (POWER and 601 use Integer Unit)
69 (define_function_unit "lsu" 1 0
70   (and (eq_attr "type" "load")
71        (eq_attr "cpu" "rs64a,mpccore,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400"))
72   2 1)
73
74 (define_function_unit "lsu" 1 0
75   (and (eq_attr "type" "load,vecload")
76        (eq_attr "cpu" "ppc7450"))
77   3 1)
78
79 (define_function_unit "lsu" 1 0
80   (and (eq_attr "type" "store,fpstore")
81        (eq_attr "cpu" "rs64a,mpccore,ppc603,ppc604,ppc604e,ppc620,ppc630"))
82   1 1)
83
84 (define_function_unit "lsu" 1 0
85   (and (eq_attr "type" "store,fpstore")
86        (eq_attr "cpu" "ppc750,ppc7400"))
87   2 1)
88
89 (define_function_unit "lsu" 1 0
90   (and (eq_attr "type" "store,vecstore")
91        (eq_attr "cpu" "ppc7450"))
92   3 1)
93
94 (define_function_unit "lsu" 1 0
95   (and (eq_attr "type" "fpstore")
96        (eq_attr "cpu" "ppc7450"))
97   3 3)
98
99 (define_function_unit "lsu" 1 0
100   (and (eq_attr "type" "fpload")
101        (eq_attr "cpu" "mpccore,ppc603,ppc750,ppc7400"))
102   2 1)
103
104 (define_function_unit "lsu" 1 0
105   (and (eq_attr "type" "fpload")
106        (eq_attr "cpu" "ppc7450"))
107   4 1)
108
109 (define_function_unit "lsu" 1 0
110   (and (eq_attr "type" "fpload")
111        (eq_attr "cpu" "rs64a,ppc604,ppc604e,ppc620,ppc630"))
112   3 1)
113
114 (define_function_unit "iu" 1 0
115   (and (eq_attr "type" "load")
116        (eq_attr "cpu" "rios1,ppc403,ppc405,ppc601"))
117   2 1)
118
119 (define_function_unit "iu" 1 0
120   (and (eq_attr "type" "store,fpstore")
121        (eq_attr "cpu" "rios1,ppc403,ppc405,ppc601"))
122   1 1)
123
124 (define_function_unit "fpu" 1 0
125   (and (eq_attr "type" "fpstore")
126        (eq_attr "cpu" "rios1,ppc601"))
127   0 1)
128
129 (define_function_unit "iu" 1 0
130   (and (eq_attr "type" "fpload")
131        (eq_attr "cpu" "rios1"))
132   2 1)
133
134 (define_function_unit "iu" 1 0
135   (and (eq_attr "type" "fpload")
136        (eq_attr "cpu" "ppc601"))
137   3 1)
138
139 (define_function_unit "iu2" 2 0
140   (and (eq_attr "type" "load,fpload")
141        (eq_attr "cpu" "rios2"))
142   2 1)
143
144 (define_function_unit "iu2" 2 0
145   (and (eq_attr "type" "store,fpstore")
146        (eq_attr "cpu" "rios2"))
147   1 1)
148
149 ; Integer Unit (RIOS1, PPC601, PPC603, RS64a)
150 (define_function_unit "iu" 1 0
151   (and (eq_attr "type" "integer")
152        (eq_attr "cpu" "rios1,rs64a,mpccore,ppc403,ppc405,ppc601,ppc603"))
153   1 1)
154
155 (define_function_unit "iu" 1 0
156   (and (eq_attr "type" "cr_logical")
157        (eq_attr "cpu" "mpccore,ppc403,ppc405,ppc601"))
158   1 1)
159
160 (define_function_unit "iu" 1 0
161   (and (eq_attr "type" "imul,imul2,imul3")
162        (eq_attr "cpu" "ppc403"))
163   4 4)
164
165 (define_function_unit "iu" 1 0
166   (and (eq_attr "type" "imul")
167        (eq_attr "cpu" "ppc405"))
168   4 3)
169
170 (define_function_unit "iu" 1 0
171   (and (eq_attr "type" "imul2,imul3")
172        (eq_attr "cpu" "ppc405"))
173   3 2)
174
175 (define_function_unit "iu" 1 0
176   (and (eq_attr "type" "imul")
177        (eq_attr "cpu" "rios1"))
178   5 5)
179
180 (define_function_unit "iu" 1 0
181   (and (eq_attr "type" "imul2")
182        (eq_attr "cpu" "rios1"))
183   4 4)
184
185 (define_function_unit "iu" 1 0
186   (and (eq_attr "type" "imul3")
187        (eq_attr "cpu" "rios1"))
188   3 3)
189
190 (define_function_unit "iu" 1 0
191   (and (eq_attr "type" "imul,imul2,imul3")
192        (eq_attr "cpu" "ppc601,ppc603"))
193   5 5)
194
195 (define_function_unit "iu" 1 0
196   (and (eq_attr "type" "imul")
197        (eq_attr "cpu" "rs64a"))
198   20 20)
199
200 (define_function_unit "iu" 1 0
201   (and (eq_attr "type" "imul2")
202        (eq_attr "cpu" "rs64a"))
203   12 12)
204
205 (define_function_unit "iu" 1 0
206   (and (eq_attr "type" "imul3")
207        (eq_attr "cpu" "rs64a"))
208   8 8)
209
210 (define_function_unit "iu" 1 0
211   (and (eq_attr "type" "lmul")
212        (eq_attr "cpu" "rs64a"))
213   34 34)
214
215 (define_function_unit "iu" 1 0
216   (and (eq_attr "type" "idiv")
217        (eq_attr "cpu" "rios1"))
218   19 19)
219
220 (define_function_unit "iu" 1 0
221   (and (eq_attr "type" "idiv")
222        (eq_attr "cpu" "rs64a"))
223   66 66)
224
225 (define_function_unit "iu" 1 0
226   (and (eq_attr "type" "ldiv")
227        (eq_attr "cpu" "rs64a"))
228   66 66)
229
230 (define_function_unit "iu" 1 0
231   (and (eq_attr "type" "idiv")
232        (eq_attr "cpu" "ppc403"))
233   33 33)
234
235 (define_function_unit "iu" 1 0
236   (and (eq_attr "type" "idiv")
237        (eq_attr "cpu" "ppc405"))
238   35 35)
239
240 (define_function_unit "iu" 1 0
241   (and (eq_attr "type" "idiv")
242        (eq_attr "cpu" "ppc601"))
243   36 36)
244
245 (define_function_unit "iu" 1 0
246   (and (eq_attr "type" "idiv")
247        (eq_attr "cpu" "ppc603"))
248   37 36)
249
250 ; RIOS2 has two integer units: a primary one which can perform all
251 ; operations and a secondary one which is fed in lock step with the first
252 ; and can perform "simple" integer operations.  
253 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
254 ; for the complex insns. 
255 (define_function_unit "iu2" 2 0
256   (and (eq_attr "type" "integer")
257        (eq_attr "cpu" "rios2"))
258   1 1)
259
260 (define_function_unit "iu2" 2 0
261   (and (eq_attr "type" "imul,imul2,imul3")
262        (eq_attr "cpu" "rios2"))
263   2 2)
264
265 (define_function_unit "iu2" 2 0
266   (and (eq_attr "type" "idiv")
267        (eq_attr "cpu" "rios2"))
268   13 13)
269
270 (define_function_unit "imuldiv" 1 0
271   (and (eq_attr "type" "imul,imul2,imul3")
272        (eq_attr "cpu" "rios2"))
273   2 2)
274
275 (define_function_unit "imuldiv" 1 0
276   (and (eq_attr "type" "idiv")
277        (eq_attr "cpu" "rios2"))
278   13 13)
279
280 ; MPCCORE has separate IMUL/IDIV unit for multicycle instructions
281 ; Divide latency varies greatly from 2-11, use 6 as average
282 (define_function_unit "imuldiv" 1 0
283   (and (eq_attr "type" "imul,imul2,imul3")
284        (eq_attr "cpu" "mpccore"))
285   2 1)
286
287 (define_function_unit "imuldiv" 1 0
288   (and (eq_attr "type" "idiv")
289        (eq_attr "cpu" "mpccore"))
290   6 6)
291
292 ; PPC604{,e} has two units that perform integer operations
293 ; and one unit for divide/multiply operations (and move
294 ; from/to spr).
295 (define_function_unit "iu2" 2 0
296   (and (eq_attr "type" "integer")
297        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc630"))
298   1 1)
299
300 (define_function_unit "imuldiv" 1 0
301   (and (eq_attr "type" "imul,imul2,imul3")
302        (eq_attr "cpu" "ppc604"))
303   4 2)
304
305 (define_function_unit "imuldiv" 1 0
306   (and (eq_attr "type" "imul,imul2,imul3")
307        (eq_attr "cpu" "ppc604e"))
308   2 1)
309
310 (define_function_unit "imuldiv" 1 0
311   (and (eq_attr "type" "imul")
312        (eq_attr "cpu" "ppc620,ppc630"))
313   5 3)
314
315 (define_function_unit "imuldiv" 1 0
316   (and (eq_attr "type" "imul2")
317        (eq_attr "cpu" "ppc620,ppc630"))
318   4 3)
319
320 (define_function_unit "imuldiv" 1 0
321   (and (eq_attr "type" "imul3")
322        (eq_attr "cpu" "ppc620,ppc630"))
323   3 3)
324
325 (define_function_unit "imuldiv" 1 0
326   (and (eq_attr "type" "lmul")
327        (eq_attr "cpu" "ppc620,ppc630"))
328   7 5)
329
330 (define_function_unit "imuldiv" 1 0
331   (and (eq_attr "type" "idiv")
332        (eq_attr "cpu" "ppc604,ppc604e"))
333   20 19)
334
335 (define_function_unit "imuldiv" 1 0
336   (and (eq_attr "type" "idiv")
337        (eq_attr "cpu" "ppc620"))
338   37 36)
339
340 (define_function_unit "imuldiv" 1 0
341   (and (eq_attr "type" "idiv")
342        (eq_attr "cpu" "ppc630"))
343   21 20)
344
345 (define_function_unit "imuldiv" 1 0
346   (and (eq_attr "type" "ldiv")
347        (eq_attr "cpu" "ppc620,ppc630"))
348   37 36)
349
350 ; PPC7450 has 3 integer units (for most integer insns) and one mul/div
351 ; unit, which also does CR-logical insns and move to/from SPR.
352 ; It also has 4 vector units, one for each type of vector instruction.
353 ; However, we can only dispatch 2 instructions per cycle. 
354 ; We model this as saying that dispatching two of the same type of instruction
355 ; in a row incurs a single cycle delay.
356 (define_function_unit "iu3" 3 0
357   (and (eq_attr "type" "integer")
358        (eq_attr "cpu" "ppc7450"))
359   1 1)
360
361 (define_function_unit "imuldiv" 1 0
362   (and (eq_attr "type" "imul")
363        (eq_attr "cpu" "ppc7450"))
364   4 2)
365
366 (define_function_unit "imuldiv" 1 0
367   (and (eq_attr "type" "imul2,imul3")
368        (eq_attr "cpu" "ppc7450"))
369   3 1)
370
371 (define_function_unit "imuldiv" 1 0
372   (and (eq_attr "type" "idiv")
373        (eq_attr "cpu" "ppc7450"))
374   23 23)
375
376 (define_function_unit "imuldiv" 1 0
377   (and (eq_attr "type" "cr_logical")
378        (eq_attr "cpu" "ppc7450"))
379   1 1)
380
381 (define_function_unit "vec_alu2" 2 0
382   (and (eq_attr "type" "vecsimple")
383        (eq_attr "cpu" "ppc7450"))
384   1 2 [(eq_attr "type" "vecsimple")])
385
386 (define_function_unit "vec_alu2" 2 0
387   (and (eq_attr "type" "vecsimple")
388        (eq_attr "cpu" "ppc7450"))
389   1 1 [(eq_attr "type" "!vecsimple")])
390
391 (define_function_unit "vec_alu2" 2 0
392   (and (eq_attr "type" "veccomplex")
393        (eq_attr "cpu" "ppc7450"))
394   4 2 [(eq_attr "type" "veccomplex")])
395
396 (define_function_unit "vec_alu2" 2 0
397   (and (eq_attr "type" "veccomplex")
398        (eq_attr "cpu" "ppc7450"))
399   4 1 [(eq_attr "type" "!veccomplex")])
400
401 (define_function_unit "vec_alu2" 2 0
402   (and (eq_attr "type" "veccmp")
403        (eq_attr "cpu" "ppc7450"))
404   2 2 [(eq_attr "type" "veccmp")])
405
406 (define_function_unit "vec_alu2" 2 0
407   (and (eq_attr "type" "veccmp")
408        (eq_attr "cpu" "ppc7450"))
409   2 1 [(eq_attr "type" "!veccmp")])
410
411 (define_function_unit "vec_alu2" 2 0
412   (and (eq_attr "type" "vecfloat")
413        (eq_attr "cpu" "ppc7450"))
414   4 2 [(eq_attr "type" "vecfloat")])
415
416 (define_function_unit "vec_alu2" 2 0
417   (and (eq_attr "type" "vecfloat")
418        (eq_attr "cpu" "ppc7450"))
419   4 1 [(eq_attr "type" "!vecfloat")])
420
421 (define_function_unit "vec_alu2" 2 0
422   (and (eq_attr "type" "vecperm")
423        (eq_attr "cpu" "ppc7450"))
424   2 2 [(eq_attr "type" "vecperm")])
425
426 (define_function_unit "vec_alu2" 2 0
427   (and (eq_attr "type" "vecperm")
428        (eq_attr "cpu" "ppc7450"))
429   2 1 [(eq_attr "type" "!vecperm")])
430
431 ; PPC750 has two integer units: a primary one which can perform all
432 ; operations and a secondary one which is fed in lock step with the first
433 ; and can perform "simple" integer operations.  
434 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
435 ; for the complex insns. 
436 (define_function_unit "iu2" 2 0
437   (and (eq_attr "type" "integer")
438        (eq_attr "cpu" "ppc750,ppc7400"))
439   1 1)
440
441 (define_function_unit "iu2" 2 0
442   (and (eq_attr "type" "imul")
443        (eq_attr "cpu" "ppc750,ppc7400"))
444   4 4)
445
446 (define_function_unit "iu2" 2 0
447   (and (eq_attr "type" "imul2")
448        (eq_attr "cpu" "ppc750,ppc7400"))
449   3 2)
450
451 (define_function_unit "iu2" 2 0
452   (and (eq_attr "type" "imul3")
453        (eq_attr "cpu" "ppc750,ppc7400"))
454   2 1)
455
456 (define_function_unit "iu2" 2 0
457   (and (eq_attr "type" "idiv")
458        (eq_attr "cpu" "ppc750,ppc7400"))
459   19 19)
460
461 (define_function_unit "imuldiv" 1 0
462   (and (eq_attr "type" "imul")
463        (eq_attr "cpu" "ppc750,ppc7400"))
464   4 4)
465
466 (define_function_unit "imuldiv" 1 0
467   (and (eq_attr "type" "imul2")
468        (eq_attr "cpu" "ppc750,ppc7400"))
469   3 2)
470
471 (define_function_unit "imuldiv" 1 0
472   (and (eq_attr "type" "imul3")
473        (eq_attr "cpu" "ppc750,ppc7400"))
474   2 1)
475
476 (define_function_unit "imuldiv" 1 0
477   (and (eq_attr "type" "idiv")
478        (eq_attr "cpu" "ppc750,ppc7400"))
479   19 19)
480
481 ; CR-logical operations are execute-serialized, that is they don't
482 ; start (and block the function unit) until all preceding operations
483 ; have finished.  They don't block dispatch of other insns, though.
484 ; I've imitated this by giving them longer latency.
485 (define_function_unit "sru" 1 0 
486   (and (eq_attr "type" "cr_logical")
487        (eq_attr "cpu" "ppc603,ppc750,ppc7400"))
488   3 2)
489
490 ; compare is done on integer unit, but feeds insns which
491 ; execute on the branch unit.
492 (define_function_unit "iu" 1 0   
493   (and (eq_attr "type" "compare")
494        (eq_attr "cpu" "rios1"))
495   4 1)
496
497 (define_function_unit "iu" 1 0   
498   (and (eq_attr "type" "delayed_compare")
499        (eq_attr "cpu" "rios1"))
500   5 1)
501
502 (define_function_unit "iu" 1 0
503   (and (eq_attr "type" "compare,delayed_compare")
504        (eq_attr "cpu" "rs64a,mpccore,ppc403,ppc405,ppc601,ppc603"))
505   3 1)
506
507 ; some extra cycles added by TARGET_SCHED_ADJUST_COST between compare
508 ; and a following branch, to reduce mispredicts
509 (define_function_unit "iu3" 3 0
510   (and (eq_attr "type" "compare,delayed_compare")
511        (eq_attr "cpu" "ppc7450"))
512   1 1)
513
514 (define_function_unit "iu2" 2 0   
515   (and (eq_attr "type" "compare,delayed_compare")
516        (eq_attr "cpu" "rios2"))
517   3 1)
518
519 (define_function_unit "iu2" 2 0
520   (and (eq_attr "type" "compare,delayed_compare")
521        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400"))
522   1 1)
523
524 ; fp compare uses fp unit
525 (define_function_unit "fpu" 1 0
526   (and (eq_attr "type" "fpcompare")
527        (eq_attr "cpu" "rios1"))
528   9 1)
529
530 ; rios1 and rios2 have different fpcompare delays
531 (define_function_unit "fpu2" 2 0
532   (and (eq_attr "type" "fpcompare")
533        (eq_attr "cpu" "rios2,ppc630"))
534   5 1)
535
536 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
537 ; the integer unit
538 ; here we do not define delays, just occupy the unit. The dependencies
539 ; will be assigned by the fpcompare definition in the fpu.
540 (define_function_unit "iu" 1 0
541   (and (eq_attr "type" "fpcompare")
542        (eq_attr "cpu" "ppc601,ppc603"))
543   0 2)
544
545 ; fp compare uses fp unit
546 (define_function_unit "fpu" 1 0
547   (and (eq_attr "type" "fpcompare")
548        (eq_attr "cpu" "rs64a,ppc601,ppc603,ppc604,ppc604e,ppc620"))
549   5 1)
550
551 (define_function_unit "fpu" 1 0
552   (and (eq_attr "type" "fpcompare")
553        (eq_attr "cpu"  "ppc750,ppc7400,ppc7450"))
554   3 1)
555
556 (define_function_unit "fpu" 1 0
557   (and (eq_attr "type" "fpcompare")
558        (eq_attr "cpu" "mpccore"))
559   1 1)
560
561 (define_function_unit "bpu" 1 0
562   (and (eq_attr "type" "mtjmpr")
563        (eq_attr "cpu" "rios1,rios2,rs64a"))
564   5 1)
565
566 (define_function_unit "bpu" 1 0
567   (and (eq_attr "type" "mtjmpr")
568        (eq_attr "cpu" "mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630"))
569   4 1)
570
571 (define_function_unit "sru" 1 0
572   (and (eq_attr "type" "mtjmpr")
573        (eq_attr "cpu" "ppc750,ppc7400"))
574   2 2)
575
576 (define_function_unit "imuldiv" 1 0
577   (and (eq_attr "type" "mtjmpr")
578        (eq_attr "cpu" "ppc7450"))
579   2 2)
580
581 (define_function_unit "bpu" 1 0
582   (and (eq_attr "type" "cr_logical")
583        (eq_attr "cpu" "rios1,rios2,ppc604"))
584   4 1)
585   
586 (define_function_unit "cru" 1 0
587   (and (eq_attr "type" "cr_logical")
588        (eq_attr "cpu" "ppc604e,ppc620,ppc630,rs64a"))
589   1 1)
590
591 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
592 (define_function_unit "bpu" 1 0
593   (eq_attr "type" "jmpreg")
594   1 1)
595
596 (define_function_unit "bpu" 1 0
597   (eq_attr "type" "branch")
598   1 1)
599
600 ; Floating Point Unit
601 (define_function_unit "fpu" 1 0
602   (and (eq_attr "type" "fp,dmul")
603        (eq_attr "cpu" "rios1"))
604   2 1)
605
606 (define_function_unit "fpu" 1 0
607   (and (eq_attr "type" "fp")
608        (eq_attr "cpu" "rs64a,mpccore"))
609   4 2)
610
611 (define_function_unit "fpu" 1 0
612   (and (eq_attr "type" "fp")
613        (eq_attr "cpu" "ppc601"))
614   4 1)
615
616 (define_function_unit "fpu" 1 0
617   (and (eq_attr "type" "fp")
618        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620,ppc750,ppc7400"))
619   3 1)
620
621 (define_function_unit "fpu" 1 0
622   (and (eq_attr "type" "fp,dmul")
623        (eq_attr "cpu" "ppc7450"))
624   5 1)
625
626 (define_function_unit "fpu" 1 0
627   (and (eq_attr "type" "dmul")
628        (eq_attr "cpu" "rs64a"))
629   7 2)
630
631 (define_function_unit "fpu" 1 0
632   (and (eq_attr "type" "dmul")
633        (eq_attr "cpu" "mpccore"))
634   5 5)
635
636 (define_function_unit "fpu" 1 0
637   (and (eq_attr "type" "dmul")
638        (eq_attr "cpu" "ppc601"))
639   5 2)
640
641 ; is this true?
642 (define_function_unit "fpu" 1 0
643   (and (eq_attr "type" "dmul")
644        (eq_attr "cpu" "ppc603,ppc750"))
645   4 2)
646
647 (define_function_unit "fpu" 1 0
648   (and (eq_attr "type" "dmul")
649        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc7400"))
650   3 1)
651
652 (define_function_unit "fpu" 1 0
653   (and (eq_attr "type" "sdiv,ddiv")
654        (eq_attr "cpu" "rios1"))
655   19 19)
656
657 (define_function_unit "fpu" 1 0
658   (and (eq_attr "type" "sdiv")
659        (eq_attr "cpu" "rs64a"))
660   31 31)
661
662 (define_function_unit "fpu" 1 0
663   (and (eq_attr "type" "sdiv")
664        (eq_attr "cpu" "ppc601,ppc750,ppc7400"))
665   17 17)
666
667 (define_function_unit "fpu" 1 0
668   (and (eq_attr "type" "sdiv")
669        (eq_attr "cpu" "ppc7450"))
670   21 21)
671
672 (define_function_unit "fpu" 1 0
673   (and (eq_attr "type" "sdiv")
674        (eq_attr "cpu" "mpccore"))
675   10 10)
676
677 (define_function_unit "fpu" 1 0
678   (and (eq_attr "type" "sdiv")
679        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620"))
680   18 18)
681
682 (define_function_unit "fpu" 1 0
683   (and (eq_attr "type" "ddiv")
684        (eq_attr "cpu" "mpccore"))
685   17 17)
686
687 (define_function_unit "fpu" 1 0
688   (and (eq_attr "type" "ddiv")
689        (eq_attr "cpu" "rs64a,ppc601,ppc750,ppc604,ppc604e,ppc620,ppc7400"))
690   31 31)
691
692 (define_function_unit "fpu" 1 0
693   (and (eq_attr "type" "ddiv")
694        (eq_attr "cpu" "ppc7450"))
695   35 35)
696
697 (define_function_unit "fpu" 1 0
698   (and (eq_attr "type" "ddiv")
699        (eq_attr "cpu" "ppc603"))
700   33 33)
701
702 (define_function_unit "fpu" 1 0
703   (and (eq_attr "type" "ssqrt")
704        (eq_attr "cpu" "ppc620"))
705   31 31)
706
707 (define_function_unit "fpu" 1 0
708   (and (eq_attr "type" "dsqrt")
709        (eq_attr "cpu" "ppc620"))
710   31 31)
711
712 ; RIOS2 has two symmetric FPUs.
713 (define_function_unit "fpu2" 2 0
714   (and (eq_attr "type" "fp,dmul")
715        (eq_attr "cpu" "rios2"))
716   2 1)
717
718 (define_function_unit "fpu2" 2 0
719   (and (eq_attr "type" "fp,dmul")
720        (eq_attr "cpu" "ppc630"))
721   3 1)
722
723 (define_function_unit "fpu2" 2 0
724   (and (eq_attr "type" "sdiv,ddiv")
725        (eq_attr "cpu" "rios2"))
726   17 17)
727
728 (define_function_unit "fpu2" 2 0
729   (and (eq_attr "type" "sdiv")
730        (eq_attr "cpu" "ppc630"))
731   17 17)
732
733 (define_function_unit "fpu2" 2 0
734   (and (eq_attr "type" "ddiv")
735        (eq_attr "cpu" "ppc630"))
736   21 21)
737
738 (define_function_unit "fpu2" 2 0
739   (and (eq_attr "type" "ssqrt,dsqrt")
740        (eq_attr "cpu" "rios2"))
741   26 26)
742
743 (define_function_unit "fpu2" 2 0
744   (and (eq_attr "type" "ssqrt")
745        (eq_attr "cpu" "ppc630"))
746   18 18)
747
748 (define_function_unit "fpu2" 2 0
749   (and (eq_attr "type" "dsqrt")
750        (eq_attr "cpu" "ppc630"))
751   26 26)
752
753 ;; Power4
754 (define_function_unit "lsu2" 2 0
755   (and (eq_attr "type" "load")
756        (eq_attr "cpu" "power4"))
757   3 1)
758
759 (define_function_unit "lsu2" 2 0
760   (and (eq_attr "type" "fpload")
761        (eq_attr "cpu" "power4"))
762   5 1)
763
764 (define_function_unit "lsu2" 2 0
765   (and (eq_attr "type" "store,fpstore")
766        (eq_attr "cpu" "power4"))
767   1 1)
768
769 (define_function_unit "iu2" 2 0
770   (and (eq_attr "type" "integer")
771        (eq_attr "cpu" "power4"))
772   2 1)
773
774 (define_function_unit "iu2" 2 0
775   (and (eq_attr "type" "imul,lmul")
776        (eq_attr "cpu" "power4"))
777   7 6)
778
779 (define_function_unit "iu2" 2 0
780   (and (eq_attr "type" "imul2")
781        (eq_attr "cpu" "power4"))
782   5 4)
783
784 (define_function_unit "iu2" 2 0
785   (and (eq_attr "type" "imul3")
786        (eq_attr "cpu" "power4"))
787   4 3)
788
789 (define_function_unit "iu2" 2 0
790   (and (eq_attr "type" "idiv")
791        (eq_attr "cpu" "power4"))
792   36 35)
793
794 (define_function_unit "iu2" 2 0
795   (and (eq_attr "type" "ldiv")
796        (eq_attr "cpu" "power4"))
797   68 67)
798
799 (define_function_unit "imuldiv" 1 0
800   (and (eq_attr "type" "idiv")
801        (eq_attr "cpu" "power4"))
802   36 35)
803
804 (define_function_unit "imuldiv" 1 0
805   (and (eq_attr "type" "ldiv")
806        (eq_attr "cpu" "power4"))
807   68 67)
808
809 (define_function_unit "iu2" 2 0
810   (and (eq_attr "type" "compare")
811        (eq_attr "cpu" "power4"))
812   3 1)
813
814 (define_function_unit "iu2" 2 0
815   (and (eq_attr "type" "delayed_compare")
816        (eq_attr "cpu" "power4"))
817   4 1)
818
819 (define_function_unit "bpu" 1 0
820   (and (eq_attr "type" "mtjmpr")
821        (eq_attr "cpu" "power4"))
822   3 1)
823
824 (define_function_unit "bpu" 1 0
825   (and (eq_attr "type" "jmpreg,branch")
826        (eq_attr "cpu" "power4"))
827   2 1)
828
829 (define_function_unit "cru" 1 0
830   (and (eq_attr "type" "cr_logical")
831        (eq_attr "cpu" "power4"))
832   4 1)
833
834 (define_function_unit "fpu2" 2 0
835   (and (eq_attr "type" "fp,dmul")
836        (eq_attr "cpu" "power4"))
837   6 1)
838
839 ; adjust_cost increases the cost of dependent branches,
840 ; so shave a few cycles off for fpcompare.
841 (define_function_unit "fpu2" 2 0
842   (and (eq_attr "type" "fpcompare")
843        (eq_attr "cpu" "power4"))
844   5 1)
845
846 (define_function_unit "fpu2" 2 0
847   (and (eq_attr "type" "sdiv,ddiv")
848        (eq_attr "cpu" "power4"))
849   33 28)
850
851 (define_function_unit "fpu2" 2 0
852   (and (eq_attr "type" "ssqrt,dsqrt")
853        (eq_attr "cpu" "power4"))
854   40 35)
855
856 \f
857 ;; Start with fixed-point load and store insns.  Here we put only the more
858 ;; complex forms.  Basic data transfer is done later.
859
860 (define_expand "zero_extendqidi2"
861   [(set (match_operand:DI 0 "gpc_reg_operand" "")
862         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
863   "TARGET_POWERPC64"
864   "")
865
866 (define_insn ""
867   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
868         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
869   "TARGET_POWERPC64"
870   "@
871    lbz%U1%X1 %0,%1
872    rldicl %0,%1,0,56"
873   [(set_attr "type" "load,*")])
874
875 (define_insn ""
876   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
877         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
878                     (const_int 0)))
879    (clobber (match_scratch:DI 2 "=r,r"))]
880   "TARGET_POWERPC64"
881   "@
882    rldicl. %2,%1,0,56
883    #"
884   [(set_attr "type" "compare")
885    (set_attr "length" "4,8")])
886
887 (define_split
888   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
889         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
890                     (const_int 0)))
891    (clobber (match_scratch:DI 2 ""))]
892   "TARGET_POWERPC64 && reload_completed"
893   [(set (match_dup 2)
894         (zero_extend:DI (match_dup 1)))
895    (set (match_dup 0)
896         (compare:CC (match_dup 2)
897                     (const_int 0)))]
898   "")
899
900 (define_insn ""
901   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
902         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
903                     (const_int 0)))
904    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
905         (zero_extend:DI (match_dup 1)))]
906   "TARGET_POWERPC64"
907   "@
908    rldicl. %0,%1,0,56
909    #"
910   [(set_attr "type" "compare")
911    (set_attr "length" "4,8")])
912
913 (define_split
914   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
915         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
916                     (const_int 0)))
917    (set (match_operand:DI 0 "gpc_reg_operand" "")
918         (zero_extend:DI (match_dup 1)))]
919   "TARGET_POWERPC64 && reload_completed"
920   [(set (match_dup 0)
921         (zero_extend:DI (match_dup 1)))
922    (set (match_dup 2)
923         (compare:CC (match_dup 0)
924                     (const_int 0)))]
925   "")
926
927 (define_insn "extendqidi2"
928   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
929         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
930   "TARGET_POWERPC64"
931   "extsb %0,%1")
932
933 (define_insn ""
934   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
935         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
936                     (const_int 0)))
937    (clobber (match_scratch:DI 2 "=r,r"))]
938   "TARGET_POWERPC64"
939   "@
940    extsb. %2,%1
941    #"
942   [(set_attr "type" "compare")
943    (set_attr "length" "4,8")])
944
945 (define_split
946   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
947         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
948                     (const_int 0)))
949    (clobber (match_scratch:DI 2 ""))]
950   "TARGET_POWERPC64 && reload_completed"
951   [(set (match_dup 2)
952         (sign_extend:DI (match_dup 1)))
953    (set (match_dup 0)
954         (compare:CC (match_dup 2)
955                     (const_int 0)))]
956   "")
957
958 (define_insn ""
959   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
960         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
961                     (const_int 0)))
962    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
963         (sign_extend:DI (match_dup 1)))]
964   "TARGET_POWERPC64"
965   "@
966    extsb. %0,%1
967    #"
968   [(set_attr "type" "compare")
969    (set_attr "length" "4,8")])
970
971 (define_split
972   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
973         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
974                     (const_int 0)))
975    (set (match_operand:DI 0 "gpc_reg_operand" "")
976         (sign_extend:DI (match_dup 1)))]
977   "TARGET_POWERPC64 && reload_completed"
978   [(set (match_dup 0)
979         (sign_extend:DI (match_dup 1)))
980    (set (match_dup 2)
981         (compare:CC (match_dup 0)
982                     (const_int 0)))]
983   "")
984
985 (define_expand "zero_extendhidi2"
986   [(set (match_operand:DI 0 "gpc_reg_operand" "")
987         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
988   "TARGET_POWERPC64"
989   "")
990
991 (define_insn ""
992   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
993         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
994   "TARGET_POWERPC64"
995   "@
996    lhz%U1%X1 %0,%1
997    rldicl %0,%1,0,48"
998   [(set_attr "type" "load,*")])
999
1000 (define_insn ""
1001   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1002         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1003                     (const_int 0)))
1004    (clobber (match_scratch:DI 2 "=r,r"))]
1005   "TARGET_POWERPC64"
1006   "@
1007    rldicl. %2,%1,0,48
1008    #"
1009   [(set_attr "type" "compare")
1010    (set_attr "length" "4,8")])
1011
1012 (define_split
1013   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1014         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1015                     (const_int 0)))
1016    (clobber (match_scratch:DI 2 ""))]
1017   "TARGET_POWERPC64 && reload_completed"
1018   [(set (match_dup 2)
1019         (zero_extend:DI (match_dup 1)))
1020    (set (match_dup 0)
1021         (compare:CC (match_dup 2)
1022                     (const_int 0)))]
1023   "")
1024
1025 (define_insn ""
1026   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1027         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1028                     (const_int 0)))
1029    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1030         (zero_extend:DI (match_dup 1)))]
1031   "TARGET_POWERPC64"
1032   "@
1033    rldicl. %0,%1,0,48
1034    #"
1035   [(set_attr "type" "compare")
1036    (set_attr "length" "4,8")])
1037
1038 (define_split
1039   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1040         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1041                     (const_int 0)))
1042    (set (match_operand:DI 0 "gpc_reg_operand" "")
1043         (zero_extend:DI (match_dup 1)))]
1044   "TARGET_POWERPC64 && reload_completed"
1045   [(set (match_dup 0)
1046         (zero_extend:DI (match_dup 1)))
1047    (set (match_dup 2)
1048         (compare:CC (match_dup 0)
1049                     (const_int 0)))]
1050   "")
1051
1052 (define_expand "extendhidi2"
1053   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1054         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
1055   "TARGET_POWERPC64"
1056   "")
1057
1058 (define_insn ""
1059   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1060         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1061   "TARGET_POWERPC64"
1062   "@
1063    lha%U1%X1 %0,%1
1064    extsh %0,%1"
1065   [(set_attr "type" "load,*")])
1066
1067 (define_insn ""
1068   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1069         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1070                     (const_int 0)))
1071    (clobber (match_scratch:DI 2 "=r,r"))]
1072   "TARGET_POWERPC64"
1073   "@
1074    extsh. %2,%1
1075    #"
1076   [(set_attr "type" "compare")
1077    (set_attr "length" "4,8")])
1078
1079 (define_split
1080   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1081         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1082                     (const_int 0)))
1083    (clobber (match_scratch:DI 2 ""))]
1084   "TARGET_POWERPC64 && reload_completed"
1085   [(set (match_dup 2)
1086         (sign_extend:DI (match_dup 1)))
1087    (set (match_dup 0)
1088         (compare:CC (match_dup 2)
1089                     (const_int 0)))]
1090   "")
1091
1092 (define_insn ""
1093   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1094         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1095                     (const_int 0)))
1096    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1097         (sign_extend:DI (match_dup 1)))]
1098   "TARGET_POWERPC64"
1099   "@
1100    extsh. %0,%1
1101    #"
1102   [(set_attr "type" "compare")
1103    (set_attr "length" "4,8")])
1104
1105 (define_split
1106   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1107         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1108                     (const_int 0)))
1109    (set (match_operand:DI 0 "gpc_reg_operand" "")
1110         (sign_extend:DI (match_dup 1)))]
1111   "TARGET_POWERPC64 && reload_completed"
1112   [(set (match_dup 0)
1113         (sign_extend:DI (match_dup 1)))
1114    (set (match_dup 2)
1115         (compare:CC (match_dup 0)
1116                     (const_int 0)))]
1117   "")
1118
1119 (define_expand "zero_extendsidi2"
1120   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1121         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1122   "TARGET_POWERPC64"
1123   "")
1124
1125 (define_insn ""
1126   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1127         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
1128   "TARGET_POWERPC64"
1129   "@
1130    lwz%U1%X1 %0,%1
1131    rldicl %0,%1,0,32"
1132   [(set_attr "type" "load,*")])
1133
1134 (define_insn ""
1135   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1136         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1137                     (const_int 0)))
1138    (clobber (match_scratch:DI 2 "=r,r"))]
1139   "TARGET_POWERPC64"
1140   "@
1141    rldicl. %2,%1,0,32
1142    #"
1143   [(set_attr "type" "compare")
1144    (set_attr "length" "4,8")])
1145
1146 (define_split
1147   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1148         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1149                     (const_int 0)))
1150    (clobber (match_scratch:DI 2 ""))]
1151   "TARGET_POWERPC64 && reload_completed"
1152   [(set (match_dup 2)
1153         (zero_extend:DI (match_dup 1)))
1154    (set (match_dup 0)
1155         (compare:CC (match_dup 2)
1156                     (const_int 0)))]
1157   "")
1158
1159 (define_insn ""
1160   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1161         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1162                     (const_int 0)))
1163    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1164         (zero_extend:DI (match_dup 1)))]
1165   "TARGET_POWERPC64"
1166   "@
1167    rldicl. %0,%1,0,32
1168    #"
1169   [(set_attr "type" "compare")
1170    (set_attr "length" "4,8")])
1171
1172 (define_split
1173   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1174         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1175                     (const_int 0)))
1176    (set (match_operand:DI 0 "gpc_reg_operand" "")
1177         (zero_extend:DI (match_dup 1)))]
1178   "TARGET_POWERPC64 && reload_completed"
1179   [(set (match_dup 0)
1180         (zero_extend:DI (match_dup 1)))
1181    (set (match_dup 2)
1182         (compare:CC (match_dup 0)
1183                     (const_int 0)))]
1184   "")
1185
1186 (define_expand "extendsidi2"
1187   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1188         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1189   "TARGET_POWERPC64"
1190   "")
1191
1192 (define_insn ""
1193   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1194         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
1195   "TARGET_POWERPC64"
1196   "@
1197    lwa%U1%X1 %0,%1
1198    extsw %0,%1"
1199   [(set_attr "type" "load,*")])
1200
1201 (define_insn ""
1202   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1203         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1204                     (const_int 0)))
1205    (clobber (match_scratch:DI 2 "=r,r"))]
1206   "TARGET_POWERPC64"
1207   "@
1208    extsw. %2,%1
1209    #"
1210   [(set_attr "type" "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 (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1216                     (const_int 0)))
1217    (clobber (match_scratch:DI 2 ""))]
1218   "TARGET_POWERPC64 && reload_completed"
1219   [(set (match_dup 2)
1220         (sign_extend:DI (match_dup 1)))
1221    (set (match_dup 0)
1222         (compare:CC (match_dup 2)
1223                     (const_int 0)))]
1224   "")
1225
1226 (define_insn ""
1227   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1228         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1229                     (const_int 0)))
1230    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1231         (sign_extend:DI (match_dup 1)))]
1232   "TARGET_POWERPC64"
1233   "@
1234    extsw. %0,%1
1235    #"
1236   [(set_attr "type" "compare")
1237    (set_attr "length" "4,8")])
1238
1239 (define_split
1240   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1241         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1242                     (const_int 0)))
1243    (set (match_operand:DI 0 "gpc_reg_operand" "")
1244         (sign_extend:DI (match_dup 1)))]
1245   "TARGET_POWERPC64 && reload_completed"
1246   [(set (match_dup 0)
1247         (sign_extend:DI (match_dup 1)))
1248    (set (match_dup 2)
1249         (compare:CC (match_dup 0)
1250                     (const_int 0)))]
1251   "")
1252
1253 (define_expand "zero_extendqisi2"
1254   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1255         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1256   ""
1257   "")
1258
1259 (define_insn ""
1260   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1261         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1262   ""
1263   "@
1264    lbz%U1%X1 %0,%1
1265    {rlinm|rlwinm} %0,%1,0,0xff"
1266   [(set_attr "type" "load,*")])
1267
1268 (define_insn ""
1269   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1270         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1271                     (const_int 0)))
1272    (clobber (match_scratch:SI 2 "=r,r"))]
1273   ""
1274   "@
1275    {andil.|andi.} %2,%1,0xff
1276    #"
1277   [(set_attr "type" "compare")
1278    (set_attr "length" "4,8")])
1279
1280 (define_split
1281   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1282         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1283                     (const_int 0)))
1284    (clobber (match_scratch:SI 2 ""))]
1285   "reload_completed"
1286   [(set (match_dup 2)
1287         (zero_extend:SI (match_dup 1)))
1288    (set (match_dup 0)
1289         (compare:CC (match_dup 2)
1290                     (const_int 0)))]
1291   "")
1292
1293 (define_insn ""
1294   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1295         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1296                     (const_int 0)))
1297    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1298         (zero_extend:SI (match_dup 1)))]
1299   ""
1300   "@
1301    {andil.|andi.} %0,%1,0xff
1302    #"
1303   [(set_attr "type" "compare")
1304    (set_attr "length" "4,8")])
1305
1306 (define_split
1307   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1308         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1309                     (const_int 0)))
1310    (set (match_operand:SI 0 "gpc_reg_operand" "")
1311         (zero_extend:SI (match_dup 1)))]
1312   "reload_completed"
1313   [(set (match_dup 0)
1314         (zero_extend:SI (match_dup 1)))
1315    (set (match_dup 2)
1316         (compare:CC (match_dup 0)
1317                     (const_int 0)))]
1318   "")
1319
1320 (define_expand "extendqisi2"
1321   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1322    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1323   ""
1324   "
1325 {
1326   if (TARGET_POWERPC)
1327     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
1328   else if (TARGET_POWER)
1329     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
1330   else
1331     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
1332   DONE;
1333 }")
1334
1335 (define_insn "extendqisi2_ppc"
1336   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1337         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1338   "TARGET_POWERPC"
1339   "extsb %0,%1")
1340
1341 (define_insn ""
1342   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1343         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1344                     (const_int 0)))
1345    (clobber (match_scratch:SI 2 "=r,r"))]
1346   "TARGET_POWERPC"
1347   "@
1348    extsb. %2,%1
1349    #"
1350   [(set_attr "type" "compare")
1351    (set_attr "length" "4,8")])
1352
1353 (define_split
1354   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1355         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1356                     (const_int 0)))
1357    (clobber (match_scratch:SI 2 ""))]
1358   "TARGET_POWERPC && reload_completed"
1359   [(set (match_dup 2)
1360         (sign_extend:SI (match_dup 1)))
1361    (set (match_dup 0)
1362         (compare:CC (match_dup 2)
1363                     (const_int 0)))]
1364   "")
1365
1366 (define_insn ""
1367   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1368         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1369                     (const_int 0)))
1370    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1371         (sign_extend:SI (match_dup 1)))]
1372   "TARGET_POWERPC"
1373   "@
1374    extsb. %0,%1
1375    #"
1376   [(set_attr "type" "compare")
1377    (set_attr "length" "4,8")])
1378
1379 (define_split
1380   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1381         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1382                     (const_int 0)))
1383    (set (match_operand:SI 0 "gpc_reg_operand" "")
1384         (sign_extend:SI (match_dup 1)))]
1385   "TARGET_POWERPC && reload_completed"
1386   [(set (match_dup 0)
1387         (sign_extend:SI (match_dup 1)))
1388    (set (match_dup 2)
1389         (compare:CC (match_dup 0)
1390                     (const_int 0)))]
1391   "")
1392
1393 (define_expand "extendqisi2_power"
1394   [(parallel [(set (match_dup 2)
1395                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1396                               (const_int 24)))
1397               (clobber (scratch:SI))])
1398    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1399                    (ashiftrt:SI (match_dup 2)
1400                                 (const_int 24)))
1401               (clobber (scratch:SI))])]
1402   "TARGET_POWER"
1403   "
1404 { operands[1] = gen_lowpart (SImode, operands[1]);
1405   operands[2] = gen_reg_rtx (SImode); }")
1406
1407 (define_expand "extendqisi2_no_power"
1408   [(set (match_dup 2)
1409         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1410                    (const_int 24)))
1411    (set (match_operand:SI 0 "gpc_reg_operand" "")
1412         (ashiftrt:SI (match_dup 2)
1413                      (const_int 24)))]
1414   "! TARGET_POWER && ! TARGET_POWERPC"
1415   "
1416 { operands[1] = gen_lowpart (SImode, operands[1]);
1417   operands[2] = gen_reg_rtx (SImode); }")
1418
1419 (define_expand "zero_extendqihi2"
1420   [(set (match_operand:HI 0 "gpc_reg_operand" "")
1421         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1422   ""
1423   "")
1424
1425 (define_insn ""
1426   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1427         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1428   ""
1429   "@
1430    lbz%U1%X1 %0,%1
1431    {rlinm|rlwinm} %0,%1,0,0xff"
1432   [(set_attr "type" "load,*")])
1433
1434 (define_insn ""
1435   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1436         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1437                     (const_int 0)))
1438    (clobber (match_scratch:HI 2 "=r,r"))]
1439   ""
1440   "@
1441    {andil.|andi.} %2,%1,0xff
1442    #"
1443   [(set_attr "type" "compare")
1444    (set_attr "length" "4,8")])
1445
1446 (define_split
1447   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1448         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1449                     (const_int 0)))
1450    (clobber (match_scratch:HI 2 ""))]
1451   "reload_completed"
1452   [(set (match_dup 2)
1453         (zero_extend:HI (match_dup 1)))
1454    (set (match_dup 0)
1455         (compare:CC (match_dup 2)
1456                     (const_int 0)))]
1457   "")
1458
1459 (define_insn ""
1460   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1461         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1462                     (const_int 0)))
1463    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1464         (zero_extend:HI (match_dup 1)))]
1465   ""
1466   "@
1467    {andil.|andi.} %0,%1,0xff
1468    #"
1469   [(set_attr "type" "compare")
1470    (set_attr "length" "4,8")])
1471
1472 (define_split
1473   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1474         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1475                     (const_int 0)))
1476    (set (match_operand:HI 0 "gpc_reg_operand" "")
1477         (zero_extend:HI (match_dup 1)))]
1478   "reload_completed"
1479   [(set (match_dup 0)
1480         (zero_extend:HI (match_dup 1)))
1481    (set (match_dup 2)
1482         (compare:CC (match_dup 0)
1483                     (const_int 0)))]
1484   "")
1485
1486 (define_expand "extendqihi2"
1487   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
1488    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1489   ""
1490   "
1491 {
1492   if (TARGET_POWERPC)
1493     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
1494   else if (TARGET_POWER)
1495     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
1496   else
1497     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
1498   DONE;
1499 }")
1500
1501 (define_insn "extendqihi2_ppc"
1502   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
1503         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1504   "TARGET_POWERPC"
1505   "extsb %0,%1")
1506
1507 (define_insn ""
1508   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1509         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1510                     (const_int 0)))
1511    (clobber (match_scratch:HI 2 "=r,r"))]
1512   "TARGET_POWERPC"
1513   "@
1514    extsb. %2,%1
1515    #"
1516   [(set_attr "type" "compare")
1517    (set_attr "length" "4,8")])
1518
1519 (define_split
1520   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1521         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1522                     (const_int 0)))
1523    (clobber (match_scratch:HI 2 ""))]
1524   "TARGET_POWERPC && reload_completed"
1525   [(set (match_dup 2)
1526         (sign_extend:HI (match_dup 1)))
1527    (set (match_dup 0)
1528         (compare:CC (match_dup 2)
1529                     (const_int 0)))]
1530   "")
1531
1532 (define_insn ""
1533   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1534         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1535                     (const_int 0)))
1536    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1537         (sign_extend:HI (match_dup 1)))]
1538   "TARGET_POWERPC"
1539   "@
1540    extsb. %0,%1
1541    #"
1542   [(set_attr "type" "compare")
1543    (set_attr "length" "4,8")])
1544
1545 (define_split
1546   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1547         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1548                     (const_int 0)))
1549    (set (match_operand:HI 0 "gpc_reg_operand" "")
1550         (sign_extend:HI (match_dup 1)))]
1551   "TARGET_POWERPC && reload_completed"
1552   [(set (match_dup 0)
1553         (sign_extend:HI (match_dup 1)))
1554    (set (match_dup 2)
1555         (compare:CC (match_dup 0)
1556                     (const_int 0)))]
1557   "")
1558
1559 (define_expand "extendqihi2_power"
1560   [(parallel [(set (match_dup 2)
1561                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1562                               (const_int 24)))
1563               (clobber (scratch:SI))])
1564    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
1565                    (ashiftrt:SI (match_dup 2)
1566                                 (const_int 24)))
1567               (clobber (scratch:SI))])]
1568   "TARGET_POWER"
1569   "
1570 { operands[0] = gen_lowpart (SImode, operands[0]);
1571   operands[1] = gen_lowpart (SImode, operands[1]);
1572   operands[2] = gen_reg_rtx (SImode); }")
1573
1574 (define_expand "extendqihi2_no_power"
1575   [(set (match_dup 2)
1576         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1577                    (const_int 24)))
1578    (set (match_operand:HI 0 "gpc_reg_operand" "")
1579         (ashiftrt:SI (match_dup 2)
1580                      (const_int 24)))]
1581   "! TARGET_POWER && ! TARGET_POWERPC"
1582   "
1583 { operands[0] = gen_lowpart (SImode, operands[0]);
1584   operands[1] = gen_lowpart (SImode, operands[1]);
1585   operands[2] = gen_reg_rtx (SImode); }")
1586
1587 (define_expand "zero_extendhisi2"
1588   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1589         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1590   ""
1591   "")
1592
1593 (define_insn ""
1594   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1595         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1596   ""
1597   "@
1598    lhz%U1%X1 %0,%1
1599    {rlinm|rlwinm} %0,%1,0,0xffff"
1600   [(set_attr "type" "load,*")])
1601
1602 (define_insn ""
1603   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1604         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1605                     (const_int 0)))
1606    (clobber (match_scratch:SI 2 "=r,r"))]
1607   ""
1608   "@
1609    {andil.|andi.} %2,%1,0xffff
1610    #"
1611   [(set_attr "type" "compare")
1612    (set_attr "length" "4,8")])
1613
1614 (define_split
1615   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1616         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1617                     (const_int 0)))
1618    (clobber (match_scratch:SI 2 ""))]
1619   "reload_completed"
1620   [(set (match_dup 2)
1621         (zero_extend:SI (match_dup 1)))
1622    (set (match_dup 0)
1623         (compare:CC (match_dup 2)
1624                     (const_int 0)))]
1625   "")
1626
1627 (define_insn ""
1628   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1629         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1630                     (const_int 0)))
1631    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1632         (zero_extend:SI (match_dup 1)))]
1633   ""
1634   "@
1635    {andil.|andi.} %0,%1,0xffff
1636    #"
1637   [(set_attr "type" "compare")
1638    (set_attr "length" "4,8")])
1639
1640 (define_split
1641   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1642         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1643                     (const_int 0)))
1644    (set (match_operand:SI 0 "gpc_reg_operand" "")
1645         (zero_extend:SI (match_dup 1)))]
1646   "reload_completed"
1647   [(set (match_dup 0)
1648         (zero_extend:SI (match_dup 1)))
1649    (set (match_dup 2)
1650         (compare:CC (match_dup 0)
1651                     (const_int 0)))]
1652   "")
1653
1654 (define_expand "extendhisi2"
1655   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1656         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1657   ""
1658   "")
1659
1660 (define_insn ""
1661   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1662         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1663   ""
1664   "@
1665    lha%U1%X1 %0,%1
1666    {exts|extsh} %0,%1"
1667   [(set_attr "type" "load,*")])
1668
1669 (define_insn ""
1670   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1671         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1672                     (const_int 0)))
1673    (clobber (match_scratch:SI 2 "=r,r"))]
1674   ""
1675   "@
1676    {exts.|extsh.} %2,%1
1677    #"
1678   [(set_attr "type" "compare")
1679    (set_attr "length" "4,8")])
1680
1681 (define_split
1682   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1683         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1684                     (const_int 0)))
1685    (clobber (match_scratch:SI 2 ""))]
1686   "reload_completed"
1687   [(set (match_dup 2)
1688         (sign_extend:SI (match_dup 1)))
1689    (set (match_dup 0)
1690         (compare:CC (match_dup 2)
1691                     (const_int 0)))]
1692   "")
1693
1694 (define_insn ""
1695   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1696         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1697                     (const_int 0)))
1698    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1699         (sign_extend:SI (match_dup 1)))]
1700   ""
1701   "@
1702    {exts.|extsh.} %0,%1
1703    #"
1704   [(set_attr "type" "compare")
1705    (set_attr "length" "4,8")])
1706 \f
1707 (define_split
1708   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1709         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1710                     (const_int 0)))
1711    (set (match_operand:SI 0 "gpc_reg_operand" "")
1712         (sign_extend:SI (match_dup 1)))]
1713   "reload_completed"
1714   [(set (match_dup 0)
1715         (sign_extend:SI (match_dup 1)))
1716    (set (match_dup 2)
1717         (compare:CC (match_dup 0)
1718                     (const_int 0)))]
1719   "")
1720
1721 ;; Fixed-point arithmetic insns.
1722
1723 ;; Discourage ai/addic because of carry but provide it in an alternative
1724 ;; allowing register zero as source.
1725 (define_expand "addsi3"
1726   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1727         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1728                  (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1729   ""
1730   "
1731 {
1732   if (GET_CODE (operands[2]) == CONST_INT
1733                 && ! add_operand (operands[2], SImode))
1734     {
1735       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1736                  ? operands[0] : gen_reg_rtx (SImode));
1737
1738       HOST_WIDE_INT val = INTVAL (operands[2]);
1739       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1740       HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1741
1742       /* The ordering here is important for the prolog expander.
1743          When space is allocated from the stack, adding 'low' first may
1744          produce a temporary deallocation (which would be bad).  */
1745       emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
1746       emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
1747       DONE;
1748     }
1749 }")
1750
1751 (define_insn "*addsi3_internal1"
1752   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
1753         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
1754                  (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1755   ""
1756   "@
1757    {cax|add} %0,%1,%2
1758    {cal %0,%2(%1)|addi %0,%1,%2}
1759    {ai|addic} %0,%1,%2
1760    {cau|addis} %0,%1,%v2"
1761   [(set_attr "length" "4,4,4,4")])
1762
1763 (define_insn "addsi3_high"
1764   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1765         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1766                  (high:SI (match_operand 2 "" ""))))]
1767   "TARGET_MACHO && !TARGET_64BIT"
1768   "{cau|addis} %0,%1,ha16(%2)"
1769   [(set_attr "length" "4")])
1770
1771 (define_insn "*addsi3_internal2"
1772   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1773         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1774                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1775                     (const_int 0)))
1776    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1777   "! TARGET_POWERPC64"
1778   "@
1779    {cax.|add.} %3,%1,%2
1780    {ai.|addic.} %3,%1,%2
1781    #
1782    #"
1783   [(set_attr "type" "compare")
1784    (set_attr "length" "4,4,8,8")])
1785
1786 (define_split
1787   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1788         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1789                              (match_operand:SI 2 "reg_or_short_operand" ""))
1790                     (const_int 0)))
1791    (clobber (match_scratch:SI 3 ""))]
1792   "! TARGET_POWERPC64 && reload_completed"
1793   [(set (match_dup 3)
1794         (plus:SI (match_dup 1)
1795                  (match_dup 2)))
1796    (set (match_dup 0)
1797         (compare:CC (match_dup 3)
1798                     (const_int 0)))]
1799   "")
1800
1801 (define_insn "*addsi3_internal3"
1802   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1803         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1804                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1805                     (const_int 0)))
1806    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1807         (plus:SI (match_dup 1)
1808                  (match_dup 2)))]
1809   "! TARGET_POWERPC64"
1810   "@
1811    {cax.|add.} %0,%1,%2
1812    {ai.|addic.} %0,%1,%2
1813    #
1814    #"
1815   [(set_attr "type" "compare")
1816    (set_attr "length" "4,4,8,8")])
1817
1818 (define_split
1819   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1820         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1821                              (match_operand:SI 2 "reg_or_short_operand" ""))
1822                     (const_int 0)))
1823    (set (match_operand:SI 0 "gpc_reg_operand" "")
1824         (plus:SI (match_dup 1) (match_dup 2)))]
1825   "! TARGET_POWERPC64 && reload_completed"
1826   [(set (match_dup 0)
1827         (plus:SI (match_dup 1)
1828                  (match_dup 2)))
1829    (set (match_dup 3)
1830         (compare:CC (match_dup 0)
1831                     (const_int 0)))]
1832   "")
1833
1834 ;; Split an add that we can't do in one insn into two insns, each of which
1835 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
1836 ;; add should be last in case the result gets used in an address.
1837
1838 (define_split
1839   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1840         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1841                  (match_operand:SI 2 "non_add_cint_operand" "")))]
1842   ""
1843   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1844    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1845 "
1846 {
1847   HOST_WIDE_INT val = INTVAL (operands[2]);
1848   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1849   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1850
1851   operands[3] = GEN_INT (rest);
1852   operands[4] = GEN_INT (low);
1853 }")
1854
1855 (define_insn "one_cmplsi2"
1856   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1857         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1858   ""
1859   "nor %0,%1,%1")
1860
1861 (define_insn ""
1862   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1863         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1864                     (const_int 0)))
1865    (clobber (match_scratch:SI 2 "=r,r"))]
1866   "! TARGET_POWERPC64"
1867   "@
1868    nor. %2,%1,%1
1869    #"
1870   [(set_attr "type" "compare")
1871    (set_attr "length" "4,8")])
1872
1873 (define_split
1874   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1875         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1876                     (const_int 0)))
1877    (clobber (match_scratch:SI 2 ""))]
1878   "! TARGET_POWERPC64 && reload_completed"
1879   [(set (match_dup 2)
1880         (not:SI (match_dup 1)))
1881    (set (match_dup 0)
1882         (compare:CC (match_dup 2)
1883                     (const_int 0)))]
1884   "")
1885
1886 (define_insn ""
1887   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1888         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1889                     (const_int 0)))
1890    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1891         (not:SI (match_dup 1)))]
1892   "! TARGET_POWERPC64"
1893   "@
1894    nor. %0,%1,%1
1895    #"
1896   [(set_attr "type" "compare")
1897    (set_attr "length" "4,8")])
1898
1899 (define_split
1900   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1901         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1902                     (const_int 0)))
1903    (set (match_operand:SI 0 "gpc_reg_operand" "")
1904         (not:SI (match_dup 1)))]
1905   "! TARGET_POWERPC64 && reload_completed"
1906   [(set (match_dup 0)
1907         (not:SI (match_dup 1)))
1908    (set (match_dup 2)
1909         (compare:CC (match_dup 0)
1910                     (const_int 0)))]
1911   "")
1912
1913 (define_insn ""
1914   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1915         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1916                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
1917   "! TARGET_POWERPC"
1918   "{sf%I1|subf%I1c} %0,%2,%1")
1919
1920 (define_insn ""
1921   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1922         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1923                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1924   "TARGET_POWERPC"
1925   "@
1926    subf %0,%2,%1
1927    subfic %0,%2,%1")
1928
1929 (define_insn ""
1930   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1931         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1932                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1933                     (const_int 0)))
1934    (clobber (match_scratch:SI 3 "=r,r"))]
1935   "! TARGET_POWERPC"
1936   "@
1937    {sf.|subfc.} %3,%2,%1
1938    #"
1939   [(set_attr "type" "compare")
1940    (set_attr "length" "4,8")])
1941
1942 (define_insn ""
1943   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1944         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1945                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1946                     (const_int 0)))
1947    (clobber (match_scratch:SI 3 "=r,r"))]
1948   "TARGET_POWERPC && ! TARGET_POWERPC64"
1949   "@
1950    subf. %3,%2,%1
1951    #"
1952   [(set_attr "type" "compare")
1953    (set_attr "length" "4,8")])
1954
1955 (define_split
1956   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1957         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1958                               (match_operand:SI 2 "gpc_reg_operand" ""))
1959                     (const_int 0)))
1960    (clobber (match_scratch:SI 3 ""))]
1961   "! TARGET_POWERPC64 && reload_completed"
1962   [(set (match_dup 3)
1963         (minus:SI (match_dup 1)
1964                   (match_dup 2)))
1965    (set (match_dup 0)
1966         (compare:CC (match_dup 3)
1967                     (const_int 0)))]
1968   "")
1969
1970 (define_insn ""
1971   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1972         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1973                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1974                     (const_int 0)))
1975    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1976         (minus:SI (match_dup 1) (match_dup 2)))]
1977   "! TARGET_POWERPC"
1978   "@
1979    {sf.|subfc.} %0,%2,%1
1980    #"
1981   [(set_attr "type" "compare")
1982    (set_attr "length" "4,8")])
1983
1984 (define_insn ""
1985   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1986         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1987                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1988                     (const_int 0)))
1989    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1990         (minus:SI (match_dup 1)
1991                   (match_dup 2)))]
1992   "TARGET_POWERPC && ! TARGET_POWERPC64"
1993   "@
1994    subf. %0,%2,%1
1995    #"
1996   [(set_attr "type" "compare")
1997    (set_attr "length" "4,8")])
1998
1999 (define_split
2000   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2001         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
2002                               (match_operand:SI 2 "gpc_reg_operand" ""))
2003                     (const_int 0)))
2004    (set (match_operand:SI 0 "gpc_reg_operand" "")
2005         (minus:SI (match_dup 1)
2006                   (match_dup 2)))]
2007   "! TARGET_POWERPC64 && reload_completed"
2008   [(set (match_dup 0)
2009         (minus:SI (match_dup 1)
2010                   (match_dup 2)))
2011    (set (match_dup 3)
2012         (compare:CC (match_dup 0)
2013                     (const_int 0)))]
2014   "")
2015
2016 (define_expand "subsi3"
2017   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2018         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
2019                   (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
2020   ""
2021   "
2022 {
2023   if (GET_CODE (operands[2]) == CONST_INT)
2024     {
2025       emit_insn (gen_addsi3 (operands[0], operands[1],
2026                              negate_rtx (SImode, operands[2])));
2027       DONE;
2028     }
2029 }")
2030
2031 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
2032 ;; instruction and some auxiliary computations.  Then we just have a single
2033 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
2034 ;; combine.
2035
2036 (define_expand "sminsi3"
2037   [(set (match_dup 3)
2038         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2039                                 (match_operand:SI 2 "reg_or_short_operand" ""))
2040                          (const_int 0)
2041                          (minus:SI (match_dup 2) (match_dup 1))))
2042    (set (match_operand:SI 0 "gpc_reg_operand" "")
2043         (minus:SI (match_dup 2) (match_dup 3)))]
2044   "TARGET_POWER || TARGET_ISEL"
2045   "
2046 {
2047   if (TARGET_ISEL)
2048     {
2049       operands[2] = force_reg (SImode, operands[2]);
2050       rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]);
2051       DONE;
2052     }
2053
2054   operands[3] = gen_reg_rtx (SImode);
2055 }")
2056
2057 (define_split
2058   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2059         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
2060                  (match_operand:SI 2 "reg_or_short_operand" "")))
2061    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
2062   "TARGET_POWER"
2063   [(set (match_dup 3)
2064         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
2065                          (const_int 0)
2066                          (minus:SI (match_dup 2) (match_dup 1))))
2067    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
2068   "")
2069
2070 (define_expand "smaxsi3"
2071   [(set (match_dup 3)
2072         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2073                                 (match_operand:SI 2 "reg_or_short_operand" ""))
2074                          (const_int 0)
2075                          (minus:SI (match_dup 2) (match_dup 1))))
2076    (set (match_operand:SI 0 "gpc_reg_operand" "")
2077         (plus:SI (match_dup 3) (match_dup 1)))]
2078   "TARGET_POWER || TARGET_ISEL"
2079   "
2080 {
2081   if (TARGET_ISEL)
2082     {
2083       operands[2] = force_reg (SImode, operands[2]);
2084       rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]);
2085       DONE;
2086     }
2087   operands[3] = gen_reg_rtx (SImode);
2088 }")
2089
2090 (define_split
2091   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2092         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
2093                  (match_operand:SI 2 "reg_or_short_operand" "")))
2094    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
2095   "TARGET_POWER"
2096   [(set (match_dup 3)
2097         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
2098                          (const_int 0)
2099                          (minus:SI (match_dup 2) (match_dup 1))))
2100    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
2101   "")
2102
2103 (define_expand "uminsi3"
2104   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2105                               (match_dup 5)))
2106    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
2107                               (match_dup 5)))
2108    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2109                                        (const_int 0)
2110                                        (minus:SI (match_dup 4) (match_dup 3))))
2111    (set (match_operand:SI 0 "gpc_reg_operand" "")
2112         (minus:SI (match_dup 2) (match_dup 3)))]
2113   "TARGET_POWER || TARGET_ISEL"
2114   "
2115 {
2116   if (TARGET_ISEL)
2117     {
2118       rs6000_emit_minmax (operands[0], UMIN, operands[1], operands[2]);
2119       DONE;
2120     }
2121   operands[3] = gen_reg_rtx (SImode);
2122   operands[4] = gen_reg_rtx (SImode);
2123   operands[5] = GEN_INT (-2147483647 - 1);
2124 }")
2125
2126 (define_expand "umaxsi3"
2127   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2128                               (match_dup 5)))
2129    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
2130                               (match_dup 5)))
2131    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2132                                        (const_int 0)
2133                                        (minus:SI (match_dup 4) (match_dup 3))))
2134    (set (match_operand:SI 0 "gpc_reg_operand" "")
2135         (plus:SI (match_dup 3) (match_dup 1)))]
2136   "TARGET_POWER || TARGET_ISEL"
2137   "
2138 {
2139   if (TARGET_ISEL)
2140     {
2141       rs6000_emit_minmax (operands[0], UMAX, operands[1], operands[2]);
2142       DONE;
2143     }
2144   operands[3] = gen_reg_rtx (SImode);
2145   operands[4] = gen_reg_rtx (SImode);
2146   operands[5] = GEN_INT (-2147483647 - 1);
2147 }")
2148
2149 (define_insn ""
2150   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2151         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
2152                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
2153                          (const_int 0)
2154                          (minus:SI (match_dup 2) (match_dup 1))))]
2155   "TARGET_POWER"
2156   "doz%I2 %0,%1,%2")
2157
2158 (define_insn ""
2159   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2160         (compare:CC
2161          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2162                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2163                           (const_int 0)
2164                           (minus:SI (match_dup 2) (match_dup 1)))
2165          (const_int 0)))
2166    (clobber (match_scratch:SI 3 "=r,r"))]
2167   "TARGET_POWER"
2168   "@
2169    doz%I2. %3,%1,%2
2170    #"
2171   [(set_attr "type" "delayed_compare")
2172    (set_attr "length" "4,8")])
2173
2174 (define_split
2175   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2176         (compare:CC
2177          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2178                               (match_operand:SI 2 "reg_or_short_operand" ""))
2179                           (const_int 0)
2180                           (minus:SI (match_dup 2) (match_dup 1)))
2181          (const_int 0)))
2182    (clobber (match_scratch:SI 3 ""))]
2183   "TARGET_POWER && reload_completed"
2184   [(set (match_dup 3)
2185         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2186                           (const_int 0)
2187                           (minus:SI (match_dup 2) (match_dup 1))))
2188    (set (match_dup 0)
2189         (compare:CC (match_dup 3)
2190                     (const_int 0)))]
2191   "")
2192
2193 (define_insn ""
2194   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2195         (compare:CC
2196          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2197                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2198                           (const_int 0)
2199                           (minus:SI (match_dup 2) (match_dup 1)))
2200          (const_int 0)))
2201    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2202         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2203                          (const_int 0)
2204                          (minus:SI (match_dup 2) (match_dup 1))))]
2205   "TARGET_POWER"
2206   "@
2207    doz%I2. %0,%1,%2
2208    #"
2209   [(set_attr "type" "delayed_compare")
2210    (set_attr "length" "4,8")])
2211
2212 (define_split
2213   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2214         (compare:CC
2215          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2216                               (match_operand:SI 2 "reg_or_short_operand" ""))
2217                           (const_int 0)
2218                           (minus:SI (match_dup 2) (match_dup 1)))
2219          (const_int 0)))
2220    (set (match_operand:SI 0 "gpc_reg_operand" "")
2221         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2222                          (const_int 0)
2223                          (minus:SI (match_dup 2) (match_dup 1))))]
2224   "TARGET_POWER && reload_completed"
2225   [(set (match_dup 0)
2226         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2227                          (const_int 0)
2228                          (minus:SI (match_dup 2) (match_dup 1))))
2229    (set (match_dup 3)
2230         (compare:CC (match_dup 0)
2231                     (const_int 0)))]
2232   "")
2233
2234 ;; We don't need abs with condition code because such comparisons should
2235 ;; never be done.
2236 (define_expand "abssi2"
2237   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2238         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2239   ""
2240   "
2241 {
2242   if (TARGET_ISEL)
2243     {
2244       emit_insn (gen_abssi2_isel (operands[0], operands[1]));
2245       DONE;
2246     }
2247   else if (! TARGET_POWER)
2248     {
2249       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2250       DONE;
2251     }
2252 }")
2253
2254 (define_insn "*abssi2_power"
2255   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2256         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2257   "TARGET_POWER"
2258   "abs %0,%1")
2259
2260 (define_insn_and_split "abssi2_isel"
2261   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2262         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "b")))
2263    (clobber (match_scratch:SI 2 "=b"))
2264    (clobber (match_scratch:CC 3 "=y"))]
2265   "TARGET_ISEL"
2266   "#"
2267   "&& reload_completed"
2268   [(set (match_dup 2) (neg:SI (match_dup 1)))
2269    (set (match_dup 3)
2270         (compare:CC (match_dup 1)
2271                     (const_int 0)))
2272    (set (match_dup 0)
2273         (if_then_else:SI (ge (match_dup 3)
2274                              (const_int 0))
2275                          (match_dup 1)
2276                          (match_dup 2)))]
2277   "")
2278
2279 (define_insn_and_split "abssi2_nopower"
2280   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2281         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2282    (clobber (match_scratch:SI 2 "=&r,&r"))]
2283   "! TARGET_POWER && ! TARGET_ISEL"
2284   "#"
2285   "&& reload_completed"
2286   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2287    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2288    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2289   "")
2290
2291 (define_insn "*nabs_power"
2292   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2293         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2294   "TARGET_POWER"
2295   "nabs %0,%1")
2296
2297 (define_insn_and_split "*nabs_nopower"
2298   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2299         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2300    (clobber (match_scratch:SI 2 "=&r,&r"))]
2301   "! TARGET_POWER"
2302   "#"
2303   "&& reload_completed"
2304   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2305    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2306    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2307   "")
2308
2309 (define_insn "negsi2"
2310   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2311         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2312   ""
2313   "neg %0,%1")
2314
2315 (define_insn ""
2316   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2317         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2318                     (const_int 0)))
2319    (clobber (match_scratch:SI 2 "=r,r"))]
2320   "! TARGET_POWERPC64"
2321   "@
2322    neg. %2,%1
2323    #"
2324   [(set_attr "type" "compare")
2325    (set_attr "length" "4,8")])
2326
2327 (define_split
2328   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2329         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2330                     (const_int 0)))
2331    (clobber (match_scratch:SI 2 ""))]
2332   "! TARGET_POWERPC64 && reload_completed"
2333   [(set (match_dup 2)
2334         (neg:SI (match_dup 1)))
2335    (set (match_dup 0)
2336         (compare:CC (match_dup 2)
2337                     (const_int 0)))]
2338   "")
2339
2340 (define_insn ""
2341   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2342         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2343                     (const_int 0)))
2344    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2345         (neg:SI (match_dup 1)))]
2346   "! TARGET_POWERPC64"
2347   "@
2348    neg. %0,%1
2349    #"
2350   [(set_attr "type" "compare")
2351    (set_attr "length" "4,8")])
2352
2353 (define_split
2354   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2355         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2356                     (const_int 0)))
2357    (set (match_operand:SI 0 "gpc_reg_operand" "")
2358         (neg:SI (match_dup 1)))]
2359   "! TARGET_POWERPC64 && reload_completed"
2360   [(set (match_dup 0)
2361         (neg:SI (match_dup 1)))
2362    (set (match_dup 2)
2363         (compare:CC (match_dup 0)
2364                     (const_int 0)))]
2365   "")
2366
2367 (define_insn "ffssi2"
2368   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
2369         (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2370   ""
2371   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
2372   [(set_attr "length" "16")])
2373
2374 (define_expand "mulsi3"
2375   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2376    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2377    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2378   ""
2379   "
2380 {
2381   if (TARGET_POWER)
2382     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2383   else
2384     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2385   DONE;
2386 }")
2387
2388 (define_insn "mulsi3_mq"
2389   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2390         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2391                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2392    (clobber (match_scratch:SI 3 "=q,q"))]
2393   "TARGET_POWER"
2394   "@
2395    {muls|mullw} %0,%1,%2
2396    {muli|mulli} %0,%1,%2"
2397    [(set (attr "type") 
2398       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2399                 (const_string "imul3")
2400              (match_operand:SI 2 "short_cint_operand" "") 
2401                 (const_string "imul2")]
2402         (const_string "imul")))])
2403
2404 (define_insn "mulsi3_no_mq"
2405   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2406         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2407                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2408   "! TARGET_POWER"
2409   "@
2410    {muls|mullw} %0,%1,%2
2411    {muli|mulli} %0,%1,%2"
2412    [(set (attr "type") 
2413       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2414                 (const_string "imul3")
2415              (match_operand:SI 2 "short_cint_operand" "") 
2416                 (const_string "imul2")]
2417         (const_string "imul")))])
2418
2419 (define_insn ""
2420   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2421         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2422                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2423                     (const_int 0)))
2424    (clobber (match_scratch:SI 3 "=r,r"))
2425    (clobber (match_scratch:SI 4 "=q,q"))]
2426   "TARGET_POWER"
2427   "@
2428    {muls.|mullw.} %3,%1,%2
2429    #"
2430   [(set_attr "type" "delayed_compare")
2431    (set_attr "length" "4,8")])
2432
2433 (define_split
2434   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2435         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2436                              (match_operand:SI 2 "gpc_reg_operand" ""))
2437                     (const_int 0)))
2438    (clobber (match_scratch:SI 3 ""))
2439    (clobber (match_scratch:SI 4 ""))]
2440   "TARGET_POWER && reload_completed"
2441   [(parallel [(set (match_dup 3)
2442         (mult:SI (match_dup 1) (match_dup 2)))
2443    (clobber (match_dup 4))])
2444    (set (match_dup 0)
2445         (compare:CC (match_dup 3)
2446                     (const_int 0)))]
2447   "")
2448
2449 (define_insn ""
2450   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2451         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2452                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2453                     (const_int 0)))
2454    (clobber (match_scratch:SI 3 "=r,r"))]
2455   "! TARGET_POWER"
2456   "@
2457    {muls.|mullw.} %3,%1,%2
2458    #"
2459   [(set_attr "type" "delayed_compare")
2460    (set_attr "length" "4,8")])
2461
2462 (define_split
2463   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2464         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2465                              (match_operand:SI 2 "gpc_reg_operand" ""))
2466                     (const_int 0)))
2467    (clobber (match_scratch:SI 3 ""))]
2468   "! TARGET_POWER && reload_completed"
2469   [(set (match_dup 3)
2470         (mult:SI (match_dup 1) (match_dup 2)))
2471    (set (match_dup 0)
2472         (compare:CC (match_dup 3)
2473                     (const_int 0)))]
2474   "")
2475
2476 (define_insn ""
2477   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2478         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2479                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2480                     (const_int 0)))
2481    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2482         (mult:SI (match_dup 1) (match_dup 2)))
2483    (clobber (match_scratch:SI 4 "=q,q"))]
2484   "TARGET_POWER"
2485   "@
2486    {muls.|mullw.} %0,%1,%2
2487    #"
2488   [(set_attr "type" "delayed_compare")
2489    (set_attr "length" "4,8")])
2490
2491 (define_split
2492   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2493         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2494                              (match_operand:SI 2 "gpc_reg_operand" ""))
2495                     (const_int 0)))
2496    (set (match_operand:SI 0 "gpc_reg_operand" "")
2497         (mult:SI (match_dup 1) (match_dup 2)))
2498    (clobber (match_scratch:SI 4 ""))]
2499   "TARGET_POWER && reload_completed"
2500   [(parallel [(set (match_dup 0)
2501         (mult:SI (match_dup 1) (match_dup 2)))
2502    (clobber (match_dup 4))])
2503    (set (match_dup 3)
2504         (compare:CC (match_dup 0)
2505                     (const_int 0)))]
2506   "")
2507
2508 (define_insn ""
2509   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2510         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2511                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2512                     (const_int 0)))
2513    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2514         (mult:SI (match_dup 1) (match_dup 2)))]
2515   "! TARGET_POWER"
2516   "@
2517    {muls.|mullw.} %0,%1,%2
2518    #"
2519   [(set_attr "type" "delayed_compare")
2520    (set_attr "length" "4,8")])
2521
2522 (define_split
2523   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2524         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2525                              (match_operand:SI 2 "gpc_reg_operand" ""))
2526                     (const_int 0)))
2527    (set (match_operand:SI 0 "gpc_reg_operand" "")
2528         (mult:SI (match_dup 1) (match_dup 2)))]
2529   "! TARGET_POWER && reload_completed"
2530   [(set (match_dup 0)
2531         (mult:SI (match_dup 1) (match_dup 2)))
2532    (set (match_dup 3)
2533         (compare:CC (match_dup 0)
2534                     (const_int 0)))]
2535   "")
2536
2537 ;; Operand 1 is divided by operand 2; quotient goes to operand
2538 ;; 0 and remainder to operand 3.
2539 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2540
2541 (define_expand "divmodsi4"
2542   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2543                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2544                            (match_operand:SI 2 "gpc_reg_operand" "")))
2545               (set (match_operand:SI 3 "gpc_reg_operand" "")
2546                    (mod:SI (match_dup 1) (match_dup 2)))])]
2547   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2548   "
2549 {
2550   if (! TARGET_POWER && ! TARGET_POWERPC)
2551     {
2552       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2553       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2554       emit_insn (gen_divss_call ());
2555       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2556       emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2557       DONE;
2558     }
2559 }")
2560
2561 (define_insn ""
2562   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2563         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2564                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2565    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
2566         (mod:SI (match_dup 1) (match_dup 2)))]
2567   "TARGET_POWER"
2568   "divs %0,%1,%2"
2569   [(set_attr "type" "idiv")])
2570
2571 (define_expand "udivsi3"
2572   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2573         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2574                  (match_operand:SI 2 "gpc_reg_operand" "")))]
2575   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2576   "
2577 {
2578   if (! TARGET_POWER && ! TARGET_POWERPC)
2579     {
2580       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2581       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2582       emit_insn (gen_quous_call ());
2583       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2584       DONE;
2585     }
2586   else if (TARGET_POWER)
2587     {
2588       emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2589       DONE;
2590     }
2591 }")
2592
2593 (define_insn "udivsi3_mq"
2594   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2595         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2596                  (match_operand:SI 2 "gpc_reg_operand" "r")))
2597    (clobber (match_scratch:SI 3 "=q"))]
2598   "TARGET_POWERPC && TARGET_POWER"
2599   "divwu %0,%1,%2"
2600   [(set_attr "type" "idiv")])
2601
2602 (define_insn "*udivsi3_no_mq"
2603   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2604         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2605                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
2606   "TARGET_POWERPC && ! TARGET_POWER"
2607   "divwu %0,%1,%2"
2608   [(set_attr "type" "idiv")])
2609
2610 ;; For powers of two we can do srai/aze for divide and then adjust for
2611 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2612 ;; used; for PowerPC, force operands into register and do a normal divide;
2613 ;; for AIX common-mode, use quoss call on register operands.
2614 (define_expand "divsi3"
2615   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2616         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2617                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
2618   ""
2619   "
2620 {
2621   if (GET_CODE (operands[2]) == CONST_INT
2622       && INTVAL (operands[2]) > 0
2623       && exact_log2 (INTVAL (operands[2])) >= 0)
2624     ;
2625   else if (TARGET_POWERPC)
2626     {
2627       operands[2] = force_reg (SImode, operands[2]);
2628       if (TARGET_POWER)
2629         {
2630           emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2631           DONE;
2632         }
2633     }
2634   else if (TARGET_POWER)
2635     FAIL;
2636   else
2637     {
2638       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2639       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2640       emit_insn (gen_quoss_call ());
2641       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2642       DONE;
2643     }
2644 }")
2645
2646 (define_insn "divsi3_mq"
2647   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2648         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2649                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2650    (clobber (match_scratch:SI 3 "=q"))]
2651   "TARGET_POWERPC && TARGET_POWER"
2652   "divw %0,%1,%2"
2653   [(set_attr "type" "idiv")])
2654
2655 (define_insn "*divsi3_no_mq"
2656   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2657         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2658                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
2659   "TARGET_POWERPC && ! TARGET_POWER"
2660   "divw %0,%1,%2"
2661   [(set_attr "type" "idiv")])
2662
2663 (define_expand "modsi3"
2664   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2665    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2666    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2667   ""
2668   "
2669 {
2670   int i;
2671   rtx temp1;
2672   rtx temp2;
2673
2674   if (GET_CODE (operands[2]) != CONST_INT
2675       || INTVAL (operands[2]) <= 0
2676       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2677     FAIL;
2678
2679   temp1 = gen_reg_rtx (SImode);
2680   temp2 = gen_reg_rtx (SImode);
2681
2682   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
2683   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
2684   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
2685   DONE;
2686 }")
2687
2688 (define_insn ""
2689   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2690         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2691                 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
2692   ""
2693   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
2694   [(set_attr "length" "8")])
2695
2696 (define_insn ""
2697   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2698         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2699                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2700                     (const_int 0)))
2701    (clobber (match_scratch:SI 3 "=r,r"))]
2702   ""
2703   "@
2704    {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
2705    #"
2706   [(set_attr "type" "compare")
2707    (set_attr "length" "8,12")])
2708
2709 (define_split
2710   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2711         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2712                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2713                     (const_int 0)))
2714    (clobber (match_scratch:SI 3 ""))]
2715   "reload_completed"
2716   [(set (match_dup 3)
2717         (div:SI (match_dup 1) (match_dup 2)))
2718    (set (match_dup 0)
2719         (compare:CC (match_dup 3)
2720                     (const_int 0)))]
2721   "")
2722
2723 (define_insn ""
2724   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2725         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2726                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2727                     (const_int 0)))
2728    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2729         (div:SI (match_dup 1) (match_dup 2)))]
2730   ""
2731   "@
2732    {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2733    #"
2734   [(set_attr "type" "compare")
2735    (set_attr "length" "8,12")])
2736
2737 (define_split
2738   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2739         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2740                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2741                     (const_int 0)))
2742    (set (match_operand:SI 0 "gpc_reg_operand" "")
2743         (div:SI (match_dup 1) (match_dup 2)))]
2744   "reload_completed"
2745   [(set (match_dup 0)
2746         (div:SI (match_dup 1) (match_dup 2)))
2747    (set (match_dup 3)
2748         (compare:CC (match_dup 0)
2749                     (const_int 0)))]
2750   "")
2751
2752 (define_insn ""
2753   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2754         (udiv:SI
2755          (plus:DI (ashift:DI
2756                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2757                    (const_int 32))
2758                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2759          (match_operand:SI 3 "gpc_reg_operand" "r")))
2760    (set (match_operand:SI 2 "register_operand" "=*q")
2761         (umod:SI
2762          (plus:DI (ashift:DI
2763                    (zero_extend:DI (match_dup 1)) (const_int 32))
2764                   (zero_extend:DI (match_dup 4)))
2765          (match_dup 3)))]
2766   "TARGET_POWER"
2767   "div %0,%1,%3"
2768   [(set_attr "type" "idiv")])
2769
2770 ;; To do unsigned divide we handle the cases of the divisor looking like a
2771 ;; negative number.  If it is a constant that is less than 2**31, we don't
2772 ;; have to worry about the branches.  So make a few subroutines here.
2773 ;;
2774 ;; First comes the normal case.
2775 (define_expand "udivmodsi4_normal"
2776   [(set (match_dup 4) (const_int 0))
2777    (parallel [(set (match_operand:SI 0 "" "")
2778                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2779                                                 (const_int 32))
2780                                      (zero_extend:DI (match_operand:SI 1 "" "")))
2781                             (match_operand:SI 2 "" "")))
2782               (set (match_operand:SI 3 "" "")
2783                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2784                                                 (const_int 32))
2785                                      (zero_extend:DI (match_dup 1)))
2786                             (match_dup 2)))])]
2787   "TARGET_POWER"
2788   "
2789 { operands[4] = gen_reg_rtx (SImode); }")
2790
2791 ;; This handles the branches.
2792 (define_expand "udivmodsi4_tests"
2793   [(set (match_operand:SI 0 "" "") (const_int 0))
2794    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2795    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2796    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2797                            (label_ref (match_operand:SI 4 "" "")) (pc)))
2798    (set (match_dup 0) (const_int 1))
2799    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2800    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2801    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2802                            (label_ref (match_dup 4)) (pc)))]
2803   "TARGET_POWER"
2804   "
2805 { operands[5] = gen_reg_rtx (CCUNSmode);
2806   operands[6] = gen_reg_rtx (CCmode);
2807 }")
2808
2809 (define_expand "udivmodsi4"
2810   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2811                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2812                             (match_operand:SI 2 "reg_or_cint_operand" "")))
2813               (set (match_operand:SI 3 "gpc_reg_operand" "")
2814                    (umod:SI (match_dup 1) (match_dup 2)))])]
2815   ""
2816   "
2817 {
2818   rtx label = 0;
2819
2820   if (! TARGET_POWER)
2821     {
2822       if (! TARGET_POWERPC)
2823         {
2824           emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2825           emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2826           emit_insn (gen_divus_call ());
2827           emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2828           emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2829           DONE;
2830         }
2831       else
2832         FAIL;
2833     }
2834
2835   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2836     {
2837       operands[2] = force_reg (SImode, operands[2]);
2838       label = gen_label_rtx ();
2839       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2840                                   operands[3], label));
2841     }
2842   else
2843     operands[2] = force_reg (SImode, operands[2]);
2844
2845   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2846                                operands[3]));
2847   if (label)
2848     emit_label (label);
2849
2850   DONE;
2851 }")
2852
2853 ;; AIX architecture-independent common-mode multiply (DImode),
2854 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
2855 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2856 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2857 ;; assumed unused if generating common-mode, so ignore.
2858 (define_insn "mulh_call"
2859   [(set (reg:SI 3)
2860         (truncate:SI
2861          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2862                                (sign_extend:DI (reg:SI 4)))
2863                       (const_int 32))))
2864    (clobber (match_scratch:SI 0 "=l"))]
2865   "! TARGET_POWER && ! TARGET_POWERPC"
2866   "bla __mulh"
2867   [(set_attr "type" "imul")])
2868
2869 (define_insn "mull_call"
2870   [(set (reg:DI 3)
2871         (mult:DI (sign_extend:DI (reg:SI 3))
2872                  (sign_extend:DI (reg:SI 4))))
2873    (clobber (match_scratch:SI 0 "=l"))
2874    (clobber (reg:SI 0))]
2875   "! TARGET_POWER && ! TARGET_POWERPC"
2876   "bla __mull"
2877   [(set_attr "type" "imul")])
2878
2879 (define_insn "divss_call"
2880   [(set (reg:SI 3)
2881         (div:SI (reg:SI 3) (reg:SI 4)))
2882    (set (reg:SI 4)
2883         (mod:SI (reg:SI 3) (reg:SI 4)))
2884    (clobber (match_scratch:SI 0 "=l"))
2885    (clobber (reg:SI 0))]
2886   "! TARGET_POWER && ! TARGET_POWERPC"
2887   "bla __divss"
2888   [(set_attr "type" "idiv")])
2889
2890 (define_insn "divus_call"
2891   [(set (reg:SI 3)
2892         (udiv:SI (reg:SI 3) (reg:SI 4)))
2893    (set (reg:SI 4)
2894         (umod:SI (reg:SI 3) (reg:SI 4)))
2895    (clobber (match_scratch:SI 0 "=l"))
2896    (clobber (reg:SI 0))
2897    (clobber (match_scratch:CC 1 "=x"))
2898    (clobber (reg:CC 69))]
2899   "! TARGET_POWER && ! TARGET_POWERPC"
2900   "bla __divus"
2901   [(set_attr "type" "idiv")])
2902
2903 (define_insn "quoss_call"
2904   [(set (reg:SI 3)
2905         (div:SI (reg:SI 3) (reg:SI 4)))
2906    (clobber (match_scratch:SI 0 "=l"))]
2907   "! TARGET_POWER && ! TARGET_POWERPC"
2908   "bla __quoss"
2909   [(set_attr "type" "idiv")])
2910
2911 (define_insn "quous_call"
2912   [(set (reg:SI 3)
2913         (udiv:SI (reg:SI 3) (reg:SI 4)))
2914    (clobber (match_scratch:SI 0 "=l"))
2915    (clobber (reg:SI 0))
2916    (clobber (match_scratch:CC 1 "=x"))
2917    (clobber (reg:CC 69))]
2918   "! TARGET_POWER && ! TARGET_POWERPC"
2919   "bla __quous"
2920   [(set_attr "type" "idiv")])
2921 \f
2922 ;; Logical instructions
2923 ;; The logical instructions are mostly combined by using match_operator,
2924 ;; but the plain AND insns are somewhat different because there is no
2925 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2926 ;; those rotate-and-mask operations.  Thus, the AND insns come first.
2927
2928 (define_insn "andsi3"
2929   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2930         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2931                 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2932    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2933   ""
2934   "@
2935    and %0,%1,%2
2936    {rlinm|rlwinm} %0,%1,0,%m2,%M2
2937    {andil.|andi.} %0,%1,%b2
2938    {andiu.|andis.} %0,%1,%u2")
2939
2940 ;; Note to set cr's other than cr0 we do the and immediate and then
2941 ;; the test again -- this avoids a mfcr which on the higher end
2942 ;; machines causes an execution serialization
2943
2944 (define_insn "*andsi3_internal2"
2945   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2946         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2947                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2948                     (const_int 0)))
2949    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2950    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2951   "! TARGET_POWERPC64"
2952   "@
2953    and. %3,%1,%2
2954    {andil.|andi.} %3,%1,%b2
2955    {andiu.|andis.} %3,%1,%u2
2956    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2957    #
2958    #
2959    #
2960    #"
2961   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2962    (set_attr "length" "4,4,4,4,8,8,8,8")])
2963
2964 (define_insn "*andsi3_internal3"
2965   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2966         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2967                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2968                     (const_int 0)))
2969    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2970    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2971   "TARGET_POWERPC64"
2972   "@
2973    #
2974    {andil.|andi.} %3,%1,%b2
2975    {andiu.|andis.} %3,%1,%u2
2976    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2977    #
2978    #
2979    #
2980    #"
2981   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2982    (set_attr "length" "8,4,4,4,8,8,8,8")])
2983
2984 (define_split
2985   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2986         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2987                             (match_operand:SI 2 "and_operand" ""))
2988                     (const_int 0)))
2989    (clobber (match_scratch:SI 3 ""))
2990    (clobber (match_scratch:CC 4 ""))]
2991   "reload_completed"
2992   [(parallel [(set (match_dup 3)
2993                    (and:SI (match_dup 1)
2994                            (match_dup 2)))
2995               (clobber (match_dup 4))])
2996    (set (match_dup 0)
2997         (compare:CC (match_dup 3)
2998                     (const_int 0)))]
2999   "")
3000
3001 ;; We don't have a 32 bit "and. rt,ra,rb" for ppc64.  cr is set from the
3002 ;; whole 64 bit reg, and we don't know what is in the high 32 bits.
3003
3004 (define_split
3005   [(set (match_operand:CC 0 "cc_reg_operand" "")
3006         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3007                             (match_operand:SI 2 "gpc_reg_operand" ""))
3008                     (const_int 0)))
3009    (clobber (match_scratch:SI 3 ""))
3010    (clobber (match_scratch:CC 4 ""))]
3011   "TARGET_POWERPC64 && reload_completed"
3012   [(parallel [(set (match_dup 3)
3013                    (and:SI (match_dup 1)
3014                            (match_dup 2)))
3015               (clobber (match_dup 4))])
3016    (set (match_dup 0)
3017         (compare:CC (match_dup 3)
3018                     (const_int 0)))]
3019   "")
3020
3021 (define_insn "*andsi3_internal4"
3022   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3023         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3024                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3025                     (const_int 0)))
3026    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
3027         (and:SI (match_dup 1)
3028                 (match_dup 2)))
3029    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3030   "! TARGET_POWERPC64"
3031   "@
3032    and. %0,%1,%2
3033    {andil.|andi.} %0,%1,%b2
3034    {andiu.|andis.} %0,%1,%u2
3035    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
3036    #
3037    #
3038    #
3039    #"
3040   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
3041    (set_attr "length" "4,4,4,4,8,8,8,8")])
3042
3043 (define_insn "*andsi3_internal5"
3044   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
3045         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
3046                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
3047                     (const_int 0)))
3048    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
3049         (and:SI (match_dup 1)
3050                 (match_dup 2)))
3051    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
3052   "TARGET_POWERPC64"
3053   "@
3054    #
3055    {andil.|andi.} %0,%1,%b2
3056    {andiu.|andis.} %0,%1,%u2
3057    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
3058    #
3059    #
3060    #
3061    #"
3062   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
3063    (set_attr "length" "8,4,4,4,8,8,8,8")])
3064
3065 (define_split
3066   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3067         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3068                             (match_operand:SI 2 "and_operand" ""))
3069                     (const_int 0)))
3070    (set (match_operand:SI 0 "gpc_reg_operand" "")
3071         (and:SI (match_dup 1)
3072                 (match_dup 2)))
3073    (clobber (match_scratch:CC 4 ""))]
3074   "reload_completed"
3075   [(parallel [(set (match_dup 0)
3076                    (and:SI (match_dup 1)
3077                            (match_dup 2)))
3078               (clobber (match_dup 4))])
3079    (set (match_dup 3)
3080         (compare:CC (match_dup 0)
3081                     (const_int 0)))]
3082   "")
3083
3084 (define_split
3085   [(set (match_operand:CC 3 "cc_reg_operand" "")
3086         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
3087                             (match_operand:SI 2 "gpc_reg_operand" ""))
3088                     (const_int 0)))
3089    (set (match_operand:SI 0 "gpc_reg_operand" "")
3090         (and:SI (match_dup 1)
3091                 (match_dup 2)))
3092    (clobber (match_scratch:CC 4 ""))]
3093   "TARGET_POWERPC64 && reload_completed"
3094   [(parallel [(set (match_dup 0)
3095                    (and:SI (match_dup 1)
3096                            (match_dup 2)))
3097               (clobber (match_dup 4))])
3098    (set (match_dup 3)
3099         (compare:CC (match_dup 0)
3100                     (const_int 0)))]
3101   "")
3102
3103 ;; Handle the PowerPC64 rlwinm corner case
3104
3105 (define_insn_and_split "*andsi3_internal6"
3106   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3107         (and:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3108                 (match_operand:SI 2 "mask_operand_wrap" "i")))]
3109   "TARGET_POWERPC64"
3110   "#"
3111   "TARGET_POWERPC64"
3112   [(set (match_dup 0)
3113         (and:SI (rotate:SI (match_dup 1) (match_dup 3))
3114                 (match_dup 4)))
3115    (set (match_dup 0)
3116         (rotate:SI (match_dup 0) (match_dup 5)))]
3117   "
3118 {
3119   int mb = extract_MB (operands[2]);
3120   int me = extract_ME (operands[2]);
3121   operands[3] = GEN_INT (me + 1);
3122   operands[5] = GEN_INT (32 - (me + 1));
3123   operands[4] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3124 }"
3125   [(set_attr "length" "8")])
3126
3127 (define_insn_and_split "*andsi3_internal7"
3128   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
3129         (compare:CC (and:SI (match_operand:SI 0 "gpc_reg_operand" "r,r")
3130                             (match_operand:SI 1 "mask_operand_wrap" "i,i"))
3131                     (const_int 0)))
3132    (clobber (match_scratch:SI 3 "=r,r"))]
3133   "TARGET_POWERPC64"
3134   "#"
3135   "TARGET_POWERPC64"
3136   [(parallel [(set (match_dup 2)
3137                    (compare:CC (and:SI (rotate:SI (match_dup 0) (match_dup 4))
3138                                        (match_dup 5))
3139                                (const_int 0)))
3140               (clobber (match_dup 3))])]
3141   "
3142 {
3143   int mb = extract_MB (operands[1]);
3144   int me = extract_ME (operands[1]);
3145   operands[4] = GEN_INT (me + 1);
3146   operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3147 }"
3148   [(set_attr "type" "delayed_compare,compare")
3149    (set_attr "length" "4,8")])
3150
3151 (define_insn_and_split "*andsi3_internal8"
3152   [(set (match_operand:CC 3 "cc_reg_operand" "=x,??y")
3153         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3154                             (match_operand:SI 2 "mask_operand_wrap" "i,i"))
3155                     (const_int 0)))
3156    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3157         (and:SI (match_dup 1)
3158                 (match_dup 2)))]
3159   "TARGET_POWERPC64"
3160   "#"
3161   "TARGET_POWERPC64"
3162   [(parallel [(set (match_dup 3)
3163                    (compare:CC (and:SI (rotate:SI (match_dup 1) (match_dup 4))
3164                                        (match_dup 5))
3165                                (const_int 0)))
3166               (set (match_dup 0)
3167                    (and:SI (rotate:SI (match_dup 1) (match_dup 4))
3168                            (match_dup 5)))])
3169    (set (match_dup 0)
3170         (rotate:SI (match_dup 0) (match_dup 6)))]
3171   "
3172 {
3173   int mb = extract_MB (operands[2]);
3174   int me = extract_ME (operands[2]);
3175   operands[4] = GEN_INT (me + 1);
3176   operands[6] = GEN_INT (32 - (me + 1));
3177   operands[5] = GEN_INT (~((HOST_WIDE_INT) -1 << (33 + me - mb)));
3178 }"
3179   [(set_attr "type" "delayed_compare,compare")
3180    (set_attr "length" "8,12")])
3181
3182 (define_expand "iorsi3"
3183   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3184         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
3185                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3186   ""
3187   "
3188 {
3189   if (GET_CODE (operands[2]) == CONST_INT
3190       && ! logical_operand (operands[2], SImode))
3191     {
3192       HOST_WIDE_INT value = INTVAL (operands[2]);
3193       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
3194                  ? operands[0] : gen_reg_rtx (SImode));
3195
3196       emit_insn (gen_iorsi3 (tmp, operands[1],
3197                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3198       emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3199       DONE;
3200     }
3201 }")
3202
3203 (define_expand "xorsi3"
3204   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3205         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
3206                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
3207   ""
3208   "
3209 {
3210   if (GET_CODE (operands[2]) == CONST_INT
3211       && ! logical_operand (operands[2], SImode))
3212     {
3213       HOST_WIDE_INT value = INTVAL (operands[2]);
3214       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
3215                  ? operands[0] : gen_reg_rtx (SImode));
3216
3217       emit_insn (gen_xorsi3 (tmp, operands[1],
3218                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3219       emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3220       DONE;
3221     }
3222 }")
3223
3224 (define_insn "*boolsi3_internal1"
3225   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3226         (match_operator:SI 3 "boolean_or_operator"
3227          [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3228           (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3229   ""
3230   "@
3231    %q3 %0,%1,%2
3232    {%q3il|%q3i} %0,%1,%b2
3233    {%q3iu|%q3is} %0,%1,%u2")
3234
3235 (define_insn "*boolsi3_internal2"
3236   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3237         (compare:CC (match_operator:SI 4 "boolean_or_operator"
3238          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3239           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3240          (const_int 0)))
3241    (clobber (match_scratch:SI 3 "=r,r"))]
3242   "! TARGET_POWERPC64"
3243   "@
3244    %q4. %3,%1,%2
3245    #"
3246   [(set_attr "type" "compare")
3247    (set_attr "length" "4,8")])
3248
3249 (define_split
3250   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3251         (compare:CC (match_operator:SI 4 "boolean_operator"
3252          [(match_operand:SI 1 "gpc_reg_operand" "")
3253           (match_operand:SI 2 "gpc_reg_operand" "")])
3254          (const_int 0)))
3255    (clobber (match_scratch:SI 3 ""))]
3256   "! TARGET_POWERPC64 && reload_completed"
3257   [(set (match_dup 3) (match_dup 4))
3258    (set (match_dup 0)
3259         (compare:CC (match_dup 3)
3260                     (const_int 0)))]
3261   "")
3262
3263 (define_insn "*boolsi3_internal3"
3264   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3265         (compare:CC (match_operator:SI 4 "boolean_operator"
3266          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3267           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3268          (const_int 0)))
3269    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3270         (match_dup 4))]
3271   "! TARGET_POWERPC64"
3272   "@
3273    %q4. %0,%1,%2
3274    #"
3275   [(set_attr "type" "compare")
3276    (set_attr "length" "4,8")])
3277
3278 (define_split
3279   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3280         (compare:CC (match_operator:SI 4 "boolean_operator"
3281          [(match_operand:SI 1 "gpc_reg_operand" "")
3282           (match_operand:SI 2 "gpc_reg_operand" "")])
3283          (const_int 0)))
3284    (set (match_operand:SI 0 "gpc_reg_operand" "")
3285         (match_dup 4))]
3286   "! TARGET_POWERPC64 && reload_completed"
3287   [(set (match_dup 0) (match_dup 4))
3288    (set (match_dup 3)
3289         (compare:CC (match_dup 0)
3290                     (const_int 0)))]
3291   "")
3292
3293 ;; Split an logical operation that we can't do in one insn into two insns, 
3294 ;; each of which does one 16-bit part.  This is used by combine.
3295
3296 (define_split
3297   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3298         (match_operator:SI 3 "boolean_or_operator"
3299          [(match_operand:SI 1 "gpc_reg_operand" "")
3300           (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3301   ""
3302   [(set (match_dup 0) (match_dup 4))
3303    (set (match_dup 0) (match_dup 5))]
3304 "
3305 {
3306   rtx i;
3307   i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3308   operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
3309                          operands[1], i);
3310   i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3311   operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
3312                          operands[0], i);
3313 }")
3314
3315 (define_insn "*boolcsi3_internal1"
3316   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3317         (match_operator:SI 3 "boolean_operator"
3318          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3319           (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3320   ""
3321   "%q3 %0,%2,%1")
3322
3323 (define_insn "*boolcsi3_internal2"
3324   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3325         (compare:CC (match_operator:SI 4 "boolean_operator"
3326          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3327           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3328          (const_int 0)))
3329    (clobber (match_scratch:SI 3 "=r,r"))]
3330   "! TARGET_POWERPC64"
3331   "@
3332    %q4. %3,%2,%1
3333    #"
3334   [(set_attr "type" "compare")
3335    (set_attr "length" "4,8")])
3336
3337 (define_split
3338   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3339         (compare:CC (match_operator:SI 4 "boolean_operator"
3340          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3341           (match_operand:SI 2 "gpc_reg_operand" "")])
3342          (const_int 0)))
3343    (clobber (match_scratch:SI 3 ""))]
3344   "! TARGET_POWERPC64 && reload_completed"
3345   [(set (match_dup 3) (match_dup 4))
3346    (set (match_dup 0)
3347         (compare:CC (match_dup 3)
3348                     (const_int 0)))]
3349   "")
3350
3351 (define_insn "*boolcsi3_internal3"
3352   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3353         (compare:CC (match_operator:SI 4 "boolean_operator"
3354          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3355           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3356          (const_int 0)))
3357    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3358         (match_dup 4))]
3359   "! TARGET_POWERPC64"
3360   "@
3361    %q4. %0,%2,%1
3362    #"
3363   [(set_attr "type" "compare")
3364    (set_attr "length" "4,8")])
3365
3366 (define_split
3367   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3368         (compare:CC (match_operator:SI 4 "boolean_operator"
3369          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3370           (match_operand:SI 2 "gpc_reg_operand" "")])
3371          (const_int 0)))
3372    (set (match_operand:SI 0 "gpc_reg_operand" "")
3373         (match_dup 4))]
3374   "! TARGET_POWERPC64 && reload_completed"
3375   [(set (match_dup 0) (match_dup 4))
3376    (set (match_dup 3)
3377         (compare:CC (match_dup 0)
3378                     (const_int 0)))]
3379   "")
3380
3381 (define_insn "*boolccsi3_internal1"
3382   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3383         (match_operator:SI 3 "boolean_operator"
3384          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3385           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3386   ""
3387   "%q3 %0,%1,%2")
3388
3389 (define_insn "*boolccsi3_internal2"
3390   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3391         (compare:CC (match_operator:SI 4 "boolean_operator"
3392          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3393           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3394          (const_int 0)))
3395    (clobber (match_scratch:SI 3 "=r,r"))]
3396   "! TARGET_POWERPC64"
3397   "@
3398    %q4. %3,%1,%2
3399    #"
3400   [(set_attr "type" "compare")
3401    (set_attr "length" "4,8")])
3402
3403 (define_split
3404   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3405         (compare:CC (match_operator:SI 4 "boolean_operator"
3406          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3407           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3408          (const_int 0)))
3409    (clobber (match_scratch:SI 3 ""))]
3410   "! TARGET_POWERPC64 && reload_completed"
3411   [(set (match_dup 3) (match_dup 4))
3412    (set (match_dup 0)
3413         (compare:CC (match_dup 3)
3414                     (const_int 0)))]
3415   "")
3416
3417 (define_insn "*boolccsi3_internal3"
3418   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3419         (compare:CC (match_operator:SI 4 "boolean_operator"
3420          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3421           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3422          (const_int 0)))
3423    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3424         (match_dup 4))]
3425   "! TARGET_POWERPC64"
3426   "@
3427    %q4. %0,%1,%2
3428    #"
3429   [(set_attr "type" "compare")
3430    (set_attr "length" "4,8")])
3431
3432 (define_split
3433   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3434         (compare:CC (match_operator:SI 4 "boolean_operator"
3435          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3436           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3437          (const_int 0)))
3438    (set (match_operand:SI 0 "gpc_reg_operand" "")
3439         (match_dup 4))]
3440   "! TARGET_POWERPC64 && reload_completed"
3441   [(set (match_dup 0) (match_dup 4))
3442    (set (match_dup 3)
3443         (compare:CC (match_dup 0)
3444                     (const_int 0)))]
3445   "")
3446
3447 ;; maskir insn.  We need four forms because things might be in arbitrary
3448 ;; orders.  Don't define forms that only set CR fields because these
3449 ;; would modify an input register.
3450
3451 (define_insn "*maskir_internal1"
3452   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3453         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3454                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3455                 (and:SI (match_dup 2)
3456                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3457   "TARGET_POWER"
3458   "maskir %0,%3,%2")
3459
3460 (define_insn "*maskir_internal2"
3461   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3462         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3463                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3464                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3465                         (match_dup 2))))]
3466   "TARGET_POWER"
3467   "maskir %0,%3,%2")
3468
3469 (define_insn "*maskir_internal3"
3470   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3471         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3472                         (match_operand:SI 3 "gpc_reg_operand" "r"))
3473                 (and:SI (not:SI (match_dup 2))
3474                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3475   "TARGET_POWER"
3476   "maskir %0,%3,%2")
3477
3478 (define_insn "*maskir_internal4"
3479   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3480         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3481                         (match_operand:SI 2 "gpc_reg_operand" "r"))
3482                 (and:SI (not:SI (match_dup 2))
3483                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3484   "TARGET_POWER"
3485   "maskir %0,%3,%2")
3486
3487 (define_insn "*maskir_internal5"
3488   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3489         (compare:CC
3490          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3491                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3492                  (and:SI (match_dup 2)
3493                          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3494          (const_int 0)))
3495    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3496         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3497                 (and:SI (match_dup 2) (match_dup 3))))]
3498   "TARGET_POWER"
3499   "@
3500    maskir. %0,%3,%2
3501    #"
3502   [(set_attr "type" "compare")
3503    (set_attr "length" "4,8")])
3504
3505 (define_split
3506   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3507         (compare:CC
3508          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3509                          (match_operand:SI 1 "gpc_reg_operand" ""))
3510                  (and:SI (match_dup 2)
3511                          (match_operand:SI 3 "gpc_reg_operand" "")))
3512          (const_int 0)))
3513    (set (match_operand:SI 0 "gpc_reg_operand" "")
3514         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3515                 (and:SI (match_dup 2) (match_dup 3))))]
3516   "TARGET_POWER && reload_completed"
3517   [(set (match_dup 0)
3518         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3519                 (and:SI (match_dup 2) (match_dup 3))))
3520    (set (match_dup 4)
3521         (compare:CC (match_dup 0)
3522                     (const_int 0)))]
3523   "")
3524
3525 (define_insn "*maskir_internal6"
3526   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3527         (compare:CC
3528          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3529                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3530                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3531                          (match_dup 2)))
3532          (const_int 0)))
3533    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3534         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3535                 (and:SI (match_dup 3) (match_dup 2))))]
3536   "TARGET_POWER"
3537   "@
3538    maskir. %0,%3,%2
3539    #"
3540   [(set_attr "type" "compare")
3541    (set_attr "length" "4,8")])
3542
3543 (define_split
3544   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3545         (compare:CC
3546          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3547                          (match_operand:SI 1 "gpc_reg_operand" ""))
3548                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3549                          (match_dup 2)))
3550          (const_int 0)))
3551    (set (match_operand:SI 0 "gpc_reg_operand" "")
3552         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3553                 (and:SI (match_dup 3) (match_dup 2))))]
3554   "TARGET_POWER && reload_completed"
3555   [(set (match_dup 0)
3556         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3557                 (and:SI (match_dup 3) (match_dup 2))))
3558    (set (match_dup 4)
3559         (compare:CC (match_dup 0)
3560                     (const_int 0)))]
3561   "")
3562
3563 (define_insn "*maskir_internal7"
3564   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3565         (compare:CC
3566          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3567                          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3568                  (and:SI (not:SI (match_dup 2))
3569                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3570          (const_int 0)))
3571    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3572         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3573                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3574   "TARGET_POWER"
3575   "@
3576    maskir. %0,%3,%2
3577    #"
3578   [(set_attr "type" "compare")
3579    (set_attr "length" "4,8")])
3580
3581 (define_split
3582   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3583         (compare:CC
3584          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3585                          (match_operand:SI 3 "gpc_reg_operand" ""))
3586                  (and:SI (not:SI (match_dup 2))
3587                          (match_operand:SI 1 "gpc_reg_operand" "")))
3588          (const_int 0)))
3589    (set (match_operand:SI 0 "gpc_reg_operand" "")
3590         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3591                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3592   "TARGET_POWER && reload_completed"
3593   [(set (match_dup 0)
3594         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3595                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3596    (set (match_dup 4)
3597         (compare:CC (match_dup 0)
3598                     (const_int 0)))]
3599   "")
3600
3601 (define_insn "*maskir_internal8"
3602   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3603         (compare:CC
3604          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3605                          (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3606                  (and:SI (not:SI (match_dup 2))
3607                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3608          (const_int 0)))
3609    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3610         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3611                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3612   "TARGET_POWER"
3613   "@
3614    maskir. %0,%3,%2
3615    #"
3616   [(set_attr "type" "compare")
3617    (set_attr "length" "4,8")])
3618 \f
3619 (define_split
3620   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3621         (compare:CC
3622          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3623                          (match_operand:SI 2 "gpc_reg_operand" ""))
3624                  (and:SI (not:SI (match_dup 2))
3625                          (match_operand:SI 1 "gpc_reg_operand" "")))
3626          (const_int 0)))
3627    (set (match_operand:SI 0 "gpc_reg_operand" "")
3628         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3629                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3630   "TARGET_POWER && reload_completed"
3631   [(set (match_dup 0)
3632         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3633                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3634    (set (match_dup 4)
3635         (compare:CC (match_dup 0)
3636                     (const_int 0)))]
3637   "")
3638
3639 ;; Rotate and shift insns, in all their variants.  These support shifts,
3640 ;; field inserts and extracts, and various combinations thereof.
3641 (define_expand "insv"
3642   [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3643                        (match_operand:SI 1 "const_int_operand" "")
3644                        (match_operand:SI 2 "const_int_operand" ""))
3645         (match_operand 3 "gpc_reg_operand" ""))]
3646   ""
3647   "
3648 {
3649   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3650      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3651      compiler if the address of the structure is taken later.  */
3652   if (GET_CODE (operands[0]) == SUBREG
3653       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3654     FAIL;
3655
3656   if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3657     emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3658   else
3659     emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3660   DONE;
3661 }")
3662
3663 (define_insn "insvsi"
3664   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3665                          (match_operand:SI 1 "const_int_operand" "i")
3666                          (match_operand:SI 2 "const_int_operand" "i"))
3667         (match_operand:SI 3 "gpc_reg_operand" "r"))]
3668   ""
3669   "*
3670 {
3671   int start = INTVAL (operands[2]) & 31;
3672   int size = INTVAL (operands[1]) & 31;
3673
3674   operands[4] = GEN_INT (32 - start - size);
3675   operands[1] = GEN_INT (start + size - 1);
3676   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3677 }")
3678
3679 (define_insn "*insvsi_internal1"
3680   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3681                          (match_operand:SI 1 "const_int_operand" "i")
3682                          (match_operand:SI 2 "const_int_operand" "i"))
3683         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3684                    (match_operand:SI 4 "const_int_operand" "i")))]
3685   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3686   "*
3687 {
3688   int shift = INTVAL (operands[4]) & 31;
3689   int start = INTVAL (operands[2]) & 31;
3690   int size = INTVAL (operands[1]) & 31;
3691
3692   operands[4] = GEN_INT (shift - start - size);
3693   operands[1] = GEN_INT (start + size - 1);
3694   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3695 }")
3696
3697 (define_insn "*insvsi_internal2"
3698   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3699                          (match_operand:SI 1 "const_int_operand" "i")
3700                          (match_operand:SI 2 "const_int_operand" "i"))
3701         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3702                      (match_operand:SI 4 "const_int_operand" "i")))]
3703   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3704   "*
3705 {
3706   int shift = INTVAL (operands[4]) & 31;
3707   int start = INTVAL (operands[2]) & 31;
3708   int size = INTVAL (operands[1]) & 31;
3709
3710   operands[4] = GEN_INT (32 - shift - start - size);
3711   operands[1] = GEN_INT (start + size - 1);
3712   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3713 }")
3714
3715 (define_insn "*insvsi_internal3"
3716   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3717                          (match_operand:SI 1 "const_int_operand" "i")
3718                          (match_operand:SI 2 "const_int_operand" "i"))
3719         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3720                      (match_operand:SI 4 "const_int_operand" "i")))]
3721   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3722   "*
3723 {
3724   int shift = INTVAL (operands[4]) & 31;
3725   int start = INTVAL (operands[2]) & 31;
3726   int size = INTVAL (operands[1]) & 31;
3727
3728   operands[4] = GEN_INT (32 - shift - start - size);
3729   operands[1] = GEN_INT (start + size - 1);
3730   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3731 }")
3732
3733 (define_insn "*insvsi_internal4"
3734   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3735                          (match_operand:SI 1 "const_int_operand" "i")
3736                          (match_operand:SI 2 "const_int_operand" "i"))
3737         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3738                          (match_operand:SI 4 "const_int_operand" "i")
3739                          (match_operand:SI 5 "const_int_operand" "i")))]
3740   "INTVAL (operands[4]) >= INTVAL (operands[1])"
3741   "*
3742 {
3743   int extract_start = INTVAL (operands[5]) & 31;
3744   int extract_size = INTVAL (operands[4]) & 31;
3745   int insert_start = INTVAL (operands[2]) & 31;
3746   int insert_size = INTVAL (operands[1]) & 31;
3747
3748 /* Align extract field with insert field */
3749   operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3750   operands[1] = GEN_INT (insert_start + insert_size - 1);
3751   return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3752 }")
3753
3754 (define_insn "insvdi"
3755   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3756                          (match_operand:SI 1 "const_int_operand" "i")
3757                          (match_operand:SI 2 "const_int_operand" "i"))
3758         (match_operand:DI 3 "gpc_reg_operand" "r"))]
3759   "TARGET_POWERPC64"
3760   "*
3761 {
3762   int start = INTVAL (operands[2]) & 63;
3763   int size = INTVAL (operands[1]) & 63;
3764
3765   operands[1] = GEN_INT (64 - start - size);
3766   return \"rldimi %0,%3,%H1,%H2\";
3767 }")
3768
3769 (define_expand "extzv"
3770   [(set (match_operand 0 "gpc_reg_operand" "")
3771         (zero_extract (match_operand 1 "gpc_reg_operand" "")
3772                        (match_operand:SI 2 "const_int_operand" "")
3773                        (match_operand:SI 3 "const_int_operand" "")))]
3774   ""
3775   "
3776 {
3777   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3778      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3779      compiler if the address of the structure is taken later.  */
3780   if (GET_CODE (operands[0]) == SUBREG
3781       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3782     FAIL;
3783
3784   if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3785     emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3786   else
3787     emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3788   DONE;
3789 }")
3790
3791 (define_insn "extzvsi"
3792   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3793         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3794                          (match_operand:SI 2 "const_int_operand" "i")
3795                          (match_operand:SI 3 "const_int_operand" "i")))]
3796   ""
3797   "*
3798 {
3799   int start = INTVAL (operands[3]) & 31;
3800   int size = INTVAL (operands[2]) & 31;
3801
3802   if (start + size >= 32)
3803     operands[3] = const0_rtx;
3804   else
3805     operands[3] = GEN_INT (start + size);
3806   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3807 }")
3808
3809 (define_insn "*extzvsi_internal1"
3810   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3811         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3812                          (match_operand:SI 2 "const_int_operand" "i,i")
3813                          (match_operand:SI 3 "const_int_operand" "i,i"))
3814                     (const_int 0)))
3815    (clobber (match_scratch:SI 4 "=r,r"))]
3816   ""
3817   "*
3818 {
3819   int start = INTVAL (operands[3]) & 31;
3820   int size = INTVAL (operands[2]) & 31;
3821
3822   /* Force split for non-cc0 compare.  */
3823   if (which_alternative == 1)
3824      return \"#\";
3825
3826   /* If the bit-field being tested fits in the upper or lower half of a
3827      word, it is possible to use andiu. or andil. to test it.  This is
3828      useful because the condition register set-use delay is smaller for
3829      andi[ul]. than for rlinm.  This doesn't work when the starting bit
3830      position is 0 because the LT and GT bits may be set wrong.  */
3831
3832   if ((start > 0 && start + size <= 16) || start >= 16)
3833     {
3834       operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3835                               - (1 << (16 - (start & 15) - size))));
3836       if (start < 16)
3837         return \"{andiu.|andis.} %4,%1,%3\";
3838       else
3839         return \"{andil.|andi.} %4,%1,%3\";
3840     }
3841
3842   if (start + size >= 32)
3843     operands[3] = const0_rtx;
3844   else
3845     operands[3] = GEN_INT (start + size);
3846   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3847 }"
3848   [(set_attr "type" "compare")
3849    (set_attr "length" "4,8")])
3850
3851 (define_split
3852   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3853         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3854                          (match_operand:SI 2 "const_int_operand" "")
3855                          (match_operand:SI 3 "const_int_operand" ""))
3856                     (const_int 0)))
3857    (clobber (match_scratch:SI 4 ""))]
3858   "reload_completed"
3859   [(set (match_dup 4)
3860         (zero_extract:SI (match_dup 1) (match_dup 2)
3861                          (match_dup 3)))
3862    (set (match_dup 0)
3863         (compare:CC (match_dup 4)
3864                     (const_int 0)))]
3865   "")
3866
3867 (define_insn "*extzvsi_internal2"
3868   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3869         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3870                          (match_operand:SI 2 "const_int_operand" "i,i")
3871                          (match_operand:SI 3 "const_int_operand" "i,i"))
3872                     (const_int 0)))
3873    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3874         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3875   ""
3876   "*
3877 {
3878   int start = INTVAL (operands[3]) & 31;
3879   int size = INTVAL (operands[2]) & 31;
3880
3881   /* Force split for non-cc0 compare.  */
3882   if (which_alternative == 1)
3883      return \"#\";
3884
3885   /* Since we are using the output value, we can't ignore any need for
3886      a shift.  The bit-field must end at the LSB.  */
3887   if (start >= 16 && start + size == 32)
3888     {
3889       operands[3] = GEN_INT ((1 << size) - 1);
3890       return \"{andil.|andi.} %0,%1,%3\";
3891     }
3892
3893   if (start + size >= 32)
3894     operands[3] = const0_rtx;
3895   else
3896     operands[3] = GEN_INT (start + size);
3897   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3898 }"
3899   [(set_attr "type" "compare")
3900    (set_attr "length" "4,8")])
3901
3902 (define_split
3903   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3904         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3905                          (match_operand:SI 2 "const_int_operand" "")
3906                          (match_operand:SI 3 "const_int_operand" ""))
3907                     (const_int 0)))
3908    (set (match_operand:SI 0 "gpc_reg_operand" "")
3909         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3910   "reload_completed"
3911   [(set (match_dup 0)
3912         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3913    (set (match_dup 4)
3914         (compare:CC (match_dup 0)
3915                     (const_int 0)))]
3916   "")
3917
3918 (define_insn "extzvdi"
3919   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3920         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3921                          (match_operand:SI 2 "const_int_operand" "i")
3922                          (match_operand:SI 3 "const_int_operand" "i")))]
3923   "TARGET_POWERPC64"
3924   "*
3925 {
3926   int start = INTVAL (operands[3]) & 63;
3927   int size = INTVAL (operands[2]) & 63;
3928
3929   if (start + size >= 64)
3930     operands[3] = const0_rtx;
3931   else
3932     operands[3] = GEN_INT (start + size);
3933   operands[2] = GEN_INT (64 - size);
3934   return \"rldicl %0,%1,%3,%2\";
3935 }")
3936
3937 (define_insn "*extzvdi_internal1"
3938   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3939         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3940                          (match_operand:SI 2 "const_int_operand" "i")
3941                          (match_operand:SI 3 "const_int_operand" "i"))
3942                     (const_int 0)))
3943    (clobber (match_scratch:DI 4 "=r"))]
3944   "TARGET_POWERPC64"
3945   "*
3946 {
3947   int start = INTVAL (operands[3]) & 63;
3948   int size = INTVAL (operands[2]) & 63;
3949
3950   if (start + size >= 64)
3951     operands[3] = const0_rtx;
3952   else
3953     operands[3] = GEN_INT (start + size);
3954   operands[2] = GEN_INT (64 - size);
3955   return \"rldicl. %4,%1,%3,%2\";
3956 }")
3957
3958 (define_insn "*extzvdi_internal2"
3959   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3960         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3961                          (match_operand:SI 2 "const_int_operand" "i")
3962                          (match_operand:SI 3 "const_int_operand" "i"))
3963                     (const_int 0)))
3964    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3965         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3966   "TARGET_POWERPC64"
3967   "*
3968 {
3969   int start = INTVAL (operands[3]) & 63;
3970   int size = INTVAL (operands[2]) & 63;
3971
3972   if (start + size >= 64)
3973     operands[3] = const0_rtx;
3974   else
3975     operands[3] = GEN_INT (start + size);
3976   operands[2] = GEN_INT (64 - size);
3977   return \"rldicl. %0,%1,%3,%2\";
3978 }")
3979
3980 (define_insn "rotlsi3"
3981   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3982         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3983                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3984   ""
3985   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3986
3987 (define_insn "*rotlsi3_internal2"
3988   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3989         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3990                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3991                     (const_int 0)))
3992    (clobber (match_scratch:SI 3 "=r,r"))]
3993   ""
3994   "@
3995    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3996    #"
3997   [(set_attr "type" "delayed_compare")
3998    (set_attr "length" "4,8")])
3999
4000 (define_split
4001   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4002         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4003                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4004                     (const_int 0)))
4005    (clobber (match_scratch:SI 3 ""))]
4006   "reload_completed"
4007   [(set (match_dup 3)
4008         (rotate:SI (match_dup 1) (match_dup 2)))
4009    (set (match_dup 0)
4010         (compare:CC (match_dup 3)
4011                     (const_int 0)))]
4012   "")
4013
4014 (define_insn "*rotlsi3_internal3"
4015   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4016         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4017                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4018                     (const_int 0)))
4019    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4020         (rotate:SI (match_dup 1) (match_dup 2)))]
4021   ""
4022   "@
4023    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
4024    #"
4025   [(set_attr "type" "delayed_compare")
4026    (set_attr "length" "4,8")])
4027
4028 (define_split
4029   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4030         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4031                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4032                     (const_int 0)))
4033    (set (match_operand:SI 0 "gpc_reg_operand" "")
4034         (rotate:SI (match_dup 1) (match_dup 2)))]
4035   "reload_completed"
4036   [(set (match_dup 0)
4037         (rotate:SI (match_dup 1) (match_dup 2)))
4038    (set (match_dup 3)
4039         (compare:CC (match_dup 0)
4040                     (const_int 0)))]
4041   "")
4042
4043 (define_insn "*rotlsi3_internal4"
4044   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4045         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4046                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
4047                 (match_operand:SI 3 "mask_operand" "n")))]
4048   ""
4049   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
4050
4051 (define_insn "*rotlsi3_internal5"
4052   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4053         (compare:CC (and:SI
4054                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4055                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4056                      (match_operand:SI 3 "mask_operand" "n,n"))
4057                     (const_int 0)))
4058    (clobber (match_scratch:SI 4 "=r,r"))]
4059   ""
4060   "@
4061    {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
4062    #"
4063   [(set_attr "type" "delayed_compare")
4064    (set_attr "length" "4,8")])
4065
4066 (define_split
4067   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4068         (compare:CC (and:SI
4069                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4070                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
4071                      (match_operand:SI 3 "mask_operand" ""))
4072                     (const_int 0)))
4073    (clobber (match_scratch:SI 4 ""))]
4074   "reload_completed"
4075   [(set (match_dup 4)
4076         (and:SI (rotate:SI (match_dup 1)
4077                                 (match_dup 2))
4078                      (match_dup 3)))
4079    (set (match_dup 0)
4080         (compare:CC (match_dup 4)
4081                     (const_int 0)))]
4082   "")
4083
4084 (define_insn "*rotlsi3_internal6"
4085   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4086         (compare:CC (and:SI
4087                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4088                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4089                      (match_operand:SI 3 "mask_operand" "n,n"))
4090                     (const_int 0)))
4091    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4092         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4093   ""
4094   "@
4095    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
4096    #"
4097   [(set_attr "type" "delayed_compare")
4098    (set_attr "length" "4,8")])
4099
4100 (define_split
4101   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4102         (compare:CC (and:SI
4103                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4104                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
4105                      (match_operand:SI 3 "mask_operand" ""))
4106                     (const_int 0)))
4107    (set (match_operand:SI 0 "gpc_reg_operand" "")
4108         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4109   "reload_completed"
4110   [(set (match_dup 0)
4111         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4112    (set (match_dup 4)
4113         (compare:CC (match_dup 0)
4114                     (const_int 0)))]
4115   "")
4116
4117 (define_insn "*rotlsi3_internal7"
4118   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4119         (zero_extend:SI
4120          (subreg:QI
4121           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4122                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
4123   ""
4124   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
4125
4126 (define_insn "*rotlsi3_internal8"
4127   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4128         (compare:CC (zero_extend:SI
4129                      (subreg:QI
4130                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4131                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
4132                     (const_int 0)))
4133    (clobber (match_scratch:SI 3 "=r,r"))]
4134   ""
4135   "@
4136    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
4137    #"
4138   [(set_attr "type" "delayed_compare")
4139    (set_attr "length" "4,8")])
4140
4141 (define_split
4142   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4143         (compare:CC (zero_extend:SI
4144                      (subreg:QI
4145                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4146                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4147                     (const_int 0)))
4148    (clobber (match_scratch:SI 3 ""))]
4149   "reload_completed"
4150   [(set (match_dup 3)
4151         (zero_extend:SI (subreg:QI
4152                       (rotate:SI (match_dup 1)
4153                                  (match_dup 2)) 0)))
4154    (set (match_dup 0)
4155         (compare:CC (match_dup 3)
4156                     (const_int 0)))]
4157   "")
4158
4159 (define_insn "*rotlsi3_internal9"
4160   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4161         (compare:CC (zero_extend:SI
4162                      (subreg:QI
4163                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4164                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
4165                     (const_int 0)))
4166    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4167         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4168   ""
4169   "@
4170    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
4171    #"
4172   [(set_attr "type" "delayed_compare")
4173    (set_attr "length" "4,8")])
4174
4175 (define_split
4176   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4177         (compare:CC (zero_extend:SI
4178                      (subreg:QI
4179                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4180                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4181                     (const_int 0)))
4182    (set (match_operand:SI 0 "gpc_reg_operand" "")
4183         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4184   "reload_completed"
4185   [(set (match_dup 0)
4186         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4187    (set (match_dup 3)
4188         (compare:CC (match_dup 0)
4189                     (const_int 0)))]
4190   "")
4191
4192 (define_insn "*rotlsi3_internal10"
4193   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4194         (zero_extend:SI
4195          (subreg:HI
4196           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4197                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
4198   ""
4199   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
4200
4201 (define_insn "*rotlsi3_internal11"
4202   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4203         (compare:CC (zero_extend:SI
4204                      (subreg:HI
4205                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4206                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
4207                     (const_int 0)))
4208    (clobber (match_scratch:SI 3 "=r,r"))]
4209   ""
4210   "@
4211    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
4212    #"
4213   [(set_attr "type" "delayed_compare")
4214    (set_attr "length" "4,8")])
4215
4216 (define_split
4217   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4218         (compare:CC (zero_extend:SI
4219                      (subreg:HI
4220                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4221                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4222                     (const_int 0)))
4223    (clobber (match_scratch:SI 3 ""))]
4224   "reload_completed"
4225   [(set (match_dup 3)
4226         (zero_extend:SI (subreg:HI
4227                       (rotate:SI (match_dup 1)
4228                                  (match_dup 2)) 0)))
4229    (set (match_dup 0)
4230         (compare:CC (match_dup 3)
4231                     (const_int 0)))]
4232   "")
4233
4234 (define_insn "*rotlsi3_internal12"
4235   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4236         (compare:CC (zero_extend:SI
4237                      (subreg:HI
4238                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4239                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
4240                     (const_int 0)))
4241    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4242         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4243   ""
4244   "@
4245    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
4246    #"
4247   [(set_attr "type" "delayed_compare")
4248    (set_attr "length" "4,8")])
4249
4250 (define_split
4251   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4252         (compare:CC (zero_extend:SI
4253                      (subreg:HI
4254                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4255                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4256                     (const_int 0)))
4257    (set (match_operand:SI 0 "gpc_reg_operand" "")
4258         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4259   "reload_completed"
4260   [(set (match_dup 0)
4261         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4262    (set (match_dup 3)
4263         (compare:CC (match_dup 0)
4264                     (const_int 0)))]
4265   "")
4266
4267 ;; Note that we use "sle." instead of "sl." so that we can set
4268 ;; SHIFT_COUNT_TRUNCATED.
4269
4270 (define_expand "ashlsi3"
4271   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4272    (use (match_operand:SI 1 "gpc_reg_operand" ""))
4273    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4274   ""
4275   "
4276 {
4277   if (TARGET_POWER)
4278     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
4279   else
4280     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
4281   DONE;
4282 }")
4283
4284 (define_insn "ashlsi3_power"
4285   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4286         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4287                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4288    (clobber (match_scratch:SI 3 "=q,X"))]
4289   "TARGET_POWER"
4290   "@
4291    sle %0,%1,%2
4292    {sli|slwi} %0,%1,%h2")
4293
4294 (define_insn "ashlsi3_no_power"
4295   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4296         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4297                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4298   "! TARGET_POWER"
4299   "{sl|slw}%I2 %0,%1,%h2")
4300
4301 (define_insn ""
4302   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4303         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4304                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4305                     (const_int 0)))
4306    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4307    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4308   "TARGET_POWER"
4309   "@
4310    sle. %3,%1,%2
4311    {sli.|slwi.} %3,%1,%h2
4312    #
4313    #"
4314   [(set_attr "type" "delayed_compare")
4315    (set_attr "length" "4,4,8,8")])
4316
4317 (define_split
4318   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4319         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4320                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4321                     (const_int 0)))
4322    (clobber (match_scratch:SI 3 ""))
4323    (clobber (match_scratch:SI 4 ""))]
4324   "TARGET_POWER && reload_completed"
4325   [(parallel [(set (match_dup 3)
4326         (ashift:SI (match_dup 1) (match_dup 2)))
4327    (clobber (match_dup 4))])
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 0 "cc_reg_operand" "=x,?y")
4335         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4336                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4337                     (const_int 0)))
4338    (clobber (match_scratch:SI 3 "=r,r"))]
4339   "! TARGET_POWER && ! TARGET_POWERPC64"
4340   "@
4341    {sl|slw}%I2. %3,%1,%h2
4342    #"
4343   [(set_attr "type" "delayed_compare")
4344    (set_attr "length" "4,8")])
4345
4346 (define_split
4347   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4348         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4349                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4350                     (const_int 0)))
4351    (clobber (match_scratch:SI 3 ""))]
4352   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4353   [(set (match_dup 3)
4354         (ashift:SI (match_dup 1) (match_dup 2)))
4355    (set (match_dup 0)
4356         (compare:CC (match_dup 3)
4357                     (const_int 0)))]
4358   "")
4359
4360 (define_insn ""
4361   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4362         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4363                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4364                     (const_int 0)))
4365    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4366         (ashift:SI (match_dup 1) (match_dup 2)))
4367    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4368   "TARGET_POWER"
4369   "@
4370    sle. %0,%1,%2
4371    {sli.|slwi.} %0,%1,%h2
4372    #
4373    #"
4374   [(set_attr "type" "delayed_compare")
4375    (set_attr "length" "4,4,8,8")])
4376
4377 (define_split
4378   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4379         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4380                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4381                     (const_int 0)))
4382    (set (match_operand:SI 0 "gpc_reg_operand" "")
4383         (ashift:SI (match_dup 1) (match_dup 2)))
4384    (clobber (match_scratch:SI 4 ""))]
4385   "TARGET_POWER && reload_completed"
4386   [(parallel [(set (match_dup 0)
4387         (ashift:SI (match_dup 1) (match_dup 2)))
4388    (clobber (match_dup 4))])
4389    (set (match_dup 3)
4390         (compare:CC (match_dup 0)
4391                     (const_int 0)))]
4392   "")
4393
4394 (define_insn ""
4395   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4396         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4397                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4398                     (const_int 0)))
4399    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4400         (ashift:SI (match_dup 1) (match_dup 2)))]
4401   "! TARGET_POWER && ! TARGET_POWERPC64"
4402   "@
4403    {sl|slw}%I2. %0,%1,%h2
4404    #"
4405   [(set_attr "type" "delayed_compare")
4406    (set_attr "length" "4,8")])
4407
4408 (define_split
4409   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4410         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4411                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4412                     (const_int 0)))
4413    (set (match_operand:SI 0 "gpc_reg_operand" "")
4414         (ashift:SI (match_dup 1) (match_dup 2)))]
4415   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4416   [(set (match_dup 0)
4417         (ashift:SI (match_dup 1) (match_dup 2)))
4418    (set (match_dup 3)
4419         (compare:CC (match_dup 0)
4420                     (const_int 0)))]
4421   "")
4422
4423 (define_insn ""
4424   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4425         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4426                            (match_operand:SI 2 "const_int_operand" "i"))
4427                 (match_operand:SI 3 "mask_operand" "n")))]
4428   "includes_lshift_p (operands[2], operands[3])"
4429   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
4430
4431 (define_insn ""
4432   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4433         (compare:CC
4434          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4435                             (match_operand:SI 2 "const_int_operand" "i,i"))
4436                  (match_operand:SI 3 "mask_operand" "n,n"))
4437          (const_int 0)))
4438    (clobber (match_scratch:SI 4 "=r,r"))]
4439   "includes_lshift_p (operands[2], operands[3])"
4440   "@
4441    {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
4442    #"
4443   [(set_attr "type" "delayed_compare")
4444    (set_attr "length" "4,8")])
4445
4446 (define_split
4447   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4448         (compare:CC
4449          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4450                             (match_operand:SI 2 "const_int_operand" ""))
4451                  (match_operand:SI 3 "mask_operand" ""))
4452          (const_int 0)))
4453    (clobber (match_scratch:SI 4 ""))]
4454   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4455   [(set (match_dup 4)
4456         (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4457                  (match_dup 3)))
4458    (set (match_dup 0)
4459         (compare:CC (match_dup 4)
4460                     (const_int 0)))]
4461   "")
4462
4463 (define_insn ""
4464   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4465         (compare:CC
4466          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4467                             (match_operand:SI 2 "const_int_operand" "i,i"))
4468                  (match_operand:SI 3 "mask_operand" "n,n"))
4469          (const_int 0)))
4470    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4471         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4472   "includes_lshift_p (operands[2], operands[3])"
4473   "@
4474    {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4475    #"
4476   [(set_attr "type" "delayed_compare")
4477    (set_attr "length" "4,8")])
4478
4479 (define_split
4480   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4481         (compare:CC
4482          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4483                             (match_operand:SI 2 "const_int_operand" ""))
4484                  (match_operand:SI 3 "mask_operand" ""))
4485          (const_int 0)))
4486    (set (match_operand:SI 0 "gpc_reg_operand" "")
4487         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4488   "includes_lshift_p (operands[2], operands[3]) && reload_completed"
4489   [(set (match_dup 0)
4490         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4491    (set (match_dup 4)
4492         (compare:CC (match_dup 0)
4493                     (const_int 0)))]
4494   "")
4495
4496 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
4497 ;; "sli x,x,0".
4498 (define_expand "lshrsi3"
4499   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4500    (use (match_operand:SI 1 "gpc_reg_operand" ""))
4501    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4502   ""
4503   "
4504 {
4505   if (TARGET_POWER)
4506     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
4507   else
4508     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
4509   DONE;
4510 }")
4511
4512 (define_insn "lshrsi3_power"
4513   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4514         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4515                      (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
4516    (clobber (match_scratch:SI 3 "=q,X,X"))]
4517   "TARGET_POWER"
4518   "@
4519   sre %0,%1,%2
4520   mr %0,%1
4521   {s%A2i|s%A2wi} %0,%1,%h2")
4522
4523 (define_insn "lshrsi3_no_power"
4524   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4525         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4526                      (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
4527   "! TARGET_POWER"
4528   "@
4529   mr %0,%1
4530   {sr|srw}%I2 %0,%1,%h2")
4531
4532 (define_insn ""
4533   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4534         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4535                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4536                     (const_int 0)))
4537    (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
4538    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4539   "TARGET_POWER"
4540   "@
4541   sre. %3,%1,%2
4542   mr. %1,%1
4543   {s%A2i.|s%A2wi.} %3,%1,%h2
4544   #
4545   #
4546   #"
4547   [(set_attr "type" "delayed_compare")
4548    (set_attr "length" "4,4,4,8,8,8")])
4549
4550 (define_split
4551   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4552         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4553                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4554                     (const_int 0)))
4555    (clobber (match_scratch:SI 3 ""))
4556    (clobber (match_scratch:SI 4 ""))]
4557   "TARGET_POWER && reload_completed"
4558   [(parallel [(set (match_dup 3)
4559         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4560    (clobber (match_dup 4))])
4561    (set (match_dup 0)
4562         (compare:CC (match_dup 3)
4563                     (const_int 0)))]
4564   "")
4565
4566 (define_insn ""
4567   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4568         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4569                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4570                     (const_int 0)))
4571    (clobber (match_scratch:SI 3 "=X,r,X,r"))]
4572   "! TARGET_POWER && ! TARGET_POWERPC64"
4573   "@
4574    mr. %1,%1
4575    {sr|srw}%I2. %3,%1,%h2
4576    #
4577    #"
4578   [(set_attr "type" "delayed_compare")
4579    (set_attr "length" "4,4,8,8")])
4580
4581 (define_split
4582   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4583         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4584                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4585                     (const_int 0)))
4586    (clobber (match_scratch:SI 3 ""))]
4587   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4588   [(set (match_dup 3)
4589         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4590    (set (match_dup 0)
4591         (compare:CC (match_dup 3)
4592                     (const_int 0)))]
4593   "")
4594
4595 (define_insn ""
4596   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4597         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4598                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4599                     (const_int 0)))
4600    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
4601         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4602    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4603   "TARGET_POWER"
4604   "@
4605   sre. %0,%1,%2
4606   mr. %0,%1
4607   {s%A2i.|s%A2wi.} %0,%1,%h2
4608   #
4609   #
4610   #"
4611   [(set_attr "type" "delayed_compare")
4612    (set_attr "length" "4,4,4,8,8,8")])
4613
4614 (define_split
4615   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4616         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4617                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4618                     (const_int 0)))
4619    (set (match_operand:SI 0 "gpc_reg_operand" "")
4620         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4621    (clobber (match_scratch:SI 4 ""))]
4622   "TARGET_POWER && reload_completed"
4623   [(parallel [(set (match_dup 0)
4624         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4625    (clobber (match_dup 4))])
4626    (set (match_dup 3)
4627         (compare:CC (match_dup 0)
4628                     (const_int 0)))]
4629   "")
4630
4631 (define_insn ""
4632   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4633         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4634                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4635                     (const_int 0)))
4636    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4637         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4638   "! TARGET_POWER && ! TARGET_POWERPC64"
4639   "@
4640    mr. %0,%1
4641    {sr|srw}%I2. %0,%1,%h2
4642    #
4643    #"
4644   [(set_attr "type" "delayed_compare")
4645    (set_attr "length" "4,4,8,8")])
4646
4647 (define_split
4648   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4649         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4650                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4651                     (const_int 0)))
4652    (set (match_operand:SI 0 "gpc_reg_operand" "")
4653         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4654   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4655   [(set (match_dup 0)
4656         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4657    (set (match_dup 3)
4658         (compare:CC (match_dup 0)
4659                     (const_int 0)))]
4660   "")
4661
4662 (define_insn ""
4663   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4664         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4665                              (match_operand:SI 2 "const_int_operand" "i"))
4666                 (match_operand:SI 3 "mask_operand" "n")))]
4667   "includes_rshift_p (operands[2], operands[3])"
4668   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
4669
4670 (define_insn ""
4671   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4672         (compare:CC
4673          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4674                               (match_operand:SI 2 "const_int_operand" "i,i"))
4675                  (match_operand:SI 3 "mask_operand" "n,n"))
4676          (const_int 0)))
4677    (clobber (match_scratch:SI 4 "=r,r"))]
4678   "includes_rshift_p (operands[2], operands[3])"
4679   "@
4680    {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4681    #"
4682   [(set_attr "type" "delayed_compare")
4683    (set_attr "length" "4,8")])
4684
4685 (define_split
4686   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4687         (compare:CC
4688          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4689                               (match_operand:SI 2 "const_int_operand" ""))
4690                  (match_operand:SI 3 "mask_operand" ""))
4691          (const_int 0)))
4692    (clobber (match_scratch:SI 4 ""))]
4693   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4694   [(set (match_dup 4)
4695         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4696                  (match_dup 3)))
4697    (set (match_dup 0)
4698         (compare:CC (match_dup 4)
4699                     (const_int 0)))]
4700   "")
4701
4702 (define_insn ""
4703   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4704         (compare:CC
4705          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4706                               (match_operand:SI 2 "const_int_operand" "i,i"))
4707                  (match_operand:SI 3 "mask_operand" "n,n"))
4708          (const_int 0)))
4709    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4710         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4711   "includes_rshift_p (operands[2], operands[3])"
4712   "@
4713    {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4714    #"
4715   [(set_attr "type" "delayed_compare")
4716    (set_attr "length" "4,8")])
4717
4718 (define_split
4719   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4720         (compare:CC
4721          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4722                               (match_operand:SI 2 "const_int_operand" ""))
4723                  (match_operand:SI 3 "mask_operand" ""))
4724          (const_int 0)))
4725    (set (match_operand:SI 0 "gpc_reg_operand" "")
4726         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4727   "includes_rshift_p (operands[2], operands[3]) && reload_completed"
4728   [(set (match_dup 0)
4729         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4730    (set (match_dup 4)
4731         (compare:CC (match_dup 0)
4732                     (const_int 0)))]
4733   "")
4734
4735 (define_insn ""
4736   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4737         (zero_extend:SI
4738          (subreg:QI
4739           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4740                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4741   "includes_rshift_p (operands[2], GEN_INT (255))"
4742   "{rlinm|rlwinm} %0,%1,%s2,0xff")
4743
4744 (define_insn ""
4745   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4746         (compare:CC
4747          (zero_extend:SI
4748           (subreg:QI
4749            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4750                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4751          (const_int 0)))
4752    (clobber (match_scratch:SI 3 "=r,r"))]
4753   "includes_rshift_p (operands[2], GEN_INT (255))"
4754   "@
4755    {rlinm.|rlwinm.} %3,%1,%s2,0xff
4756    #"
4757   [(set_attr "type" "delayed_compare")
4758    (set_attr "length" "4,8")])
4759
4760 (define_split
4761   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4762         (compare:CC
4763          (zero_extend:SI
4764           (subreg:QI
4765            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4766                         (match_operand:SI 2 "const_int_operand" "")) 0))
4767          (const_int 0)))
4768    (clobber (match_scratch:SI 3 ""))]
4769   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4770   [(set (match_dup 3)
4771         (zero_extend:SI (subreg:QI
4772            (lshiftrt:SI (match_dup 1)
4773                         (match_dup 2)) 0)))
4774    (set (match_dup 0)
4775         (compare:CC (match_dup 3)
4776                     (const_int 0)))]
4777   "")
4778
4779 (define_insn ""
4780   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4781         (compare:CC
4782          (zero_extend:SI
4783           (subreg:QI
4784            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4785                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4786          (const_int 0)))
4787    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4788         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4789   "includes_rshift_p (operands[2], GEN_INT (255))"
4790   "@
4791    {rlinm.|rlwinm.} %0,%1,%s2,0xff
4792    #"
4793   [(set_attr "type" "delayed_compare")
4794    (set_attr "length" "4,8")])
4795
4796 (define_split
4797   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4798         (compare:CC
4799          (zero_extend:SI
4800           (subreg:QI
4801            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4802                         (match_operand:SI 2 "const_int_operand" "")) 0))
4803          (const_int 0)))
4804    (set (match_operand:SI 0 "gpc_reg_operand" "")
4805         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4806   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4807   [(set (match_dup 0)
4808         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4809    (set (match_dup 3)
4810         (compare:CC (match_dup 0)
4811                     (const_int 0)))]
4812   "")
4813
4814 (define_insn ""
4815   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4816         (zero_extend:SI
4817          (subreg:HI
4818           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4819                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4820   "includes_rshift_p (operands[2], GEN_INT (65535))"
4821   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4822
4823 (define_insn ""
4824   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4825         (compare:CC
4826          (zero_extend:SI
4827           (subreg:HI
4828            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4829                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4830          (const_int 0)))
4831    (clobber (match_scratch:SI 3 "=r,r"))]
4832   "includes_rshift_p (operands[2], GEN_INT (65535))"
4833   "@
4834    {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4835    #"
4836   [(set_attr "type" "delayed_compare")
4837    (set_attr "length" "4,8")])
4838
4839 (define_split
4840   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4841         (compare:CC
4842          (zero_extend:SI
4843           (subreg:HI
4844            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4845                         (match_operand:SI 2 "const_int_operand" "")) 0))
4846          (const_int 0)))
4847    (clobber (match_scratch:SI 3 ""))]
4848   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4849   [(set (match_dup 3)
4850         (zero_extend:SI (subreg:HI
4851            (lshiftrt:SI (match_dup 1)
4852                         (match_dup 2)) 0)))
4853    (set (match_dup 0)
4854         (compare:CC (match_dup 3)
4855                     (const_int 0)))]
4856   "")
4857
4858 (define_insn ""
4859   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4860         (compare:CC
4861          (zero_extend:SI
4862           (subreg:HI
4863            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4864                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4865          (const_int 0)))
4866    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4867         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4868   "includes_rshift_p (operands[2], GEN_INT (65535))"
4869   "@
4870    {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4871    #"
4872   [(set_attr "type" "delayed_compare")
4873    (set_attr "length" "4,8")])
4874
4875 (define_split
4876   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4877         (compare:CC
4878          (zero_extend:SI
4879           (subreg:HI
4880            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4881                         (match_operand:SI 2 "const_int_operand" "")) 0))
4882          (const_int 0)))
4883    (set (match_operand:SI 0 "gpc_reg_operand" "")
4884         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4885   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4886   [(set (match_dup 0)
4887         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4888    (set (match_dup 3)
4889         (compare:CC (match_dup 0)
4890                     (const_int 0)))]
4891   "")
4892
4893 (define_insn ""
4894   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4895                          (const_int 1)
4896                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4897         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4898                      (const_int 31)))]
4899   "TARGET_POWER"
4900   "rrib %0,%1,%2")
4901
4902 (define_insn ""
4903   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4904                          (const_int 1)
4905                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4906         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4907                      (const_int 31)))]
4908   "TARGET_POWER"
4909   "rrib %0,%1,%2")
4910
4911 (define_insn ""
4912   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4913                          (const_int 1)
4914                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4915         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4916                          (const_int 1)
4917                          (const_int 0)))]
4918   "TARGET_POWER"
4919   "rrib %0,%1,%2")
4920
4921 (define_expand "ashrsi3"
4922   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4923         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4924                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4925   ""
4926   "
4927 {
4928   if (TARGET_POWER)
4929     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4930   else
4931     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4932   DONE;
4933 }")
4934
4935 (define_insn "ashrsi3_power"
4936   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4937         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4938                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4939    (clobber (match_scratch:SI 3 "=q,X"))]
4940   "TARGET_POWER"
4941   "@
4942    srea %0,%1,%2
4943    {srai|srawi} %0,%1,%h2")
4944
4945 (define_insn "ashrsi3_no_power"
4946   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4947         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4948                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4949   "! TARGET_POWER"
4950   "{sra|sraw}%I2 %0,%1,%h2")
4951
4952 (define_insn ""
4953   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4954         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4955                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4956                     (const_int 0)))
4957    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4958    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4959   "TARGET_POWER"
4960   "@
4961    srea. %3,%1,%2
4962    {srai.|srawi.} %3,%1,%h2
4963    #
4964    #"
4965   [(set_attr "type" "delayed_compare")
4966    (set_attr "length" "4,4,8,8")])
4967
4968 (define_split
4969   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4970         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4971                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4972                     (const_int 0)))
4973    (clobber (match_scratch:SI 3 ""))
4974    (clobber (match_scratch:SI 4 ""))]
4975   "TARGET_POWER && reload_completed"
4976   [(parallel [(set (match_dup 3)
4977         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4978    (clobber (match_dup 4))])
4979    (set (match_dup 0)
4980         (compare:CC (match_dup 3)
4981                     (const_int 0)))]
4982   "")
4983
4984 (define_insn ""
4985   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4986         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4987                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4988                     (const_int 0)))
4989    (clobber (match_scratch:SI 3 "=r,r"))]
4990   "! TARGET_POWER"
4991   "@
4992    {sra|sraw}%I2. %3,%1,%h2
4993    #"
4994   [(set_attr "type" "delayed_compare")
4995    (set_attr "length" "4,8")])
4996
4997 (define_split
4998   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4999         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
5000                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
5001                     (const_int 0)))
5002    (clobber (match_scratch:SI 3 ""))]
5003   "! TARGET_POWER && reload_completed"
5004   [(set (match_dup 3)
5005         (ashiftrt:SI (match_dup 1) (match_dup 2)))
5006    (set (match_dup 0)
5007         (compare:CC (match_dup 3)
5008                     (const_int 0)))]
5009   "")
5010
5011 (define_insn ""
5012   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5013         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
5014                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
5015                     (const_int 0)))
5016    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
5017         (ashiftrt:SI (match_dup 1) (match_dup 2)))
5018    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
5019   "TARGET_POWER"
5020   "@
5021    srea. %0,%1,%2
5022    {srai.|srawi.} %0,%1,%h2
5023    #
5024    #"
5025   [(set_attr "type" "delayed_compare")
5026    (set_attr "length" "4,4,8,8")])
5027
5028 (define_split
5029   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5030         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
5031                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
5032                     (const_int 0)))
5033    (set (match_operand:SI 0 "gpc_reg_operand" "")
5034         (ashiftrt:SI (match_dup 1) (match_dup 2)))
5035    (clobber (match_scratch:SI 4 ""))]
5036   "TARGET_POWER && reload_completed"
5037   [(parallel [(set (match_dup 0)
5038         (ashiftrt:SI (match_dup 1) (match_dup 2)))
5039    (clobber (match_dup 4))])
5040    (set (match_dup 3)
5041         (compare:CC (match_dup 0)
5042                     (const_int 0)))]
5043   "")
5044
5045 (define_insn ""
5046   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
5047         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
5048                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
5049                     (const_int 0)))
5050    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
5051         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
5052   "! TARGET_POWER"
5053   "@
5054    {sra|sraw}%I2. %0,%1,%h2
5055    #"
5056   [(set_attr "type" "delayed_compare")
5057    (set_attr "length" "4,8")])
5058 \f
5059 (define_split
5060   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5061         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
5062                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
5063                     (const_int 0)))
5064    (set (match_operand:SI 0 "gpc_reg_operand" "")
5065         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
5066   "! TARGET_POWER && reload_completed"
5067   [(set (match_dup 0)
5068         (ashiftrt:SI (match_dup 1) (match_dup 2)))
5069    (set (match_dup 3)
5070         (compare:CC (match_dup 0)
5071                     (const_int 0)))]
5072   "")
5073
5074 ;; Floating-point insns, excluding normal data motion.
5075 ;;
5076 ;; PowerPC has a full set of single-precision floating point instructions.
5077 ;;
5078 ;; For the POWER architecture, we pretend that we have both SFmode and
5079 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
5080 ;; The only conversions we will do will be when storing to memory.  In that
5081 ;; case, we will use the "frsp" instruction before storing.
5082 ;;
5083 ;; Note that when we store into a single-precision memory location, we need to
5084 ;; use the frsp insn first.  If the register being stored isn't dead, we
5085 ;; need a scratch register for the frsp.  But this is difficult when the store
5086 ;; is done by reload.  It is not incorrect to do the frsp on the register in
5087 ;; this case, we just lose precision that we would have otherwise gotten but
5088 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
5089
5090 (define_insn "extendsfdf2"
5091   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5092         (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5093   "TARGET_HARD_FLOAT && TARGET_FPRS"
5094   "*
5095 {
5096   if (REGNO (operands[0]) == REGNO (operands[1]))
5097     return \"\";
5098   else
5099     return \"fmr %0,%1\";
5100 }"
5101   [(set_attr "type" "fp")])
5102
5103 (define_insn "truncdfsf2"
5104   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5105         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5106   "TARGET_HARD_FLOAT && TARGET_FPRS"
5107   "frsp %0,%1"
5108   [(set_attr "type" "fp")])
5109
5110 (define_insn "aux_truncdfsf2"
5111   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5112         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
5113   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5114   "frsp %0,%1"
5115   [(set_attr "type" "fp")])
5116
5117 (define_expand "negsf2"
5118   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5119         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5120   "TARGET_HARD_FLOAT"
5121   "")
5122
5123 (define_insn "*negsf2"
5124   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5125         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5126   "TARGET_HARD_FLOAT && TARGET_FPRS"
5127   "fneg %0,%1"
5128   [(set_attr "type" "fp")])
5129
5130 (define_expand "abssf2"
5131   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5132         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5133   "TARGET_HARD_FLOAT"
5134   "")
5135
5136 (define_insn "*abssf2"
5137   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5138         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5139   "TARGET_HARD_FLOAT && TARGET_FPRS"
5140   "fabs %0,%1"
5141   [(set_attr "type" "fp")])
5142
5143 (define_insn ""
5144   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5145         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
5146   "TARGET_HARD_FLOAT && TARGET_FPRS"
5147   "fnabs %0,%1"
5148   [(set_attr "type" "fp")])
5149
5150 (define_expand "addsf3"
5151   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5152         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5153                  (match_operand:SF 2 "gpc_reg_operand" "")))]
5154   "TARGET_HARD_FLOAT"
5155   "")
5156
5157 (define_insn ""
5158   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5159         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5160                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
5161   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5162   "fadds %0,%1,%2"
5163   [(set_attr "type" "fp")])
5164
5165 (define_insn ""
5166   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5167         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5168                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
5169   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5170   "{fa|fadd} %0,%1,%2"
5171   [(set_attr "type" "fp")])
5172
5173 (define_expand "subsf3"
5174   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5175         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
5176                   (match_operand:SF 2 "gpc_reg_operand" "")))]
5177   "TARGET_HARD_FLOAT"
5178   "")
5179
5180 (define_insn ""
5181   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5182         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5183                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
5184   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5185   "fsubs %0,%1,%2"
5186   [(set_attr "type" "fp")])
5187
5188 (define_insn ""
5189   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5190         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5191                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
5192   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5193   "{fs|fsub} %0,%1,%2"
5194   [(set_attr "type" "fp")])
5195
5196 (define_expand "mulsf3"
5197   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5198         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
5199                  (match_operand:SF 2 "gpc_reg_operand" "")))]
5200   "TARGET_HARD_FLOAT"
5201   "")
5202
5203 (define_insn ""
5204   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5205         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5206                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
5207   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5208   "fmuls %0,%1,%2"
5209   [(set_attr "type" "fp")])
5210
5211 (define_insn ""
5212   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5213         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5214                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
5215   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5216   "{fm|fmul} %0,%1,%2"
5217   [(set_attr "type" "dmul")])
5218
5219 (define_expand "divsf3"
5220   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5221         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
5222                 (match_operand:SF 2 "gpc_reg_operand" "")))]
5223   "TARGET_HARD_FLOAT"
5224   "")
5225
5226 (define_insn ""
5227   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5228         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5229                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5230   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5231   "fdivs %0,%1,%2"
5232   [(set_attr "type" "sdiv")])
5233
5234 (define_insn ""
5235   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5236         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5237                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5238   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS"
5239   "{fd|fdiv} %0,%1,%2"
5240   [(set_attr "type" "ddiv")])
5241
5242 (define_insn ""
5243   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5244         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5245                           (match_operand:SF 2 "gpc_reg_operand" "f"))
5246                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
5247   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5248   "fmadds %0,%1,%2,%3"
5249   [(set_attr "type" "fp")])
5250
5251 (define_insn ""
5252   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5253         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5254                           (match_operand:SF 2 "gpc_reg_operand" "f"))
5255                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
5256   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5257   "{fma|fmadd} %0,%1,%2,%3"
5258   [(set_attr "type" "dmul")])
5259
5260 (define_insn ""
5261   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5262         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5263                            (match_operand:SF 2 "gpc_reg_operand" "f"))
5264                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
5265   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5266   "fmsubs %0,%1,%2,%3"
5267   [(set_attr "type" "fp")])
5268
5269 (define_insn ""
5270   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5271         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5272                            (match_operand:SF 2 "gpc_reg_operand" "f"))
5273                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
5274   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5275   "{fms|fmsub} %0,%1,%2,%3"
5276   [(set_attr "type" "dmul")])
5277
5278 (define_insn ""
5279   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5280         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5281                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
5282                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5283   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5284   "fnmadds %0,%1,%2,%3"
5285   [(set_attr "type" "fp")])
5286
5287 (define_insn ""
5288   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5289         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5290                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
5291                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5292   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5293   "{fnma|fnmadd} %0,%1,%2,%3"
5294   [(set_attr "type" "dmul")])
5295
5296 (define_insn ""
5297   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5298         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5299                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
5300                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5301   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5302   "fnmsubs %0,%1,%2,%3"
5303   [(set_attr "type" "fp")])
5304
5305 (define_insn ""
5306   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5307         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5308                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
5309                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5310   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5311   "{fnms|fnmsub} %0,%1,%2,%3"
5312   [(set_attr "type" "dmul")])
5313
5314 (define_expand "sqrtsf2"
5315   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5316         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5317   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5318   "")
5319
5320 (define_insn ""
5321   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5322         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5323   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5324   "fsqrts %0,%1"
5325   [(set_attr "type" "ssqrt")])
5326
5327 (define_insn ""
5328   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5329         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5330   "TARGET_POWER2 && TARGET_HARD_FLOAT && TARGET_FPRS"
5331   "fsqrt %0,%1"
5332   [(set_attr "type" "dsqrt")])
5333
5334 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5335 ;; fsel instruction and some auxiliary computations.  Then we just have a
5336 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5337 ;; combine.
5338 (define_expand "maxsf3"
5339   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5340         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5341                              (match_operand:SF 2 "gpc_reg_operand" ""))
5342                          (match_dup 1)
5343                          (match_dup 2)))]
5344   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5345   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5346
5347 (define_expand "minsf3"
5348   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5349         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5350                              (match_operand:SF 2 "gpc_reg_operand" ""))
5351                          (match_dup 2)
5352                          (match_dup 1)))]
5353   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5354   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5355
5356 (define_split
5357   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5358         (match_operator:SF 3 "min_max_operator"
5359          [(match_operand:SF 1 "gpc_reg_operand" "")
5360           (match_operand:SF 2 "gpc_reg_operand" "")]))]
5361   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5362   [(const_int 0)]
5363   "
5364 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5365                       operands[1], operands[2]);
5366   DONE;
5367 }")
5368
5369 (define_expand "movsicc"
5370    [(set (match_operand:SI 0 "gpc_reg_operand" "")
5371          (if_then_else:SI (match_operand 1 "comparison_operator" "")
5372                           (match_operand:SI 2 "gpc_reg_operand" "")
5373                           (match_operand:SI 3 "gpc_reg_operand" "")))]
5374   "TARGET_ISEL"
5375   "
5376 {
5377   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5378     DONE;
5379   else
5380     FAIL;
5381 }")
5382
5383 ;; We use the BASE_REGS for the isel input operands because, if rA is
5384 ;; 0, the value of 0 is placed in rD upon truth.  Similarly for rB
5385 ;; because we may switch the operands and rB may end up being rA.
5386 ;;
5387 ;; We need 2 patterns: an unsigned and a signed pattern.  We could
5388 ;; leave out the mode in operand 4 and use one pattern, but reload can
5389 ;; change the mode underneath our feet and then gets confused trying
5390 ;; to reload the value.
5391 (define_insn "isel_signed"
5392   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5393         (if_then_else:SI
5394          (match_operator 1 "comparison_operator"
5395                          [(match_operand:CC 4 "cc_reg_operand" "y")
5396                           (const_int 0)])
5397          (match_operand:SI 2 "gpc_reg_operand" "b")
5398          (match_operand:SI 3 "gpc_reg_operand" "b")))]
5399   "TARGET_ISEL"
5400   "*
5401 { return output_isel (operands); }"
5402   [(set_attr "length" "4")])
5403
5404 (define_insn "isel_unsigned"
5405   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5406         (if_then_else:SI
5407          (match_operator 1 "comparison_operator"
5408                          [(match_operand:CCUNS 4 "cc_reg_operand" "y")
5409                           (const_int 0)])
5410          (match_operand:SI 2 "gpc_reg_operand" "b")
5411          (match_operand:SI 3 "gpc_reg_operand" "b")))]
5412   "TARGET_ISEL"
5413   "*
5414 { return output_isel (operands); }"
5415   [(set_attr "length" "4")])
5416
5417 (define_expand "movsfcc"
5418    [(set (match_operand:SF 0 "gpc_reg_operand" "")
5419          (if_then_else:SF (match_operand 1 "comparison_operator" "")
5420                           (match_operand:SF 2 "gpc_reg_operand" "")
5421                           (match_operand:SF 3 "gpc_reg_operand" "")))]
5422   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5423   "
5424 {
5425   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5426     DONE;
5427   else
5428     FAIL;
5429 }")
5430
5431 (define_insn "*fselsfsf4"
5432   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5433         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5434                              (match_operand:SF 4 "zero_fp_constant" "F"))
5435                          (match_operand:SF 2 "gpc_reg_operand" "f")
5436                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5437   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5438   "fsel %0,%1,%2,%3"
5439   [(set_attr "type" "fp")])
5440
5441 (define_insn "*fseldfsf4"
5442   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5443         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5444                              (match_operand:DF 4 "zero_fp_constant" "F"))
5445                          (match_operand:SF 2 "gpc_reg_operand" "f")
5446                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5447   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5448   "fsel %0,%1,%2,%3"
5449   [(set_attr "type" "fp")])
5450
5451 (define_insn "negdf2"
5452   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5453         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5454   "TARGET_HARD_FLOAT && TARGET_FPRS"
5455   "fneg %0,%1"
5456   [(set_attr "type" "fp")])
5457
5458 (define_insn "absdf2"
5459   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5460         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5461   "TARGET_HARD_FLOAT && TARGET_FPRS"
5462   "fabs %0,%1"
5463   [(set_attr "type" "fp")])
5464
5465 (define_insn ""
5466   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5467         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
5468   "TARGET_HARD_FLOAT && TARGET_FPRS"
5469   "fnabs %0,%1"
5470   [(set_attr "type" "fp")])
5471
5472 (define_insn "adddf3"
5473   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5474         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5475                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5476   "TARGET_HARD_FLOAT && TARGET_FPRS"
5477   "{fa|fadd} %0,%1,%2"
5478   [(set_attr "type" "fp")])
5479
5480 (define_insn "subdf3"
5481   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5482         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5483                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
5484   "TARGET_HARD_FLOAT && TARGET_FPRS"
5485   "{fs|fsub} %0,%1,%2"
5486   [(set_attr "type" "fp")])
5487
5488 (define_insn "muldf3"
5489   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5490         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5491                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5492   "TARGET_HARD_FLOAT && TARGET_FPRS"
5493   "{fm|fmul} %0,%1,%2"
5494   [(set_attr "type" "dmul")])
5495
5496 (define_insn "divdf3"
5497   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5498         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5499                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5500   "TARGET_HARD_FLOAT && TARGET_FPRS"
5501   "{fd|fdiv} %0,%1,%2"
5502   [(set_attr "type" "ddiv")])
5503
5504 (define_insn ""
5505   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5506         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5507                           (match_operand:DF 2 "gpc_reg_operand" "f"))
5508                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
5509   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5510   "{fma|fmadd} %0,%1,%2,%3"
5511   [(set_attr "type" "dmul")])
5512
5513 (define_insn ""
5514   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5515         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5516                            (match_operand:DF 2 "gpc_reg_operand" "f"))
5517                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
5518   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5519   "{fms|fmsub} %0,%1,%2,%3"
5520   [(set_attr "type" "dmul")])
5521
5522 (define_insn ""
5523   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5524         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5525                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
5526                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5527   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5528   "{fnma|fnmadd} %0,%1,%2,%3"
5529   [(set_attr "type" "dmul")])
5530
5531 (define_insn ""
5532   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5533         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5534                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
5535                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5536   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_FUSED_MADD"
5537   "{fnms|fnmsub} %0,%1,%2,%3"
5538   [(set_attr "type" "dmul")])
5539
5540 (define_insn "sqrtdf2"
5541   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5542         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5543   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT && TARGET_FPRS"
5544   "fsqrt %0,%1"
5545   [(set_attr "type" "dsqrt")])
5546
5547 ;; The conditional move instructions allow us to perform max and min
5548 ;; operations even when 
5549
5550 (define_expand "maxdf3"
5551   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5552         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5553                              (match_operand:DF 2 "gpc_reg_operand" ""))
5554                          (match_dup 1)
5555                          (match_dup 2)))]
5556   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5557   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5558
5559 (define_expand "mindf3"
5560   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5561         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5562                              (match_operand:DF 2 "gpc_reg_operand" ""))
5563                          (match_dup 2)
5564                          (match_dup 1)))]
5565   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5566   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5567
5568 (define_split
5569   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5570         (match_operator:DF 3 "min_max_operator"
5571          [(match_operand:DF 1 "gpc_reg_operand" "")
5572           (match_operand:DF 2 "gpc_reg_operand" "")]))]
5573   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5574   [(const_int 0)]
5575   "
5576 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5577                       operands[1], operands[2]);
5578   DONE;
5579 }")
5580
5581 (define_expand "movdfcc"
5582    [(set (match_operand:DF 0 "gpc_reg_operand" "")
5583          (if_then_else:DF (match_operand 1 "comparison_operator" "")
5584                           (match_operand:DF 2 "gpc_reg_operand" "")
5585                           (match_operand:DF 3 "gpc_reg_operand" "")))]
5586   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5587   "
5588 {
5589   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5590     DONE;
5591   else
5592     FAIL;
5593 }")
5594
5595 (define_insn "*fseldfdf4"
5596   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5597         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5598                              (match_operand:DF 4 "zero_fp_constant" "F"))
5599                          (match_operand:DF 2 "gpc_reg_operand" "f")
5600                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5601   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT && TARGET_FPRS"
5602   "fsel %0,%1,%2,%3"
5603   [(set_attr "type" "fp")])
5604
5605 (define_insn "*fselsfdf4"
5606   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5607         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5608                              (match_operand:SF 4 "zero_fp_constant" "F"))
5609                          (match_operand:DF 2 "gpc_reg_operand" "f")
5610                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5611   "TARGET_PPC_GFXOPT"
5612   "fsel %0,%1,%2,%3"
5613   [(set_attr "type" "fp")])
5614 \f
5615 ;; Conversions to and from floating-point.
5616
5617 (define_expand "fixunssfsi2"
5618   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5619         (unsigned_fix:SI (fix:SF (match_operand:SF 1 "gpc_reg_operand" ""))))]
5620   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5621   "")
5622
5623 (define_expand "fix_truncsfsi2"
5624   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5625         (fix:SI (match_operand:SF 1 "gpc_reg_operand" "")))]
5626   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5627   "")
5628
5629 ; For each of these conversions, there is a define_expand, a define_insn
5630 ; with a '#' template, and a define_split (with C code).  The idea is
5631 ; to allow constant folding with the template of the define_insn,
5632 ; then to have the insns split later (between sched1 and final).
5633
5634 (define_expand "floatsidf2"
5635   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5636                    (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5637               (use (match_dup 2))
5638               (use (match_dup 3))
5639               (clobber (match_dup 4))
5640               (clobber (match_dup 5))
5641               (clobber (match_dup 6))])]
5642   "TARGET_HARD_FLOAT && TARGET_FPRS"
5643   "
5644 {
5645   if (TARGET_POWERPC64)
5646     {
5647       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5648       rtx t1 = gen_reg_rtx (DImode);
5649       rtx t2 = gen_reg_rtx (DImode);
5650       emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5651       DONE;
5652     }
5653
5654   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5655   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5656   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5657   operands[5] = gen_reg_rtx (DFmode);
5658   operands[6] = gen_reg_rtx (SImode);
5659 }")
5660
5661 (define_insn "*floatsidf2_internal"
5662   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5663         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5664    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5665    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5666    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5667    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))
5668    (clobber (match_operand:SI 6 "gpc_reg_operand" "=r"))]
5669   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5670   "#"
5671   [(set_attr "length" "24")])
5672
5673 (define_split
5674   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5675         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5676    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5677    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5678    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5679    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5680    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5681   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5682   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5683         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5684    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5685    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5686    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5687    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5688    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5689   "
5690 {
5691   rtx lowword, highword;
5692   if (GET_CODE (operands[4]) != MEM)
5693     abort();
5694   highword = XEXP (operands[4], 0);
5695   lowword = plus_constant (highword, 4);
5696   if (! WORDS_BIG_ENDIAN)
5697     {
5698       rtx tmp;
5699       tmp = highword; highword = lowword; lowword = tmp;
5700     }
5701
5702   emit_insn (gen_xorsi3 (operands[6], operands[1], 
5703                          GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5704   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5705   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5706   emit_move_insn (operands[5], operands[4]);
5707   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5708   DONE;
5709 }")
5710
5711 (define_expand "floatunssisf2"
5712   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5713         (unsigned_float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5714   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5715   "")
5716
5717 (define_expand "floatunssidf2"
5718   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5719                    (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5720               (use (match_dup 2))
5721               (use (match_dup 3))
5722               (clobber (match_dup 4))
5723               (clobber (match_dup 5))])]
5724   "TARGET_HARD_FLOAT && TARGET_FPRS"
5725   "
5726 {
5727   if (TARGET_POWERPC64)
5728     {
5729       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5730       rtx t1 = gen_reg_rtx (DImode);
5731       rtx t2 = gen_reg_rtx (DImode);
5732       emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5733                                          t1, t2));
5734       DONE;
5735     }
5736
5737   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5738   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5739   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5740   operands[5] = gen_reg_rtx (DFmode);
5741 }")
5742
5743 (define_insn "*floatunssidf2_internal"
5744   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5745         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5746    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5747    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5748    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5749    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))]
5750   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5751   "#"
5752   [(set_attr "length" "20")])
5753
5754 (define_split
5755   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5756         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5757    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5758    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5759    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5760    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5761   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5762   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5763         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5764    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5765    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5766    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5767    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5768   "
5769 {
5770   rtx lowword, highword;
5771   if (GET_CODE (operands[4]) != MEM)
5772     abort();
5773   highword = XEXP (operands[4], 0);
5774   lowword = plus_constant (highword, 4);
5775   if (! WORDS_BIG_ENDIAN)
5776     {
5777       rtx tmp;
5778       tmp = highword; highword = lowword; lowword = tmp;
5779     }
5780
5781   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5782   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5783   emit_move_insn (operands[5], operands[4]);
5784   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5785   DONE;
5786 }")
5787
5788 (define_expand "fix_truncdfsi2"
5789   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5790                    (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5791               (clobber (match_dup 2))
5792               (clobber (match_dup 3))])]
5793   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5794   "
5795 {
5796   operands[2] = gen_reg_rtx (DImode);
5797   operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5798 }")
5799
5800 (define_insn "*fix_truncdfsi2_internal"
5801   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5802         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5803    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5804    (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5805   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5806   "#"
5807   [(set_attr "length" "16")])
5808
5809 (define_split
5810   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5811         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5812    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5813    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5814   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5815   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5816         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5817    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5818    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5819   "
5820 {
5821   rtx lowword;
5822   if (GET_CODE (operands[3]) != MEM)
5823     abort();
5824   lowword = XEXP (operands[3], 0);
5825   if (WORDS_BIG_ENDIAN)
5826     lowword = plus_constant (lowword, 4);
5827
5828   emit_insn (gen_fctiwz (operands[2], operands[1]));
5829   emit_move_insn (operands[3], operands[2]);
5830   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5831   DONE;
5832 }")
5833
5834 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] 10))
5835 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5836 ; because the first makes it clear that operand 0 is not live
5837 ; before the instruction.
5838 (define_insn "fctiwz"
5839   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5840         (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))] 10))]
5841   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT && TARGET_FPRS"
5842   "{fcirz|fctiwz} %0,%1"
5843   [(set_attr "type" "fp")])
5844
5845 (define_expand "floatsisf2"
5846   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5847         (float:SF (match_operand:SI 1 "gpc_reg_operand" "")))]
5848   "TARGET_HARD_FLOAT && !TARGET_FPRS"
5849   "")
5850
5851 (define_insn "floatdidf2"
5852   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5853         (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
5854   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5855   "fcfid %0,%1"
5856   [(set_attr "type" "fp")])
5857
5858 (define_insn_and_split "floatsidf_ppc64"
5859   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5860         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5861    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5862    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5863    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5864   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5865   "#"
5866   ""
5867   [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5868    (set (match_dup 2) (match_dup 3))
5869    (set (match_dup 4) (match_dup 2))
5870    (set (match_dup 0) (float:DF (match_dup 4)))]
5871   "")
5872
5873 (define_insn_and_split "floatunssidf_ppc64"
5874   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5875         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5876    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5877    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5878    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5879   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5880   "#"
5881   ""
5882   [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5883    (set (match_dup 2) (match_dup 3))
5884    (set (match_dup 4) (match_dup 2))
5885    (set (match_dup 0) (float:DF (match_dup 4)))]
5886   "")
5887
5888 (define_insn "fix_truncdfdi2"
5889   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5890         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5891   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5892   "fctidz %0,%1"
5893   [(set_attr "type" "fp")])
5894
5895 (define_expand "floatdisf2"
5896   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5897         (float:SF (match_operand:DI 1 "gpc_reg_operand" "")))]
5898   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5899   "
5900 {
5901   if (!flag_unsafe_math_optimizations)
5902     {
5903       rtx label = gen_label_rtx ();
5904       emit_insn (gen_floatdisf2_internal2 (operands[1], label));
5905       emit_label (label);
5906     }
5907   emit_insn (gen_floatdisf2_internal1 (operands[0], operands[1]));
5908   DONE;
5909 }")
5910
5911 ;; This is not IEEE compliant if rounding mode is "round to nearest".
5912 ;; If the DI->DF conversion is inexact, then it's possible to suffer
5913 ;; from double rounding.
5914 (define_insn_and_split "floatdisf2_internal1"
5915   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5916         (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
5917    (clobber (match_scratch:DF 2 "=f"))]
5918   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5919   "#"
5920   "&& reload_completed"
5921   [(set (match_dup 2)
5922         (float:DF (match_dup 1)))
5923    (set (match_dup 0)
5924         (float_truncate:SF (match_dup 2)))]
5925   "")
5926
5927 ;; Twiddles bits to avoid double rounding.
5928 ;; Bits that might be trucated when converting to DFmode are replaced
5929 ;; by a bit that won't be lost at that stage, but is below the SFmode
5930 ;; rounding position.
5931 (define_expand "floatdisf2_internal2"
5932   [(parallel [(set (match_dup 4)
5933                    (compare:CC (and:DI (match_operand:DI 0 "" "")
5934                                        (const_int 2047))
5935                                (const_int 0)))
5936               (set (match_dup 2) (and:DI (match_dup 0) (const_int 2047)))
5937               (clobber (match_scratch:CC 7 ""))])
5938    (set (match_dup 3) (ashiftrt:DI (match_dup 0) (const_int 53)))
5939    (set (match_dup 3) (plus:DI (match_dup 3) (const_int 1)))
5940    (set (pc) (if_then_else (eq (match_dup 4) (const_int 0))
5941                            (label_ref (match_operand:DI 1 "" ""))
5942                            (pc)))
5943    (set (match_dup 5) (compare:CCUNS (match_dup 3) (const_int 2)))
5944    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
5945                            (label_ref (match_dup 1))
5946                            (pc)))
5947    (set (match_dup 0) (xor:DI (match_dup 0) (match_dup 2)))
5948    (set (match_dup 0) (ior:DI (match_dup 0) (const_int 2048)))]
5949   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS"
5950   "
5951 {
5952   operands[2] = gen_reg_rtx (DImode);
5953   operands[3] = gen_reg_rtx (DImode);
5954   operands[4] = gen_reg_rtx (CCmode);
5955   operands[5] = gen_reg_rtx (CCUNSmode);
5956 }")
5957 \f
5958 ;; Define the DImode operations that can be done in a small number
5959 ;; of instructions.  The & constraints are to prevent the register
5960 ;; allocator from allocating registers that overlap with the inputs
5961 ;; (for example, having an input in 7,8 and an output in 6,7).  We
5962 ;; also allow for the output being the same as one of the inputs.
5963
5964 (define_insn "*adddi3_noppc64"
5965   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5966         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5967                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5968   "! TARGET_POWERPC64"
5969   "*
5970 {
5971   if (WORDS_BIG_ENDIAN)
5972     return (GET_CODE (operands[2])) != CONST_INT
5973             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5974             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5975   else
5976     return (GET_CODE (operands[2])) != CONST_INT
5977             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5978             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5979 }"
5980   [(set_attr "length" "8")])
5981
5982 (define_insn "*subdi3_noppc64"
5983   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5984         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5985                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5986   "! TARGET_POWERPC64"
5987   "*
5988 {
5989   if (WORDS_BIG_ENDIAN)
5990     return (GET_CODE (operands[1]) != CONST_INT)
5991             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5992             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5993   else
5994     return (GET_CODE (operands[1]) != CONST_INT)
5995             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5996             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5997 }"
5998   [(set_attr "length" "8")])
5999
6000 (define_insn "*negdi2_noppc64"
6001   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6002         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
6003   "! TARGET_POWERPC64"
6004   "*
6005 {
6006   return (WORDS_BIG_ENDIAN)
6007     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
6008     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
6009 }"
6010   [(set_attr "length" "8")])
6011
6012 (define_expand "mulsidi3"
6013   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6014         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6015                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6016   "! TARGET_POWERPC64"
6017   "
6018 {
6019   if (! TARGET_POWER && ! TARGET_POWERPC)
6020     {
6021       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6022       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
6023       emit_insn (gen_mull_call ());
6024       if (WORDS_BIG_ENDIAN)
6025         emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
6026       else
6027         {
6028           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
6029                           gen_rtx_REG (SImode, 3));
6030           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
6031                           gen_rtx_REG (SImode, 4));
6032         }
6033       DONE;
6034     }
6035   else if (TARGET_POWER)
6036     {
6037       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
6038       DONE;
6039     }
6040 }")
6041
6042 (define_insn "mulsidi3_mq"
6043   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6044         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6045                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
6046    (clobber (match_scratch:SI 3 "=q"))]
6047   "TARGET_POWER"
6048   "mul %0,%1,%2\;mfmq %L0"
6049   [(set_attr "type" "imul")
6050    (set_attr "length" "8")])
6051
6052 (define_insn "*mulsidi3_no_mq"
6053   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6054         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6055                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
6056   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
6057   "*
6058 {
6059   return (WORDS_BIG_ENDIAN)
6060     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
6061     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
6062 }"
6063   [(set_attr "type" "imul")
6064    (set_attr "length" "8")])
6065
6066 (define_split
6067   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6068         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6069                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6070   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
6071   [(set (match_dup 3)
6072         (truncate:SI
6073          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
6074                                (sign_extend:DI (match_dup 2)))
6075                       (const_int 32))))
6076    (set (match_dup 4)
6077         (mult:SI (match_dup 1)
6078                  (match_dup 2)))]
6079   "
6080 {
6081   int endian = (WORDS_BIG_ENDIAN == 0);
6082   operands[3] = operand_subword (operands[0], endian, 0, DImode);
6083   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6084 }")
6085
6086 (define_expand "umulsidi3"
6087   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6088         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6089                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6090   "TARGET_POWERPC && ! TARGET_POWERPC64"
6091   "
6092 {
6093   if (TARGET_POWER)
6094     {
6095       emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
6096       DONE;
6097     }
6098 }")
6099
6100 (define_insn "umulsidi3_mq"
6101   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6102         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6103                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
6104    (clobber (match_scratch:SI 3 "=q"))]
6105   "TARGET_POWERPC && TARGET_POWER"
6106   "*
6107 {
6108   return (WORDS_BIG_ENDIAN)
6109     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6110     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6111 }"
6112   [(set_attr "type" "imul")
6113    (set_attr "length" "8")])
6114
6115 (define_insn "*umulsidi3_no_mq"
6116   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6117         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
6118                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
6119   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
6120   "*
6121 {
6122   return (WORDS_BIG_ENDIAN)
6123     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
6124     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
6125 }"
6126   [(set_attr "type" "imul")
6127    (set_attr "length" "8")])
6128
6129 (define_split
6130   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6131         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
6132                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
6133   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
6134   [(set (match_dup 3)
6135         (truncate:SI
6136          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
6137                                (zero_extend:DI (match_dup 2)))
6138                       (const_int 32))))
6139    (set (match_dup 4)
6140         (mult:SI (match_dup 1)
6141                  (match_dup 2)))]
6142   "
6143 {
6144   int endian = (WORDS_BIG_ENDIAN == 0);
6145   operands[3] = operand_subword (operands[0], endian, 0, DImode);
6146   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
6147 }")
6148
6149 (define_expand "smulsi3_highpart"
6150   [(set (match_operand:SI 0 "gpc_reg_operand" "")
6151         (truncate:SI
6152          (lshiftrt:DI (mult:DI (sign_extend:DI
6153                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6154                                (sign_extend:DI
6155                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
6156                       (const_int 32))))]
6157   ""
6158   "
6159 {
6160   if (! TARGET_POWER && ! TARGET_POWERPC)
6161     {
6162       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
6163       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
6164       emit_insn (gen_mulh_call ());
6165       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
6166       DONE;
6167     }
6168   else if (TARGET_POWER)
6169     {
6170       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6171       DONE;
6172     }
6173 }")
6174
6175 (define_insn "smulsi3_highpart_mq"
6176   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6177         (truncate:SI
6178          (lshiftrt:DI (mult:DI (sign_extend:DI
6179                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6180                                (sign_extend:DI
6181                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
6182                       (const_int 32))))
6183    (clobber (match_scratch:SI 3 "=q"))]
6184   "TARGET_POWER"
6185   "mul %0,%1,%2"
6186   [(set_attr "type" "imul")])
6187
6188 (define_insn "*smulsi3_highpart_no_mq"
6189   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6190         (truncate:SI
6191          (lshiftrt:DI (mult:DI (sign_extend:DI
6192                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6193                                (sign_extend:DI
6194                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
6195                       (const_int 32))))]
6196   "TARGET_POWERPC && ! TARGET_POWER"
6197   "mulhw %0,%1,%2"
6198   [(set_attr "type" "imul")])
6199
6200 (define_expand "umulsi3_highpart"
6201   [(set (match_operand:SI 0 "gpc_reg_operand" "")
6202         (truncate:SI
6203          (lshiftrt:DI (mult:DI (zero_extend:DI
6204                                 (match_operand:SI 1 "gpc_reg_operand" ""))
6205                                (zero_extend:DI
6206                                 (match_operand:SI 2 "gpc_reg_operand" "")))
6207                       (const_int 32))))]
6208   "TARGET_POWERPC"
6209   "
6210 {
6211   if (TARGET_POWER)
6212     {
6213       emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
6214       DONE;
6215     }
6216 }")
6217
6218 (define_insn "umulsi3_highpart_mq"
6219   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6220         (truncate:SI
6221          (lshiftrt:DI (mult:DI (zero_extend:DI
6222                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6223                                (zero_extend:DI
6224                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
6225                       (const_int 32))))
6226    (clobber (match_scratch:SI 3 "=q"))]
6227   "TARGET_POWERPC && TARGET_POWER"
6228   "mulhwu %0,%1,%2"
6229   [(set_attr "type" "imul")])
6230
6231 (define_insn "*umulsi3_highpart_no_mq"
6232   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
6233         (truncate:SI
6234          (lshiftrt:DI (mult:DI (zero_extend:DI
6235                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
6236                                (zero_extend:DI
6237                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
6238                       (const_int 32))))]
6239   "TARGET_POWERPC && ! TARGET_POWER"
6240   "mulhwu %0,%1,%2"
6241   [(set_attr "type" "imul")])
6242
6243 ;; If operands 0 and 2 are in the same register, we have a problem.  But
6244 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
6245 ;; why we have the strange constraints below.
6246 (define_insn "ashldi3_power"
6247   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
6248         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6249                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6250    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6251   "TARGET_POWER"
6252   "@
6253    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
6254    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6255    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
6256    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
6257   [(set_attr "length" "8")])
6258
6259 (define_insn "lshrdi3_power"
6260   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
6261         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
6262                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
6263    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
6264   "TARGET_POWER"
6265   "@
6266    {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
6267    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6268    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
6269    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
6270   [(set_attr "length" "8")])
6271
6272 ;; Shift by a variable amount is too complex to be worth open-coding.  We
6273 ;; just handle shifts by constants.
6274 (define_insn "ashrdi3_power"
6275   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6276         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6277                      (match_operand:SI 2 "const_int_operand" "M,i")))
6278    (clobber (match_scratch:SI 3 "=X,q"))]
6279   "TARGET_POWER"
6280   "@
6281    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6282    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
6283   [(set_attr "length" "8")])
6284
6285 (define_insn "ashrdi3_no_power"
6286   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
6287         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6288                      (match_operand:SI 2 "const_int_operand" "M,i")))]
6289   "TARGET_32BIT && !TARGET_POWER"
6290   "@
6291    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
6292    {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
6293   [(set_attr "length" "8,12")])
6294 \f
6295 ;; PowerPC64 DImode operations.
6296
6297 (define_expand "adddi3"
6298   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6299         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6300                  (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
6301   ""
6302   "
6303 {
6304   if (! TARGET_POWERPC64)
6305     {
6306       if (non_short_cint_operand (operands[2], DImode))
6307         FAIL;
6308     }
6309   else
6310     if (GET_CODE (operands[2]) == CONST_INT
6311         && ! add_operand (operands[2], DImode))
6312       {
6313         rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
6314                    ? operands[0] : gen_reg_rtx (DImode));
6315
6316         HOST_WIDE_INT val = INTVAL (operands[2]);
6317         HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
6318         HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
6319
6320         if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
6321           FAIL;
6322
6323         /* The ordering here is important for the prolog expander.
6324            When space is allocated from the stack, adding 'low' first may
6325            produce a temporary deallocation (which would be bad).  */
6326         emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
6327         emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
6328         DONE;
6329       }
6330 }")
6331
6332 ;; Discourage ai/addic because of carry but provide it in an alternative
6333 ;; allowing register zero as source.
6334
6335 (define_insn "*adddi3_internal1"
6336   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
6337         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
6338                  (match_operand:DI 2 "add_operand" "r,I,I,L")))]
6339   "TARGET_POWERPC64"
6340   "@
6341    add %0,%1,%2
6342    addi %0,%1,%2
6343    addic %0,%1,%2
6344    addis %0,%1,%v2")
6345
6346 (define_insn "*adddi3_internal2"
6347   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6348         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
6349                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
6350                     (const_int 0)))
6351    (clobber (match_scratch:DI 3 "=r,r,r,r"))]
6352   "TARGET_POWERPC64"
6353   "@
6354    add. %3,%1,%2
6355    addic. %3,%1,%2
6356    #
6357    #"
6358   [(set_attr "type" "compare")
6359    (set_attr "length" "4,4,8,8")])
6360
6361 (define_split
6362   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6363         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6364                              (match_operand:DI 2 "reg_or_short_operand" ""))
6365                     (const_int 0)))
6366    (clobber (match_scratch:DI 3 ""))]
6367   "TARGET_POWERPC64 && reload_completed"
6368   [(set (match_dup 3)
6369         (plus:DI (match_dup 1) (match_dup 2)))
6370    (set (match_dup 0)
6371         (compare:CC (match_dup 3)
6372                     (const_int 0)))]
6373   "")
6374
6375 (define_insn "*adddi3_internal3"
6376   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
6377         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
6378                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
6379                     (const_int 0)))
6380    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
6381         (plus:DI (match_dup 1) (match_dup 2)))]
6382   "TARGET_POWERPC64"
6383   "@
6384    add. %0,%1,%2
6385    addic. %0,%1,%2
6386    #
6387    #"
6388   [(set_attr "type" "compare")
6389    (set_attr "length" "4,4,8,8")])
6390
6391 (define_split
6392   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6393         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6394                              (match_operand:DI 2 "reg_or_short_operand" ""))
6395                     (const_int 0)))
6396    (set (match_operand:DI 0 "gpc_reg_operand" "")
6397         (plus:DI (match_dup 1) (match_dup 2)))]
6398   "TARGET_POWERPC64 && reload_completed"
6399   [(set (match_dup 0)
6400         (plus:DI (match_dup 1) (match_dup 2)))
6401    (set (match_dup 3)
6402         (compare:CC (match_dup 0)
6403                     (const_int 0)))]
6404   "")
6405
6406 ;; Split an add that we can't do in one insn into two insns, each of which
6407 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
6408 ;; add should be last in case the result gets used in an address.
6409
6410 (define_split
6411   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6412         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6413                  (match_operand:DI 2 "non_add_cint_operand" "")))]
6414   "TARGET_POWERPC64"
6415   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
6416    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
6417 "
6418 {
6419   HOST_WIDE_INT val = INTVAL (operands[2]);
6420   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
6421   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
6422
6423   operands[4] = GEN_INT (low);
6424   if (CONST_OK_FOR_LETTER_P (rest, 'L'))
6425     operands[3] = GEN_INT (rest);
6426   else if (! no_new_pseudos)
6427     {
6428       operands[3] = gen_reg_rtx (DImode);
6429       emit_move_insn (operands[3], operands[2]);
6430       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
6431       DONE;
6432     }
6433   else
6434     FAIL;
6435 }")
6436
6437 (define_insn "one_cmpldi2"
6438   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6439         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6440   "TARGET_POWERPC64"
6441   "nor %0,%1,%1")
6442
6443 (define_insn ""
6444   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6445         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6446                     (const_int 0)))
6447    (clobber (match_scratch:DI 2 "=r,r"))]
6448   "TARGET_POWERPC64"
6449   "@
6450    nor. %2,%1,%1
6451    #"
6452   [(set_attr "type" "compare")
6453    (set_attr "length" "4,8")])
6454
6455 (define_split
6456   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6457         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6458                     (const_int 0)))
6459    (clobber (match_scratch:DI 2 ""))]
6460   "TARGET_POWERPC64 && reload_completed"
6461   [(set (match_dup 2)
6462         (not:DI (match_dup 1)))
6463    (set (match_dup 0)
6464         (compare:CC (match_dup 2)
6465                     (const_int 0)))]
6466   "")
6467
6468 (define_insn ""
6469   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6470         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6471                     (const_int 0)))
6472    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6473         (not:DI (match_dup 1)))]
6474   "TARGET_POWERPC64"
6475   "@
6476    nor. %0,%1,%1
6477    #"
6478   [(set_attr "type" "compare")
6479    (set_attr "length" "4,8")])
6480
6481 (define_split
6482   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6483         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6484                     (const_int 0)))
6485    (set (match_operand:DI 0 "gpc_reg_operand" "")
6486         (not:DI (match_dup 1)))]
6487   "TARGET_POWERPC64 && reload_completed"
6488   [(set (match_dup 0)
6489         (not:DI (match_dup 1)))
6490    (set (match_dup 2)
6491         (compare:CC (match_dup 0)
6492                     (const_int 0)))]
6493   "")
6494
6495 (define_insn ""
6496   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6497         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
6498                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
6499   "TARGET_POWERPC64"
6500   "@
6501    subf %0,%2,%1
6502    subfic %0,%2,%1")
6503
6504 (define_insn ""
6505   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6506         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6507                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6508                     (const_int 0)))
6509    (clobber (match_scratch:DI 3 "=r,r"))]
6510   "TARGET_POWERPC64"
6511   "@
6512    subf. %3,%2,%1
6513    #"
6514   [(set_attr "type" "compare")
6515    (set_attr "length" "4,8")])
6516
6517 (define_split
6518   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6519         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6520                               (match_operand:DI 2 "gpc_reg_operand" ""))
6521                     (const_int 0)))
6522    (clobber (match_scratch:DI 3 ""))]
6523   "TARGET_POWERPC64 && reload_completed"
6524   [(set (match_dup 3)
6525         (minus:DI (match_dup 1) (match_dup 2)))
6526    (set (match_dup 0)
6527         (compare:CC (match_dup 3)
6528                     (const_int 0)))]
6529   "")
6530
6531 (define_insn ""
6532   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6533         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6534                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6535                     (const_int 0)))
6536    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6537         (minus:DI (match_dup 1) (match_dup 2)))]
6538   "TARGET_POWERPC64"
6539   "@
6540    subf. %0,%2,%1
6541    #"
6542   [(set_attr "type" "compare")
6543    (set_attr "length" "4,8")])
6544
6545 (define_split
6546   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6547         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6548                               (match_operand:DI 2 "gpc_reg_operand" ""))
6549                     (const_int 0)))
6550    (set (match_operand:DI 0 "gpc_reg_operand" "")
6551         (minus:DI (match_dup 1) (match_dup 2)))]
6552   "TARGET_POWERPC64 && reload_completed"
6553   [(set (match_dup 0)
6554         (minus:DI (match_dup 1) (match_dup 2)))
6555    (set (match_dup 3)
6556         (compare:CC (match_dup 0)
6557                     (const_int 0)))]
6558   "")
6559
6560 (define_expand "subdi3"
6561   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6562         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
6563                   (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
6564   ""
6565   "
6566 {
6567   if (GET_CODE (operands[2]) == CONST_INT)
6568     {
6569       emit_insn (gen_adddi3 (operands[0], operands[1],
6570                              negate_rtx (DImode, operands[2])));
6571       DONE;
6572     }
6573 }")
6574
6575 (define_insn_and_split "absdi2"
6576   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6577         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
6578    (clobber (match_scratch:DI 2 "=&r,&r"))]
6579   "TARGET_POWERPC64"
6580   "#"
6581   "&& reload_completed"
6582   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6583    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6584    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
6585   "")
6586
6587 (define_insn_and_split "*nabsdi2"
6588   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6589         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
6590    (clobber (match_scratch:DI 2 "=&r,&r"))]
6591   "TARGET_POWERPC64"
6592   "#"
6593   "&& reload_completed"
6594   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6595    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6596    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
6597   "")
6598
6599 (define_expand "negdi2"
6600   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6601         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
6602   ""
6603   "")
6604
6605 (define_insn ""
6606   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6607         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6608   "TARGET_POWERPC64"
6609   "neg %0,%1")
6610
6611 (define_insn ""
6612   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6613         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6614                     (const_int 0)))
6615    (clobber (match_scratch:DI 2 "=r,r"))]
6616   "TARGET_POWERPC64"
6617   "@
6618    neg. %2,%1
6619    #"
6620   [(set_attr "type" "compare")
6621    (set_attr "length" "4,8")])
6622
6623 (define_split
6624   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6625         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6626                     (const_int 0)))
6627    (clobber (match_scratch:DI 2 ""))]
6628   "TARGET_POWERPC64 && reload_completed"
6629   [(set (match_dup 2)
6630         (neg:DI (match_dup 1)))
6631    (set (match_dup 0)
6632         (compare:CC (match_dup 2)
6633                     (const_int 0)))]
6634   "")
6635
6636 (define_insn ""
6637   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6638         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6639                     (const_int 0)))
6640    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6641         (neg:DI (match_dup 1)))]
6642   "TARGET_POWERPC64"
6643   "@
6644    neg. %0,%1
6645    #"
6646   [(set_attr "type" "compare")
6647    (set_attr "length" "4,8")])
6648
6649 (define_split
6650   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6651         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6652                     (const_int 0)))
6653    (set (match_operand:DI 0 "gpc_reg_operand" "")
6654         (neg:DI (match_dup 1)))]
6655   "TARGET_POWERPC64 && reload_completed"
6656   [(set (match_dup 0)
6657         (neg:DI (match_dup 1)))
6658    (set (match_dup 2)
6659         (compare:CC (match_dup 0)
6660                     (const_int 0)))]
6661   "")
6662
6663 (define_insn "ffsdi2"
6664   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6665         (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6666   "TARGET_POWERPC64"
6667   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
6668   [(set_attr "length" "16")])
6669
6670 (define_insn "muldi3"
6671   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6672         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6673                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6674   "TARGET_POWERPC64"
6675   "mulld %0,%1,%2"
6676    [(set_attr "type" "lmul")])
6677
6678 (define_insn "smuldi3_highpart"
6679   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6680         (truncate:DI
6681          (lshiftrt:TI (mult:TI (sign_extend:TI
6682                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6683                                (sign_extend:TI
6684                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6685                       (const_int 64))))]
6686   "TARGET_POWERPC64"
6687   "mulhd %0,%1,%2"
6688   [(set_attr "type" "lmul")])
6689
6690 (define_insn "umuldi3_highpart"
6691   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6692         (truncate:DI
6693          (lshiftrt:TI (mult:TI (zero_extend:TI
6694                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6695                                (zero_extend:TI
6696                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6697                       (const_int 64))))]
6698   "TARGET_POWERPC64"
6699   "mulhdu %0,%1,%2"
6700   [(set_attr "type" "lmul")])
6701
6702 (define_expand "divdi3"
6703   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6704         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6705                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6706   "TARGET_POWERPC64"
6707   "
6708 {
6709   if (GET_CODE (operands[2]) == CONST_INT
6710       && INTVAL (operands[2]) > 0
6711       && exact_log2 (INTVAL (operands[2])) >= 0)
6712     ;
6713   else
6714     operands[2] = force_reg (DImode, operands[2]);
6715 }")
6716
6717 (define_expand "moddi3"
6718   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6719    (use (match_operand:DI 1 "gpc_reg_operand" ""))
6720    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6721   "TARGET_POWERPC64"
6722   "
6723 {
6724   int i;
6725   rtx temp1;
6726   rtx temp2;
6727
6728   if (GET_CODE (operands[2]) != CONST_INT
6729       || INTVAL (operands[2]) <= 0
6730       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
6731     FAIL;
6732
6733   temp1 = gen_reg_rtx (DImode);
6734   temp2 = gen_reg_rtx (DImode);
6735
6736   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6737   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6738   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6739   DONE;
6740 }")
6741
6742 (define_insn ""
6743   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6744         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6745                 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6746   "TARGET_POWERPC64"
6747   "sradi %0,%1,%p2\;addze %0,%0"
6748   [(set_attr "length" "8")])
6749
6750 (define_insn ""
6751   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6752         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6753                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6754                     (const_int 0)))
6755    (clobber (match_scratch:DI 3 "=r,r"))]
6756   "TARGET_POWERPC64"
6757   "@
6758    sradi %3,%1,%p2\;addze. %3,%3
6759    #"
6760   [(set_attr "type" "compare")
6761    (set_attr "length" "8,12")])
6762
6763 (define_split
6764   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6765         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6766                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6767                     (const_int 0)))
6768    (clobber (match_scratch:DI 3 ""))]
6769   "TARGET_POWERPC64 && reload_completed"
6770   [(set (match_dup 3)
6771         (div:DI (match_dup 1) (match_dup 2)))
6772    (set (match_dup 0)
6773         (compare:CC (match_dup 3)
6774                     (const_int 0)))]
6775   "")
6776
6777 (define_insn ""
6778   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6779         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6780                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6781                     (const_int 0)))
6782    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6783         (div:DI (match_dup 1) (match_dup 2)))]
6784   "TARGET_POWERPC64"
6785   "@
6786    sradi %0,%1,%p2\;addze. %0,%0
6787    #"
6788   [(set_attr "type" "compare")
6789    (set_attr "length" "8,12")])
6790
6791 (define_split
6792   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6793         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6794                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6795                     (const_int 0)))
6796    (set (match_operand:DI 0 "gpc_reg_operand" "")
6797         (div:DI (match_dup 1) (match_dup 2)))]
6798   "TARGET_POWERPC64 && reload_completed"
6799   [(set (match_dup 0)
6800         (div:DI (match_dup 1) (match_dup 2)))
6801    (set (match_dup 3)
6802         (compare:CC (match_dup 0)
6803                     (const_int 0)))]
6804   "")
6805
6806 (define_insn ""
6807   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6808         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6809                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6810   "TARGET_POWERPC64"
6811   "divd %0,%1,%2"
6812   [(set_attr "type" "ldiv")])
6813
6814 (define_insn "udivdi3"
6815   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6816         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6817                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6818   "TARGET_POWERPC64"
6819   "divdu %0,%1,%2"
6820   [(set_attr "type" "ldiv")])
6821
6822 (define_insn "rotldi3"
6823   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6824         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6825                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6826   "TARGET_POWERPC64"
6827   "rld%I2cl %0,%1,%H2,0")
6828
6829 (define_insn "*rotldi3_internal2"
6830   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6831         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6832                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6833                     (const_int 0)))
6834    (clobber (match_scratch:DI 3 "=r,r"))]
6835   "TARGET_POWERPC64"
6836   "@
6837    rld%I2cl. %3,%1,%H2,0
6838    #"
6839   [(set_attr "type" "delayed_compare")
6840    (set_attr "length" "4,8")])
6841
6842 (define_split
6843   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6844         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6845                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6846                     (const_int 0)))
6847    (clobber (match_scratch:DI 3 ""))]
6848   "TARGET_POWERPC64 && reload_completed"
6849   [(set (match_dup 3)
6850         (rotate:DI (match_dup 1) (match_dup 2)))
6851    (set (match_dup 0)
6852         (compare:CC (match_dup 3)
6853                     (const_int 0)))]
6854   "")
6855
6856 (define_insn "*rotldi3_internal3"
6857   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6858         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6859                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6860                     (const_int 0)))
6861    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6862         (rotate:DI (match_dup 1) (match_dup 2)))]
6863   "TARGET_POWERPC64"
6864   "@
6865    rld%I2cl. %0,%1,%H2,0
6866    #"
6867   [(set_attr "type" "delayed_compare")
6868    (set_attr "length" "4,8")])
6869
6870 (define_split
6871   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6872         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6873                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6874                     (const_int 0)))
6875    (set (match_operand:DI 0 "gpc_reg_operand" "")
6876         (rotate:DI (match_dup 1) (match_dup 2)))]
6877   "TARGET_POWERPC64 && reload_completed"
6878   [(set (match_dup 0)
6879         (rotate:DI (match_dup 1) (match_dup 2)))
6880    (set (match_dup 3)
6881         (compare:CC (match_dup 0)
6882                     (const_int 0)))]
6883   "")
6884
6885 (define_insn "*rotldi3_internal4"
6886   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6887         (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6888                            (match_operand:DI 2 "reg_or_cint_operand" "ri"))
6889                 (match_operand:DI 3 "mask64_operand" "n")))]
6890   "TARGET_POWERPC64"
6891   "rld%I2c%B3 %0,%1,%H2,%S3")
6892
6893 (define_insn "*rotldi3_internal5"
6894   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6895         (compare:CC (and:DI
6896                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6897                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6898                      (match_operand:DI 3 "mask64_operand" "n,n"))
6899                     (const_int 0)))
6900    (clobber (match_scratch:DI 4 "=r,r"))]
6901   "TARGET_POWERPC64"
6902   "@
6903    rld%I2c%B3. %4,%1,%H2,%S3
6904    #"
6905   [(set_attr "type" "delayed_compare")
6906    (set_attr "length" "4,8")])
6907
6908 (define_split
6909   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6910         (compare:CC (and:DI
6911                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6912                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6913                      (match_operand:DI 3 "mask64_operand" ""))
6914                     (const_int 0)))
6915    (clobber (match_scratch:DI 4 ""))]
6916   "TARGET_POWERPC64 && reload_completed"
6917   [(set (match_dup 4)
6918         (and:DI (rotate:DI (match_dup 1)
6919                                 (match_dup 2))
6920                      (match_dup 3)))
6921    (set (match_dup 0)
6922         (compare:CC (match_dup 4)
6923                     (const_int 0)))]
6924   "")
6925
6926 (define_insn "*rotldi3_internal6"
6927   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6928         (compare:CC (and:DI
6929                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6930                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6931                      (match_operand:DI 3 "mask64_operand" "n,n"))
6932                     (const_int 0)))
6933    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6934         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6935   "TARGET_POWERPC64"
6936   "@
6937    rld%I2c%B3. %0,%1,%H2,%S3
6938    #"
6939   [(set_attr "type" "delayed_compare")
6940    (set_attr "length" "4,8")])
6941
6942 (define_split
6943   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6944         (compare:CC (and:DI
6945                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6946                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6947                      (match_operand:DI 3 "mask64_operand" ""))
6948                     (const_int 0)))
6949    (set (match_operand:DI 0 "gpc_reg_operand" "")
6950         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6951   "TARGET_POWERPC64 && reload_completed"
6952   [(set (match_dup 0)
6953         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6954    (set (match_dup 4)
6955         (compare:CC (match_dup 0)
6956                     (const_int 0)))]
6957   "")
6958
6959 (define_insn "*rotldi3_internal7"
6960   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6961         (zero_extend:DI
6962          (subreg:QI
6963           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6964                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6965   "TARGET_POWERPC64"
6966   "rld%I2cl %0,%1,%H2,56")
6967
6968 (define_insn "*rotldi3_internal8"
6969   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6970         (compare:CC (zero_extend:DI
6971                      (subreg:QI
6972                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6973                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6974                     (const_int 0)))
6975    (clobber (match_scratch:DI 3 "=r,r"))]
6976   "TARGET_POWERPC64"
6977   "@
6978    rld%I2cl. %3,%1,%H2,56
6979    #"
6980   [(set_attr "type" "delayed_compare")
6981    (set_attr "length" "4,8")])
6982
6983 (define_split
6984   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6985         (compare:CC (zero_extend:DI
6986                      (subreg:QI
6987                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6988                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6989                     (const_int 0)))
6990    (clobber (match_scratch:DI 3 ""))]
6991   "TARGET_POWERPC64 && reload_completed"
6992   [(set (match_dup 3)
6993         (zero_extend:DI (subreg:QI
6994                       (rotate:DI (match_dup 1)
6995                                  (match_dup 2)) 0)))
6996    (set (match_dup 0)
6997         (compare:CC (match_dup 3)
6998                     (const_int 0)))]
6999   "")
7000
7001 (define_insn "*rotldi3_internal9"
7002   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7003         (compare:CC (zero_extend:DI
7004                      (subreg:QI
7005                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7006                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
7007                     (const_int 0)))
7008    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7009         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7010   "TARGET_POWERPC64"
7011   "@
7012    rld%I2cl. %0,%1,%H2,56
7013    #"
7014   [(set_attr "type" "delayed_compare")
7015    (set_attr "length" "4,8")])
7016
7017 (define_split
7018   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7019         (compare:CC (zero_extend:DI
7020                      (subreg:QI
7021                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7022                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7023                     (const_int 0)))
7024    (set (match_operand:DI 0 "gpc_reg_operand" "")
7025         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7026   "TARGET_POWERPC64 && reload_completed"
7027   [(set (match_dup 0)
7028         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7029    (set (match_dup 3)
7030         (compare:CC (match_dup 0)
7031                     (const_int 0)))]
7032   "")
7033
7034 (define_insn "*rotldi3_internal10"
7035   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7036         (zero_extend:DI
7037          (subreg:HI
7038           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7039                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
7040   "TARGET_POWERPC64"
7041   "rld%I2cl %0,%1,%H2,48")
7042
7043 (define_insn "*rotldi3_internal11"
7044   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7045         (compare:CC (zero_extend:DI
7046                      (subreg:HI
7047                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7048                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
7049                     (const_int 0)))
7050    (clobber (match_scratch:DI 3 "=r,r"))]
7051   "TARGET_POWERPC64"
7052   "@
7053    rld%I2cl. %3,%1,%H2,48
7054    #"
7055   [(set_attr "type" "delayed_compare")
7056    (set_attr "length" "4,8")])
7057
7058 (define_split
7059   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7060         (compare:CC (zero_extend:DI
7061                      (subreg:HI
7062                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7063                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7064                     (const_int 0)))
7065    (clobber (match_scratch:DI 3 ""))]
7066   "TARGET_POWERPC64 && reload_completed"
7067   [(set (match_dup 3)
7068         (zero_extend:DI (subreg:HI
7069                       (rotate:DI (match_dup 1)
7070                                  (match_dup 2)) 0)))
7071    (set (match_dup 0)
7072         (compare:CC (match_dup 3)
7073                     (const_int 0)))]
7074   "")
7075
7076 (define_insn "*rotldi3_internal12"
7077   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7078         (compare:CC (zero_extend:DI
7079                      (subreg:HI
7080                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7081                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
7082                     (const_int 0)))
7083    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7084         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7085   "TARGET_POWERPC64"
7086   "@
7087    rld%I2cl. %0,%1,%H2,48
7088    #"
7089   [(set_attr "type" "delayed_compare")
7090    (set_attr "length" "4,8")])
7091
7092 (define_split
7093   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7094         (compare:CC (zero_extend:DI
7095                      (subreg:HI
7096                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7097                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7098                     (const_int 0)))
7099    (set (match_operand:DI 0 "gpc_reg_operand" "")
7100         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7101   "TARGET_POWERPC64 && reload_completed"
7102   [(set (match_dup 0)
7103         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7104    (set (match_dup 3)
7105         (compare:CC (match_dup 0)
7106                     (const_int 0)))]
7107   "")
7108
7109 (define_insn "*rotldi3_internal13"
7110   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7111         (zero_extend:DI
7112          (subreg:SI
7113           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7114                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
7115   "TARGET_POWERPC64"
7116   "rld%I2cl %0,%1,%H2,32")
7117
7118 (define_insn "*rotldi3_internal14"
7119   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7120         (compare:CC (zero_extend:DI
7121                      (subreg:SI
7122                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7123                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
7124                     (const_int 0)))
7125    (clobber (match_scratch:DI 3 "=r,r"))]
7126   "TARGET_POWERPC64"
7127   "@
7128    rld%I2cl. %3,%1,%H2,32
7129    #"
7130   [(set_attr "type" "delayed_compare")
7131    (set_attr "length" "4,8")])
7132
7133 (define_split
7134   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7135         (compare:CC (zero_extend:DI
7136                      (subreg:SI
7137                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7138                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7139                     (const_int 0)))
7140    (clobber (match_scratch:DI 3 ""))]
7141   "TARGET_POWERPC64 && reload_completed"
7142   [(set (match_dup 3)
7143         (zero_extend:DI (subreg:SI
7144                       (rotate:DI (match_dup 1)
7145                                  (match_dup 2)) 0)))
7146    (set (match_dup 0)
7147         (compare:CC (match_dup 3)
7148                     (const_int 0)))]
7149   "")
7150
7151 (define_insn "*rotldi3_internal15"
7152   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7153         (compare:CC (zero_extend:DI
7154                      (subreg:SI
7155                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7156                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
7157                     (const_int 0)))
7158    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7159         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7160   "TARGET_POWERPC64"
7161   "@
7162    rld%I2cl. %0,%1,%H2,32
7163    #"
7164   [(set_attr "type" "delayed_compare")
7165    (set_attr "length" "4,8")])
7166
7167 (define_split
7168   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7169         (compare:CC (zero_extend:DI
7170                      (subreg:SI
7171                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
7172                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
7173                     (const_int 0)))
7174    (set (match_operand:DI 0 "gpc_reg_operand" "")
7175         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
7176   "TARGET_POWERPC64 && reload_completed"
7177   [(set (match_dup 0)
7178         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
7179    (set (match_dup 3)
7180         (compare:CC (match_dup 0)
7181                     (const_int 0)))]
7182   "")
7183
7184 (define_expand "ashldi3"
7185   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7186         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7187                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
7188   "TARGET_POWERPC64 || TARGET_POWER"
7189   "
7190 {
7191   if (TARGET_POWERPC64)
7192     ;
7193   else if (TARGET_POWER)
7194     {
7195       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
7196       DONE;
7197     }
7198   else
7199     FAIL;
7200 }")
7201
7202 (define_insn "*ashldi3_internal1"
7203   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7204         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7205                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7206   "TARGET_POWERPC64"
7207   "sld%I2 %0,%1,%H2"
7208   [(set_attr "length" "8")])
7209   
7210 (define_insn "*ashldi3_internal2"
7211   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7212         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7213                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7214                     (const_int 0)))
7215    (clobber (match_scratch:DI 3 "=r,r"))]
7216   "TARGET_POWERPC64"
7217   "@
7218    sld%I2. %3,%1,%H2
7219    #"
7220   [(set_attr "type" "delayed_compare")
7221    (set_attr "length" "4,8")])
7222   
7223 (define_split
7224   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7225         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7226                                (match_operand:SI 2 "reg_or_cint_operand" ""))
7227                     (const_int 0)))
7228    (clobber (match_scratch:DI 3 ""))]
7229   "TARGET_POWERPC64 && reload_completed"
7230   [(set (match_dup 3)
7231         (ashift:DI (match_dup 1) (match_dup 2)))
7232    (set (match_dup 0)
7233         (compare:CC (match_dup 3)
7234                     (const_int 0)))]
7235   "")
7236
7237 (define_insn "*ashldi3_internal3"
7238   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7239         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7240                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7241                     (const_int 0)))
7242    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7243         (ashift:DI (match_dup 1) (match_dup 2)))]
7244   "TARGET_POWERPC64"
7245   "@
7246    sld%I2. %0,%1,%H2
7247    #"
7248   [(set_attr "type" "delayed_compare")
7249    (set_attr "length" "4,8")])
7250
7251 (define_split
7252   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7253         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7254                                (match_operand:SI 2 "reg_or_cint_operand" ""))
7255                     (const_int 0)))
7256    (set (match_operand:DI 0 "gpc_reg_operand" "")
7257         (ashift:DI (match_dup 1) (match_dup 2)))]
7258   "TARGET_POWERPC64 && reload_completed"
7259   [(set (match_dup 0)
7260         (ashift:DI (match_dup 1) (match_dup 2)))
7261    (set (match_dup 3)
7262         (compare:CC (match_dup 0)
7263                     (const_int 0)))]
7264   "")
7265
7266 (define_insn "*ashldi3_internal4"
7267   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7268         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7269                            (match_operand:SI 2 "const_int_operand" "i"))
7270                 (match_operand:DI 3 "const_int_operand" "n")))]
7271   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
7272   "rldic %0,%1,%H2,%W3")
7273
7274 (define_insn "ashldi3_internal5"
7275   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7276         (compare:CC
7277          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7278                             (match_operand:SI 2 "const_int_operand" "i,i"))
7279                  (match_operand:DI 3 "const_int_operand" "n,n"))
7280          (const_int 0)))
7281    (clobber (match_scratch:DI 4 "=r,r"))]
7282   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
7283   "@
7284    rldic. %4,%1,%H2,%W3
7285    #"
7286   [(set_attr "type" "delayed_compare")
7287    (set_attr "length" "4,8")])
7288
7289 (define_split
7290   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7291         (compare:CC
7292          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7293                             (match_operand:SI 2 "const_int_operand" ""))
7294                  (match_operand:DI 3 "const_int_operand" ""))
7295          (const_int 0)))
7296    (clobber (match_scratch:DI 4 ""))]
7297   "TARGET_POWERPC64 && reload_completed
7298    && includes_rldic_lshift_p (operands[2], operands[3])"
7299   [(set (match_dup 4)
7300         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7301                 (match_dup 3)))
7302    (set (match_dup 0)
7303         (compare:CC (match_dup 4)
7304                     (const_int 0)))]
7305   "")
7306
7307 (define_insn "*ashldi3_internal6"
7308   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7309         (compare:CC
7310          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7311                             (match_operand:SI 2 "const_int_operand" "i,i"))
7312                     (match_operand:DI 3 "const_int_operand" "n,n"))
7313          (const_int 0)))
7314    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7315         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7316   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
7317   "@
7318    rldic. %0,%1,%H2,%W3
7319    #"
7320   [(set_attr "type" "delayed_compare")
7321    (set_attr "length" "4,8")])
7322
7323 (define_split
7324   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7325         (compare:CC
7326          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7327                             (match_operand:SI 2 "const_int_operand" ""))
7328                  (match_operand:DI 3 "const_int_operand" ""))
7329          (const_int 0)))
7330    (set (match_operand:DI 0 "gpc_reg_operand" "")
7331         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7332   "TARGET_POWERPC64 && reload_completed
7333    && includes_rldic_lshift_p (operands[2], operands[3])"
7334   [(set (match_dup 0)
7335         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7336                 (match_dup 3)))
7337    (set (match_dup 4)
7338         (compare:CC (match_dup 0)
7339                     (const_int 0)))]
7340   "")
7341
7342 (define_insn "*ashldi3_internal7"
7343   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7344         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7345                            (match_operand:SI 2 "const_int_operand" "i"))
7346                 (match_operand:DI 3 "mask64_operand" "n")))]
7347   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7348   "rldicr %0,%1,%H2,%S3")
7349
7350 (define_insn "ashldi3_internal8"
7351   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7352         (compare:CC
7353          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7354                             (match_operand:SI 2 "const_int_operand" "i,i"))
7355                  (match_operand:DI 3 "mask64_operand" "n,n"))
7356          (const_int 0)))
7357    (clobber (match_scratch:DI 4 "=r,r"))]
7358   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7359   "@
7360    rldicr. %4,%1,%H2,%S3
7361    #"
7362   [(set_attr "type" "delayed_compare")
7363    (set_attr "length" "4,8")])
7364
7365 (define_split
7366   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7367         (compare:CC
7368          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7369                             (match_operand:SI 2 "const_int_operand" ""))
7370                  (match_operand:DI 3 "mask64_operand" ""))
7371          (const_int 0)))
7372    (clobber (match_scratch:DI 4 ""))]
7373   "TARGET_POWERPC64 && reload_completed
7374    && includes_rldicr_lshift_p (operands[2], operands[3])"
7375   [(set (match_dup 4)
7376         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7377                 (match_dup 3)))
7378    (set (match_dup 0)
7379         (compare:CC (match_dup 4)
7380                     (const_int 0)))]
7381   "")
7382
7383 (define_insn "*ashldi3_internal9"
7384   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7385         (compare:CC
7386          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7387                             (match_operand:SI 2 "const_int_operand" "i,i"))
7388                     (match_operand:DI 3 "mask64_operand" "n,n"))
7389          (const_int 0)))
7390    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7391         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7392   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7393   "@
7394    rldicr. %0,%1,%H2,%S3
7395    #"
7396   [(set_attr "type" "delayed_compare")
7397    (set_attr "length" "4,8")])
7398
7399 (define_split
7400   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7401         (compare:CC
7402          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7403                             (match_operand:SI 2 "const_int_operand" ""))
7404                  (match_operand:DI 3 "mask64_operand" ""))
7405          (const_int 0)))
7406    (set (match_operand:DI 0 "gpc_reg_operand" "")
7407         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7408   "TARGET_POWERPC64 && reload_completed
7409    && includes_rldicr_lshift_p (operands[2], operands[3])"
7410   [(set (match_dup 0)
7411         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7412                 (match_dup 3)))
7413    (set (match_dup 4)
7414         (compare:CC (match_dup 0)
7415                     (const_int 0)))]
7416   "")
7417
7418 (define_expand "lshrdi3"
7419   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7420         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7421                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7422   "TARGET_POWERPC64 || TARGET_POWER"
7423   "
7424 {
7425   if (TARGET_POWERPC64)
7426     ;
7427   else if (TARGET_POWER)
7428     {
7429       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
7430       DONE;
7431     }
7432   else
7433     FAIL;
7434 }")
7435
7436 (define_insn "*lshrdi3_internal1"
7437   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7438         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7439                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7440   "TARGET_POWERPC64"
7441   "srd%I2 %0,%1,%H2")
7442
7443 (define_insn "*lshrdi3_internal2"
7444   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7445         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7446                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7447                     (const_int 0)))
7448    (clobber (match_scratch:DI 3 "=r,r"))]
7449   "TARGET_POWERPC64"
7450   "@
7451    srd%I2. %3,%1,%H2
7452    #"
7453   [(set_attr "type" "delayed_compare")
7454    (set_attr "length" "4,8")])
7455
7456 (define_split
7457   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7458         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7459                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7460                     (const_int 0)))
7461    (clobber (match_scratch:DI 3 ""))]
7462   "TARGET_POWERPC64 && reload_completed"
7463   [(set (match_dup 3)
7464         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7465    (set (match_dup 0)
7466         (compare:CC (match_dup 3)
7467                     (const_int 0)))]
7468   "")
7469
7470 (define_insn "*lshrdi3_internal3"
7471   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7472         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7473                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7474                     (const_int 0)))
7475    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7476         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7477   "TARGET_POWERPC64"
7478   "@
7479    srd%I2. %0,%1,%H2
7480    #"
7481   [(set_attr "type" "delayed_compare")
7482    (set_attr "length" "4,8")])
7483
7484 (define_split
7485   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7486         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7487                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7488                     (const_int 0)))
7489    (set (match_operand:DI 0 "gpc_reg_operand" "")
7490         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7491   "TARGET_POWERPC64 && reload_completed"
7492   [(set (match_dup 0)
7493         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7494    (set (match_dup 3)
7495         (compare:CC (match_dup 0)
7496                     (const_int 0)))]
7497   "")
7498
7499 (define_expand "ashrdi3"
7500   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7501         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7502                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7503   ""
7504   "
7505 {
7506   if (TARGET_POWERPC64)
7507     ;
7508   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7509     {
7510       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7511       DONE;
7512     }
7513   else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT)
7514     {
7515       emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7516       DONE;
7517     }
7518   else
7519     FAIL;
7520 }")
7521
7522 (define_insn "*ashrdi3_internal1"
7523   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7524         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7525                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7526   "TARGET_POWERPC64"
7527   "srad%I2 %0,%1,%H2")
7528
7529 (define_insn "*ashrdi3_internal2"
7530   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7531         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7532                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7533                     (const_int 0)))
7534    (clobber (match_scratch:DI 3 "=r,r"))]
7535   "TARGET_POWERPC64"
7536   "@
7537    srad%I2. %3,%1,%H2
7538    #"
7539   [(set_attr "type" "delayed_compare")
7540    (set_attr "length" "4,8")])
7541
7542 (define_split
7543   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7544         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7545                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7546                     (const_int 0)))
7547    (clobber (match_scratch:DI 3 ""))]
7548   "TARGET_POWERPC64 && reload_completed"
7549   [(set (match_dup 3)
7550         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7551    (set (match_dup 0)
7552         (compare:CC (match_dup 3)
7553                     (const_int 0)))]
7554   "")
7555
7556 (define_insn "*ashrdi3_internal3"
7557   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7558         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7559                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7560                     (const_int 0)))
7561    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7562         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7563   "TARGET_POWERPC64"
7564   "@
7565    srad%I2. %0,%1,%H2
7566    #"
7567   [(set_attr "type" "delayed_compare")
7568    (set_attr "length" "4,8")])
7569
7570 (define_split
7571   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7572         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7573                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7574                     (const_int 0)))
7575    (set (match_operand:DI 0 "gpc_reg_operand" "")
7576         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7577   "TARGET_POWERPC64 && reload_completed"
7578   [(set (match_dup 0)
7579         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7580    (set (match_dup 3)
7581         (compare:CC (match_dup 0)
7582                     (const_int 0)))]
7583   "")
7584
7585 (define_insn "anddi3"
7586   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
7587         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
7588                 (match_operand:DI 2 "and64_2_operand" "?r,S,K,J,t")))
7589    (clobber (match_scratch:CC 3 "=X,X,x,x,X"))]
7590   "TARGET_POWERPC64"
7591   "@
7592    and %0,%1,%2
7593    rldic%B2 %0,%1,0,%S2
7594    andi. %0,%1,%b2
7595    andis. %0,%1,%u2
7596    #"
7597   [(set_attr "length" "4,4,4,4,8")])
7598
7599 (define_split
7600   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7601         (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7602                 (match_operand:DI 2 "mask64_2_operand" "")))
7603    (clobber (match_scratch:CC 3 ""))]
7604   "TARGET_POWERPC64
7605     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7606     && !mask64_operand (operands[2], DImode)"
7607   [(set (match_dup 0)
7608         (and:DI (rotate:DI (match_dup 1)
7609                            (match_dup 4))
7610                 (match_dup 5)))
7611    (set (match_dup 0)
7612         (and:DI (rotate:DI (match_dup 0)
7613                            (match_dup 6))
7614                 (match_dup 7)))]
7615   "
7616 {
7617   build_mask64_2_operands (operands[2], &operands[4]);
7618 }")
7619
7620 (define_insn "*anddi3_internal2"
7621   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7622         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7623                             (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7624                     (const_int 0)))
7625    (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r,r,r"))
7626    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7627   "TARGET_POWERPC64"
7628   "@
7629    and. %3,%1,%2
7630    rldic%B2. %3,%1,0,%S2
7631    andi. %3,%1,%b2
7632    andis. %3,%1,%u2
7633    #
7634    #
7635    #
7636    #
7637    #
7638    #"
7639   [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7640    (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7641
7642 (define_split
7643   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7644         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7645                             (match_operand:DI 2 "and64_operand" ""))
7646                     (const_int 0)))
7647    (clobber (match_scratch:DI 3 ""))
7648    (clobber (match_scratch:CC 4 ""))]
7649   "TARGET_POWERPC64 && reload_completed"
7650   [(parallel [(set (match_dup 3)
7651                    (and:DI (match_dup 1)
7652                            (match_dup 2)))
7653               (clobber (match_dup 4))])
7654    (set (match_dup 0)
7655         (compare:CC (match_dup 3)
7656                     (const_int 0)))]
7657   "")
7658
7659 (define_split
7660   [(set (match_operand:CC 0 "cc_reg_operand" "")
7661         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7662                             (match_operand:DI 2 "mask64_2_operand" ""))
7663                     (const_int 0)))
7664    (clobber (match_scratch:DI 3 ""))
7665    (clobber (match_scratch:CC 4 ""))]
7666   "TARGET_POWERPC64 && reload_completed
7667     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7668     && !mask64_operand (operands[2], DImode)"
7669   [(set (match_dup 3)
7670         (and:DI (rotate:DI (match_dup 1)
7671                            (match_dup 5))
7672                 (match_dup 6)))
7673    (parallel [(set (match_dup 0)
7674                    (compare:CC (and:DI (rotate:DI (match_dup 3)
7675                                                   (match_dup 7))
7676                                        (match_dup 8))
7677                                (const_int 0)))
7678               (clobber (match_dup 3))])]
7679   "
7680 {
7681   build_mask64_2_operands (operands[2], &operands[5]);
7682 }")
7683
7684 (define_insn "*anddi3_internal3"
7685   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,x,?y,?y,??y,??y,?y")
7686         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
7687                             (match_operand:DI 2 "and64_2_operand" "r,S,K,J,t,r,S,K,J,t"))
7688                     (const_int 0)))
7689    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
7690         (and:DI (match_dup 1) (match_dup 2)))
7691    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,X,x,x,X"))]
7692   "TARGET_POWERPC64"
7693   "@
7694    and. %0,%1,%2
7695    rldic%B2. %0,%1,0,%S2
7696    andi. %0,%1,%b2
7697    andis. %0,%1,%u2
7698    #
7699    #
7700    #
7701    #
7702    #
7703    #"
7704   [(set_attr "type" "compare,delayed_compare,compare,compare,delayed_compare,compare,compare,compare,compare,compare")
7705    (set_attr "length" "4,4,4,4,8,8,8,8,8,12")])
7706
7707 (define_split
7708   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7709         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7710                             (match_operand:DI 2 "and64_operand" ""))
7711                     (const_int 0)))
7712    (set (match_operand:DI 0 "gpc_reg_operand" "")
7713         (and:DI (match_dup 1) (match_dup 2)))
7714    (clobber (match_scratch:CC 4 ""))]
7715   "TARGET_POWERPC64 && reload_completed"
7716   [(parallel [(set (match_dup 0)
7717                     (and:DI (match_dup 1) (match_dup 2)))
7718                (clobber (match_dup 4))])
7719    (set (match_dup 3)
7720         (compare:CC (match_dup 0)
7721                     (const_int 0)))]
7722   "")
7723
7724 (define_split
7725   [(set (match_operand:CC 3 "cc_reg_operand" "")
7726         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7727                             (match_operand:DI 2 "mask64_2_operand" ""))
7728                     (const_int 0)))
7729    (set (match_operand:DI 0 "gpc_reg_operand" "")
7730         (and:DI (match_dup 1) (match_dup 2)))
7731    (clobber (match_scratch:CC 4 ""))]
7732   "TARGET_POWERPC64 && reload_completed
7733     && (fixed_regs[CR0_REGNO] || !logical_operand (operands[2], DImode))
7734     && !mask64_operand (operands[2], DImode)"
7735   [(set (match_dup 0)
7736         (and:DI (rotate:DI (match_dup 1)
7737                            (match_dup 5))
7738                 (match_dup 6)))
7739    (parallel [(set (match_dup 3)
7740                    (compare:CC (and:DI (rotate:DI (match_dup 0)
7741                                                   (match_dup 7))
7742                                        (match_dup 8))
7743                                (const_int 0)))
7744               (set (match_dup 0)
7745                    (and:DI (rotate:DI (match_dup 0)
7746                                       (match_dup 7))
7747                            (match_dup 8)))])]
7748   "
7749 {
7750   build_mask64_2_operands (operands[2], &operands[5]);
7751 }")
7752
7753 (define_expand "iordi3"
7754   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7755         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7756                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7757   "TARGET_POWERPC64"
7758   "
7759 {
7760   if (non_logical_cint_operand (operands[2], DImode))
7761     {
7762       HOST_WIDE_INT value;
7763       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7764                  ? operands[0] : gen_reg_rtx (DImode));
7765
7766       if (GET_CODE (operands[2]) == CONST_INT)
7767         {
7768           value = INTVAL (operands[2]);
7769           emit_insn (gen_iordi3 (tmp, operands[1],
7770                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7771         }
7772       else
7773         {
7774           value = CONST_DOUBLE_LOW (operands[2]);
7775           emit_insn (gen_iordi3 (tmp, operands[1],
7776                                  immed_double_const (value
7777                                                      & (~ (HOST_WIDE_INT) 0xffff),
7778                                                      0, DImode)));
7779         }
7780
7781       emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7782       DONE;
7783     }
7784 }")
7785
7786 (define_expand "xordi3"
7787   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7788         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7789                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7790   "TARGET_POWERPC64"
7791   "
7792 {
7793   if (non_logical_cint_operand (operands[2], DImode))
7794     {
7795       HOST_WIDE_INT value;
7796       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7797                  ? operands[0] : gen_reg_rtx (DImode));
7798
7799       if (GET_CODE (operands[2]) == CONST_INT)
7800         {
7801           value = INTVAL (operands[2]);
7802           emit_insn (gen_xordi3 (tmp, operands[1],
7803                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7804         }
7805       else
7806         {
7807           value = CONST_DOUBLE_LOW (operands[2]);
7808           emit_insn (gen_xordi3 (tmp, operands[1],
7809                                  immed_double_const (value
7810                                                      & (~ (HOST_WIDE_INT) 0xffff),
7811                                                      0, DImode)));
7812         }
7813
7814       emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7815       DONE;
7816     }
7817 }")
7818
7819 (define_insn "*booldi3_internal1"
7820   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7821         (match_operator:DI 3 "boolean_or_operator"
7822          [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7823           (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7824   "TARGET_POWERPC64"
7825   "@
7826    %q3 %0,%1,%2
7827    %q3i %0,%1,%b2
7828    %q3is %0,%1,%u2")
7829
7830 (define_insn "*booldi3_internal2"
7831   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7832         (compare:CC (match_operator:DI 4 "boolean_or_operator"
7833          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7834           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7835          (const_int 0)))
7836    (clobber (match_scratch:DI 3 "=r,r"))]
7837   "TARGET_POWERPC64"
7838   "@
7839    %q4. %3,%1,%2
7840    #"
7841   [(set_attr "type" "compare")
7842    (set_attr "length" "4,8")])
7843
7844 (define_split
7845   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7846         (compare:CC (match_operator:DI 4 "boolean_operator"
7847          [(match_operand:DI 1 "gpc_reg_operand" "")
7848           (match_operand:DI 2 "gpc_reg_operand" "")])
7849          (const_int 0)))
7850    (clobber (match_scratch:DI 3 ""))]
7851   "TARGET_POWERPC64 && reload_completed"
7852   [(set (match_dup 3) (match_dup 4))
7853    (set (match_dup 0)
7854         (compare:CC (match_dup 3)
7855                     (const_int 0)))]
7856   "")
7857
7858 (define_insn "*booldi3_internal3"
7859   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7860         (compare:CC (match_operator:DI 4 "boolean_operator"
7861          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7862           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7863          (const_int 0)))
7864    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7865         (match_dup 4))]
7866   "TARGET_POWERPC64"
7867   "@
7868    %q4. %0,%1,%2
7869    #"
7870   [(set_attr "type" "compare")
7871    (set_attr "length" "4,8")])
7872
7873 (define_split
7874   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7875         (compare:CC (match_operator:DI 4 "boolean_operator"
7876          [(match_operand:DI 1 "gpc_reg_operand" "")
7877           (match_operand:DI 2 "gpc_reg_operand" "")])
7878          (const_int 0)))
7879    (set (match_operand:DI 0 "gpc_reg_operand" "")
7880         (match_dup 4))]
7881   "TARGET_POWERPC64 && reload_completed"
7882   [(set (match_dup 0) (match_dup 4))
7883    (set (match_dup 3)
7884         (compare:CC (match_dup 0)
7885                     (const_int 0)))]
7886   "")
7887
7888 ;; Split an logical operation that we can't do in one insn into two insns, 
7889 ;; each of which does one 16-bit part.  This is used by combine.
7890
7891 (define_split
7892   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7893         (match_operator:DI 3 "boolean_or_operator"
7894          [(match_operand:DI 1 "gpc_reg_operand" "")
7895           (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7896   "TARGET_POWERPC64"
7897   [(set (match_dup 0) (match_dup 4))
7898    (set (match_dup 0) (match_dup 5))]
7899 "
7900 {
7901   rtx i3,i4;
7902   
7903   if (GET_CODE (operands[2]) == CONST_DOUBLE)
7904     {
7905       HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7906       i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7907                                         0, DImode);
7908       i4 = GEN_INT (value & 0xffff);
7909     }
7910   else
7911     {
7912       i3 = GEN_INT (INTVAL (operands[2])
7913                              & (~ (HOST_WIDE_INT) 0xffff));
7914       i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7915     }
7916   operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
7917                          operands[1], i3);
7918   operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
7919                          operands[0], i4);
7920 }")
7921
7922 (define_insn "*boolcdi3_internal1"
7923   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7924         (match_operator:DI 3 "boolean_operator"
7925          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7926           (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7927   "TARGET_POWERPC64"
7928   "%q3 %0,%2,%1")
7929
7930 (define_insn "*boolcdi3_internal2"
7931   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7932         (compare:CC (match_operator:DI 4 "boolean_operator"
7933          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7934           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7935          (const_int 0)))
7936    (clobber (match_scratch:DI 3 "=r,r"))]
7937   "TARGET_POWERPC64"
7938   "@
7939    %q4. %3,%2,%1
7940    #"
7941   [(set_attr "type" "compare")
7942    (set_attr "length" "4,8")])
7943
7944 (define_split
7945   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7946         (compare:CC (match_operator:DI 4 "boolean_operator"
7947          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7948           (match_operand:DI 2 "gpc_reg_operand" "")])
7949          (const_int 0)))
7950    (clobber (match_scratch:DI 3 ""))]
7951   "TARGET_POWERPC64 && reload_completed"
7952   [(set (match_dup 3) (match_dup 4))
7953    (set (match_dup 0)
7954         (compare:CC (match_dup 3)
7955                     (const_int 0)))]
7956   "")
7957
7958 (define_insn "*boolcdi3_internal3"
7959   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7960         (compare:CC (match_operator:DI 4 "boolean_operator"
7961          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7962           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7963          (const_int 0)))
7964    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7965         (match_dup 4))]
7966   "TARGET_POWERPC64"
7967   "@
7968    %q4. %0,%2,%1
7969    #"
7970   [(set_attr "type" "compare")
7971    (set_attr "length" "4,8")])
7972
7973 (define_split
7974   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7975         (compare:CC (match_operator:DI 4 "boolean_operator"
7976          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7977           (match_operand:DI 2 "gpc_reg_operand" "")])
7978          (const_int 0)))
7979    (set (match_operand:DI 0 "gpc_reg_operand" "")
7980         (match_dup 4))]
7981   "TARGET_POWERPC64 && reload_completed"
7982   [(set (match_dup 0) (match_dup 4))
7983    (set (match_dup 3)
7984         (compare:CC (match_dup 0)
7985                     (const_int 0)))]
7986   "")
7987
7988 (define_insn "*boolccdi3_internal1"
7989   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7990         (match_operator:DI 3 "boolean_operator"
7991          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7992           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7993   "TARGET_POWERPC64"
7994   "%q3 %0,%1,%2")
7995
7996 (define_insn "*boolccdi3_internal2"
7997   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7998         (compare:CC (match_operator:DI 4 "boolean_operator"
7999          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
8000           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
8001          (const_int 0)))
8002    (clobber (match_scratch:DI 3 "=r,r"))]
8003   "TARGET_POWERPC64"
8004   "@
8005    %q4. %3,%1,%2
8006    #"
8007   [(set_attr "type" "compare")
8008    (set_attr "length" "4,8")])
8009
8010 (define_split
8011   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
8012         (compare:CC (match_operator:DI 4 "boolean_operator"
8013          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
8014           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
8015          (const_int 0)))
8016    (clobber (match_scratch:DI 3 ""))]
8017   "TARGET_POWERPC64 && reload_completed"
8018   [(set (match_dup 3) (match_dup 4))
8019    (set (match_dup 0)
8020         (compare:CC (match_dup 3)
8021                     (const_int 0)))]
8022   "")
8023
8024 (define_insn "*boolccdi3_internal3"
8025   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
8026         (compare:CC (match_operator:DI 4 "boolean_operator"
8027          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
8028           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
8029          (const_int 0)))
8030    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
8031         (match_dup 4))]
8032   "TARGET_POWERPC64"
8033   "@
8034    %q4. %0,%1,%2
8035    #"
8036   [(set_attr "type" "compare")
8037    (set_attr "length" "4,8")])
8038
8039 (define_split
8040   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
8041         (compare:CC (match_operator:DI 4 "boolean_operator"
8042          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
8043           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
8044          (const_int 0)))
8045    (set (match_operand:DI 0 "gpc_reg_operand" "")
8046         (match_dup 4))]
8047   "TARGET_POWERPC64 && reload_completed"
8048   [(set (match_dup 0) (match_dup 4))
8049    (set (match_dup 3)
8050         (compare:CC (match_dup 0)
8051                     (const_int 0)))]
8052   "")
8053 \f
8054 ;; Now define ways of moving data around.
8055
8056 ;; Elf specific ways of loading addresses for non-PIC code.
8057 ;; The output of this could be r0, but we make a very strong
8058 ;; preference for a base register because it will usually
8059 ;; be needed there.
8060 (define_insn "elf_high"
8061   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
8062         (high:SI (match_operand 1 "" "")))]
8063   "TARGET_ELF && ! TARGET_64BIT"
8064   "{liu|lis} %0,%1@ha")
8065
8066 (define_insn "elf_low"
8067   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8068         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
8069                    (match_operand 2 "" "")))]
8070    "TARGET_ELF && ! TARGET_64BIT"
8071    "@
8072     {cal|la} %0,%2@l(%1)
8073     {ai|addic} %0,%1,%K2")
8074
8075 ;; Mach-O PIC trickery.
8076 (define_insn "macho_high"
8077   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
8078         (high:SI (match_operand 1 "" "")))]
8079   "TARGET_MACHO && ! TARGET_64BIT"
8080   "{liu|lis} %0,ha16(%1)")
8081
8082 (define_insn "macho_low"
8083   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
8084         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
8085                    (match_operand 2 "" "")))]
8086    "TARGET_MACHO && ! TARGET_64BIT"
8087    "@
8088     {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
8089     {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
8090
8091 ;; Set up a register with a value from the GOT table
8092
8093 (define_expand "movsi_got"
8094   [(set (match_operand:SI 0 "gpc_reg_operand" "")
8095         (unspec:SI [(match_operand:SI 1 "got_operand" "")
8096                     (match_dup 2)] 8))]
8097   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
8098   "
8099 {
8100   if (GET_CODE (operands[1]) == CONST)
8101     {
8102       rtx offset = const0_rtx;
8103       HOST_WIDE_INT value;
8104
8105       operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
8106       value = INTVAL (offset);
8107       if (value != 0)
8108         {
8109           rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
8110           emit_insn (gen_movsi_got (tmp, operands[1]));
8111           emit_insn (gen_addsi3 (operands[0], tmp, offset));
8112           DONE;
8113         }
8114     }
8115
8116   operands[2] = rs6000_got_register (operands[1]);
8117 }")
8118
8119 (define_insn "*movsi_got_internal"
8120   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8121         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
8122                     (match_operand:SI 2 "gpc_reg_operand" "b")] 8))]
8123   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
8124   "{l|lwz} %0,%a1@got(%2)"
8125   [(set_attr "type" "load")])
8126
8127 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
8128 ;; didn't get allocated to a hard register.
8129 (define_split 
8130   [(set (match_operand:SI 0 "gpc_reg_operand" "")
8131         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
8132                     (match_operand:SI 2 "memory_operand" "")] 8))]
8133   "DEFAULT_ABI == ABI_V4
8134     && flag_pic == 1
8135     && (reload_in_progress || reload_completed)"
8136   [(set (match_dup 0) (match_dup 2))
8137    (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)] 8))]
8138   "")
8139
8140 ;; For SI, we special-case integers that can't be loaded in one insn.  We
8141 ;; do the load 16-bits at a time.  We could do this by loading from memory,
8142 ;; and this is even supposed to be faster, but it is simpler not to get
8143 ;; integers in the TOC.
8144 (define_expand "movsi"
8145   [(set (match_operand:SI 0 "general_operand" "")
8146         (match_operand:SI 1 "any_operand" ""))]
8147   ""
8148   "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
8149
8150 (define_insn "movsi_low"
8151   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8152         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
8153                            (match_operand 2 "" ""))))]
8154   "TARGET_MACHO && ! TARGET_64BIT"
8155   "{l|lwz} %0,lo16(%2)(%1)"
8156   [(set_attr "type" "load")
8157    (set_attr "length" "4")])
8158
8159 (define_insn "movsi_low_st"
8160   [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
8161                            (match_operand 2 "" "")))
8162         (match_operand:SI 0 "gpc_reg_operand" "r"))]
8163   "TARGET_MACHO && ! TARGET_64BIT"
8164   "{st|stw} %0,lo16(%2)(%1)"
8165   [(set_attr "type" "store")
8166    (set_attr "length" "4")])
8167
8168 (define_insn "movdf_low"
8169   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
8170         (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
8171                            (match_operand 2 "" ""))))]
8172   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
8173   "*
8174 {
8175   switch (which_alternative)
8176     {
8177       case 0:
8178         return \"lfd %0,lo16(%2)(%1)\";
8179       case 1:
8180         {
8181           rtx operands2[4];
8182           operands2[0] = operands[0];
8183           operands2[1] = operands[1];
8184           operands2[2] = operands[2];
8185           operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
8186           output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
8187           /* We cannot rely on ha16(low half)==ha16(high half), alas,
8188              although in practice it almost always is.  */
8189           output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
8190           return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
8191         }
8192       default:
8193         abort();
8194     }
8195 }"
8196   [(set_attr "type" "load")
8197    (set_attr "length" "4,12")])
8198
8199 (define_insn "movdf_low_st"
8200   [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
8201                            (match_operand 2 "" "")))
8202         (match_operand:DF 0 "gpc_reg_operand" "f"))]
8203   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
8204   "stfd %0,lo16(%2)(%1)"
8205   [(set_attr "type" "store")
8206    (set_attr "length" "4")])
8207
8208 (define_insn "movsf_low"
8209   [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
8210         (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
8211                            (match_operand 2 "" ""))))]
8212   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
8213   "@
8214    lfs %0,lo16(%2)(%1)
8215    {l|lwz} %0,lo16(%2)(%1)"
8216   [(set_attr "type" "load")
8217    (set_attr "length" "4")])
8218
8219 (define_insn "movsf_low_st"
8220   [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
8221                            (match_operand 2 "" "")))
8222         (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
8223   "TARGET_MACHO && TARGET_HARD_FLOAT && TARGET_FPRS && ! TARGET_64BIT"
8224   "@
8225    stfs %0,lo16(%2)(%1)
8226    {st|stw} %0,lo16(%2)(%1)"
8227   [(set_attr "type" "store")
8228    (set_attr "length" "4")])
8229
8230 (define_insn "*movsi_internal1"
8231   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
8232         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
8233   "gpc_reg_operand (operands[0], SImode)
8234    || gpc_reg_operand (operands[1], SImode)"
8235   "@
8236    mr %0,%1
8237    {cal|la} %0,%a1
8238    {l%U1%X1|lwz%U1%X1} %0,%1
8239    {st%U0%X0|stw%U0%X0} %1,%0
8240    {lil|li} %0,%1
8241    {liu|lis} %0,%v1
8242    #
8243    {cal|la} %0,%a1
8244    mf%1 %0
8245    mt%0 %1
8246    mt%0 %1
8247    mt%0 %1
8248    {cror 0,0,0|nop}"
8249   [(set_attr "type" "*,*,load,store,*,*,*,*,*,*,mtjmpr,*,*")
8250    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
8251
8252 ;; Split a load of a large constant into the appropriate two-insn
8253 ;; sequence.
8254
8255 (define_split
8256   [(set (match_operand:SI 0 "gpc_reg_operand" "")
8257         (match_operand:SI 1 "const_int_operand" ""))]
8258   "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
8259    && (INTVAL (operands[1]) & 0xffff) != 0"
8260   [(set (match_dup 0)
8261         (match_dup 2))
8262    (set (match_dup 0)
8263         (ior:SI (match_dup 0)
8264                 (match_dup 3)))]
8265   "
8266 { rtx tem = rs6000_emit_set_const (operands[0], SImode, operands[1], 2);
8267
8268   if (tem == operands[0])
8269     DONE;
8270   else
8271     FAIL;
8272 }")
8273
8274 (define_insn "*movsi_internal2"
8275   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
8276         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r,r")
8277                     (const_int 0)))
8278    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
8279   "! TARGET_POWERPC64"
8280   "@
8281    mr. %0,%1
8282    #"
8283   [(set_attr "type" "compare")
8284    (set_attr "length" "4,8")])
8285 \f
8286 (define_split
8287   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8288         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
8289                     (const_int 0)))
8290    (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
8291   "! TARGET_POWERPC64 && reload_completed"
8292   [(set (match_dup 0) (match_dup 1))
8293    (set (match_dup 2)
8294         (compare:CC (match_dup 0)
8295                     (const_int 0)))]
8296   "")
8297
8298 (define_expand "movhi"
8299   [(set (match_operand:HI 0 "general_operand" "")
8300         (match_operand:HI 1 "any_operand" ""))]
8301   ""
8302   "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
8303
8304 (define_insn "*movhi_internal"
8305   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8306         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
8307   "gpc_reg_operand (operands[0], HImode)
8308    || gpc_reg_operand (operands[1], HImode)"
8309   "@
8310    mr %0,%1
8311    lhz%U1%X1 %0,%1
8312    sth%U0%X0 %1,%0
8313    {lil|li} %0,%w1
8314    mf%1 %0
8315    mt%0 %1
8316    mt%0 %1
8317    {cror 0,0,0|nop}"
8318   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
8319
8320 (define_expand "movqi"
8321   [(set (match_operand:QI 0 "general_operand" "")
8322         (match_operand:QI 1 "any_operand" ""))]
8323   ""
8324   "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
8325
8326 (define_insn "*movqi_internal"
8327   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
8328         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
8329   "gpc_reg_operand (operands[0], QImode)
8330    || gpc_reg_operand (operands[1], QImode)"
8331   "@
8332    mr %0,%1
8333    lbz%U1%X1 %0,%1
8334    stb%U0%X0 %1,%0
8335    {lil|li} %0,%1
8336    mf%1 %0
8337    mt%0 %1
8338    mt%0 %1
8339    {cror 0,0,0|nop}"
8340   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
8341 \f
8342 ;; Here is how to move condition codes around.  When we store CC data in
8343 ;; an integer register or memory, we store just the high-order 4 bits.
8344 ;; This lets us not shift in the most common case of CR0.
8345 (define_expand "movcc"
8346   [(set (match_operand:CC 0 "nonimmediate_operand" "")
8347         (match_operand:CC 1 "nonimmediate_operand" ""))]
8348   ""
8349   "")
8350
8351 (define_insn "*movcc_internal1"
8352   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
8353         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
8354   "register_operand (operands[0], CCmode)
8355    || register_operand (operands[1], CCmode)"
8356   "@
8357    mcrf %0,%1
8358    mtcrf 128,%1
8359    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
8360    mfcr %0
8361    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
8362    mr %0,%1
8363    {l%U1%X1|lwz%U1%X1} %0,%1
8364    {st%U0%U1|stw%U0%U1} %1,%0"
8365   [(set_attr "type" "cr_logical,cr_logical,cr_logical,cr_logical,cr_logical,*,load,store")
8366    (set_attr "length" "*,*,12,*,8,*,*,*")])
8367 \f
8368 ;; For floating-point, we normally deal with the floating-point registers
8369 ;; unless -msoft-float is used.  The sole exception is that parameter passing
8370 ;; can produce floating-point values in fixed-point registers.  Unless the
8371 ;; value is a simple constant or already in memory, we deal with this by
8372 ;; allocating memory and copying the value explicitly via that memory location.
8373 (define_expand "movsf"
8374   [(set (match_operand:SF 0 "nonimmediate_operand" "")
8375         (match_operand:SF 1 "any_operand" ""))]
8376   ""
8377   "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
8378
8379 (define_split
8380   [(set (match_operand:SF 0 "gpc_reg_operand" "")
8381         (match_operand:SF 1 "const_double_operand" ""))]
8382   "reload_completed
8383    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8384        || (GET_CODE (operands[0]) == SUBREG
8385            && GET_CODE (SUBREG_REG (operands[0])) == REG
8386            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8387   [(set (match_dup 2) (match_dup 3))]
8388   "
8389 {
8390   long l;
8391   REAL_VALUE_TYPE rv;
8392
8393   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8394   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
8395
8396   if (! TARGET_POWERPC64)
8397     operands[2] = operand_subword (operands[0], 0, 0, SFmode);
8398   else
8399     operands[2] = gen_lowpart (SImode, operands[0]);
8400
8401   operands[3] = gen_int_mode (l, SImode);
8402 }")
8403
8404 (define_insn "*movsf_hardfloat"
8405   [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!r,!r")
8406         (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,G,Fn"))]
8407   "(gpc_reg_operand (operands[0], SFmode)
8408    || gpc_reg_operand (operands[1], SFmode))
8409    && (TARGET_HARD_FLOAT && TARGET_FPRS)"
8410   "@
8411    mr %0,%1
8412    {l%U1%X1|lwz%U1%X1} %0,%1
8413    {st%U0%X0|stw%U0%X0} %1,%0
8414    fmr %0,%1
8415    lfs%U1%X1 %0,%1
8416    stfs%U0%X0 %1,%0
8417    #
8418    #"
8419   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*")
8420    (set_attr "length" "4,4,4,4,4,4,4,8")])
8421
8422 (define_insn "*movsf_softfloat"
8423   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,r")
8424         (match_operand:SF 1 "input_operand" "r,m,r,I,L,R,G,Fn"))]
8425   "(gpc_reg_operand (operands[0], SFmode)
8426    || gpc_reg_operand (operands[1], SFmode))
8427    && (TARGET_SOFT_FLOAT || !TARGET_FPRS)"
8428   "@
8429    mr %0,%1
8430    {l%U1%X1|lwz%U1%X1} %0,%1
8431    {st%U0%X0|stw%U0%X0} %1,%0
8432    {lil|li} %0,%1
8433    {liu|lis} %0,%v1
8434    {cal|la} %0,%a1
8435    #
8436    #"
8437   [(set_attr "type" "*,load,store,*,*,*,*,*")
8438    (set_attr "length" "4,4,4,4,4,4,4,8")])
8439
8440 \f
8441 (define_expand "movdf"
8442   [(set (match_operand:DF 0 "nonimmediate_operand" "")
8443         (match_operand:DF 1 "any_operand" ""))]
8444   ""
8445   "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
8446
8447 (define_split
8448   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8449         (match_operand:DF 1 "const_int_operand" ""))]
8450   "! TARGET_POWERPC64 && reload_completed
8451    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8452        || (GET_CODE (operands[0]) == SUBREG
8453            && GET_CODE (SUBREG_REG (operands[0])) == REG
8454            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8455   [(set (match_dup 2) (match_dup 4))
8456    (set (match_dup 3) (match_dup 1))]
8457   "
8458 {
8459   int endian = (WORDS_BIG_ENDIAN == 0);
8460   HOST_WIDE_INT value = INTVAL (operands[1]);
8461
8462   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8463   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8464 #if HOST_BITS_PER_WIDE_INT == 32
8465   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8466 #else
8467   operands[4] = GEN_INT (value >> 32);
8468   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8469 #endif
8470 }")
8471
8472 (define_split
8473   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8474         (match_operand:DF 1 "const_double_operand" ""))]
8475   "! TARGET_POWERPC64 && reload_completed
8476    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8477        || (GET_CODE (operands[0]) == SUBREG
8478            && GET_CODE (SUBREG_REG (operands[0])) == REG
8479            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8480   [(set (match_dup 2) (match_dup 4))
8481    (set (match_dup 3) (match_dup 5))]
8482   "
8483 {
8484   int endian = (WORDS_BIG_ENDIAN == 0);
8485   long l[2];
8486   REAL_VALUE_TYPE rv;
8487
8488   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8489   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8490
8491   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8492   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8493   operands[4] = gen_int_mode (l[endian], SImode);
8494   operands[5] = gen_int_mode (l[1 - endian], SImode);
8495 }")
8496
8497 (define_split
8498   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8499         (match_operand:DF 1 "easy_fp_constant" ""))]
8500   "TARGET_POWERPC64 && reload_completed
8501    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8502        || (GET_CODE (operands[0]) == SUBREG
8503            && GET_CODE (SUBREG_REG (operands[0])) == REG
8504            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8505   [(set (match_dup 2) (match_dup 3))]
8506   "
8507 {
8508   int endian = (WORDS_BIG_ENDIAN == 0);
8509   long l[2];
8510   REAL_VALUE_TYPE rv;
8511   HOST_WIDE_INT val;
8512
8513   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8514   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8515
8516   operands[2] = gen_lowpart (DImode, operands[0]);
8517   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
8518 #if HOST_BITS_PER_WIDE_INT >= 64
8519   val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32 |
8520         ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
8521
8522   operands[3] = immed_double_const (val, -(val < 0), DImode);
8523 #else
8524   operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
8525 #endif
8526 }")
8527
8528 ;; Don't have reload use general registers to load a constant.  First,
8529 ;; it might not work if the output operand is the equivalent of
8530 ;; a non-offsettable memref, but also it is less efficient than loading
8531 ;; the constant into an FP register, since it will probably be used there.
8532 ;; The "??" is a kludge until we can figure out a more reasonable way
8533 ;; of handling these non-offsettable values.
8534 (define_insn "*movdf_hardfloat32"
8535   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
8536         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
8537   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8538    && (gpc_reg_operand (operands[0], DFmode)
8539        || gpc_reg_operand (operands[1], DFmode))"
8540   "*
8541 {
8542   switch (which_alternative)
8543     {
8544     default:
8545       abort ();
8546     case 0:
8547       /* We normally copy the low-numbered register first.  However, if
8548          the first register operand 0 is the same as the second register
8549          of operand 1, we must copy in the opposite order.  */
8550       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8551         return \"mr %L0,%L1\;mr %0,%1\";
8552       else
8553         return \"mr %0,%1\;mr %L0,%L1\";
8554     case 1:
8555       if (offsettable_memref_p (operands[1])
8556           || (GET_CODE (operands[1]) == MEM
8557               && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8558                   || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
8559                   || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
8560         {
8561           /* If the low-address word is used in the address, we must load
8562              it last.  Otherwise, load it first.  Note that we cannot have
8563              auto-increment in that case since the address register is
8564              known to be dead.  */
8565           if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8566                                  operands[1], 0))
8567             return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8568           else
8569             return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8570         }
8571       else
8572         {
8573           rtx addreg;
8574
8575           addreg = find_addr_reg (XEXP (operands[1], 0));
8576           if (refers_to_regno_p (REGNO (operands[0]),
8577                                  REGNO (operands[0]) + 1,
8578                                  operands[1], 0))
8579             {
8580               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8581               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8582               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8583               return \"{lx|lwzx} %0,%1\";
8584             }
8585           else
8586             {
8587               output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
8588               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8589               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8590               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8591               return \"\";
8592             }
8593         }
8594     case 2:
8595       if (offsettable_memref_p (operands[0])
8596           || (GET_CODE (operands[0]) == MEM
8597               && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8598                   || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8599                   || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
8600         return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8601       else
8602         {
8603           rtx addreg;
8604
8605           addreg = find_addr_reg (XEXP (operands[0], 0));
8606           output_asm_insn (\"{stx|stwx} %1,%0\", operands);
8607           output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8608           output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
8609           output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8610           return \"\";
8611         }
8612     case 3:
8613     case 4:
8614     case 5:
8615       return \"#\";
8616     case 6:
8617       return \"fmr %0,%1\";
8618     case 7:
8619       return \"lfd%U1%X1 %0,%1\";
8620     case 8:
8621       return \"stfd%U0%X0 %1,%0\";
8622     }
8623 }"
8624   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8625    (set_attr "length" "8,16,16,8,12,16,*,*,*")])
8626
8627 (define_insn "*movdf_softfloat32"
8628   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8629         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8630   "! TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8631    && (gpc_reg_operand (operands[0], DFmode)
8632        || gpc_reg_operand (operands[1], DFmode))"
8633   "*
8634 {
8635   switch (which_alternative)
8636     {
8637     default:
8638       abort ();
8639     case 0:
8640       /* We normally copy the low-numbered register first.  However, if
8641          the first register operand 0 is the same as the second register of
8642          operand 1, we must copy in the opposite order.  */
8643       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8644         return \"mr %L0,%L1\;mr %0,%1\";
8645       else
8646         return \"mr %0,%1\;mr %L0,%L1\";
8647     case 1:
8648       /* If the low-address word is used in the address, we must load
8649          it last.  Otherwise, load it first.  Note that we cannot have
8650          auto-increment in that case since the address register is
8651          known to be dead.  */
8652       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8653                              operands[1], 0))
8654         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8655       else
8656         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8657     case 2:
8658       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8659     case 3:
8660     case 4:
8661     case 5:
8662       return \"#\";
8663     }
8664 }"
8665   [(set_attr "type" "*,load,store,*,*,*")
8666    (set_attr "length" "8,8,8,8,12,16")])
8667
8668 (define_insn "*movdf_hardfloat64"
8669   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
8670         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
8671   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && TARGET_FPRS
8672    && (gpc_reg_operand (operands[0], DFmode)
8673        || gpc_reg_operand (operands[1], DFmode))"
8674   "@
8675    mr %0,%1
8676    ld%U1%X1 %0,%1
8677    std%U0%X0 %1,%0
8678    #
8679    #
8680    #
8681    fmr %0,%1
8682    lfd%U1%X1 %0,%1
8683    stfd%U0%X0 %1,%0"
8684   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8685    (set_attr "length" "4,4,4,8,12,16,4,4,4")])
8686
8687 (define_insn "*movdf_softfloat64"
8688   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8689         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8690   "TARGET_POWERPC64 && (TARGET_SOFT_FLOAT || !TARGET_FPRS)
8691    && (gpc_reg_operand (operands[0], DFmode)
8692        || gpc_reg_operand (operands[1], DFmode))"
8693   "@
8694    mr %0,%1
8695    ld%U1%X1 %0,%1
8696    std%U0%X0 %1,%0
8697    #
8698    #
8699    #"
8700   [(set_attr "type" "*,load,store,*,*,*")
8701    (set_attr "length" "*,*,*,8,12,16")])
8702 \f
8703 (define_expand "movtf"
8704   [(set (match_operand:TF 0 "general_operand" "")
8705         (match_operand:TF 1 "any_operand" ""))]
8706   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8707    && TARGET_LONG_DOUBLE_128"
8708   "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8709
8710 (define_insn "*movtf_internal"
8711   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
8712         (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
8713   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8714    && TARGET_LONG_DOUBLE_128
8715    && (gpc_reg_operand (operands[0], TFmode)
8716        || gpc_reg_operand (operands[1], TFmode))"
8717   "*
8718 {
8719   switch (which_alternative)
8720     {
8721     default:
8722       abort ();
8723     case 0:
8724       /* We normally copy the low-numbered register first.  However, if
8725          the first register operand 0 is the same as the second register of
8726          operand 1, we must copy in the opposite order.  */
8727       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8728         return \"fmr %L0,%L1\;fmr %0,%1\";
8729       else
8730         return \"fmr %0,%1\;fmr %L0,%L1\";
8731     case 1:
8732       return \"lfd %0,%1\;lfd %L0,%L1\";
8733     case 2:
8734       return \"stfd %1,%0\;stfd %L1,%L0\";
8735     case 3:
8736     case 4:
8737     case 5:
8738       return \"#\";
8739     }
8740 }"
8741   [(set_attr "type" "fp,fpload,fpstore,*,*,*")
8742    (set_attr "length" "8,8,8,12,16,20")])
8743
8744 (define_split
8745   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8746         (match_operand:TF 1 "const_double_operand" ""))]
8747   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8748    && TARGET_LONG_DOUBLE_128"
8749   [(set (match_dup 3) (match_dup 1))
8750    (set (match_dup 0)
8751         (float_extend:TF (match_dup 3)))]
8752   "
8753 {
8754   operands[2] = operand_subword (operands[1], 0, 0, DFmode);
8755   operands[3] = gen_reg_rtx (DFmode);
8756 }")
8757
8758 (define_insn_and_split "extenddftf2"
8759   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8760         (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
8761   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8762    && TARGET_LONG_DOUBLE_128"
8763   "#"
8764   ""
8765   [(set (match_dup 2) (match_dup 3))]
8766   "
8767 {
8768   operands[2] = gen_rtx_REG (DFmode, REGNO (operands[0] + 1));
8769   operands[3] = CONST0_RTX (DFmode);
8770 }")
8771
8772 (define_insn_and_split "extendsftf2"
8773   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8774         (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
8775   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8776    && TARGET_LONG_DOUBLE_128"
8777   "#"
8778   ""
8779   [(set (match_dup 2) (match_dup 3))]
8780   "
8781 {
8782   operands[2] = gen_rtx_REG (SFmode, REGNO (operands[0] + 1));
8783   operands[3] = CONST0_RTX (SFmode);
8784 }")
8785
8786 (define_insn "trunctfdf2"
8787   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8788         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8789   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8790    && TARGET_LONG_DOUBLE_128"
8791   "fadd %0,%1,%L1"
8792   [(set_attr "type" "fp")
8793    (set_attr "length" "8")])
8794
8795 (define_insn_and_split "trunctfsf2"
8796   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8797         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8798    (clobber (match_scratch:DF 2 "=f"))]
8799   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
8800    && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8801   "#"
8802   "&& reload_completed"
8803   [(set (match_dup 2)
8804         (float_truncate:DF (match_dup 1)))
8805    (set (match_dup 0)
8806         (float_truncate:SF (match_dup 2)))]
8807   "")
8808
8809 (define_insn_and_split "floatditf2"
8810   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8811         (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
8812    (clobber (match_scratch:DF 2 "=f"))]
8813   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8814    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8815   "#"
8816   "&& reload_completed"
8817   [(set (match_dup 2)
8818         (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))
8819    (set (match_operand:TF 0 "gpc_reg_operand" "")
8820         (float_extend:TF (match_dup 2)))]
8821   "")
8822
8823 (define_insn_and_split "floatsitf2"
8824   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8825         (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))
8826    (clobber (match_scratch:DF 2 "=f"))]
8827   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8828    && TARGET_LONG_DOUBLE_128"
8829   "#"
8830   "&& reload_completed"
8831   [(set (match_dup 2)
8832         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
8833    (set (match_operand:TF 0 "gpc_reg_operand" "")
8834         (float_extend:TF (match_dup 2)))]
8835   "")
8836
8837 (define_insn_and_split "fix_trunctfdi2"
8838   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
8839         (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))]
8840   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8841    && TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
8842   "#"
8843   "&& reload_completed"
8844   [(set (match_dup 2)
8845         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8846    (set (match_operand:DI 0 "gpc_reg_operand" "")
8847         (fix:SI (match_dup 2)))]
8848   "")
8849
8850 (define_insn_and_split "fix_trunctfsi2"
8851   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8852         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))]
8853   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8854    && TARGET_LONG_DOUBLE_128"
8855   "#"
8856   "&& reload_completed"
8857   [(set (match_dup 2)
8858         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8859    (set (match_operand:SI 0 "gpc_reg_operand" "")
8860         (fix:SI (match_dup 2)))]
8861   "")
8862
8863 (define_insn "negtf2"
8864   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8865         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8866   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8867    && TARGET_LONG_DOUBLE_128"
8868   "*
8869 {
8870   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8871     return \"fneg %L0,%L1\;fneg %0,%1\";
8872   else
8873     return \"fneg %0,%1\;fneg %L0,%L1\";
8874 }"
8875   [(set_attr "type" "fp")
8876    (set_attr "length" "8")])
8877
8878 (define_insn "abstf2"
8879   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8880         (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8881   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8882    && TARGET_LONG_DOUBLE_128"
8883   "*
8884 {
8885   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8886     return \"fabs %L0,%L1\;fabs %0,%1\";
8887   else
8888     return \"fabs %0,%1\;fabs %L0,%L1\";
8889 }"
8890   [(set_attr "type" "fp")
8891    (set_attr "length" "8")])
8892
8893 (define_insn ""
8894   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8895         (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
8896   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
8897    && TARGET_LONG_DOUBLE_128"
8898   "*
8899 {
8900   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8901     return \"fnabs %L0,%L1\;fnabs %0,%1\";
8902   else
8903     return \"fnabs %0,%1\;fnabs %L0,%L1\";
8904 }"
8905   [(set_attr "type" "fp")
8906    (set_attr "length" "8")])
8907 \f
8908 ;; Next come the multi-word integer load and store and the load and store
8909 ;; multiple insns.
8910 (define_expand "movdi"
8911   [(set (match_operand:DI 0 "general_operand" "")
8912         (match_operand:DI 1 "any_operand" ""))]
8913   ""
8914   "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
8915
8916 (define_insn "*movdi_internal32"
8917   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
8918         (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
8919   "! TARGET_POWERPC64
8920    && (gpc_reg_operand (operands[0], DImode)
8921        || gpc_reg_operand (operands[1], DImode))"
8922   "*
8923 {
8924   switch (which_alternative)
8925     {
8926     default:
8927       abort ();
8928     case 0:
8929       /* We normally copy the low-numbered register first.  However, if
8930          the first register operand 0 is the same as the second register of
8931          operand 1, we must copy in the opposite order.  */
8932       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8933         return \"mr %L0,%L1\;mr %0,%1\";
8934       else
8935         return \"mr %0,%1\;mr %L0,%L1\";
8936     case 1:
8937       /* If the low-address word is used in the address, we must load it
8938          last.  Otherwise, load it first.  Note that we cannot have
8939          auto-increment in that case since the address register is known to be
8940          dead.  */
8941       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8942                              operands[1], 0))
8943         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8944       else
8945         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8946     case 2:
8947       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8948     case 3:
8949       return \"fmr %0,%1\";
8950     case 4:
8951       return \"lfd%U1%X1 %0,%1\";
8952     case 5:
8953       return \"stfd%U0%X0 %1,%0\";
8954     case 6:
8955     case 7:
8956     case 8:
8957     case 9:
8958     case 10:
8959       return \"#\";
8960     }
8961 }"
8962   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
8963    (set_attr "length" "8,8,8,*,*,*,8,12,8,12,16")])
8964
8965 (define_split
8966   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8967         (match_operand:DI 1 "const_int_operand" ""))]
8968   "! TARGET_POWERPC64 && reload_completed"
8969   [(set (match_dup 2) (match_dup 4))
8970    (set (match_dup 3) (match_dup 1))]
8971   "
8972 {
8973   HOST_WIDE_INT value = INTVAL (operands[1]);
8974   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8975                                        DImode);
8976   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8977                                        DImode);
8978 #if HOST_BITS_PER_WIDE_INT == 32
8979   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8980 #else
8981   operands[4] = GEN_INT (value >> 32);
8982   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8983 #endif
8984 }")
8985
8986 (define_split
8987   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8988         (match_operand:DI 1 "const_double_operand" ""))]
8989   "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
8990   [(set (match_dup 2) (match_dup 4))
8991    (set (match_dup 3) (match_dup 5))]
8992   "
8993 {
8994   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8995                                        DImode);
8996   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8997                                        DImode);
8998   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8999   operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
9000 }")
9001
9002 (define_insn "*movdi_internal64"
9003   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,f,f,m,r,*h,*h")
9004         (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
9005   "TARGET_POWERPC64
9006    && (gpc_reg_operand (operands[0], DImode)
9007        || gpc_reg_operand (operands[1], DImode))"
9008   "@
9009    mr %0,%1
9010    ld%U1%X1 %0,%1
9011    std%U0%X0 %1,%0
9012    li %0,%1
9013    lis %0,%v1
9014    #
9015    {cal|la} %0,%a1
9016    fmr %0,%1
9017    lfd%U1%X1 %0,%1
9018    stfd%U0%X0 %1,%0
9019    mf%1 %0
9020    mt%0 %1
9021    {cror 0,0,0|nop}"
9022   [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
9023    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
9024
9025 ;; immediate value valid for a single instruction hiding in a const_double
9026 (define_insn ""
9027   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9028         (match_operand:DI 1 "const_double_operand" "F"))]
9029   "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
9030    && GET_CODE (operands[1]) == CONST_DOUBLE
9031    && num_insns_constant (operands[1], DImode) == 1"
9032   "*
9033 {
9034   return ((unsigned HOST_WIDE_INT)
9035           (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
9036          ? \"li %0,%1\" : \"lis %0,%v1\";
9037 }")
9038
9039 ;; Generate all one-bits and clear left or right.
9040 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
9041 (define_split
9042   [(set (match_operand:DI 0 "gpc_reg_operand" "")
9043         (match_operand:DI 1 "mask64_operand" ""))]
9044   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9045   [(set (match_dup 0) (const_int -1))
9046    (set (match_dup 0)
9047         (and:DI (rotate:DI (match_dup 0)
9048                            (const_int 0))
9049                 (match_dup 1)))]
9050   "")
9051
9052 ;; Split a load of a large constant into the appropriate five-instruction
9053 ;; sequence.  Handle anything in a constant number of insns.
9054 ;; When non-easy constants can go in the TOC, this should use
9055 ;; easy_fp_constant predicate.
9056 (define_split
9057   [(set (match_operand:DI 0 "gpc_reg_operand" "")
9058         (match_operand:DI 1 "const_int_operand" ""))]
9059   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9060   [(set (match_dup 0) (match_dup 2))
9061    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9062   "
9063 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9064
9065   if (tem == operands[0])
9066     DONE;
9067   else
9068     FAIL;
9069 }")
9070
9071 (define_split
9072   [(set (match_operand:DI 0 "gpc_reg_operand" "")
9073         (match_operand:DI 1 "const_double_operand" ""))]
9074   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
9075   [(set (match_dup 0) (match_dup 2))
9076    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
9077   "
9078 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
9079
9080   if (tem == operands[0])
9081     DONE;
9082   else
9083     FAIL;
9084 }")
9085
9086 ;; Split a load of a large constant into the appropriate five-instruction
9087 (define_insn "*movdi_internal2"
9088   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
9089         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r,r")
9090                     (const_int 0)))
9091    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
9092   "TARGET_POWERPC64"
9093   "@
9094    mr. %0,%1
9095    #"
9096   [(set_attr "type" "compare")
9097    (set_attr "length" "4,8")])
9098
9099 (define_split
9100   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
9101         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
9102                     (const_int 0)))
9103    (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
9104   "TARGET_POWERPC64 && reload_completed"
9105   [(set (match_dup 0) (match_dup 1))
9106    (set (match_dup 2)
9107         (compare:CC (match_dup 0)
9108                     (const_int 0)))]
9109   "")
9110 \f
9111 ;; TImode is similar, except that we usually want to compute the address into
9112 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
9113 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
9114 (define_expand "movti"
9115   [(parallel [(set (match_operand:TI 0 "general_operand" "")
9116                    (match_operand:TI 1 "general_operand" ""))
9117               (clobber (scratch:SI))])]
9118   "TARGET_STRING || TARGET_POWERPC64"
9119   "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
9120
9121 ;; We say that MQ is clobbered in the last alternative because the first
9122 ;; alternative would never get used otherwise since it would need a reload
9123 ;; while the 2nd alternative would not.  We put memory cases first so they
9124 ;; are preferred.  Otherwise, we'd try to reload the output instead of
9125 ;; giving the SCRATCH mq.
9126 (define_insn "*movti_power"
9127   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
9128         (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
9129    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
9130   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9131    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
9132   "*
9133 {
9134   switch (which_alternative)
9135     {
9136     default:
9137       abort ();
9138
9139     case 0:
9140       return \"{stsi|stswi} %1,%P0,16\";
9141
9142     case 1:
9143       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
9144
9145     case 2:
9146       /* Normally copy registers with lowest numbered register copied first.
9147          But copy in the other order if the first register of the output
9148          is the second, third, or fourth register in the input.  */
9149       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
9150           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
9151         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
9152       else
9153         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
9154     case 3:
9155       /* If the address is not used in the output, we can use lsi.  Otherwise,
9156          fall through to generating four loads.  */
9157       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
9158         return \"{lsi|lswi} %0,%P1,16\";
9159       /* ... fall through ...  */
9160     case 4:
9161       /* If the address register is the same as the register for the lowest-
9162          addressed word, load it last.  Similarly for the next two words.
9163          Otherwise load lowest address to highest.  */
9164       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
9165                              operands[1], 0))
9166         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
9167       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
9168                                   REGNO (operands[0]) + 2, operands[1], 0))
9169         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
9170       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
9171                                   REGNO (operands[0]) + 3, operands[1], 0))
9172         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
9173       else
9174         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
9175     }
9176 }"
9177   [(set_attr "type" "store,store,*,load,load")
9178    (set_attr "length" "*,16,16,*,16")])
9179
9180 (define_insn "*movti_string"
9181   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
9182         (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
9183    (clobber (match_scratch:SI 2 "=X,X,X"))]
9184   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9185    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
9186   "*
9187 {
9188   switch (which_alternative)
9189     {
9190     default:
9191       abort ();
9192
9193     case 0:
9194       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
9195
9196     case 1:
9197       /* Normally copy registers with lowest numbered register copied first.
9198          But copy in the other order if the first register of the output
9199          is the second, third, or fourth register in the input.  */
9200       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
9201           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
9202         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
9203       else
9204         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
9205     case 2:
9206       /* If the address register is the same as the register for the lowest-
9207          addressed word, load it last.  Similarly for the next two words.
9208          Otherwise load lowest address to highest.  */
9209       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
9210                              operands[1], 0))
9211         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
9212       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
9213                                   REGNO (operands[0]) + 2, operands[1], 0))
9214         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
9215       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
9216                                   REGNO (operands[0]) + 3, operands[1], 0))
9217         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
9218       else
9219         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
9220     }
9221 }"
9222   [(set_attr "type" "store,*,load")
9223    (set_attr "length" "16,16,16")])
9224
9225 (define_insn "*movti_ppc64"
9226   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
9227         (match_operand:TI 1 "input_operand" "r,m,r"))]
9228   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
9229    || gpc_reg_operand (operands[1], TImode))"
9230   "*
9231 {
9232   switch (which_alternative)
9233     {
9234     default:
9235       abort ();
9236     case 0:
9237       /* We normally copy the low-numbered register first.  However, if
9238          the first register operand 0 is the same as the second register of
9239          operand 1, we must copy in the opposite order.  */
9240       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
9241         return \"mr %L0,%L1\;mr %0,%1\";
9242       else
9243         return \"mr %0,%1\;mr %L0,%L1\";
9244     case 1:
9245       /* If the low-address word is used in the address, we must load it
9246          last.  Otherwise, load it first.  Note that we cannot have
9247          auto-increment in that case since the address register is known to be
9248          dead.  */
9249       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
9250                              operands[1], 0))
9251         return \"ld %L0,%L1\;ld %0,%1\";
9252       else
9253         return \"ld%U1 %0,%1\;ld %L0,%L1\";
9254     case 2:
9255       return \"std%U0 %1,%0\;std %L1,%L0\";
9256     }
9257 }"
9258   [(set_attr "type" "*,load,store")
9259    (set_attr "length" "8,8,8")])
9260 \f
9261 (define_expand "load_multiple"
9262   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9263                           (match_operand:SI 1 "" ""))
9264                      (use (match_operand:SI 2 "" ""))])]
9265   "TARGET_STRING && !TARGET_POWERPC64"
9266   "
9267 {
9268   int regno;
9269   int count;
9270   rtx op1;
9271   int i;
9272
9273   /* Support only loading a constant number of fixed-point registers from
9274      memory and only bother with this if more than two; the machine
9275      doesn't support more than eight.  */
9276   if (GET_CODE (operands[2]) != CONST_INT
9277       || INTVAL (operands[2]) <= 2
9278       || INTVAL (operands[2]) > 8
9279       || GET_CODE (operands[1]) != MEM
9280       || GET_CODE (operands[0]) != REG
9281       || REGNO (operands[0]) >= 32)
9282     FAIL;
9283
9284   count = INTVAL (operands[2]);
9285   regno = REGNO (operands[0]);
9286
9287   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
9288   op1 = replace_equiv_address (operands[1],
9289                                force_reg (SImode, XEXP (operands[1], 0)));
9290
9291   for (i = 0; i < count; i++)
9292     XVECEXP (operands[3], 0, i)
9293       = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
9294                      adjust_address (op1, SImode, i * 4));
9295 }")
9296
9297 (define_insn ""
9298   [(match_parallel 0 "load_multiple_operation"
9299                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
9300                          (mem:SI (match_operand:SI 2 "gpc_reg_operand" "b")))])]
9301   "TARGET_STRING"
9302   "*
9303 {
9304   /* We have to handle the case where the pseudo used to contain the address
9305      is assigned to one of the output registers.  */
9306   int i, j;
9307   int words = XVECLEN (operands[0], 0);
9308   rtx xop[10];
9309
9310   if (XVECLEN (operands[0], 0) == 1)
9311     return \"{l|lwz} %1,0(%2)\";
9312
9313   for (i = 0; i < words; i++)
9314     if (refers_to_regno_p (REGNO (operands[1]) + i,
9315                            REGNO (operands[1]) + i + 1, operands[2], 0))
9316       {
9317         if (i == words-1)
9318           {
9319             xop[0] = operands[1];
9320             xop[1] = operands[2];
9321             xop[2] = GEN_INT (4 * (words-1));
9322             output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
9323             return \"\";
9324           }
9325         else if (i == 0)
9326           {
9327             xop[0] = operands[1];
9328             xop[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
9329             xop[2] = GEN_INT (4 * (words-1));
9330             output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
9331             return \"\";
9332           }
9333         else
9334           {
9335             for (j = 0; j < words; j++)
9336               if (j != i)
9337                 {
9338                   xop[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + j);
9339                   xop[1] = operands[2];
9340                   xop[2] = GEN_INT (j * 4);
9341                   output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
9342                 }
9343             xop[0] = operands[2];
9344             xop[1] = GEN_INT (i * 4);
9345             output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
9346             return \"\";
9347           }
9348       }
9349
9350   return \"{lsi|lswi} %1,%2,%N0\";
9351 }"
9352   [(set_attr "type" "load")
9353    (set_attr "length" "32")])
9354
9355 \f
9356 (define_expand "store_multiple"
9357   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
9358                           (match_operand:SI 1 "" ""))
9359                      (clobber (scratch:SI))
9360                      (use (match_operand:SI 2 "" ""))])]
9361   "TARGET_STRING && !TARGET_POWERPC64"
9362   "
9363 {
9364   int regno;
9365   int count;
9366   rtx to;
9367   rtx op0;
9368   int i;
9369
9370   /* Support only storing a constant number of fixed-point registers to
9371      memory and only bother with this if more than two; the machine
9372      doesn't support more than eight.  */
9373   if (GET_CODE (operands[2]) != CONST_INT
9374       || INTVAL (operands[2]) <= 2
9375       || INTVAL (operands[2]) > 8
9376       || GET_CODE (operands[0]) != MEM
9377       || GET_CODE (operands[1]) != REG
9378       || REGNO (operands[1]) >= 32)
9379     FAIL;
9380
9381   count = INTVAL (operands[2]);
9382   regno = REGNO (operands[1]);
9383
9384   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
9385   to = force_reg (SImode, XEXP (operands[0], 0));
9386   op0 = replace_equiv_address (operands[0], to);
9387
9388   XVECEXP (operands[3], 0, 0)
9389     = gen_rtx_SET (VOIDmode, adjust_address (op0, SImode, 0), operands[1]);
9390   XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
9391                                                  gen_rtx_SCRATCH (SImode));
9392
9393   for (i = 1; i < count; i++)
9394     XVECEXP (operands[3], 0, i + 1)
9395       = gen_rtx_SET (VOIDmode,
9396                      adjust_address (op0, SImode, i * 4),
9397                      gen_rtx_REG (SImode, regno + i));
9398 }")
9399
9400 (define_insn ""
9401   [(match_parallel 0 "store_multiple_operation"
9402                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
9403                          (match_operand:SI 2 "gpc_reg_operand" "r"))
9404                     (clobber (match_scratch:SI 3 "=q"))])]
9405   "TARGET_STRING && TARGET_POWER"
9406   "{stsi|stswi} %2,%P1,%O0"
9407   [(set_attr "type" "store")])
9408
9409 (define_insn ""
9410   [(match_parallel 0 "store_multiple_operation"
9411                    [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
9412                          (match_operand:SI 2 "gpc_reg_operand" "r"))
9413                     (clobber (match_scratch:SI 3 "X"))])]
9414   "TARGET_STRING && ! TARGET_POWER"
9415   "{stsi|stswi} %2,%1,%O0"
9416   [(set_attr "type" "store")])
9417
9418 \f
9419 ;; String/block move insn.
9420 ;; Argument 0 is the destination
9421 ;; Argument 1 is the source
9422 ;; Argument 2 is the length
9423 ;; Argument 3 is the alignment
9424
9425 (define_expand "movstrsi"
9426   [(parallel [(set (match_operand:BLK 0 "" "")
9427                    (match_operand:BLK 1 "" ""))
9428               (use (match_operand:SI 2 "" ""))
9429               (use (match_operand:SI 3 "" ""))])]
9430   ""
9431   "
9432 {
9433   if (expand_block_move (operands))
9434     DONE;
9435   else
9436     FAIL;
9437 }")
9438
9439 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
9440 ;; register allocator doesn't have a clue about allocating 8 word registers.
9441 ;; rD/rS = r5 is preferred, efficient form.
9442 (define_expand "movstrsi_8reg"
9443   [(parallel [(set (match_operand 0 "" "")
9444                    (match_operand 1 "" ""))
9445               (use (match_operand 2 "" ""))
9446               (use (match_operand 3 "" ""))
9447               (clobber (reg:SI  5))
9448               (clobber (reg:SI  6))
9449               (clobber (reg:SI  7))
9450               (clobber (reg:SI  8))
9451               (clobber (reg:SI  9))
9452               (clobber (reg:SI 10))
9453               (clobber (reg:SI 11))
9454               (clobber (reg:SI 12))
9455               (clobber (match_scratch:SI 4 ""))])]
9456   "TARGET_STRING"
9457   "")
9458
9459 (define_insn ""
9460   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9461         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9462    (use (match_operand:SI 2 "immediate_operand" "i"))
9463    (use (match_operand:SI 3 "immediate_operand" "i"))
9464    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9465    (clobber (reg:SI  6))
9466    (clobber (reg:SI  7))
9467    (clobber (reg:SI  8))
9468    (clobber (reg:SI  9))
9469    (clobber (reg:SI 10))
9470    (clobber (reg:SI 11))
9471    (clobber (reg:SI 12))
9472    (clobber (match_scratch:SI 5 "=q"))]
9473   "TARGET_STRING && TARGET_POWER
9474    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9475        || INTVAL (operands[2]) == 0)
9476    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9477    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9478    && REGNO (operands[4]) == 5"
9479   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9480   [(set_attr "type" "load")
9481    (set_attr "length" "8")])
9482
9483 (define_insn ""
9484   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9485         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9486    (use (match_operand:SI 2 "immediate_operand" "i"))
9487    (use (match_operand:SI 3 "immediate_operand" "i"))
9488    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9489    (clobber (reg:SI  6))
9490    (clobber (reg:SI  7))
9491    (clobber (reg:SI  8))
9492    (clobber (reg:SI  9))
9493    (clobber (reg:SI 10))
9494    (clobber (reg:SI 11))
9495    (clobber (reg:SI 12))
9496    (clobber (match_scratch:SI 5 "X"))]
9497   "TARGET_STRING && ! TARGET_POWER
9498    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9499        || INTVAL (operands[2]) == 0)
9500    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9501    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9502    && REGNO (operands[4]) == 5"
9503   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9504   [(set_attr "type" "load")
9505    (set_attr "length" "8")])
9506
9507 (define_insn ""
9508   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9509         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9510    (use (match_operand:SI 2 "immediate_operand" "i"))
9511    (use (match_operand:SI 3 "immediate_operand" "i"))
9512    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9513    (clobber (reg:SI  6))
9514    (clobber (reg:SI  7))
9515    (clobber (reg:SI  8))
9516    (clobber (reg:SI  9))
9517    (clobber (reg:SI 10))
9518    (clobber (reg:SI 11))
9519    (clobber (reg:SI 12))
9520    (clobber (match_scratch:SI 5 "X"))]
9521   "TARGET_STRING && TARGET_POWERPC64
9522    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9523        || INTVAL (operands[2]) == 0)
9524    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9525    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9526    && REGNO (operands[4]) == 5"
9527   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9528   [(set_attr "type" "load")
9529    (set_attr "length" "8")])
9530
9531 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
9532 ;; register allocator doesn't have a clue about allocating 6 word registers.
9533 ;; rD/rS = r5 is preferred, efficient form.
9534 (define_expand "movstrsi_6reg"
9535   [(parallel [(set (match_operand 0 "" "")
9536                    (match_operand 1 "" ""))
9537               (use (match_operand 2 "" ""))
9538               (use (match_operand 3 "" ""))
9539               (clobber (reg:SI  5))
9540               (clobber (reg:SI  6))
9541               (clobber (reg:SI  7))
9542               (clobber (reg:SI  8))
9543               (clobber (reg:SI  9))
9544               (clobber (reg:SI 10))
9545               (clobber (match_scratch:SI 4 ""))])]
9546   "TARGET_STRING"
9547   "")
9548
9549 (define_insn ""
9550   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9551         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9552    (use (match_operand:SI 2 "immediate_operand" "i"))
9553    (use (match_operand:SI 3 "immediate_operand" "i"))
9554    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9555    (clobber (reg:SI  6))
9556    (clobber (reg:SI  7))
9557    (clobber (reg:SI  8))
9558    (clobber (reg:SI  9))
9559    (clobber (reg:SI 10))
9560    (clobber (match_scratch:SI 5 "=q"))]
9561   "TARGET_STRING && TARGET_POWER
9562    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
9563    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9564    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9565    && REGNO (operands[4]) == 5"
9566   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9567   [(set_attr "type" "load")
9568    (set_attr "length" "8")])
9569
9570 (define_insn ""
9571   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9572         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9573    (use (match_operand:SI 2 "immediate_operand" "i"))
9574    (use (match_operand:SI 3 "immediate_operand" "i"))
9575    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9576    (clobber (reg:SI  6))
9577    (clobber (reg:SI  7))
9578    (clobber (reg:SI  8))
9579    (clobber (reg:SI  9))
9580    (clobber (reg:SI 10))
9581    (clobber (match_scratch:SI 5 "X"))]
9582   "TARGET_STRING && ! TARGET_POWER
9583    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9584    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9585    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9586    && REGNO (operands[4]) == 5"
9587   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9588   [(set_attr "type" "load")
9589    (set_attr "length" "8")])
9590
9591 (define_insn ""
9592   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9593         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9594    (use (match_operand:SI 2 "immediate_operand" "i"))
9595    (use (match_operand:SI 3 "immediate_operand" "i"))
9596    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9597    (clobber (reg:SI  6))
9598    (clobber (reg:SI  7))
9599    (clobber (reg:SI  8))
9600    (clobber (reg:SI  9))
9601    (clobber (reg:SI 10))
9602    (clobber (match_scratch:SI 5 "X"))]
9603   "TARGET_STRING && TARGET_POWERPC64
9604    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9605    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9606    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9607    && REGNO (operands[4]) == 5"
9608   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9609   [(set_attr "type" "load")
9610    (set_attr "length" "8")])
9611
9612 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9613 ;; problems with TImode.
9614 ;; rD/rS = r5 is preferred, efficient form.
9615 (define_expand "movstrsi_4reg"
9616   [(parallel [(set (match_operand 0 "" "")
9617                    (match_operand 1 "" ""))
9618               (use (match_operand 2 "" ""))
9619               (use (match_operand 3 "" ""))
9620               (clobber (reg:SI 5))
9621               (clobber (reg:SI 6))
9622               (clobber (reg:SI 7))
9623               (clobber (reg:SI 8))
9624               (clobber (match_scratch:SI 4 ""))])]
9625   "TARGET_STRING"
9626   "")
9627
9628 (define_insn ""
9629   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9630         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9631    (use (match_operand:SI 2 "immediate_operand" "i"))
9632    (use (match_operand:SI 3 "immediate_operand" "i"))
9633    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9634    (clobber (reg:SI 6))
9635    (clobber (reg:SI 7))
9636    (clobber (reg:SI 8))
9637    (clobber (match_scratch:SI 5 "=q"))]
9638   "TARGET_STRING && TARGET_POWER
9639    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9640    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9641    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9642    && REGNO (operands[4]) == 5"
9643   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9644   [(set_attr "type" "load")
9645    (set_attr "length" "8")])
9646
9647 (define_insn ""
9648   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9649         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9650    (use (match_operand:SI 2 "immediate_operand" "i"))
9651    (use (match_operand:SI 3 "immediate_operand" "i"))
9652    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9653    (clobber (reg:SI 6))
9654    (clobber (reg:SI 7))
9655    (clobber (reg:SI 8))
9656    (clobber (match_scratch:SI 5 "X"))]
9657   "TARGET_STRING && ! TARGET_POWER
9658    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9659    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9660    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9661    && REGNO (operands[4]) == 5"
9662   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9663   [(set_attr "type" "load")
9664    (set_attr "length" "8")])
9665
9666 (define_insn ""
9667   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9668         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9669    (use (match_operand:SI 2 "immediate_operand" "i"))
9670    (use (match_operand:SI 3 "immediate_operand" "i"))
9671    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9672    (clobber (reg:SI 6))
9673    (clobber (reg:SI 7))
9674    (clobber (reg:SI 8))
9675    (clobber (match_scratch:SI 5 "X"))]
9676   "TARGET_STRING && TARGET_POWERPC64
9677    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9678    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9679    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9680    && REGNO (operands[4]) == 5"
9681   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9682   [(set_attr "type" "load")
9683    (set_attr "length" "8")])
9684
9685 ;; Move up to 8 bytes at a time.
9686 (define_expand "movstrsi_2reg"
9687   [(parallel [(set (match_operand 0 "" "")
9688                    (match_operand 1 "" ""))
9689               (use (match_operand 2 "" ""))
9690               (use (match_operand 3 "" ""))
9691               (clobber (match_scratch:DI 4 ""))
9692               (clobber (match_scratch:SI 5 ""))])]
9693   "TARGET_STRING && ! TARGET_POWERPC64"
9694   "")
9695
9696 (define_insn ""
9697   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9698         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9699    (use (match_operand:SI 2 "immediate_operand" "i"))
9700    (use (match_operand:SI 3 "immediate_operand" "i"))
9701    (clobber (match_scratch:DI 4 "=&r"))
9702    (clobber (match_scratch:SI 5 "=q"))]
9703   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9704    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9705   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9706   [(set_attr "type" "load")
9707    (set_attr "length" "8")])
9708
9709 (define_insn ""
9710   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9711         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9712    (use (match_operand:SI 2 "immediate_operand" "i"))
9713    (use (match_operand:SI 3 "immediate_operand" "i"))
9714    (clobber (match_scratch:DI 4 "=&r"))
9715    (clobber (match_scratch:SI 5 "X"))]
9716   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9717    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9718   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9719   [(set_attr "type" "load")
9720    (set_attr "length" "8")])
9721
9722 ;; Move up to 4 bytes at a time.
9723 (define_expand "movstrsi_1reg"
9724   [(parallel [(set (match_operand 0 "" "")
9725                    (match_operand 1 "" ""))
9726               (use (match_operand 2 "" ""))
9727               (use (match_operand 3 "" ""))
9728               (clobber (match_scratch:SI 4 ""))
9729               (clobber (match_scratch:SI 5 ""))])]
9730   "TARGET_STRING"
9731   "")
9732
9733 (define_insn ""
9734   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9735         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9736    (use (match_operand:SI 2 "immediate_operand" "i"))
9737    (use (match_operand:SI 3 "immediate_operand" "i"))
9738    (clobber (match_scratch:SI 4 "=&r"))
9739    (clobber (match_scratch:SI 5 "=q"))]
9740   "TARGET_STRING && TARGET_POWER
9741    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9742   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9743   [(set_attr "type" "load")
9744    (set_attr "length" "8")])
9745
9746 (define_insn ""
9747   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9748         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9749    (use (match_operand:SI 2 "immediate_operand" "i"))
9750    (use (match_operand:SI 3 "immediate_operand" "i"))
9751    (clobber (match_scratch:SI 4 "=&r"))
9752    (clobber (match_scratch:SI 5 "X"))]
9753   "TARGET_STRING && ! TARGET_POWER
9754    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9755   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9756   [(set_attr "type" "load")
9757    (set_attr "length" "8")])
9758
9759 (define_insn ""
9760   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9761         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9762    (use (match_operand:SI 2 "immediate_operand" "i"))
9763    (use (match_operand:SI 3 "immediate_operand" "i"))
9764    (clobber (match_scratch:SI 4 "=&r"))
9765    (clobber (match_scratch:SI 5 "X"))]
9766   "TARGET_STRING && TARGET_POWERPC64
9767    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9768   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9769   [(set_attr "type" "load")
9770    (set_attr "length" "8")])
9771
9772 \f
9773 ;; Define insns that do load or store with update.  Some of these we can
9774 ;; get by using pre-decrement or pre-increment, but the hardware can also
9775 ;; do cases where the increment is not the size of the object.
9776 ;;
9777 ;; In all these cases, we use operands 0 and 1 for the register being
9778 ;; incremented because those are the operands that local-alloc will
9779 ;; tie and these are the pair most likely to be tieable (and the ones
9780 ;; that will benefit the most).
9781
9782 (define_insn "*movdi_update1"
9783   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9784         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9785                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9786    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9787         (plus:DI (match_dup 1) (match_dup 2)))]
9788   "TARGET_POWERPC64 && TARGET_UPDATE"
9789   "@
9790    ldux %3,%0,%2
9791    ldu %3,%2(%0)"
9792   [(set_attr "type" "load")])
9793
9794 (define_insn "*movdi_update2"
9795   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9796         (sign_extend:DI
9797          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9798                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
9799    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9800         (plus:DI (match_dup 1) (match_dup 2)))]
9801   "TARGET_POWERPC64"
9802   "lwaux %3,%0,%2"
9803   [(set_attr "type" "load")])
9804
9805 (define_insn "movdi_update"
9806   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9807                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
9808         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9809    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9810         (plus:DI (match_dup 1) (match_dup 2)))]
9811   "TARGET_POWERPC64 && TARGET_UPDATE"
9812   "@
9813    stdux %3,%0,%2
9814    stdu %3,%2(%0)"
9815   [(set_attr "type" "store")])
9816
9817 (define_insn "*movsi_update1"
9818   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9819         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9820                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9821    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9822         (plus:SI (match_dup 1) (match_dup 2)))]
9823   ""
9824   "@
9825    {lux|lwzux} %3,%0,%2
9826    {lu|lwzu} %3,%2(%0)"
9827   [(set_attr "type" "load")])
9828
9829 (define_insn "movsi_update"
9830   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9831                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9832         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9833    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9834         (plus:SI (match_dup 1) (match_dup 2)))]
9835   "TARGET_UPDATE"
9836   "@
9837    {stux|stwux} %3,%0,%2
9838    {stu|stwu} %3,%2(%0)"
9839   [(set_attr "type" "store")])
9840
9841 (define_insn "*movhi_update"
9842   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9843         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9844                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9845    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9846         (plus:SI (match_dup 1) (match_dup 2)))]
9847   "TARGET_UPDATE"
9848   "@
9849    lhzux %3,%0,%2
9850    lhzu %3,%2(%0)"
9851   [(set_attr "type" "load")])
9852
9853 (define_insn "*movhi_update2"
9854   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9855         (zero_extend:SI
9856          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9857                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9858    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9859         (plus:SI (match_dup 1) (match_dup 2)))]
9860   "TARGET_UPDATE"
9861   "@
9862    lhzux %3,%0,%2
9863    lhzu %3,%2(%0)"
9864   [(set_attr "type" "load")])
9865
9866 (define_insn "*movhi_update3"
9867   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9868         (sign_extend:SI
9869          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9870                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9871    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9872         (plus:SI (match_dup 1) (match_dup 2)))]
9873   "TARGET_UPDATE"
9874   "@
9875    lhaux %3,%0,%2
9876    lhau %3,%2(%0)"
9877   [(set_attr "type" "load")])
9878
9879 (define_insn "*movhi_update4"
9880   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9881                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9882         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9883    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9884         (plus:SI (match_dup 1) (match_dup 2)))]
9885   "TARGET_UPDATE"
9886   "@
9887    sthux %3,%0,%2
9888    sthu %3,%2(%0)"
9889   [(set_attr "type" "store")])
9890
9891 (define_insn "*movqi_update1"
9892   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9893         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9894                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9895    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9896         (plus:SI (match_dup 1) (match_dup 2)))]
9897   "TARGET_UPDATE"
9898   "@
9899    lbzux %3,%0,%2
9900    lbzu %3,%2(%0)"
9901   [(set_attr "type" "load")])
9902
9903 (define_insn "*movqi_update2"
9904   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9905         (zero_extend:SI
9906          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9907                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9908    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9909         (plus:SI (match_dup 1) (match_dup 2)))]
9910   "TARGET_UPDATE"
9911   "@
9912    lbzux %3,%0,%2
9913    lbzu %3,%2(%0)"
9914   [(set_attr "type" "load")])
9915
9916 (define_insn "*movqi_update3"
9917   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9918                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9919         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9920    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9921         (plus:SI (match_dup 1) (match_dup 2)))]
9922   "TARGET_UPDATE"
9923   "@
9924    stbux %3,%0,%2
9925    stbu %3,%2(%0)"
9926   [(set_attr "type" "store")])
9927
9928 (define_insn "*movsf_update1"
9929   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9930         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9931                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9932    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9933         (plus:SI (match_dup 1) (match_dup 2)))]
9934   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9935   "@
9936    lfsux %3,%0,%2
9937    lfsu %3,%2(%0)"
9938   [(set_attr "type" "fpload")])
9939
9940 (define_insn "*movsf_update2"
9941   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9942                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9943         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9944    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9945         (plus:SI (match_dup 1) (match_dup 2)))]
9946   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9947   "@
9948    stfsux %3,%0,%2
9949    stfsu %3,%2(%0)"
9950   [(set_attr "type" "fpstore")])
9951
9952 (define_insn "*movsf_update3"
9953   [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9954         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9955                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9956    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9957         (plus:SI (match_dup 1) (match_dup 2)))]
9958   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9959   "@
9960    {lux|lwzux} %3,%0,%2
9961    {lu|lwzu} %3,%2(%0)"
9962   [(set_attr "type" "load")])
9963
9964 (define_insn "*movsf_update4"
9965   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9966                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9967         (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9968    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9969         (plus:SI (match_dup 1) (match_dup 2)))]
9970   "(TARGET_SOFT_FLOAT || !TARGET_FPRS) && TARGET_UPDATE"
9971   "@
9972    {stux|stwux} %3,%0,%2
9973    {stu|stwu} %3,%2(%0)"
9974   [(set_attr "type" "store")])
9975
9976 (define_insn "*movdf_update1"
9977   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9978         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9979                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9980    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9981         (plus:SI (match_dup 1) (match_dup 2)))]
9982   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9983   "@
9984    lfdux %3,%0,%2
9985    lfdu %3,%2(%0)"
9986   [(set_attr "type" "fpload")])
9987
9988 (define_insn "*movdf_update2"
9989   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9990                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9991         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9992    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9993         (plus:SI (match_dup 1) (match_dup 2)))]
9994   "TARGET_HARD_FLOAT && TARGET_FPRS && TARGET_UPDATE"
9995   "@
9996    stfdux %3,%0,%2
9997    stfdu %3,%2(%0)"
9998   [(set_attr "type" "fpstore")])
9999
10000 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
10001
10002 (define_peephole
10003   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
10004         (match_operand:DF 1 "memory_operand" ""))
10005    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
10006         (match_operand:DF 3 "memory_operand" ""))]
10007   "TARGET_POWER2
10008    && TARGET_HARD_FLOAT && TARGET_FPRS
10009    && registers_ok_for_quad_peep (operands[0], operands[2])
10010    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
10011    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
10012   "lfq%U1%X1 %0,%1")
10013
10014 (define_peephole
10015   [(set (match_operand:DF 0 "memory_operand" "")
10016         (match_operand:DF 1 "gpc_reg_operand" "f"))
10017    (set (match_operand:DF 2 "memory_operand" "")
10018         (match_operand:DF 3 "gpc_reg_operand" "f"))]
10019   "TARGET_POWER2
10020    && TARGET_HARD_FLOAT && TARGET_FPRS
10021    && registers_ok_for_quad_peep (operands[1], operands[3])
10022    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
10023    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
10024   "stfq%U0%X0 %1,%0")
10025 \f
10026 ;; Next come insns related to the calling sequence.
10027 ;;
10028 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
10029 ;; We move the back-chain and decrement the stack pointer.
10030
10031 (define_expand "allocate_stack"
10032   [(set (match_operand 0 "gpc_reg_operand" "=r")
10033         (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
10034    (set (reg 1)
10035         (minus (reg 1) (match_dup 1)))]
10036   ""
10037   "
10038 { rtx chain = gen_reg_rtx (Pmode);
10039   rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
10040   rtx neg_op0;
10041
10042   emit_move_insn (chain, stack_bot);
10043
10044   /* Check stack bounds if necessary.  */
10045   if (current_function_limit_stack)
10046     {
10047       rtx available;
10048       available = expand_binop (Pmode, sub_optab, 
10049                                 stack_pointer_rtx, stack_limit_rtx,
10050                                 NULL_RTX, 1, OPTAB_WIDEN);
10051       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
10052     }
10053
10054   if (GET_CODE (operands[1]) != CONST_INT
10055       || INTVAL (operands[1]) < -32767
10056       || INTVAL (operands[1]) > 32768)
10057     {
10058       neg_op0 = gen_reg_rtx (Pmode);
10059       if (TARGET_32BIT)
10060         emit_insn (gen_negsi2 (neg_op0, operands[1]));
10061       else
10062         emit_insn (gen_negdi2 (neg_op0, operands[1]));
10063     }
10064   else
10065     neg_op0 = GEN_INT (- INTVAL (operands[1]));
10066
10067   if (TARGET_UPDATE)
10068     emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
10069                 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
10070
10071   else
10072     {
10073       emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
10074                  (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
10075       emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
10076     }
10077
10078   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
10079   DONE;
10080 }")
10081
10082 ;; These patterns say how to save and restore the stack pointer.  We need not
10083 ;; save the stack pointer at function level since we are careful to
10084 ;; preserve the backchain.  At block level, we have to restore the backchain
10085 ;; when we restore the stack pointer.
10086 ;;
10087 ;; For nonlocal gotos, we must save both the stack pointer and its
10088 ;; backchain and restore both.  Note that in the nonlocal case, the
10089 ;; save area is a memory location.
10090
10091 (define_expand "save_stack_function"
10092   [(match_operand 0 "any_operand" "")
10093    (match_operand 1 "any_operand" "")]
10094   ""
10095   "DONE;")
10096
10097 (define_expand "restore_stack_function"
10098   [(match_operand 0 "any_operand" "")
10099    (match_operand 1 "any_operand" "")]
10100   ""
10101   "DONE;")
10102
10103 (define_expand "restore_stack_block"
10104   [(use (match_operand 0 "register_operand" ""))
10105    (set (match_dup 2) (match_dup 3))
10106    (set (match_dup 0) (match_operand 1 "register_operand" ""))
10107    (set (match_dup 3) (match_dup 2))]
10108   ""
10109   "
10110 {
10111   operands[2] = gen_reg_rtx (Pmode);
10112   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
10113 }")
10114
10115 (define_expand "save_stack_nonlocal"
10116   [(match_operand 0 "memory_operand" "")
10117    (match_operand 1 "register_operand" "")]
10118   ""
10119   "
10120 {
10121   rtx temp = gen_reg_rtx (Pmode);
10122
10123   /* Copy the backchain to the first word, sp to the second.  */
10124   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
10125   emit_move_insn (operand_subword (operands[0], 0, 0,
10126                                    (TARGET_32BIT ? DImode : TImode)),
10127                   temp);
10128   emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
10129                   operands[1]);
10130   DONE;
10131 }")
10132
10133 (define_expand "restore_stack_nonlocal"
10134   [(match_operand 0 "register_operand" "")
10135    (match_operand 1 "memory_operand" "")]
10136   ""
10137   "
10138 {
10139   rtx temp = gen_reg_rtx (Pmode);
10140
10141   /* Restore the backchain from the first word, sp from the second.  */
10142   emit_move_insn (temp,
10143                   operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
10144   emit_move_insn (operands[0],
10145                   operand_subword (operands[1], 1, 0,
10146                                    (TARGET_32BIT ? DImode : TImode)));
10147   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
10148   DONE;
10149 }")
10150 \f
10151 ;; TOC register handling.
10152
10153 ;; Code to initialize the TOC register...
10154
10155 (define_insn "load_toc_aix_si"
10156   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10157                    (unspec:SI [(const_int 0)] 7))
10158               (use (reg:SI 2))])]
10159   "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
10160   "*
10161 {
10162   char buf[30];
10163   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10164   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10165   operands[2] = gen_rtx_REG (Pmode, 2);
10166   return \"{l|lwz} %0,%1(%2)\";
10167 }"
10168   [(set_attr "type" "load")])
10169
10170 (define_insn "load_toc_aix_di"
10171   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10172                    (unspec:DI [(const_int 0)] 7))
10173               (use (reg:DI 2))])]
10174   "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
10175   "*
10176 {
10177   char buf[30];
10178 #ifdef TARGET_RELOCATABLE
10179   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
10180                                !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
10181 #else
10182   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
10183 #endif
10184   if (TARGET_ELF)
10185     strcat (buf, \"@toc\");
10186   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
10187   operands[2] = gen_rtx_REG (Pmode, 2);
10188   return \"ld %0,%1(%2)\";
10189 }"
10190   [(set_attr "type" "load")])
10191
10192 (define_insn "load_toc_v4_pic_si"
10193   [(set (match_operand:SI 0 "register_operand" "=l")
10194         (unspec:SI [(const_int 0)] 7))]
10195   "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
10196   "bl _GLOBAL_OFFSET_TABLE_@local-4"
10197   [(set_attr "type" "branch")
10198    (set_attr "length" "4")])
10199
10200 (define_insn "load_toc_v4_PIC_1"
10201   [(set (match_operand:SI 0 "register_operand" "=l")
10202         (match_operand:SI 1 "immediate_operand" "s"))
10203    (unspec [(match_dup 1)] 7)]
10204   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10205   "bl %1\\n%1:"
10206   [(set_attr "type" "branch")
10207    (set_attr "length" "4")])
10208
10209 (define_insn "load_toc_v4_PIC_1b"
10210   [(set (match_operand:SI 0 "register_operand" "=l")
10211         (match_operand:SI 1 "immediate_operand" "s"))
10212    (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")] 6)]
10213   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10214   "bl %1\\n\\t.long %2-%1+4\\n%1:"
10215   [(set_attr "type" "branch")
10216    (set_attr "length" "8")])
10217
10218 (define_insn "load_toc_v4_PIC_2"
10219   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10220         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
10221                    (minus:SI (match_operand:SI 2 "immediate_operand" "s")
10222                              (match_operand:SI 3 "immediate_operand" "s")))))]
10223   "TARGET_ELF && DEFAULT_ABI != ABI_AIX && flag_pic == 2"
10224   "{l|lwz} %0,%2-%3(%1)"
10225   [(set_attr "type" "load")])
10226
10227 (define_insn "load_macho_picbase"
10228   [(set (match_operand:SI 0 "register_operand" "=l")
10229         (unspec:SI [(match_operand:SI 1 "immediate_operand" "s")] 15))]
10230   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
10231   "bcl 20,31,%1\\n%1:"
10232   [(set_attr "type" "branch")
10233    (set_attr "length" "4")])
10234
10235 (define_insn "macho_correct_pic"
10236   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10237         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "=r")
10238                  (unspec:SI [(match_operand:SI 2 "immediate_operand" "s")
10239                              (match_operand:SI 3 "immediate_operand" "s")]
10240                             16)))]
10241   "DEFAULT_ABI == ABI_DARWIN"
10242   "addis %0,%1,ha16(%2-%3)\n\taddi %1,%1,lo16(%2-%3)"
10243   [(set_attr "length" "8")])
10244
10245 ;; If the TOC is shared over a translation unit, as happens with all
10246 ;; the kinds of PIC that we support, we need to restore the TOC
10247 ;; pointer only when jumping over units of translation.
10248 ;; On Darwin, we need to reload the picbase.
10249
10250 (define_expand "builtin_setjmp_receiver"
10251   [(use (label_ref (match_operand 0 "" "")))]
10252   "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
10253    || (TARGET_TOC && TARGET_MINIMAL_TOC)
10254    || (DEFAULT_ABI == ABI_DARWIN && flag_pic)"
10255   "
10256 {
10257 #if TARGET_MACHO
10258   if (DEFAULT_ABI == ABI_DARWIN)
10259     {
10260       char *picbase = machopic_function_base_name ();
10261       rtx picrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
10262       rtx picreg = gen_rtx_REG (Pmode, RS6000_PIC_OFFSET_TABLE_REGNUM);
10263       rtx tmplabrtx;
10264       char tmplab[20];
10265
10266       ASM_GENERATE_INTERNAL_LABEL(tmplab, \"LSJR\",
10267                                   CODE_LABEL_NUMBER (operands[0]));
10268       tmplabrtx = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (tmplab, -1));
10269
10270       emit_insn (gen_load_macho_picbase (picreg, tmplabrtx));
10271       emit_insn (gen_macho_correct_pic (picreg, picreg, picrtx, tmplabrtx));
10272     }
10273   else
10274 #endif
10275     rs6000_emit_load_toc_table (FALSE);
10276   DONE;
10277 }")
10278 \f
10279 ;; A function pointer under AIX is a pointer to a data area whose first word
10280 ;; contains the actual address of the function, whose second word contains a
10281 ;; pointer to its TOC, and whose third word contains a value to place in the
10282 ;; static chain register (r11).  Note that if we load the static chain, our
10283 ;; "trampoline" need not have any executable code.
10284
10285 (define_expand "call_indirect_aix32"
10286   [(set (match_dup 2)
10287         (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
10288    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10289         (reg:SI 2))
10290    (set (reg:SI 2)
10291         (mem:SI (plus:SI (match_dup 0)
10292                          (const_int 4))))
10293    (set (reg:SI 11)
10294         (mem:SI (plus:SI (match_dup 0)
10295                          (const_int 8))))
10296    (parallel [(call (mem:SI (match_dup 2))
10297                     (match_operand 1 "" ""))
10298               (use (reg:SI 2))
10299               (use (reg:SI 11))
10300               (set (reg:SI 2)
10301                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10302               (clobber (scratch:SI))])]
10303   "TARGET_32BIT"
10304   "
10305 { operands[2] = gen_reg_rtx (SImode); }")
10306
10307 (define_expand "call_indirect_aix64"
10308   [(set (match_dup 2)
10309         (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
10310    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10311         (reg:DI 2))
10312    (set (reg:DI 2)
10313         (mem:DI (plus:DI (match_dup 0)
10314                          (const_int 8))))
10315    (set (reg:DI 11)
10316         (mem:DI (plus:DI (match_dup 0)
10317                          (const_int 16))))
10318    (parallel [(call (mem:SI (match_dup 2))
10319                     (match_operand 1 "" ""))
10320               (use (reg:DI 2))
10321               (use (reg:DI 11))
10322               (set (reg:DI 2)
10323                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10324               (clobber (scratch:SI))])]
10325   "TARGET_64BIT"
10326   "
10327 { operands[2] = gen_reg_rtx (DImode); }")
10328
10329 (define_expand "call_value_indirect_aix32"
10330   [(set (match_dup 3)
10331         (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
10332    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
10333         (reg:SI 2))
10334    (set (reg:SI 2)
10335         (mem:SI (plus:SI (match_dup 1)
10336                          (const_int 4))))
10337    (set (reg:SI 11)
10338         (mem:SI (plus:SI (match_dup 1)
10339                          (const_int 8))))
10340    (parallel [(set (match_operand 0 "" "")
10341                    (call (mem:SI (match_dup 3))
10342                          (match_operand 2 "" "")))
10343               (use (reg:SI 2))
10344               (use (reg:SI 11))
10345               (set (reg:SI 2)
10346                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10347               (clobber (scratch:SI))])]
10348   "TARGET_32BIT"
10349   "
10350 { operands[3] = gen_reg_rtx (SImode); }")
10351
10352 (define_expand "call_value_indirect_aix64"
10353   [(set (match_dup 3)
10354         (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
10355    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
10356         (reg:DI 2))
10357    (set (reg:DI 2)
10358         (mem:DI (plus:DI (match_dup 1)
10359                          (const_int 8))))
10360    (set (reg:DI 11)
10361         (mem:DI (plus:DI (match_dup 1)
10362                          (const_int 16))))
10363    (parallel [(set (match_operand 0 "" "")
10364                    (call (mem:SI (match_dup 3))
10365                          (match_operand 2 "" "")))
10366               (use (reg:DI 2))
10367               (use (reg:DI 11))
10368               (set (reg:DI 2)
10369                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10370               (clobber (scratch:SI))])]
10371   "TARGET_64BIT"
10372   "
10373 { operands[3] = gen_reg_rtx (DImode); }")
10374
10375 ;; Now the definitions for the call and call_value insns
10376 (define_expand "call"
10377   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10378                     (match_operand 1 "" ""))
10379               (use (match_operand 2 "" ""))
10380               (clobber (scratch:SI))])]
10381   ""
10382   "
10383 {
10384 #if TARGET_MACHO
10385   if (flag_pic)
10386     operands[0] = machopic_indirect_call_target (operands[0]);
10387 #endif
10388
10389   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10390     abort ();
10391
10392   operands[0] = XEXP (operands[0], 0);
10393
10394   if (GET_CODE (operands[0]) != SYMBOL_REF
10395       || (INTVAL (operands[2]) & CALL_LONG) != 0)
10396     {
10397       if (INTVAL (operands[2]) & CALL_LONG)
10398         operands[0] = rs6000_longcall_ref (operands[0]);
10399
10400       if (DEFAULT_ABI == ABI_V4
10401           || DEFAULT_ABI == ABI_AIX_NODESC
10402           || DEFAULT_ABI == ABI_DARWIN)
10403         operands[0] = force_reg (Pmode, operands[0]);
10404
10405       else if (DEFAULT_ABI == ABI_AIX)
10406         {
10407           /* AIX function pointers are really pointers to a three word
10408              area.  */
10409           emit_call_insn (TARGET_32BIT
10410                           ? gen_call_indirect_aix32 (force_reg (SImode,
10411                                                                 operands[0]),
10412                                                      operands[1])
10413                           : gen_call_indirect_aix64 (force_reg (DImode,
10414                                                                 operands[0]),
10415                                                      operands[1]));
10416           DONE;
10417         }
10418       else
10419         abort ();
10420     }
10421 }")
10422
10423 (define_expand "call_value"
10424   [(parallel [(set (match_operand 0 "" "")
10425                    (call (mem:SI (match_operand 1 "address_operand" ""))
10426                          (match_operand 2 "" "")))
10427               (use (match_operand 3 "" ""))
10428               (clobber (scratch:SI))])]
10429   ""
10430   "
10431 {
10432 #if TARGET_MACHO
10433   if (flag_pic)
10434     operands[1] = machopic_indirect_call_target (operands[1]);
10435 #endif
10436
10437   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10438     abort ();
10439
10440   operands[1] = XEXP (operands[1], 0);
10441
10442   if (GET_CODE (operands[1]) != SYMBOL_REF
10443       || (INTVAL (operands[3]) & CALL_LONG) != 0)
10444     {
10445       if (INTVAL (operands[3]) & CALL_LONG)
10446         operands[1] = rs6000_longcall_ref (operands[1]);
10447
10448       if (DEFAULT_ABI == ABI_V4
10449           || DEFAULT_ABI == ABI_AIX_NODESC
10450           || DEFAULT_ABI == ABI_DARWIN)
10451         operands[0] = force_reg (Pmode, operands[0]);
10452
10453       else if (DEFAULT_ABI == ABI_AIX)
10454         {
10455           /* AIX function pointers are really pointers to a three word
10456              area.  */
10457           emit_call_insn (TARGET_32BIT
10458                           ? gen_call_value_indirect_aix32 (operands[0],
10459                                                            force_reg (SImode,
10460                                                                       operands[1]),
10461                                                            operands[2])
10462                           : gen_call_value_indirect_aix64 (operands[0],
10463                                                            force_reg (DImode,
10464                                                                       operands[1]),
10465                                                            operands[2]));
10466           DONE;
10467         }
10468       else
10469         abort ();
10470     }
10471 }")
10472
10473 ;; Call to function in current module.  No TOC pointer reload needed.
10474 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10475 ;; either the function was not prototyped, or it was prototyped as a
10476 ;; variable argument function.  It is > 0 if FP registers were passed
10477 ;; and < 0 if they were not.
10478
10479 (define_insn "*call_local32"
10480   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10481          (match_operand 1 "" "g,g"))
10482    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10483    (clobber (match_scratch:SI 3 "=l,l"))]
10484   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10485   "*
10486 {
10487   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10488     output_asm_insn (\"crxor 6,6,6\", operands);
10489
10490   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10491     output_asm_insn (\"creqv 6,6,6\", operands);
10492
10493   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10494 }"
10495   [(set_attr "type" "branch")
10496    (set_attr "length" "4,8")])
10497
10498 (define_insn "*call_local64"
10499   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10500          (match_operand 1 "" "g,g"))
10501    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10502    (clobber (match_scratch:SI 3 "=l,l"))]
10503   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10504   "*
10505 {
10506   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10507     output_asm_insn (\"crxor 6,6,6\", operands);
10508
10509   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10510     output_asm_insn (\"creqv 6,6,6\", operands);
10511
10512   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10513 }"
10514   [(set_attr "type" "branch")
10515    (set_attr "length" "4,8")])
10516
10517 (define_insn "*call_value_local32"
10518   [(set (match_operand 0 "" "")
10519         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10520               (match_operand 2 "" "g,g")))
10521    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10522    (clobber (match_scratch:SI 4 "=l,l"))]
10523   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10524   "*
10525 {
10526   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10527     output_asm_insn (\"crxor 6,6,6\", operands);
10528
10529   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10530     output_asm_insn (\"creqv 6,6,6\", operands);
10531
10532   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10533 }"
10534   [(set_attr "type" "branch")
10535    (set_attr "length" "4,8")])
10536
10537
10538 (define_insn "*call_value_local64"
10539   [(set (match_operand 0 "" "")
10540         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10541               (match_operand 2 "" "g,g")))
10542    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10543    (clobber (match_scratch:SI 4 "=l,l"))]
10544   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10545   "*
10546 {
10547   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10548     output_asm_insn (\"crxor 6,6,6\", operands);
10549
10550   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10551     output_asm_insn (\"creqv 6,6,6\", operands);
10552
10553   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10554 }"
10555   [(set_attr "type" "branch")
10556    (set_attr "length" "4,8")])
10557
10558 ;; Call to function which may be in another module.  Restore the TOC
10559 ;; pointer (r2) after the call unless this is System V.
10560 ;; Operand2 is nonzero if we are using the V.4 calling sequence and
10561 ;; either the function was not prototyped, or it was prototyped as a
10562 ;; variable argument function.  It is > 0 if FP registers were passed
10563 ;; and < 0 if they were not.
10564
10565 (define_insn "*call_indirect_nonlocal_aix32"
10566   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10567          (match_operand 1 "" "g"))
10568    (use (reg:SI 2))
10569    (use (reg:SI 11))
10570    (set (reg:SI 2)
10571         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10572    (clobber (match_scratch:SI 2 "=l"))]
10573   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10574   "b%T0l\;{l|lwz} 2,20(1)"
10575   [(set_attr "type" "jmpreg")
10576    (set_attr "length" "8")])
10577
10578 (define_insn "*call_nonlocal_aix32"
10579   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10580          (match_operand 1 "" "g"))
10581    (use (match_operand:SI 2 "immediate_operand" "O"))
10582    (clobber (match_scratch:SI 3 "=l"))]
10583   "TARGET_32BIT
10584    && DEFAULT_ABI == ABI_AIX
10585    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10586   "bl %z0\;%."
10587   [(set_attr "type" "branch")
10588    (set_attr "length" "8")])
10589
10590 (define_insn "*call_indirect_nonlocal_aix64"
10591   [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10592          (match_operand 1 "" "g"))
10593    (use (reg:DI 2))
10594    (use (reg:DI 11))
10595    (set (reg:DI 2)
10596         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10597    (clobber (match_scratch:SI 2 "=l"))]
10598   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10599   "b%T0l\;ld 2,40(1)"
10600   [(set_attr "type" "jmpreg")
10601    (set_attr "length" "8")])
10602
10603 (define_insn "*call_nonlocal_aix64"
10604   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10605          (match_operand 1 "" "g"))
10606    (use (match_operand:SI 2 "immediate_operand" "O"))
10607    (clobber (match_scratch:SI 3 "=l"))]
10608   "TARGET_64BIT 
10609    && DEFAULT_ABI == ABI_AIX
10610    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10611   "bl %z0\;%."
10612   [(set_attr "type" "branch")
10613    (set_attr "length" "8")])
10614
10615 (define_insn "*call_value_indirect_nonlocal_aix32"
10616   [(set (match_operand 0 "" "")
10617         (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10618               (match_operand 2 "" "g")))
10619    (use (reg:SI 2))
10620    (use (reg:SI 11))
10621    (set (reg:SI 2)
10622         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10623    (clobber (match_scratch:SI 3 "=l"))]
10624   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10625   "b%T1l\;{l|lwz} 2,20(1)"
10626   [(set_attr "type" "jmpreg")
10627    (set_attr "length" "8")])
10628
10629 (define_insn "*call_value_nonlocal_aix32"
10630   [(set (match_operand 0 "" "")
10631         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10632               (match_operand 2 "" "g")))
10633    (use (match_operand:SI 3 "immediate_operand" "O"))
10634    (clobber (match_scratch:SI 4 "=l"))]
10635   "TARGET_32BIT
10636    && DEFAULT_ABI == ABI_AIX
10637    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10638   "bl %z1\;%."
10639   [(set_attr "type" "branch")
10640    (set_attr "length" "8")])
10641
10642 (define_insn "*call_value_indirect_nonlocal_aix64"
10643   [(set (match_operand 0 "" "")
10644         (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10645               (match_operand 2 "" "g")))
10646    (use (reg:DI 2))
10647    (use (reg:DI 11))
10648    (set (reg:DI 2)
10649         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10650    (clobber (match_scratch:SI 3 "=l"))]
10651   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10652   "b%T1l\;ld 2,40(1)"
10653   [(set_attr "type" "jmpreg")
10654    (set_attr "length" "8")])
10655
10656 (define_insn "*call_value_nonlocal_aix64"
10657   [(set (match_operand 0 "" "")
10658         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10659               (match_operand 2 "" "g")))
10660    (use (match_operand:SI 3 "immediate_operand" "O"))
10661    (clobber (match_scratch:SI 4 "=l"))]
10662   "TARGET_64BIT 
10663    && DEFAULT_ABI == ABI_AIX
10664    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10665   "bl %z1\;%."
10666   [(set_attr "type" "branch")
10667    (set_attr "length" "8")])
10668
10669 ;; A function pointer under System V is just a normal pointer
10670 ;; operands[0] is the function pointer
10671 ;; operands[1] is the stack size to clean up
10672 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10673 ;; which indicates how to set cr1
10674
10675 (define_insn "*call_indirect_nonlocal_sysv"
10676   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10677          (match_operand 1 "" "g,g"))
10678    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10679    (clobber (match_scratch:SI 3 "=l,l"))]
10680   "DEFAULT_ABI == ABI_AIX_NODESC
10681    || DEFAULT_ABI == ABI_V4
10682    || DEFAULT_ABI == ABI_DARWIN"
10683 {
10684   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10685     output_asm_insn ("crxor 6,6,6", operands);
10686
10687   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10688     output_asm_insn ("creqv 6,6,6", operands);
10689
10690   return "b%T0l";
10691 }
10692   [(set_attr "type" "jmpreg,jmpreg")
10693    (set_attr "length" "4,8")])
10694
10695 (define_insn "*call_nonlocal_sysv"
10696   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10697          (match_operand 1 "" "g,g"))
10698    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10699    (clobber (match_scratch:SI 3 "=l,l"))]
10700   "(DEFAULT_ABI == ABI_AIX_NODESC
10701     || DEFAULT_ABI == ABI_V4
10702     || DEFAULT_ABI == ABI_DARWIN)
10703    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10704 {
10705   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10706     output_asm_insn ("crxor 6,6,6", operands);
10707
10708   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10709     output_asm_insn ("creqv 6,6,6", operands);
10710
10711   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
10712 }
10713   [(set_attr "type" "branch,branch")
10714    (set_attr "length" "4,8")])
10715
10716 (define_insn "*call_value_indirect_nonlocal_sysv"
10717   [(set (match_operand 0 "" "")
10718         (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10719               (match_operand 2 "" "g,g")))
10720    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10721    (clobber (match_scratch:SI 4 "=l,l"))]
10722   "DEFAULT_ABI == ABI_AIX_NODESC
10723    || DEFAULT_ABI == ABI_V4
10724    || DEFAULT_ABI == ABI_DARWIN"
10725 {
10726   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10727     output_asm_insn ("crxor 6,6,6", operands);
10728
10729   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10730     output_asm_insn ("creqv 6,6,6", operands);
10731
10732   return "b%T1l";
10733 }
10734   [(set_attr "type" "jmpreg,jmpreg")
10735    (set_attr "length" "4,8")])
10736
10737 (define_insn "*call_value_nonlocal_sysv"
10738   [(set (match_operand 0 "" "")
10739         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10740               (match_operand 2 "" "g,g")))
10741    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10742    (clobber (match_scratch:SI 4 "=l,l"))]
10743   "(DEFAULT_ABI == ABI_AIX_NODESC
10744     || DEFAULT_ABI == ABI_V4
10745     || DEFAULT_ABI == ABI_DARWIN)
10746    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10747 {
10748   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10749     output_asm_insn ("crxor 6,6,6", operands);
10750
10751   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10752     output_asm_insn ("creqv 6,6,6", operands);
10753
10754   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
10755 }
10756   [(set_attr "type" "branch,branch")
10757    (set_attr "length" "4,8")])
10758
10759 ;; Call subroutine returning any type.
10760 (define_expand "untyped_call"
10761   [(parallel [(call (match_operand 0 "" "")
10762                     (const_int 0))
10763               (match_operand 1 "" "")
10764               (match_operand 2 "" "")])]
10765   ""
10766   "
10767 {
10768   int i;
10769
10770   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10771
10772   for (i = 0; i < XVECLEN (operands[2], 0); i++)
10773     {
10774       rtx set = XVECEXP (operands[2], 0, i);
10775       emit_move_insn (SET_DEST (set), SET_SRC (set));
10776     }
10777
10778   /* The optimizer does not know that the call sets the function value
10779      registers we stored in the result block.  We avoid problems by
10780      claiming that all hard registers are used and clobbered at this
10781      point.  */
10782   emit_insn (gen_blockage ());
10783
10784   DONE;
10785 }")
10786
10787 ;; sibling call patterns
10788 (define_expand "sibcall"
10789   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
10790                     (match_operand 1 "" ""))
10791               (use (match_operand 2 "" ""))
10792               (use (scratch:SI))
10793               (return)])]
10794   ""
10795   "
10796 {
10797 #if TARGET_MACHO
10798   if (flag_pic)
10799     operands[0] = machopic_indirect_call_target (operands[0]);
10800 #endif
10801
10802   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
10803     abort ();
10804
10805   operands[0] = XEXP (operands[0], 0);
10806
10807 }")
10808
10809 ;; this and similar patterns must be marked as using LR, otherwise
10810 ;; dataflow will try to delete the store into it.  This is true
10811 ;; even when the actual reg to jump to is in CTR, when LR was
10812 ;; saved and restored around the PIC-setting BCL.
10813 (define_insn "*sibcall_local32"
10814   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10815          (match_operand 1 "" "g,g"))
10816    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10817    (use (match_scratch:SI 3 "=l,l"))
10818    (return)]
10819   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10820   "*
10821 {
10822   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10823     output_asm_insn (\"crxor 6,6,6\", operands);
10824
10825   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10826     output_asm_insn (\"creqv 6,6,6\", operands);
10827
10828   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10829 }"
10830   [(set_attr "type" "branch")
10831    (set_attr "length" "4,8")])
10832
10833 (define_insn "*sibcall_local64"
10834   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10835          (match_operand 1 "" "g,g"))
10836    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10837    (use (match_scratch:SI 3 "=l,l"))
10838    (return)]
10839   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10840   "*
10841 {
10842   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10843     output_asm_insn (\"crxor 6,6,6\", operands);
10844
10845   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10846     output_asm_insn (\"creqv 6,6,6\", operands);
10847
10848   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@local\" : \"b %z0\";
10849 }"
10850   [(set_attr "type" "branch")
10851    (set_attr "length" "4,8")])
10852
10853 (define_insn "*sibcall_value_local32"
10854   [(set (match_operand 0 "" "")
10855         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10856               (match_operand 2 "" "g,g")))
10857    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10858    (use (match_scratch:SI 4 "=l,l"))
10859    (return)]
10860   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10861   "*
10862 {
10863   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10864     output_asm_insn (\"crxor 6,6,6\", operands);
10865
10866   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10867     output_asm_insn (\"creqv 6,6,6\", operands);
10868
10869   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10870 }"
10871   [(set_attr "type" "branch")
10872    (set_attr "length" "4,8")])
10873
10874
10875 (define_insn "*sibcall_value_local64"
10876   [(set (match_operand 0 "" "")
10877         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10878               (match_operand 2 "" "g,g")))
10879    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10880    (use (match_scratch:SI 4 "=l,l"))
10881    (return)]
10882   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10883   "*
10884 {
10885   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10886     output_asm_insn (\"crxor 6,6,6\", operands);
10887
10888   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10889     output_asm_insn (\"creqv 6,6,6\", operands);
10890
10891   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@local\" : \"b %z1\";
10892 }"
10893   [(set_attr "type" "branch")
10894    (set_attr "length" "4,8")])
10895
10896 (define_insn "*sibcall_nonlocal_aix32"
10897   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10898          (match_operand 1 "" "g"))
10899    (use (match_operand:SI 2 "immediate_operand" "O"))
10900    (use (match_scratch:SI 3 "=l"))
10901    (return)]
10902   "TARGET_32BIT
10903    && DEFAULT_ABI == ABI_AIX
10904    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10905   "b %z0"
10906   [(set_attr "type" "branch")
10907    (set_attr "length" "4")])
10908
10909 (define_insn "*sibcall_nonlocal_aix64"
10910   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10911          (match_operand 1 "" "g"))
10912    (use (match_operand:SI 2 "immediate_operand" "O"))
10913    (use (match_scratch:SI 3 "=l"))
10914    (return)]
10915   "TARGET_64BIT 
10916    && DEFAULT_ABI == ABI_AIX
10917    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10918   "b %z0"
10919   [(set_attr "type" "branch")
10920    (set_attr "length" "4")])
10921
10922 (define_insn "*sibcall_value_nonlocal_aix32"
10923   [(set (match_operand 0 "" "")
10924         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10925               (match_operand 2 "" "g")))
10926    (use (match_operand:SI 3 "immediate_operand" "O"))
10927    (use (match_scratch:SI 4 "=l"))
10928    (return)]
10929   "TARGET_32BIT
10930    && DEFAULT_ABI == ABI_AIX
10931    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10932   "b %z1"
10933   [(set_attr "type" "branch")
10934    (set_attr "length" "4")])
10935
10936 (define_insn "*sibcall_value_nonlocal_aix64"
10937   [(set (match_operand 0 "" "")
10938         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10939               (match_operand 2 "" "g")))
10940    (use (match_operand:SI 3 "immediate_operand" "O"))
10941    (use (match_scratch:SI 4 "=l"))
10942    (return)]
10943   "TARGET_64BIT 
10944    && DEFAULT_ABI == ABI_AIX
10945    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10946   "b %z1"
10947   [(set_attr "type" "branch")
10948    (set_attr "length" "4")])
10949
10950 (define_insn "*sibcall_nonlocal_sysv"
10951   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10952          (match_operand 1 "" ""))
10953    (use (match_operand 2 "immediate_operand" "O,n"))
10954    (use (match_scratch:SI 3 "=l,l"))
10955    (return)]
10956   "(DEFAULT_ABI == ABI_DARWIN
10957      || DEFAULT_ABI == ABI_V4
10958      || DEFAULT_ABI == ABI_AIX_NODESC)
10959    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10960   "*
10961 {
10962   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10963     output_asm_insn (\"crxor 6,6,6\", operands);
10964
10965   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10966     output_asm_insn (\"creqv 6,6,6\", operands);
10967
10968   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z0@plt\" : \"b %z0\";
10969 }"
10970   [(set_attr "type" "branch,branch")
10971    (set_attr "length" "4,8")])
10972
10973 (define_expand "sibcall_value"
10974   [(parallel [(set (match_operand 0 "register_operand" "")
10975                 (call (mem:SI (match_operand 1 "address_operand" ""))
10976                       (match_operand 2 "" "")))
10977               (use (match_operand 3 "" ""))
10978               (use (scratch:SI))
10979               (return)])]
10980   ""
10981   "
10982 {
10983 #if TARGET_MACHO
10984   if (flag_pic)
10985     operands[1] = machopic_indirect_call_target (operands[1]);
10986 #endif
10987
10988   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
10989     abort ();
10990
10991   operands[1] = XEXP (operands[1], 0);
10992
10993 }")
10994
10995 (define_insn "*sibcall_value_nonlocal_sysv"
10996   [(set (match_operand 0 "" "")
10997         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10998               (match_operand 2 "" "")))
10999    (use (match_operand:SI 3 "immediate_operand" "O,n"))
11000    (use (match_scratch:SI 4 "=l,l"))
11001    (return)]
11002   "(DEFAULT_ABI == ABI_DARWIN
11003        || DEFAULT_ABI == ABI_V4
11004        || DEFAULT_ABI == ABI_AIX_NODESC)
11005    && (INTVAL (operands[3]) & CALL_LONG) == 0"
11006   "*
11007 {
11008   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
11009     output_asm_insn (\"crxor 6,6,6\", operands);
11010
11011   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
11012     output_asm_insn (\"creqv 6,6,6\", operands);
11013
11014   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"b %z1@plt\" : \"b %z1\";
11015 }"
11016   [(set_attr "type" "branch,branch")
11017    (set_attr "length" "4,8")])
11018
11019 (define_expand "sibcall_epilogue"
11020   [(use (const_int 0))]
11021   "TARGET_SCHED_PROLOG"
11022   "
11023 {
11024       rs6000_emit_epilogue (TRUE);
11025       DONE;
11026 }")
11027
11028 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
11029 ;; all of memory.  This blocks insns from being moved across this point.
11030
11031 (define_insn "blockage"
11032   [(unspec_volatile [(const_int 0)] 0)]
11033   ""
11034   "")
11035 \f
11036 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
11037 ;; signed & unsigned, and one type of branch.
11038 ;;
11039 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
11040 ;; insns, and branches.  We store the operands of compares until we see
11041 ;; how it is used.
11042 (define_expand "cmpsi"
11043   [(set (cc0)
11044         (compare (match_operand:SI 0 "gpc_reg_operand" "")
11045                  (match_operand:SI 1 "reg_or_short_operand" "")))]
11046   ""
11047   "
11048 {
11049   /* Take care of the possibility that operands[1] might be negative but
11050      this might be a logical operation.  That insn doesn't exist.  */
11051   if (GET_CODE (operands[1]) == CONST_INT
11052       && INTVAL (operands[1]) < 0)
11053     operands[1] = force_reg (SImode, operands[1]);
11054
11055   rs6000_compare_op0 = operands[0];
11056   rs6000_compare_op1 = operands[1];
11057   rs6000_compare_fp_p = 0;
11058   DONE;
11059 }")
11060
11061 (define_expand "cmpdi"
11062   [(set (cc0)
11063         (compare (match_operand:DI 0 "gpc_reg_operand" "")
11064                  (match_operand:DI 1 "reg_or_short_operand" "")))]
11065   "TARGET_POWERPC64"
11066   "
11067 {
11068   /* Take care of the possibility that operands[1] might be negative but
11069      this might be a logical operation.  That insn doesn't exist.  */
11070   if (GET_CODE (operands[1]) == CONST_INT
11071       && INTVAL (operands[1]) < 0)
11072     operands[1] = force_reg (DImode, operands[1]);
11073
11074   rs6000_compare_op0 = operands[0];
11075   rs6000_compare_op1 = operands[1];
11076   rs6000_compare_fp_p = 0;
11077   DONE;
11078 }")
11079
11080 (define_expand "cmpsf"
11081   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
11082                        (match_operand:SF 1 "gpc_reg_operand" "")))]
11083   "TARGET_HARD_FLOAT"
11084   "
11085 {
11086   rs6000_compare_op0 = operands[0];
11087   rs6000_compare_op1 = operands[1];
11088   rs6000_compare_fp_p = 1;
11089   DONE;
11090 }")
11091
11092 (define_expand "cmpdf"
11093   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
11094                        (match_operand:DF 1 "gpc_reg_operand" "")))]
11095   "TARGET_HARD_FLOAT && TARGET_FPRS"
11096   "
11097 {
11098   rs6000_compare_op0 = operands[0];
11099   rs6000_compare_op1 = operands[1];
11100   rs6000_compare_fp_p = 1;
11101   DONE;
11102 }")
11103
11104 (define_expand "cmptf"
11105   [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
11106                        (match_operand:TF 1 "gpc_reg_operand" "")))]
11107   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT
11108    && TARGET_FPRS && TARGET_LONG_DOUBLE_128"
11109   "
11110 {
11111   rs6000_compare_op0 = operands[0];
11112   rs6000_compare_op1 = operands[1];
11113   rs6000_compare_fp_p = 1;
11114   DONE;
11115 }")
11116
11117 (define_expand "beq"
11118   [(use (match_operand 0 "" ""))]
11119   ""
11120   "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
11121
11122 (define_expand "bne"
11123   [(use (match_operand 0 "" ""))]
11124   ""
11125   "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
11126
11127 (define_expand "bge"
11128   [(use (match_operand 0 "" ""))]
11129   ""
11130   "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
11131
11132 (define_expand "bgt"
11133   [(use (match_operand 0 "" ""))]
11134   ""
11135   "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
11136
11137 (define_expand "ble"
11138   [(use (match_operand 0 "" ""))]
11139   ""
11140   "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
11141
11142 (define_expand "blt"
11143   [(use (match_operand 0 "" ""))]
11144   ""
11145   "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
11146
11147 (define_expand "bgeu"
11148   [(use (match_operand 0 "" ""))]
11149   ""
11150   "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
11151
11152 (define_expand "bgtu"
11153   [(use (match_operand 0 "" ""))]
11154   ""
11155   "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
11156
11157 (define_expand "bleu"
11158   [(use (match_operand 0 "" ""))]
11159   ""
11160   "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
11161
11162 (define_expand "bltu"
11163   [(use (match_operand 0 "" ""))]
11164   ""
11165   "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
11166
11167 (define_expand "bunordered"
11168   [(use (match_operand 0 "" ""))]
11169   ""
11170   "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
11171
11172 (define_expand "bordered"
11173   [(use (match_operand 0 "" ""))]
11174   ""
11175   "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
11176
11177 (define_expand "buneq"
11178   [(use (match_operand 0 "" ""))]
11179   ""
11180   "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
11181
11182 (define_expand "bunge"
11183   [(use (match_operand 0 "" ""))]
11184   ""
11185   "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
11186
11187 (define_expand "bungt"
11188   [(use (match_operand 0 "" ""))]
11189   ""
11190   "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
11191
11192 (define_expand "bunle"
11193   [(use (match_operand 0 "" ""))]
11194   ""
11195   "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
11196
11197 (define_expand "bunlt"
11198   [(use (match_operand 0 "" ""))]
11199   ""
11200   "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
11201
11202 (define_expand "bltgt"
11203   [(use (match_operand 0 "" ""))]
11204   ""
11205   "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
11206
11207 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
11208 ;; For SEQ, likewise, except that comparisons with zero should be done
11209 ;; with an scc insns.  However, due to the order that combine see the
11210 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
11211 ;; the cases we don't want to handle.
11212 (define_expand "seq"
11213   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11214   ""
11215   "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
11216
11217 (define_expand "sne"
11218   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11219   ""
11220   "
11221
11222   if (! rs6000_compare_fp_p)
11223     FAIL;
11224
11225   rs6000_emit_sCOND (NE, operands[0]); 
11226   DONE;
11227 }")
11228
11229 ;; A > 0 is best done using the portable sequence, so fail in that case.
11230 (define_expand "sgt"
11231   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11232   ""
11233   "
11234 {
11235   if (! rs6000_compare_fp_p
11236       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11237     FAIL;
11238
11239   rs6000_emit_sCOND (GT, operands[0]); 
11240   DONE;
11241 }")
11242
11243 ;; A < 0 is best done in the portable way for A an integer.
11244 (define_expand "slt"
11245   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11246   ""
11247   "
11248 {
11249   if (! rs6000_compare_fp_p 
11250       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11251     FAIL;
11252
11253   rs6000_emit_sCOND (LT, operands[0]); 
11254   DONE;
11255 }")
11256
11257 ;; A >= 0 is best done the portable way for A an integer.
11258 (define_expand "sge"
11259   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11260   ""
11261   "
11262 {
11263   if (! rs6000_compare_fp_p
11264       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11265     FAIL;
11266
11267   rs6000_emit_sCOND (GE, operands[0]);
11268   DONE;
11269 }")
11270
11271 ;; A <= 0 is best done the portable way for A an integer.
11272 (define_expand "sle"
11273   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11274   ""
11275   "
11276 {
11277   if (! rs6000_compare_fp_p
11278       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
11279     FAIL;
11280
11281   rs6000_emit_sCOND (LE, operands[0]); 
11282   DONE;
11283 }")
11284
11285 (define_expand "sgtu"
11286   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11287   ""
11288   "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
11289
11290 (define_expand "sltu"
11291   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11292   ""
11293   "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
11294
11295 (define_expand "sgeu"
11296   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11297   ""
11298   "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
11299
11300 (define_expand "sleu"
11301   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
11302   ""
11303   "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
11304 \f
11305 ;; Here are the actual compare insns.
11306 (define_insn "*cmpsi_internal1"
11307   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11308         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11309                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11310   ""
11311   "{cmp%I2|cmpw%I2} %0,%1,%2"
11312   [(set_attr "type" "compare")])
11313
11314 (define_insn "*cmpdi_internal1"
11315   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
11316         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
11317                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11318   "TARGET_POWERPC64"
11319   "cmpd%I2 %0,%1,%2"
11320   [(set_attr "type" "compare")])
11321
11322 ;; If we are comparing a register for equality with a large constant,
11323 ;; we can do this with an XOR followed by a compare.  But we need a scratch
11324 ;; register for the result of the XOR.
11325
11326 (define_split
11327   [(set (match_operand:CC 0 "cc_reg_operand" "")
11328         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11329                     (match_operand:SI 2 "non_short_cint_operand" "")))
11330    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
11331   "find_single_use (operands[0], insn, 0)
11332    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
11333        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
11334   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
11335    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
11336   "
11337 {
11338   /* Get the constant we are comparing against, C,  and see what it looks like
11339      sign-extended to 16 bits.  Then see what constant could be XOR'ed
11340      with C to get the sign-extended value.  */
11341
11342   HOST_WIDE_INT c = INTVAL (operands[2]);
11343   HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
11344   HOST_WIDE_INT xorv = c ^ sextc;
11345
11346   operands[4] = GEN_INT (xorv);
11347   operands[5] = GEN_INT (sextc);
11348 }")
11349
11350 (define_insn "*cmpsi_internal2"
11351   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11352         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11353                        (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
11354   ""
11355   "{cmpl%I2|cmplw%I2} %0,%1,%b2"
11356   [(set_attr "type" "compare")])
11357
11358 (define_insn "*cmpdi_internal2"
11359   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
11360         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
11361                        (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
11362   ""
11363   "cmpld%I2 %0,%1,%b2"
11364   [(set_attr "type" "compare")])
11365
11366 ;; The following two insns don't exist as single insns, but if we provide
11367 ;; them, we can swap an add and compare, which will enable us to overlap more
11368 ;; of the required delay between a compare and branch.  We generate code for
11369 ;; them by splitting.
11370
11371 (define_insn ""
11372   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
11373         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
11374                     (match_operand:SI 2 "short_cint_operand" "i")))
11375    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11376         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11377   ""
11378   "#"
11379   [(set_attr "length" "8")])
11380
11381 (define_insn ""
11382   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
11383         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
11384                        (match_operand:SI 2 "u_short_cint_operand" "i")))
11385    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
11386         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
11387   ""
11388   "#"
11389   [(set_attr "length" "8")])
11390
11391 (define_split
11392   [(set (match_operand:CC 3 "cc_reg_operand" "")
11393         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
11394                     (match_operand:SI 2 "short_cint_operand" "")))
11395    (set (match_operand:SI 0 "gpc_reg_operand" "")
11396         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11397   ""
11398   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
11399    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11400
11401 (define_split
11402   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
11403         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
11404                        (match_operand:SI 2 "u_short_cint_operand" "")))
11405    (set (match_operand:SI 0 "gpc_reg_operand" "")
11406         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
11407   ""
11408   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
11409    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
11410
11411 (define_insn "*cmpsf_internal1"
11412   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11413         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
11414                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
11415   "TARGET_HARD_FLOAT && TARGET_FPRS"
11416   "fcmpu %0,%1,%2"
11417   [(set_attr "type" "fpcompare")])
11418
11419 (define_insn "*cmpdf_internal1"
11420   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11421         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
11422                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
11423   "TARGET_HARD_FLOAT && TARGET_FPRS"
11424   "fcmpu %0,%1,%2"
11425   [(set_attr "type" "fpcompare")])
11426
11427 ;; Only need to compare second words if first words equal
11428 (define_insn "*cmptf_internal1"
11429   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
11430         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
11431                       (match_operand:TF 2 "gpc_reg_operand" "f")))]
11432   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_FPRS
11433    && TARGET_LONG_DOUBLE_128"
11434   "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
11435   [(set_attr "type" "fpcompare")
11436    (set_attr "length" "12")])
11437 \f
11438 ;; Now we have the scc insns.  We can do some combinations because of the
11439 ;; way the machine works.
11440 ;;
11441 ;; Note that this is probably faster if we can put an insn between the
11442 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
11443 ;; cases the insns below which don't use an intermediate CR field will
11444 ;; be used instead.
11445 (define_insn ""
11446   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11447         (match_operator:SI 1 "scc_comparison_operator"
11448                            [(match_operand 2 "cc_reg_operand" "y")
11449                             (const_int 0)]))]
11450   ""
11451   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
11452   [(set_attr "type" "cr_logical")
11453    (set_attr "length" "12")])
11454
11455 ;; Same as above, but get the OV/ORDERED bit.
11456 (define_insn "move_from_CR_ov_bit"
11457   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11458         (unspec:SI [(match_operand 1 "cc_reg_operand" "y")] 724))]
11459   "TARGET_ISEL"
11460   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%t1,1"
11461   [(set_attr "length" "12")])
11462
11463 (define_insn ""
11464   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11465         (match_operator:DI 1 "scc_comparison_operator"
11466                            [(match_operand 2 "cc_reg_operand" "y")
11467                             (const_int 0)]))]
11468   "TARGET_POWERPC64"
11469   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
11470   [(set_attr "type" "cr_logical")
11471    (set_attr "length" "12")])
11472
11473 (define_insn ""
11474   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11475         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11476                                        [(match_operand 2 "cc_reg_operand" "y,y")
11477                                         (const_int 0)])
11478                     (const_int 0)))
11479    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
11480         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11481   "! TARGET_POWERPC64"
11482   "@
11483    %D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1
11484    #"
11485   [(set_attr "type" "delayed_compare")
11486    (set_attr "length" "12,16")])
11487
11488 (define_split
11489   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11490         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
11491                                        [(match_operand 2 "cc_reg_operand" "")
11492                                         (const_int 0)])
11493                     (const_int 0)))
11494    (set (match_operand:SI 3 "gpc_reg_operand" "")
11495         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
11496   "! TARGET_POWERPC64 && reload_completed"
11497   [(set (match_dup 3)
11498         (match_op_dup 1 [(match_dup 2) (const_int 0)]))
11499    (set (match_dup 0)
11500         (compare:CC (match_dup 3)
11501                     (const_int 0)))]
11502   "")
11503
11504 (define_insn ""
11505   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11506         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11507                                       [(match_operand 2 "cc_reg_operand" "y")
11508                                        (const_int 0)])
11509                    (match_operand:SI 3 "const_int_operand" "n")))]
11510   ""
11511   "*
11512 {
11513   int is_bit = ccr_bit (operands[1], 1);
11514   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11515   int count;
11516
11517   if (is_bit >= put_bit)
11518     count = is_bit - put_bit;
11519   else
11520     count = 32 - (put_bit - is_bit);
11521
11522   operands[4] = GEN_INT (count);
11523   operands[5] = GEN_INT (put_bit);
11524
11525   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
11526 }"
11527   [(set_attr "type" "cr_logical")
11528    (set_attr "length" "12")])
11529
11530 (define_insn ""
11531   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11532         (compare:CC
11533          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11534                                        [(match_operand 2 "cc_reg_operand" "y,y")
11535                                         (const_int 0)])
11536                     (match_operand:SI 3 "const_int_operand" "n,n"))
11537          (const_int 0)))
11538    (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
11539         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11540                    (match_dup 3)))]
11541   ""
11542   "*
11543 {
11544   int is_bit = ccr_bit (operands[1], 1);
11545   int put_bit = 31 - (INTVAL (operands[3]) & 31);
11546   int count;
11547
11548   /* Force split for non-cc0 compare.  */
11549   if (which_alternative == 1)
11550      return \"#\";
11551
11552   if (is_bit >= put_bit)
11553     count = is_bit - put_bit;
11554   else
11555     count = 32 - (put_bit - is_bit);
11556
11557   operands[5] = GEN_INT (count);
11558   operands[6] = GEN_INT (put_bit);
11559
11560   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
11561 }"
11562   [(set_attr "type" "delayed_compare")
11563    (set_attr "length" "12,16")])
11564
11565 (define_split
11566   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11567         (compare:CC
11568          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
11569                                        [(match_operand 2 "cc_reg_operand" "")
11570                                         (const_int 0)])
11571                     (match_operand:SI 3 "const_int_operand" ""))
11572          (const_int 0)))
11573    (set (match_operand:SI 4 "gpc_reg_operand" "")
11574         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11575                    (match_dup 3)))]
11576   "reload_completed"
11577   [(set (match_dup 4)
11578         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
11579                    (match_dup 3)))
11580    (set (match_dup 0)
11581         (compare:CC (match_dup 4)
11582                     (const_int 0)))]
11583   "")
11584
11585 ;; There is a 3 cycle delay between consecutive mfcr instructions
11586 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
11587
11588 (define_peephole
11589   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11590         (match_operator:SI 1 "scc_comparison_operator"
11591                            [(match_operand 2 "cc_reg_operand" "y")
11592                             (const_int 0)]))
11593    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
11594         (match_operator:SI 4 "scc_comparison_operator"
11595                            [(match_operand 5 "cc_reg_operand" "y")
11596                             (const_int 0)]))]
11597   "REGNO (operands[2]) != REGNO (operands[5])"
11598   "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11599   [(set_attr "type" "cr_logical")
11600    (set_attr "length" "20")])
11601
11602 (define_peephole
11603   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11604         (match_operator:DI 1 "scc_comparison_operator"
11605                            [(match_operand 2 "cc_reg_operand" "y")
11606                             (const_int 0)]))
11607    (set (match_operand:DI 3 "gpc_reg_operand" "=r")
11608         (match_operator:DI 4 "scc_comparison_operator"
11609                            [(match_operand 5 "cc_reg_operand" "y")
11610                             (const_int 0)]))]
11611   "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
11612   "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
11613   [(set_attr "type" "cr_logical")
11614    (set_attr "length" "20")])
11615
11616 ;; There are some scc insns that can be done directly, without a compare.
11617 ;; These are faster because they don't involve the communications between
11618 ;; the FXU and branch units.   In fact, we will be replacing all of the
11619 ;; integer scc insns here or in the portable methods in emit_store_flag.
11620 ;;
11621 ;; Also support (neg (scc ..)) since that construct is used to replace
11622 ;; branches, (plus (scc ..) ..) since that construct is common and
11623 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
11624 ;; cases where it is no more expensive than (neg (scc ..)).
11625
11626 ;; Have reload force a constant into a register for the simple insns that
11627 ;; otherwise won't accept constants.  We do this because it is faster than
11628 ;; the cmp/mfcr sequence we would otherwise generate.
11629
11630 (define_insn ""
11631   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11632         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11633                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
11634    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
11635   "! TARGET_POWERPC64"
11636   "@
11637    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11638    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
11639    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11640    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
11641    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
11642   [(set_attr "length" "12,8,12,12,12")])
11643
11644 (define_insn ""
11645   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
11646         (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
11647                (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
11648    (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
11649   "TARGET_POWERPC64"
11650   "@
11651    xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
11652    subfic %3,%1,0\;adde %0,%3,%1
11653    xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
11654    xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
11655    subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
11656   [(set_attr "length" "12,8,12,12,12")])
11657
11658 (define_insn ""
11659   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11660         (compare:CC
11661          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11662                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11663          (const_int 0)))
11664    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11665         (eq:SI (match_dup 1) (match_dup 2)))
11666    (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11667   "! TARGET_POWERPC64"
11668   "@
11669    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11670    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
11671    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11672    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11673    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
11674    #
11675    #
11676    #
11677    #
11678    #"
11679   [(set_attr "type" "compare")
11680    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11681
11682 (define_split
11683   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11684         (compare:CC
11685          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11686                 (match_operand:SI 2 "reg_or_cint_operand" ""))
11687          (const_int 0)))
11688    (set (match_operand:SI 0 "gpc_reg_operand" "")
11689         (eq:SI (match_dup 1) (match_dup 2)))
11690    (clobber (match_scratch:SI 3 ""))]
11691   "! TARGET_POWERPC64 && reload_completed"
11692   [(parallel [(set (match_dup 0)
11693         (eq:SI (match_dup 1) (match_dup 2)))
11694    (clobber (match_dup 3))])
11695    (set (match_dup 4)
11696         (compare:CC (match_dup 0)
11697                     (const_int 0)))]
11698   "")
11699
11700 (define_insn ""
11701   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11702         (compare:CC
11703          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11704                 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
11705          (const_int 0)))
11706    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
11707         (eq:DI (match_dup 1) (match_dup 2)))
11708    (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
11709   "TARGET_POWERPC64"
11710   "@
11711    xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11712    subfic %3,%1,0\;adde. %0,%3,%1
11713    xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
11714    xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
11715    subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
11716    #
11717    #
11718    #
11719    #
11720    #"
11721   [(set_attr "type" "compare")
11722    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11723
11724 (define_split
11725   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11726         (compare:CC
11727          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11728                 (match_operand:DI 2 "reg_or_cint_operand" ""))
11729          (const_int 0)))
11730    (set (match_operand:DI 0 "gpc_reg_operand" "")
11731         (eq:DI (match_dup 1) (match_dup 2)))
11732    (clobber (match_scratch:DI 3 ""))]
11733   "TARGET_POWERPC64 && reload_completed"
11734   [(parallel [(set (match_dup 0)
11735         (eq:DI (match_dup 1) (match_dup 2)))
11736    (clobber (match_dup 3))])
11737    (set (match_dup 4)
11738         (compare:CC (match_dup 0)
11739                     (const_int 0)))]
11740   "")
11741
11742 ;; We have insns of the form shown by the first define_insn below.  If
11743 ;; there is something inside the comparison operation, we must split it.
11744 (define_split
11745   [(set (match_operand:SI 0 "gpc_reg_operand" "")
11746         (plus:SI (match_operator 1 "comparison_operator"
11747                                  [(match_operand:SI 2 "" "")
11748                                   (match_operand:SI 3
11749                                                     "reg_or_cint_operand" "")])
11750                  (match_operand:SI 4 "gpc_reg_operand" "")))
11751    (clobber (match_operand:SI 5 "register_operand" ""))]
11752   "! gpc_reg_operand (operands[2], SImode)"
11753   [(set (match_dup 5) (match_dup 2))
11754    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11755                                (match_dup 4)))])
11756
11757 (define_insn ""
11758   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11759         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11760                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
11761                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11762   "! TARGET_POWERPC64"
11763   "@
11764    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11765    {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11766    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11767    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11768    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11769   [(set_attr "length" "12,8,12,12,12")])
11770
11771 (define_insn ""
11772   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11773         (compare:CC
11774          (plus:SI
11775           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11776                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11777           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11778          (const_int 0)))
11779    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11780   "! TARGET_POWERPC64"
11781   "@
11782    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11783    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11784    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11785    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11786    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11787    #
11788    #
11789    #
11790    #
11791    #"
11792   [(set_attr "type" "compare")
11793    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11794
11795 (define_split
11796   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11797         (compare:CC
11798          (plus:SI
11799           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11800                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11801           (match_operand:SI 3 "gpc_reg_operand" ""))
11802          (const_int 0)))
11803    (clobber (match_scratch:SI 4 ""))]
11804   "! TARGET_POWERPC64 && reload_completed"
11805   [(set (match_dup 4)
11806         (plus:SI (eq:SI (match_dup 1)
11807                  (match_dup 2))
11808           (match_dup 3)))
11809    (set (match_dup 0)
11810         (compare:CC (match_dup 4)
11811                     (const_int 0)))]
11812   "")
11813
11814 (define_insn ""
11815   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11816         (compare:CC
11817          (plus:SI
11818           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11819                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11820           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11821          (const_int 0)))
11822    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11823         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11824   "! TARGET_POWERPC64"
11825   "@
11826    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11827    {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11828    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11829    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11830    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11831    #
11832    #
11833    #
11834    #
11835    #"
11836   [(set_attr "type" "compare")
11837    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11838
11839 (define_split
11840   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11841         (compare:CC
11842          (plus:SI
11843           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11844                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11845           (match_operand:SI 3 "gpc_reg_operand" ""))
11846          (const_int 0)))
11847    (set (match_operand:SI 0 "gpc_reg_operand" "")
11848         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11849   "! TARGET_POWERPC64 && reload_completed"
11850   [(set (match_dup 0)
11851         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11852    (set (match_dup 4)
11853         (compare:CC (match_dup 0)
11854                     (const_int 0)))]
11855   "")
11856
11857 (define_insn ""
11858   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11859         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11860                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
11861   "! TARGET_POWERPC64"
11862   "@
11863    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11864    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11865    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11866    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11867    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
11868    [(set_attr "length" "12,8,12,12,12")])
11869
11870 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
11871 ;; since it nabs/sr is just as fast.
11872 (define_insn "*ne0"
11873   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11874         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11875                      (const_int 31)))
11876    (clobber (match_scratch:SI 2 "=&r"))]
11877   "! TARGET_POWER && ! TARGET_POWERPC64 && !TARGET_ISEL"
11878   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11879   [(set_attr "length" "8")])
11880
11881 (define_insn ""
11882   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11883         (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11884                      (const_int 63)))
11885    (clobber (match_scratch:DI 2 "=&r"))]
11886   "TARGET_POWERPC64"
11887   "addic %2,%1,-1\;subfe %0,%2,%1"
11888   [(set_attr "length" "8")])
11889
11890 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11891 (define_insn ""
11892   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11893         (plus:SI (lshiftrt:SI
11894                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11895                   (const_int 31))
11896                  (match_operand:SI 2 "gpc_reg_operand" "r")))
11897    (clobber (match_scratch:SI 3 "=&r"))]
11898   "! TARGET_POWERPC64"
11899   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11900   [(set_attr "length" "8")])
11901
11902 (define_insn ""
11903   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11904         (plus:DI (lshiftrt:DI
11905                   (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11906                   (const_int 63))
11907                  (match_operand:DI 2 "gpc_reg_operand" "r")))
11908    (clobber (match_scratch:DI 3 "=&r"))]
11909   "TARGET_POWERPC64"
11910   "addic %3,%1,-1\;addze %0,%2"
11911   [(set_attr "length" "8")])
11912
11913 (define_insn ""
11914   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11915         (compare:CC
11916          (plus:SI (lshiftrt:SI
11917                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11918                    (const_int 31))
11919                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11920          (const_int 0)))
11921    (clobber (match_scratch:SI 3 "=&r,&r"))
11922    (clobber (match_scratch:SI 4 "=X,&r"))]
11923   "! TARGET_POWERPC64"
11924   "@
11925    {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11926    #"
11927   [(set_attr "type" "compare")
11928    (set_attr "length" "8,12")])
11929
11930 (define_split
11931   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11932         (compare:CC
11933          (plus:SI (lshiftrt:SI
11934                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11935                    (const_int 31))
11936                   (match_operand:SI 2 "gpc_reg_operand" ""))
11937          (const_int 0)))
11938    (clobber (match_scratch:SI 3 ""))
11939    (clobber (match_scratch:SI 4 ""))]
11940   "! TARGET_POWERPC64 && reload_completed"
11941   [(parallel [(set (match_dup 3)
11942                    (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11943                                          (const_int 31))
11944                             (match_dup 2)))
11945               (clobber (match_dup 4))])
11946    (set (match_dup 0)
11947         (compare:CC (match_dup 3)
11948                     (const_int 0)))]
11949   "")
11950
11951 (define_insn ""
11952   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11953         (compare:CC
11954          (plus:DI (lshiftrt:DI
11955                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11956                    (const_int 63))
11957                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11958          (const_int 0)))
11959    (clobber (match_scratch:DI 3 "=&r,&r"))]
11960   "TARGET_POWERPC64"
11961   "@
11962    addic %3,%1,-1\;addze. %3,%2
11963    #"
11964   [(set_attr "type" "compare")
11965    (set_attr "length" "8,12")])
11966
11967 (define_split
11968   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11969         (compare:CC
11970          (plus:DI (lshiftrt:DI
11971                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11972                    (const_int 63))
11973                   (match_operand:DI 2 "gpc_reg_operand" ""))
11974          (const_int 0)))
11975    (clobber (match_scratch:DI 3 ""))]
11976   "TARGET_POWERPC64 && reload_completed"
11977   [(set (match_dup 3)
11978         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11979                    (const_int 63))
11980                   (match_dup 2)))
11981    (set (match_dup 0)
11982         (compare:CC (match_dup 3)
11983                     (const_int 0)))]
11984   "")
11985
11986 (define_insn ""
11987   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11988         (compare:CC
11989          (plus:SI (lshiftrt:SI
11990                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11991                    (const_int 31))
11992                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11993          (const_int 0)))
11994    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11995         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11996                  (match_dup 2)))
11997    (clobber (match_scratch:SI 3 "=&r,&r"))]
11998   "! TARGET_POWERPC64"
11999   "@
12000    {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
12001    #"
12002   [(set_attr "type" "compare")
12003    (set_attr "length" "8,12")])
12004
12005 (define_split
12006   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12007         (compare:CC
12008          (plus:SI (lshiftrt:SI
12009                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
12010                    (const_int 31))
12011                   (match_operand:SI 2 "gpc_reg_operand" ""))
12012          (const_int 0)))
12013    (set (match_operand:SI 0 "gpc_reg_operand" "")
12014         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12015                  (match_dup 2)))
12016    (clobber (match_scratch:SI 3 ""))]
12017   "! TARGET_POWERPC64 && reload_completed"
12018   [(parallel [(set (match_dup 0)
12019         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
12020                  (match_dup 2)))
12021    (clobber (match_dup 3))])
12022    (set (match_dup 4)
12023         (compare:CC (match_dup 0)
12024                     (const_int 0)))]
12025   "")
12026
12027 (define_insn ""
12028   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12029         (compare:CC
12030          (plus:DI (lshiftrt:DI
12031                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
12032                    (const_int 63))
12033                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12034          (const_int 0)))
12035    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12036         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12037                  (match_dup 2)))
12038    (clobber (match_scratch:DI 3 "=&r,&r"))]
12039   "TARGET_POWERPC64"
12040   "@
12041    addic %3,%1,-1\;addze. %0,%2
12042    #"
12043   [(set_attr "type" "compare")
12044    (set_attr "length" "8,12")])
12045
12046 (define_split
12047   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12048         (compare:CC
12049          (plus:DI (lshiftrt:DI
12050                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
12051                    (const_int 63))
12052                   (match_operand:DI 2 "gpc_reg_operand" ""))
12053          (const_int 0)))
12054    (set (match_operand:DI 0 "gpc_reg_operand" "")
12055         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12056                  (match_dup 2)))
12057    (clobber (match_scratch:DI 3 ""))]
12058   "TARGET_POWERPC64 && reload_completed"
12059   [(parallel [(set (match_dup 0)
12060         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
12061                  (match_dup 2)))
12062    (clobber (match_dup 3))])
12063    (set (match_dup 4)
12064         (compare:CC (match_dup 0)
12065                     (const_int 0)))]
12066   "")
12067
12068 (define_insn ""
12069   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12070         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12071                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
12072    (clobber (match_scratch:SI 3 "=r,X"))]
12073   "TARGET_POWER"
12074   "@
12075    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
12076    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
12077   [(set_attr "length" "12")])
12078
12079 (define_insn ""
12080   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12081         (compare:CC
12082          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12083                 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12084          (const_int 0)))
12085    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12086         (le:SI (match_dup 1) (match_dup 2)))
12087    (clobber (match_scratch:SI 3 "=r,X,r,X"))]
12088   "TARGET_POWER"
12089   "@
12090    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12091    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
12092    #
12093    #"
12094   [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
12095    (set_attr "length" "12,12,16,16")])
12096
12097 (define_split
12098   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12099         (compare:CC
12100          (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12101                 (match_operand:SI 2 "reg_or_short_operand" ""))
12102          (const_int 0)))
12103    (set (match_operand:SI 0 "gpc_reg_operand" "")
12104         (le:SI (match_dup 1) (match_dup 2)))
12105    (clobber (match_scratch:SI 3 ""))]
12106   "TARGET_POWER && reload_completed"
12107   [(parallel [(set (match_dup 0)
12108         (le:SI (match_dup 1) (match_dup 2)))
12109    (clobber (match_dup 3))])
12110    (set (match_dup 4)
12111         (compare:CC (match_dup 0)
12112                     (const_int 0)))]
12113   "")
12114
12115 (define_insn ""
12116   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12117         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12118                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
12119                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12120   "TARGET_POWER"
12121   "@
12122    doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
12123    {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze|addze} %0,%3"
12124   [(set_attr "length" "12")])
12125
12126 (define_insn ""
12127   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12128         (compare:CC
12129          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12130                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12131                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12132          (const_int 0)))
12133    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12134   "TARGET_POWER"
12135   "@
12136    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12137    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
12138    #
12139    #"
12140   [(set_attr "type" "compare")
12141    (set_attr "length" "12,12,16,16")])
12142
12143 (define_split
12144   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12145         (compare:CC
12146          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12147                          (match_operand:SI 2 "reg_or_short_operand" ""))
12148                   (match_operand:SI 3 "gpc_reg_operand" ""))
12149          (const_int 0)))
12150    (clobber (match_scratch:SI 4 ""))]
12151   "TARGET_POWER && reload_completed"
12152   [(set (match_dup 4)
12153         (plus:SI (le:SI (match_dup 1) (match_dup 2))
12154                  (match_dup 3)))
12155    (set (match_dup 0)
12156         (compare:CC (match_dup 4)
12157                     (const_int 0)))]
12158   "")
12159
12160 (define_insn ""
12161   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12162         (compare:CC
12163          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12164                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
12165                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12166          (const_int 0)))
12167    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12168         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12169   "TARGET_POWER"
12170   "@
12171    doz %0,%2,%1\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12172    {srai|srawi} %0,%1,31\;{sf|subfc} %0,%1,%0\;{aze.|addze.} %0,%3
12173    #
12174    #"
12175   [(set_attr "type" "compare")
12176    (set_attr "length" "12,12,16,16")])
12177
12178 (define_split
12179   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12180         (compare:CC
12181          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
12182                          (match_operand:SI 2 "reg_or_short_operand" ""))
12183                   (match_operand:SI 3 "gpc_reg_operand" ""))
12184          (const_int 0)))
12185    (set (match_operand:SI 0 "gpc_reg_operand" "")
12186         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12187   "TARGET_POWER && reload_completed"
12188   [(set (match_dup 0)
12189         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12190    (set (match_dup 4)
12191         (compare:CC (match_dup 0)
12192                     (const_int 0)))]
12193   "")
12194
12195 (define_insn ""
12196   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12197         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12198                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
12199   "TARGET_POWER"
12200   "@
12201    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
12202    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
12203   [(set_attr "length" "12")])
12204
12205 (define_insn ""
12206   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12207         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12208                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12209   "! TARGET_POWERPC64"
12210   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12211   [(set_attr "length" "12")])
12212
12213 (define_insn ""
12214   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12215         (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12216                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
12217   "TARGET_POWERPC64"
12218   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
12219   [(set_attr "length" "12")])
12220
12221 (define_insn ""
12222   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12223         (compare:CC
12224          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12225                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
12226          (const_int 0)))
12227    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12228         (leu:DI (match_dup 1) (match_dup 2)))]
12229   "TARGET_POWERPC64"
12230   "@
12231    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12232    #"
12233   [(set_attr "type" "compare")
12234    (set_attr "length" "12,16")])
12235
12236 (define_split
12237   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12238         (compare:CC
12239          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12240                  (match_operand:DI 2 "reg_or_short_operand" ""))
12241          (const_int 0)))
12242    (set (match_operand:DI 0 "gpc_reg_operand" "")
12243         (leu:DI (match_dup 1) (match_dup 2)))]
12244   "TARGET_POWERPC64 && reload_completed"
12245   [(set (match_dup 0)
12246         (leu:DI (match_dup 1) (match_dup 2)))
12247    (set (match_dup 3)
12248         (compare:CC (match_dup 0)
12249                     (const_int 0)))]
12250   "")
12251
12252 (define_insn ""
12253   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12254         (compare:CC
12255          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12256                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12257          (const_int 0)))
12258    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12259         (leu:SI (match_dup 1) (match_dup 2)))]
12260   "! TARGET_POWERPC64"
12261   "@
12262    {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12263    #"
12264   [(set_attr "type" "compare")
12265    (set_attr "length" "12,16")])
12266
12267 (define_split
12268   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12269         (compare:CC
12270          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12271                  (match_operand:SI 2 "reg_or_short_operand" ""))
12272          (const_int 0)))
12273    (set (match_operand:SI 0 "gpc_reg_operand" "")
12274         (leu:SI (match_dup 1) (match_dup 2)))]
12275   "! TARGET_POWERPC64 && reload_completed"
12276   [(set (match_dup 0)
12277         (leu:SI (match_dup 1) (match_dup 2)))
12278    (set (match_dup 3)
12279         (compare:CC (match_dup 0)
12280                     (const_int 0)))]
12281   "")
12282
12283 (define_insn ""
12284   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12285         (compare:CC
12286          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12287                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
12288          (const_int 0)))
12289    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12290         (leu:DI (match_dup 1) (match_dup 2)))]
12291   "TARGET_POWERPC64"
12292   "@
12293    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
12294    #"
12295   [(set_attr "type" "compare")
12296    (set_attr "length" "12,16")])
12297
12298 (define_insn ""
12299   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12300         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12301                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
12302                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12303   "! TARGET_POWERPC64"
12304   "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
12305   [(set_attr "length" "8")])
12306
12307 (define_insn ""
12308   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12309         (compare:CC
12310          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12311                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12312                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12313          (const_int 0)))
12314    (clobber (match_scratch:SI 4 "=&r,&r"))]
12315   "! TARGET_POWERPC64"
12316   "@
12317    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
12318    #"
12319   [(set_attr "type" "compare")
12320    (set_attr "length" "8,12")])
12321
12322 (define_split
12323   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12324         (compare:CC
12325          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12326                           (match_operand:SI 2 "reg_or_short_operand" ""))
12327                   (match_operand:SI 3 "gpc_reg_operand" ""))
12328          (const_int 0)))
12329    (clobber (match_scratch:SI 4 ""))]
12330   "! TARGET_POWERPC64 && reload_completed"
12331   [(set (match_dup 4)
12332         (plus:SI (leu:SI (match_dup 1) (match_dup 2))
12333                   (match_dup 3)))
12334    (set (match_dup 0)
12335         (compare:CC (match_dup 4)
12336                     (const_int 0)))]
12337   "")
12338
12339 (define_insn ""
12340   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12341         (compare:CC
12342          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12343                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12344                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12345          (const_int 0)))
12346    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12347         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12348   "! TARGET_POWERPC64"
12349   "@
12350    {sf%I2|subf%I2c} %0,%1,%2\;{aze.|addze.} %0,%3
12351    #"
12352   [(set_attr "type" "compare")
12353    (set_attr "length" "8,12")])
12354
12355 (define_split
12356   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12357         (compare:CC
12358          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12359                           (match_operand:SI 2 "reg_or_short_operand" ""))
12360                   (match_operand:SI 3 "gpc_reg_operand" ""))
12361          (const_int 0)))
12362    (set (match_operand:SI 0 "gpc_reg_operand" "")
12363         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12364   "! TARGET_POWERPC64 && reload_completed"
12365   [(set (match_dup 0)
12366         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12367    (set (match_dup 4)
12368         (compare:CC (match_dup 0)
12369                     (const_int 0)))]
12370   "")
12371
12372 (define_insn ""
12373   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12374         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12375                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12376   "! TARGET_POWERPC64"
12377   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
12378    [(set_attr "length" "12")])
12379
12380 (define_insn ""
12381   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12382         (and:SI (neg:SI
12383                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12384                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
12385                 (match_operand:SI 3 "gpc_reg_operand" "r")))]
12386   "! TARGET_POWERPC64"
12387   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
12388   [(set_attr "length" "12")])
12389
12390 (define_insn ""
12391   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12392         (compare:CC
12393          (and:SI (neg:SI
12394                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12395                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12396                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12397          (const_int 0)))
12398    (clobber (match_scratch:SI 4 "=&r,&r"))]
12399   "! TARGET_POWERPC64"
12400   "@
12401    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12402    #"
12403   [(set_attr "type" "compare")
12404    (set_attr "length" "12,16")])
12405
12406 (define_split
12407   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12408         (compare:CC
12409          (and:SI (neg:SI
12410                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12411                           (match_operand:SI 2 "reg_or_short_operand" "")))
12412                  (match_operand:SI 3 "gpc_reg_operand" ""))
12413          (const_int 0)))
12414    (clobber (match_scratch:SI 4 ""))]
12415   "! TARGET_POWERPC64 && reload_completed"
12416   [(set (match_dup 4)
12417         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12418                 (match_dup 3)))
12419    (set (match_dup 0)
12420         (compare:CC (match_dup 4)
12421                     (const_int 0)))]
12422   "")
12423
12424 (define_insn ""
12425   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12426         (compare:CC
12427          (and:SI (neg:SI
12428                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12429                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
12430                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12431          (const_int 0)))
12432    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12433         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12434   "! TARGET_POWERPC64"
12435   "@
12436    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
12437    #"
12438   [(set_attr "type" "compare")
12439    (set_attr "length" "12,16")])
12440
12441 (define_split
12442   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12443         (compare:CC
12444          (and:SI (neg:SI
12445                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12446                           (match_operand:SI 2 "reg_or_short_operand" "")))
12447                  (match_operand:SI 3 "gpc_reg_operand" ""))
12448          (const_int 0)))
12449    (set (match_operand:SI 0 "gpc_reg_operand" "")
12450         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
12451   "! TARGET_POWERPC64 && reload_completed"
12452   [(set (match_dup 0)
12453         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2)))
12454                 (match_dup 3)))
12455    (set (match_dup 4)
12456         (compare:CC (match_dup 0)
12457                     (const_int 0)))]
12458   "")
12459
12460 (define_insn ""
12461   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12462         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12463                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12464   "TARGET_POWER"
12465   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12466    [(set_attr "length" "12")])
12467
12468 (define_insn ""
12469   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12470         (compare:CC
12471          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12472                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12473          (const_int 0)))
12474    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12475         (lt:SI (match_dup 1) (match_dup 2)))]
12476   "TARGET_POWER"
12477   "@
12478    doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12479    #"
12480   [(set_attr "type" "delayed_compare")
12481    (set_attr "length" "12,16")])
12482
12483 (define_split
12484   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12485         (compare:CC
12486          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12487                 (match_operand:SI 2 "reg_or_short_operand" ""))
12488          (const_int 0)))
12489    (set (match_operand:SI 0 "gpc_reg_operand" "")
12490         (lt:SI (match_dup 1) (match_dup 2)))]
12491   "TARGET_POWER && reload_completed"
12492   [(set (match_dup 0)
12493         (lt:SI (match_dup 1) (match_dup 2)))
12494    (set (match_dup 3)
12495         (compare:CC (match_dup 0)
12496                     (const_int 0)))]
12497   "")
12498
12499 (define_insn ""
12500   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12501         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12502                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
12503                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12504   "TARGET_POWER"
12505   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
12506   [(set_attr "length" "12")])
12507
12508 (define_insn ""
12509   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12510         (compare:CC
12511          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12512                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12513                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12514          (const_int 0)))
12515    (clobber (match_scratch:SI 4 "=&r,&r"))]
12516   "TARGET_POWER"
12517   "@
12518    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12519    #"
12520   [(set_attr "type" "compare")
12521    (set_attr "length" "12,16")])
12522
12523 (define_split
12524   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12525         (compare:CC
12526          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12527                          (match_operand:SI 2 "reg_or_short_operand" ""))
12528                   (match_operand:SI 3 "gpc_reg_operand" ""))
12529          (const_int 0)))
12530    (clobber (match_scratch:SI 4 ""))]
12531   "TARGET_POWER && reload_completed"
12532   [(set (match_dup 4)
12533         (plus:SI (lt:SI (match_dup 1) (match_dup 2))
12534                  (match_dup 3)))
12535    (set (match_dup 0)
12536         (compare:CC (match_dup 4)
12537                     (const_int 0)))]
12538   "")
12539
12540 (define_insn ""
12541   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12542         (compare:CC
12543          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12544                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12545                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12546          (const_int 0)))
12547    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12548         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12549   "TARGET_POWER"
12550   "@
12551    doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
12552    #"
12553   [(set_attr "type" "compare")
12554    (set_attr "length" "12,16")])
12555
12556 (define_split
12557   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12558         (compare:CC
12559          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12560                          (match_operand:SI 2 "reg_or_short_operand" ""))
12561                   (match_operand:SI 3 "gpc_reg_operand" ""))
12562          (const_int 0)))
12563    (set (match_operand:SI 0 "gpc_reg_operand" "")
12564         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12565   "TARGET_POWER && reload_completed"
12566   [(set (match_dup 0)
12567         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12568    (set (match_dup 4)
12569         (compare:CC (match_dup 0)
12570                     (const_int 0)))]
12571   "")
12572
12573 (define_insn ""
12574   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12575         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12576                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12577   "TARGET_POWER"
12578   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12579   [(set_attr "length" "12")])
12580
12581 (define_insn ""
12582   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12583         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12584                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12585   "! TARGET_POWERPC64"
12586   "@
12587    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
12588    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
12589   [(set_attr "length" "12")])
12590
12591 (define_insn ""
12592   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12593         (compare:CC
12594          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12595                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12596          (const_int 0)))
12597    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12598         (ltu:SI (match_dup 1) (match_dup 2)))]
12599   "! TARGET_POWERPC64"
12600   "@
12601    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12602    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12603    #
12604    #"
12605   [(set_attr "type" "compare")
12606    (set_attr "length" "12,12,16,16")])
12607
12608 (define_split
12609   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12610         (compare:CC
12611          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12612                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12613          (const_int 0)))
12614    (set (match_operand:SI 0 "gpc_reg_operand" "")
12615         (ltu:SI (match_dup 1) (match_dup 2)))]
12616   "! TARGET_POWERPC64 && reload_completed"
12617   [(set (match_dup 0)
12618         (ltu:SI (match_dup 1) (match_dup 2)))
12619    (set (match_dup 3)
12620         (compare:CC (match_dup 0)
12621                     (const_int 0)))]
12622   "")
12623
12624 (define_insn ""
12625   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12626         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12627                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12628                  (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
12629   "! TARGET_POWERPC64"
12630   "@
12631   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
12632   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
12633  [(set_attr "length" "12")])
12634
12635 (define_insn ""
12636   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12637         (compare:CC
12638          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12639                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12640                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12641          (const_int 0)))
12642    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12643   "! TARGET_POWERPC64"
12644   "@
12645    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12646    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12647    #
12648    #"
12649   [(set_attr "type" "compare")
12650    (set_attr "length" "12,12,16,16")])
12651
12652 (define_split
12653   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12654         (compare:CC
12655          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12656                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12657                   (match_operand:SI 3 "gpc_reg_operand" ""))
12658          (const_int 0)))
12659    (clobber (match_scratch:SI 4 ""))]
12660   "! TARGET_POWERPC64 && reload_completed"
12661   [(set (match_dup 4)
12662         (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
12663                  (match_dup 3)))
12664    (set (match_dup 0)
12665         (compare:CC (match_dup 4)
12666                     (const_int 0)))]
12667   "")
12668
12669 (define_insn ""
12670   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12671         (compare:CC
12672          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12673                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12674                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12675          (const_int 0)))
12676    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12677         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12678   "! TARGET_POWERPC64"
12679   "@
12680    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12681    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
12682    #
12683    #"
12684   [(set_attr "type" "compare")
12685    (set_attr "length" "12,12,16,16")])
12686
12687 (define_split
12688   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12689         (compare:CC
12690          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12691                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12692                   (match_operand:SI 3 "gpc_reg_operand" ""))
12693          (const_int 0)))
12694    (set (match_operand:SI 0 "gpc_reg_operand" "")
12695         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12696   "! TARGET_POWERPC64 && reload_completed"
12697   [(set (match_dup 0)
12698         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12699    (set (match_dup 4)
12700         (compare:CC (match_dup 0)
12701                     (const_int 0)))]
12702   "")
12703
12704 (define_insn ""
12705   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12706         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12707                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
12708   "! TARGET_POWERPC64"
12709   "@
12710    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12711    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12712   [(set_attr "length" "8")])
12713
12714 (define_insn ""
12715   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12716         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12717                (match_operand:SI 2 "reg_or_short_operand" "rI")))
12718    (clobber (match_scratch:SI 3 "=r"))]
12719   "TARGET_POWER"
12720   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12721    [(set_attr "length" "12")])
12722
12723 (define_insn ""
12724   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12725         (compare:CC
12726          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12727                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12728          (const_int 0)))
12729    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12730         (ge:SI (match_dup 1) (match_dup 2)))
12731    (clobber (match_scratch:SI 3 "=r,r"))]
12732   "TARGET_POWER"
12733   "@
12734    doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12735    #"
12736   [(set_attr "type" "compare")
12737    (set_attr "length" "12,16")])
12738
12739 (define_split
12740   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12741         (compare:CC
12742          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12743                 (match_operand:SI 2 "reg_or_short_operand" ""))
12744          (const_int 0)))
12745    (set (match_operand:SI 0 "gpc_reg_operand" "")
12746         (ge:SI (match_dup 1) (match_dup 2)))
12747    (clobber (match_scratch:SI 3 ""))]
12748   "TARGET_POWER && reload_completed"
12749   [(parallel [(set (match_dup 0)
12750                    (ge:SI (match_dup 1) (match_dup 2)))
12751               (clobber (match_dup 3))])
12752    (set (match_dup 4)
12753         (compare:CC (match_dup 0)
12754                     (const_int 0)))]
12755   "")
12756
12757 (define_insn ""
12758   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12759         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12760                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
12761                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
12762   "TARGET_POWER"
12763   "doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
12764   [(set_attr "length" "12")])
12765
12766 (define_insn ""
12767   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12768         (compare:CC
12769          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12770                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12771                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12772          (const_int 0)))
12773    (clobber (match_scratch:SI 4 "=&r,&r"))]
12774   "TARGET_POWER"
12775   "@
12776    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12777    #"
12778   [(set_attr "type" "compare")
12779    (set_attr "length" "12,16")])
12780
12781 (define_split
12782   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12783         (compare:CC
12784          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12785                          (match_operand:SI 2 "reg_or_short_operand" ""))
12786                   (match_operand:SI 3 "gpc_reg_operand" ""))
12787          (const_int 0)))
12788    (clobber (match_scratch:SI 4 ""))]
12789   "TARGET_POWER && reload_completed"
12790   [(set (match_dup 4)
12791         (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12792                  (match_dup 3)))
12793    (set (match_dup 0)
12794         (compare:CC (match_dup 4)
12795                     (const_int 0)))]
12796   "")
12797
12798 (define_insn ""
12799   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12800         (compare:CC
12801          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12802                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12803                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12804          (const_int 0)))
12805    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12806         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12807   "TARGET_POWER"
12808   "@
12809    doz%I2 %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
12810    #"
12811   [(set_attr "type" "compare")
12812    (set_attr "length" "12,16")])
12813
12814 (define_split
12815   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12816         (compare:CC
12817          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12818                          (match_operand:SI 2 "reg_or_short_operand" ""))
12819                   (match_operand:SI 3 "gpc_reg_operand" ""))
12820          (const_int 0)))
12821    (set (match_operand:SI 0 "gpc_reg_operand" "")
12822         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12823   "TARGET_POWER && reload_completed"
12824   [(set (match_dup 0)
12825         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12826    (set (match_dup 4)
12827         (compare:CC (match_dup 0)
12828                     (const_int 0)))]
12829   "")
12830
12831 (define_insn ""
12832   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12833         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12834                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12835   "TARGET_POWER"
12836   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12837   [(set_attr "length" "12")])
12838
12839 (define_insn ""
12840   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12841         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12842                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12843   "! TARGET_POWERPC64"
12844   "@
12845    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12846    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12847   [(set_attr "length" "12")])
12848
12849 (define_insn ""
12850   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12851         (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12852                 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
12853   "TARGET_POWERPC64"
12854   "@
12855    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12856    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12857   [(set_attr "length" "12")])
12858
12859 (define_insn ""
12860   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12861         (compare:CC
12862          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12863                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12864          (const_int 0)))
12865    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12866         (geu:SI (match_dup 1) (match_dup 2)))]
12867   "! TARGET_POWERPC64"
12868   "@
12869    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12870    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12871    #
12872    #"
12873   [(set_attr "type" "compare")
12874    (set_attr "length" "12,12,16,16")])
12875
12876 (define_split
12877   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12878         (compare:CC
12879          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12880                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12881          (const_int 0)))
12882    (set (match_operand:SI 0 "gpc_reg_operand" "")
12883         (geu:SI (match_dup 1) (match_dup 2)))]
12884   "! TARGET_POWERPC64 && reload_completed"
12885   [(set (match_dup 0)
12886         (geu:SI (match_dup 1) (match_dup 2)))
12887    (set (match_dup 3)
12888         (compare:CC (match_dup 0)
12889                     (const_int 0)))]
12890   "")
12891
12892 (define_insn ""
12893   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12894         (compare:CC
12895          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12896                  (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12897          (const_int 0)))
12898    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12899         (geu:DI (match_dup 1) (match_dup 2)))]
12900   "TARGET_POWERPC64"
12901   "@
12902    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12903    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12904    #
12905    #"
12906   [(set_attr "type" "compare")
12907    (set_attr "length" "12,12,16,16")])
12908
12909 (define_split
12910   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12911         (compare:CC
12912          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12913                  (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12914          (const_int 0)))
12915    (set (match_operand:DI 0 "gpc_reg_operand" "")
12916         (geu:DI (match_dup 1) (match_dup 2)))]
12917   "TARGET_POWERPC64 && reload_completed"
12918   [(set (match_dup 0)
12919         (geu:DI (match_dup 1) (match_dup 2)))
12920    (set (match_dup 3)
12921         (compare:CC (match_dup 0)
12922                     (const_int 0)))]
12923   "")
12924
12925 (define_insn ""
12926   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12927         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12928                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12929                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12930   "! TARGET_POWERPC64"
12931   "@
12932    {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12933    {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
12934   [(set_attr "length" "8")])
12935
12936 (define_insn ""
12937   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12938         (compare:CC
12939          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12940                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12941                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12942          (const_int 0)))
12943    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12944   "! TARGET_POWERPC64"
12945   "@
12946    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12947    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12948    #
12949    #"
12950   [(set_attr "type" "compare")
12951    (set_attr "length" "8,8,12,12")])
12952
12953 (define_split
12954   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12955         (compare:CC
12956          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12957                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12958                   (match_operand:SI 3 "gpc_reg_operand" ""))
12959          (const_int 0)))
12960    (clobber (match_scratch:SI 4 ""))]
12961   "! TARGET_POWERPC64 && reload_completed"
12962   [(set (match_dup 4)
12963         (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12964                   (match_dup 3)))
12965    (set (match_dup 0)
12966         (compare:CC (match_dup 4)
12967                     (const_int 0)))]
12968   "")
12969
12970 (define_insn ""
12971   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
12972         (compare:CC
12973          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12974                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12975                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12976          (const_int 0)))
12977    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
12978         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12979   "! TARGET_POWERPC64"
12980   "@
12981    {sf|subfc} %0,%2,%1\;{aze.|addze.} %0,%3
12982    {ai|addic} %0,%1,%n2\;{aze.|addze.} %0,%3
12983    #
12984    #"
12985   [(set_attr "type" "compare")
12986    (set_attr "length" "8,8,12,12")])
12987
12988 (define_split
12989   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12990         (compare:CC
12991          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12992                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12993                   (match_operand:SI 3 "gpc_reg_operand" ""))
12994          (const_int 0)))
12995    (set (match_operand:SI 0 "gpc_reg_operand" "")
12996         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
12997   "! TARGET_POWERPC64 && reload_completed"
12998   [(set (match_dup 0)
12999         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13000    (set (match_dup 4)
13001         (compare:CC (match_dup 0)
13002                     (const_int 0)))]
13003   "")
13004
13005 (define_insn ""
13006   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13007         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13008                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
13009   "! TARGET_POWERPC64"
13010   "@
13011    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
13012    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
13013   [(set_attr "length" "12")])
13014
13015 (define_insn ""
13016   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13017         (and:SI (neg:SI
13018                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13019                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
13020                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
13021   "! TARGET_POWERPC64"
13022   "@
13023    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0
13024    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc %0,%3,%0"
13025   [(set_attr "length" "12")])
13026
13027 (define_insn ""
13028   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13029         (compare:CC
13030          (and:SI (neg:SI
13031                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13032                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13033                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13034          (const_int 0)))
13035    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13036   "! TARGET_POWERPC64"
13037   "@
13038    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13039    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
13040    #
13041    #"
13042   [(set_attr "type" "compare")
13043    (set_attr "length" "12,12,16,16")])
13044
13045 (define_split
13046   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13047         (compare:CC
13048          (and:SI (neg:SI
13049                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13050                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13051                  (match_operand:SI 3 "gpc_reg_operand" ""))
13052          (const_int 0)))
13053    (clobber (match_scratch:SI 4 ""))]
13054   "! TARGET_POWERPC64 && reload_completed"
13055   [(set (match_dup 4)
13056         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2)))
13057                 (match_dup 3)))
13058    (set (match_dup 0)
13059         (compare:CC (match_dup 4)
13060                     (const_int 0)))]
13061   "")
13062
13063 (define_insn ""
13064   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13065         (compare:CC
13066          (and:SI (neg:SI
13067                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13068                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
13069                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13070          (const_int 0)))
13071    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13072         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13073   "! TARGET_POWERPC64"
13074   "@
13075    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13076    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;andc. %0,%3,%0
13077    #
13078    #"
13079   [(set_attr "type" "compare")
13080    (set_attr "length" "12,12,16,16")])
13081
13082 (define_split
13083   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13084         (compare:CC
13085          (and:SI (neg:SI
13086                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13087                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
13088                  (match_operand:SI 3 "gpc_reg_operand" ""))
13089          (const_int 0)))
13090    (set (match_operand:SI 0 "gpc_reg_operand" "")
13091         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))]
13092   "! TARGET_POWERPC64 && reload_completed"
13093   [(set (match_dup 0)
13094         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
13095    (set (match_dup 4)
13096         (compare:CC (match_dup 0)
13097                     (const_int 0)))]
13098   "")
13099
13100 (define_insn ""
13101   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13102         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13103                (const_int 0)))]
13104   "! TARGET_POWERPC64"
13105   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
13106   [(set_attr "length" "12")])
13107
13108 (define_insn ""
13109   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13110         (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13111                (const_int 0)))]
13112   "TARGET_POWERPC64"
13113   "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
13114   [(set_attr "length" "12")])
13115
13116 (define_insn ""
13117   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
13118         (compare:CC
13119          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13120                 (const_int 0))
13121          (const_int 0)))
13122    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13123         (gt:SI (match_dup 1) (const_int 0)))]
13124   "! TARGET_POWERPC64"
13125   "@
13126    {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
13127    #"
13128   [(set_attr "type" "delayed_compare")
13129    (set_attr "length" "12,16")])
13130
13131 (define_split
13132   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13133         (compare:CC
13134          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13135                 (const_int 0))
13136          (const_int 0)))
13137    (set (match_operand:SI 0 "gpc_reg_operand" "")
13138         (gt:SI (match_dup 1) (const_int 0)))]
13139   "! TARGET_POWERPC64 && reload_completed"
13140   [(set (match_dup 0)
13141         (gt:SI (match_dup 1) (const_int 0)))
13142    (set (match_dup 2)
13143         (compare:CC (match_dup 0)
13144                     (const_int 0)))]
13145   "")
13146
13147 (define_insn ""
13148   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
13149         (compare:CC
13150          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13151                 (const_int 0))
13152          (const_int 0)))
13153    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
13154         (gt:DI (match_dup 1) (const_int 0)))]
13155   "TARGET_POWERPC64"
13156   "@
13157    subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
13158    #"
13159   [(set_attr "type" "delayed_compare")
13160    (set_attr "length" "12,16")])
13161
13162 (define_split
13163   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
13164         (compare:CC
13165          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13166                 (const_int 0))
13167          (const_int 0)))
13168    (set (match_operand:DI 0 "gpc_reg_operand" "")
13169         (gt:DI (match_dup 1) (const_int 0)))]
13170   "TARGET_POWERPC64 && reload_completed"
13171   [(set (match_dup 0)
13172         (gt:DI (match_dup 1) (const_int 0)))
13173    (set (match_dup 2)
13174         (compare:CC (match_dup 0)
13175                     (const_int 0)))]
13176   "")
13177
13178 (define_insn ""
13179   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13180         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13181                (match_operand:SI 2 "reg_or_short_operand" "r")))]
13182   "TARGET_POWER"
13183   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
13184   [(set_attr "length" "12")])
13185
13186 (define_insn ""
13187   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13188         (compare:CC
13189          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13190                 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13191          (const_int 0)))
13192    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13193         (gt:SI (match_dup 1) (match_dup 2)))]
13194   "TARGET_POWER"
13195   "@
13196    doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
13197    #"
13198   [(set_attr "type" "delayed_compare")
13199    (set_attr "length" "12,16")])
13200
13201 (define_split
13202   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13203         (compare:CC
13204          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13205                 (match_operand:SI 2 "reg_or_short_operand" ""))
13206          (const_int 0)))
13207    (set (match_operand:SI 0 "gpc_reg_operand" "")
13208         (gt:SI (match_dup 1) (match_dup 2)))]
13209   "TARGET_POWER && reload_completed"
13210   [(set (match_dup 0)
13211         (gt:SI (match_dup 1) (match_dup 2)))
13212    (set (match_dup 3)
13213         (compare:CC (match_dup 0)
13214                     (const_int 0)))]
13215   "")
13216
13217 (define_insn ""
13218   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13219         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13220                         (const_int 0))
13221                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
13222   "! TARGET_POWERPC64"
13223   "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
13224   [(set_attr "length" "12")])
13225
13226 (define_insn ""
13227   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
13228         (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13229                         (const_int 0))
13230                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
13231   "TARGET_POWERPC64"
13232   "addc %0,%1,%1\;subfe %0,%1,%0\;addze %0,%2"
13233   [(set_attr "length" "12")])
13234
13235 (define_insn ""
13236   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13237         (compare:CC
13238          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13239                          (const_int 0))
13240                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13241          (const_int 0)))
13242    (clobber (match_scratch:SI 3 "=&r,&r"))]
13243   "! TARGET_POWERPC64"
13244   "@
13245    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
13246    #"
13247   [(set_attr "type" "compare")
13248    (set_attr "length" "12,16")])
13249
13250 (define_split
13251   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13252         (compare:CC
13253          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13254                          (const_int 0))
13255                   (match_operand:SI 2 "gpc_reg_operand" ""))
13256          (const_int 0)))
13257    (clobber (match_scratch:SI 3 ""))]
13258   "! TARGET_POWERPC64 && reload_completed"
13259   [(set (match_dup 3)
13260         (plus:SI (gt:SI (match_dup 1) (const_int 0))
13261                   (match_dup 2)))
13262    (set (match_dup 0)
13263         (compare:CC (match_dup 3)
13264                     (const_int 0)))]
13265   "")
13266
13267 (define_insn ""
13268   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13269         (compare:CC
13270          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13271                          (const_int 0))
13272                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13273          (const_int 0)))
13274    (clobber (match_scratch:DI 3 "=&r,&r"))]
13275   "TARGET_POWERPC64"
13276   "@
13277    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
13278    #"
13279   [(set_attr "type" "compare")
13280    (set_attr "length" "12,16")])
13281
13282 (define_split
13283   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13284         (compare:CC
13285          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13286                          (const_int 0))
13287                   (match_operand:DI 2 "gpc_reg_operand" ""))
13288          (const_int 0)))
13289    (clobber (match_scratch:DI 3 ""))]
13290   "TARGET_POWERPC64 && reload_completed"
13291   [(set (match_dup 3)
13292         (plus:DI (gt:DI (match_dup 1) (const_int 0))
13293                  (match_dup 2)))
13294    (set (match_dup 0)
13295         (compare:CC (match_dup 3)
13296                     (const_int 0)))]
13297   "")
13298
13299 (define_insn ""
13300   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13301         (compare:CC
13302          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13303                          (const_int 0))
13304                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
13305          (const_int 0)))
13306    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13307         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13308   "! TARGET_POWERPC64"
13309   "@
13310    {a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze.|addze.} %0,%2
13311    #"
13312   [(set_attr "type" "compare")
13313    (set_attr "length" "12,16")])
13314
13315 (define_split
13316   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13317         (compare:CC
13318          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13319                          (const_int 0))
13320                   (match_operand:SI 2 "gpc_reg_operand" ""))
13321          (const_int 0)))
13322    (set (match_operand:SI 0 "gpc_reg_operand" "")
13323         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))]
13324   "! TARGET_POWERPC64 && reload_completed"
13325   [(set (match_dup 0)
13326         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
13327    (set (match_dup 3)
13328         (compare:CC (match_dup 0)
13329                     (const_int 0)))]
13330   "")
13331
13332 (define_insn ""
13333   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13334         (compare:CC
13335          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13336                          (const_int 0))
13337                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
13338          (const_int 0)))
13339    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13340         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13341   "TARGET_POWERPC64"
13342   "@
13343    addc %0,%1,%1\;subfe %0,%1,%0\;addze. %0,%2
13344    #"
13345   [(set_attr "type" "compare")
13346    (set_attr "length" "12,16")])
13347
13348 (define_split
13349   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13350         (compare:CC
13351          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
13352                          (const_int 0))
13353                   (match_operand:DI 2 "gpc_reg_operand" ""))
13354          (const_int 0)))
13355    (set (match_operand:DI 0 "gpc_reg_operand" "")
13356         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))]
13357   "TARGET_POWERPC64 && reload_completed"
13358   [(set (match_dup 0)
13359         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
13360    (set (match_dup 3)
13361         (compare:CC (match_dup 0)
13362                     (const_int 0)))]
13363   "")
13364
13365 (define_insn ""
13366   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
13367         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13368                         (match_operand:SI 2 "reg_or_short_operand" "r"))
13369                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
13370   "TARGET_POWER"
13371   "doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze|addze} %0,%3"
13372   [(set_attr "length" "12")])
13373
13374 (define_insn ""
13375   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
13376         (compare:CC
13377          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13378                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13379                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13380          (const_int 0)))
13381    (clobber (match_scratch:SI 4 "=&r,&r"))]
13382   "TARGET_POWER"
13383   "@
13384    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
13385    #"
13386   [(set_attr "type" "compare")
13387    (set_attr "length" "12,16")])
13388
13389 (define_split
13390   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13391         (compare:CC
13392          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13393                          (match_operand:SI 2 "reg_or_short_operand" ""))
13394                   (match_operand:SI 3 "gpc_reg_operand" ""))
13395          (const_int 0)))
13396    (clobber (match_scratch:SI 4 ""))]
13397   "TARGET_POWER && reload_completed"
13398   [(set (match_dup 4)
13399         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13400    (set (match_dup 0)
13401         (compare:CC (match_dup 4)
13402                     (const_int 0)))]
13403   "")
13404
13405 (define_insn ""
13406   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
13407         (compare:CC
13408          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13409                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
13410                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
13411          (const_int 0)))
13412    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13413         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13414   "TARGET_POWER"
13415   "@
13416    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{aze.|addze.} %0,%3
13417    #"
13418   [(set_attr "type" "compare")
13419    (set_attr "length" "12,16")])
13420
13421 (define_split
13422   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13423         (compare:CC
13424          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
13425                          (match_operand:SI 2 "reg_or_short_operand" ""))
13426                   (match_operand:SI 3 "gpc_reg_operand" ""))
13427          (const_int 0)))
13428    (set (match_operand:SI 0 "gpc_reg_operand" "")
13429         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13430   "TARGET_POWER && reload_completed"
13431   [(set (match_dup 0)
13432         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13433    (set (match_dup 4)
13434         (compare:CC (match_dup 0)
13435                     (const_int 0)))]
13436   "")
13437
13438 (define_insn ""
13439   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13440         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13441                        (const_int 0))))]
13442   "! TARGET_POWERPC64"
13443   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
13444   [(set_attr "length" "12")])
13445
13446 (define_insn ""
13447   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13448         (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13449                        (const_int 0))))]
13450   "TARGET_POWERPC64"
13451   "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
13452   [(set_attr "length" "12")])
13453
13454 (define_insn ""
13455   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13456         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13457                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
13458   "TARGET_POWER"
13459   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
13460   [(set_attr "length" "12")])
13461
13462 (define_insn ""
13463   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13464         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13465                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
13466   "! TARGET_POWERPC64"
13467   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
13468   [(set_attr "length" "12")])
13469
13470 (define_insn ""
13471   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13472         (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13473                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
13474   "TARGET_POWERPC64"
13475   "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
13476   [(set_attr "length" "12")])
13477
13478 (define_insn ""
13479   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13480         (compare:CC
13481          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13482                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
13483          (const_int 0)))
13484    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
13485         (gtu:SI (match_dup 1) (match_dup 2)))]
13486   "! TARGET_POWERPC64"
13487   "@
13488    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
13489    #"
13490   [(set_attr "type" "compare")
13491    (set_attr "length" "12,16")])
13492
13493 (define_split
13494   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13495         (compare:CC
13496          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13497                  (match_operand:SI 2 "reg_or_short_operand" ""))
13498          (const_int 0)))
13499    (set (match_operand:SI 0 "gpc_reg_operand" "")
13500         (gtu:SI (match_dup 1) (match_dup 2)))]
13501   "! TARGET_POWERPC64 && reload_completed"
13502   [(set (match_dup 0)
13503         (gtu:SI (match_dup 1) (match_dup 2)))
13504    (set (match_dup 3)
13505         (compare:CC (match_dup 0)
13506                     (const_int 0)))]
13507   "")
13508
13509 (define_insn ""
13510   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
13511         (compare:CC
13512          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13513                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
13514          (const_int 0)))
13515    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
13516         (gtu:DI (match_dup 1) (match_dup 2)))]
13517   "TARGET_POWERPC64"
13518   "@
13519    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
13520    #"
13521   [(set_attr "type" "compare")
13522    (set_attr "length" "12,16")])
13523
13524 (define_split
13525   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
13526         (compare:CC
13527          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13528                  (match_operand:DI 2 "reg_or_short_operand" ""))
13529          (const_int 0)))
13530    (set (match_operand:DI 0 "gpc_reg_operand" "")
13531         (gtu:DI (match_dup 1) (match_dup 2)))]
13532   "TARGET_POWERPC64 && reload_completed"
13533   [(set (match_dup 0)
13534         (gtu:DI (match_dup 1) (match_dup 2)))
13535    (set (match_dup 3)
13536         (compare:CC (match_dup 0)
13537                     (const_int 0)))]
13538   "")
13539
13540 (define_insn ""
13541   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
13542         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
13543                          (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
13544                  (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
13545   "! TARGET_POWERPC64"
13546   "@
13547    {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
13548    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
13549   [(set_attr "length" "8,12")])
13550
13551 (define_insn ""
13552   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
13553         (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
13554                          (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
13555                  (match_operand:DI 3 "reg_or_short_operand" "r,rI")))]
13556   "TARGET_POWERPC64"
13557   "@
13558    addic %0,%1,%k2\;addze %0,%3
13559    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subf%I3c %0,%0,%3"
13560   [(set_attr "length" "8,12")])
13561
13562 (define_insn ""
13563   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13564         (compare:CC
13565          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13566                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13567                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13568          (const_int 0)))
13569    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
13570   "! TARGET_POWERPC64"
13571   "@
13572    {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
13573    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
13574    #
13575    #"
13576   [(set_attr "type" "compare")
13577    (set_attr "length" "8,12,12,16")])
13578
13579 (define_split
13580   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13581         (compare:CC
13582          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13583                           (match_operand:SI 2 "reg_or_short_operand" ""))
13584                   (match_operand:SI 3 "gpc_reg_operand" ""))
13585          (const_int 0)))
13586    (clobber (match_scratch:SI 4 ""))]
13587   "! TARGET_POWERPC64 && reload_completed"
13588   [(set (match_dup 4)
13589         (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
13590                  (match_dup 3)))
13591    (set (match_dup 0)
13592         (compare:CC (match_dup 4)
13593                     (const_int 0)))]
13594   "")
13595
13596 (define_insn ""
13597   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
13598         (compare:CC
13599          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13600                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13601                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13602          (const_int 0)))
13603    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
13604   "TARGET_POWERPC64"
13605   "@
13606    addic %4,%1,%k2\;addze. %4,%3
13607    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
13608    #
13609    #"
13610   [(set_attr "type" "compare")
13611    (set_attr "length" "8,12,12,16")])
13612
13613 (define_split
13614   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
13615         (compare:CC
13616          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13617                           (match_operand:DI 2 "reg_or_short_operand" ""))
13618                   (match_operand:DI 3 "gpc_reg_operand" ""))
13619          (const_int 0)))
13620    (clobber (match_scratch:DI 4 ""))]
13621   "TARGET_POWERPC64 && reload_completed"
13622   [(set (match_dup 4)
13623         (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
13624                   (match_dup 3)))
13625    (set (match_dup 0)
13626         (compare:CC (match_dup 4)
13627                     (const_int 0)))]
13628   "")
13629
13630 (define_insn ""
13631   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13632         (compare:CC
13633          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
13634                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
13635                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
13636          (const_int 0)))
13637    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13638         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13639   "! TARGET_POWERPC64"
13640   "@
13641    {ai|addic} %0,%1,%k2\;{aze.|addze.} %0,%3
13642    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf.|subfc.} %0,%0,%3
13643    #
13644    #"
13645   [(set_attr "type" "compare")
13646    (set_attr "length" "8,12,12,16")])
13647
13648 (define_split
13649   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13650         (compare:CC
13651          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
13652                           (match_operand:SI 2 "reg_or_short_operand" ""))
13653                   (match_operand:SI 3 "gpc_reg_operand" ""))
13654          (const_int 0)))
13655    (set (match_operand:SI 0 "gpc_reg_operand" "")
13656         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13657   "! TARGET_POWERPC64 && reload_completed"
13658   [(set (match_dup 0)
13659         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
13660    (set (match_dup 4)
13661         (compare:CC (match_dup 0)
13662                     (const_int 0)))]
13663   "")
13664
13665 (define_insn ""
13666   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
13667         (compare:CC
13668          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
13669                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
13670                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
13671          (const_int 0)))
13672    (set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,&r,&r")
13673         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13674   "TARGET_POWERPC64"
13675   "@
13676    addic %0,%1,%k2\;addze. %0,%3
13677    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;subfc. %0,%0,%3
13678    #
13679    #"
13680   [(set_attr "type" "compare")
13681    (set_attr "length" "8,12,12,16")])
13682
13683 (define_split
13684   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
13685         (compare:CC
13686          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13687                           (match_operand:DI 2 "reg_or_short_operand" ""))
13688                   (match_operand:DI 3 "gpc_reg_operand" ""))
13689          (const_int 0)))
13690    (set (match_operand:DI 0 "gpc_reg_operand" "")
13691         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
13692   "TARGET_POWERPC64 && reload_completed"
13693   [(set (match_dup 0)
13694         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13695    (set (match_dup 4)
13696         (compare:CC (match_dup 0)
13697                     (const_int 0)))]
13698   "")
13699
13700 (define_insn ""
13701   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13702         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13703                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13704   "! TARGET_POWERPC64"
13705   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
13706   [(set_attr "length" "8")])
13707
13708 (define_insn ""
13709   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13710         (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13711                         (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
13712   "TARGET_POWERPC64"
13713   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13714   [(set_attr "length" "8")])
13715 \f
13716 ;; Define both directions of branch and return.  If we need a reload
13717 ;; register, we'd rather use CR0 since it is much easier to copy a
13718 ;; register CC value to there.
13719
13720 (define_insn ""
13721   [(set (pc)
13722         (if_then_else (match_operator 1 "branch_comparison_operator"
13723                                       [(match_operand 2
13724                                                       "cc_reg_operand" "x,?y")
13725                                        (const_int 0)])
13726                       (label_ref (match_operand 0 "" ""))
13727                       (pc)))]
13728   ""
13729   "*
13730 {
13731   return output_cbranch (operands[1], \"%l0\", 0, insn);
13732 }"
13733   [(set_attr "type" "branch")])
13734
13735 (define_insn ""
13736   [(set (pc)
13737         (if_then_else (match_operator 0 "branch_comparison_operator"
13738                                       [(match_operand 1
13739                                                       "cc_reg_operand" "x,?y")
13740                                        (const_int 0)])
13741                       (return)
13742                       (pc)))]
13743   "direct_return ()"
13744   "*
13745 {
13746   return output_cbranch (operands[0], NULL, 0, insn);
13747 }"
13748   [(set_attr "type" "branch")
13749    (set_attr "length" "4")])
13750
13751 (define_insn ""
13752   [(set (pc)
13753         (if_then_else (match_operator 1 "branch_comparison_operator"
13754                                       [(match_operand 2
13755                                                       "cc_reg_operand" "x,?y")
13756                                        (const_int 0)])
13757                       (pc)
13758                       (label_ref (match_operand 0 "" ""))))]
13759   ""
13760   "*
13761 {
13762   return output_cbranch (operands[1], \"%l0\", 1, insn);
13763 }"
13764   [(set_attr "type" "branch")])
13765
13766 (define_insn ""
13767   [(set (pc)
13768         (if_then_else (match_operator 0 "branch_comparison_operator"
13769                                       [(match_operand 1
13770                                                       "cc_reg_operand" "x,?y")
13771                                        (const_int 0)])
13772                       (pc)
13773                       (return)))]
13774   "direct_return ()"
13775   "*
13776 {
13777   return output_cbranch (operands[0], NULL, 1, insn);
13778 }"
13779   [(set_attr "type" "branch")
13780    (set_attr "length" "4")])
13781
13782 ;; Logic on condition register values.
13783
13784 ; This pattern matches things like
13785 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13786 ;                                          (eq:SI (reg:CCFP 68) (const_int 0)))
13787 ;                                  (const_int 1)))
13788 ; which are generated by the branch logic.
13789
13790 (define_insn ""
13791   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13792         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13793                         [(match_operator:SI 2 
13794                                       "branch_positive_comparison_operator"
13795                                       [(match_operand 3
13796                                                       "cc_reg_operand" "y")
13797                                        (const_int 0)])
13798                          (match_operator:SI 4 
13799                                       "branch_positive_comparison_operator"
13800                                       [(match_operand 5
13801                                                       "cc_reg_operand" "y")
13802                                        (const_int 0)])])
13803                       (const_int 1)))]
13804   ""
13805   "cr%q1 %E0,%j2,%j4"
13806   [(set_attr "type" "cr_logical")])
13807
13808 ; Why is the constant -1 here, but 1 in the previous pattern?
13809 ; Because ~1 has all but the low bit set.
13810 (define_insn ""
13811   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13812         (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13813                         [(not:SI (match_operator:SI 2 
13814                                       "branch_positive_comparison_operator"
13815                                       [(match_operand 3
13816                                                       "cc_reg_operand" "y")
13817                                        (const_int 0)]))
13818                          (match_operator:SI 4
13819                                 "branch_positive_comparison_operator"
13820                                 [(match_operand 5
13821                                                 "cc_reg_operand" "y")
13822                                  (const_int 0)])])
13823                       (const_int -1)))]
13824   ""
13825   "cr%q1 %E0,%j2,%j4"
13826   [(set_attr "type" "cr_logical")])
13827
13828 (define_insn ""
13829   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13830         (compare:CCEQ (match_operator:SI 1
13831                                       "branch_positive_comparison_operator"
13832                                       [(match_operand 2
13833                                                       "cc_reg_operand" "y")
13834                                        (const_int 0)])
13835                       (const_int 0)))]
13836   "!TARGET_SPE"
13837   "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
13838   [(set_attr "type" "cr_logical")])
13839
13840 ;; If we are comparing the result of two comparisons, this can be done
13841 ;; using creqv or crxor.
13842
13843 (define_insn_and_split ""
13844   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13845         (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13846                               [(match_operand 2 "cc_reg_operand" "y")
13847                                (const_int 0)])
13848                       (match_operator 3 "branch_comparison_operator"
13849                               [(match_operand 4 "cc_reg_operand" "y")
13850                                (const_int 0)])))]
13851   ""
13852   "#"
13853   ""
13854   [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13855                                     (match_dup 5)))]
13856   "
13857 {
13858   int positive_1, positive_2;
13859
13860   positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13861   positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13862
13863   if (! positive_1)
13864     operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
13865                                                      GET_CODE (operands[1])),
13866                            SImode,
13867                            operands[2], const0_rtx);
13868   else if (GET_MODE (operands[1]) != SImode)
13869     operands[1] = gen_rtx (GET_CODE (operands[1]),
13870                            SImode,
13871                            operands[2], const0_rtx);
13872
13873   if (! positive_2)
13874     operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
13875                                                      GET_CODE (operands[3])),
13876                            SImode,
13877                            operands[4], const0_rtx);
13878   else if (GET_MODE (operands[3]) != SImode)
13879     operands[3] = gen_rtx (GET_CODE (operands[3]),
13880                            SImode,
13881                            operands[4], const0_rtx);
13882
13883   if (positive_1 == positive_2)
13884     {
13885       operands[1] = gen_rtx_NOT (SImode, operands[1]);
13886       operands[5] = constm1_rtx;
13887     }
13888   else
13889     {
13890       operands[5] = const1_rtx;
13891     }
13892 }")
13893
13894 ;; Unconditional branch and return.
13895
13896 (define_insn "jump"
13897   [(set (pc)
13898         (label_ref (match_operand 0 "" "")))]
13899   ""
13900   "b %l0"
13901   [(set_attr "type" "branch")])
13902
13903 (define_insn "return"
13904   [(return)]
13905   "direct_return ()"
13906   "{br|blr}"
13907   [(set_attr "type" "jmpreg")])
13908
13909 (define_expand "indirect_jump"
13910   [(set (pc) (match_operand 0 "register_operand" ""))]
13911   ""
13912   "
13913 {
13914   if (TARGET_32BIT)
13915     emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13916   else
13917     emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13918   DONE;
13919 }")
13920
13921 (define_insn "indirect_jumpsi"
13922   [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
13923   "TARGET_32BIT"
13924   "@
13925    bctr
13926    {br|blr}"
13927   [(set_attr "type" "jmpreg")])
13928
13929 (define_insn "indirect_jumpdi"
13930   [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
13931   "TARGET_64BIT"
13932   "@
13933    bctr
13934    blr"
13935   [(set_attr "type" "jmpreg")])
13936
13937 ;; Table jump for switch statements:
13938 (define_expand "tablejump"
13939   [(use (match_operand 0 "" ""))
13940    (use (label_ref (match_operand 1 "" "")))]
13941   ""
13942   "
13943 {
13944   if (TARGET_32BIT)
13945     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13946   else
13947     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13948   DONE;
13949 }")
13950
13951 (define_expand "tablejumpsi"
13952   [(set (match_dup 3)
13953         (plus:SI (match_operand:SI 0 "" "")
13954                  (match_dup 2)))
13955    (parallel [(set (pc) (match_dup 3))
13956               (use (label_ref (match_operand 1 "" "")))])]
13957   "TARGET_32BIT"
13958   "
13959 { operands[0] = force_reg (SImode, operands[0]);
13960   operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13961   operands[3] = gen_reg_rtx (SImode);
13962 }")
13963
13964 (define_expand "tablejumpdi"
13965   [(set (match_dup 4) 
13966         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13967    (set (match_dup 3)
13968         (plus:DI (match_dup 4)
13969                  (match_dup 2)))
13970    (parallel [(set (pc) (match_dup 3))
13971               (use (label_ref (match_operand 1 "" "")))])]
13972   "TARGET_64BIT"
13973   "
13974 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13975   operands[3] = gen_reg_rtx (DImode);
13976   operands[4] = gen_reg_rtx (DImode);
13977 }")
13978
13979 (define_insn ""
13980   [(set (pc)
13981         (match_operand:SI 0 "register_operand" "c,*l"))
13982    (use (label_ref (match_operand 1 "" "")))]
13983   "TARGET_32BIT"
13984   "@
13985    bctr
13986    {br|blr}"
13987   [(set_attr "type" "jmpreg")])
13988
13989 (define_insn ""
13990   [(set (pc)
13991         (match_operand:DI 0 "register_operand" "c,*l"))
13992    (use (label_ref (match_operand 1 "" "")))]
13993   "TARGET_64BIT"
13994   "@
13995    bctr
13996    blr"
13997   [(set_attr "type" "jmpreg")])
13998
13999 (define_insn "nop"
14000   [(const_int 0)]
14001   ""
14002   "{cror 0,0,0|nop}")
14003 \f
14004 ;; Define the subtract-one-and-jump insns, starting with the template
14005 ;; so loop.c knows what to generate.
14006
14007 (define_expand "doloop_end"
14008   [(use (match_operand 0 "" ""))        ; loop pseudo
14009    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
14010    (use (match_operand 2 "" ""))        ; max iterations
14011    (use (match_operand 3 "" ""))        ; loop level
14012    (use (match_operand 4 "" ""))]       ; label
14013   ""
14014   "
14015 {
14016   /* Only use this on innermost loops.  */
14017   if (INTVAL (operands[3]) > 1)
14018     FAIL;
14019   if (TARGET_POWERPC64)
14020     {
14021       if (GET_MODE (operands[0]) != DImode)
14022         FAIL;
14023       emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
14024     }
14025   else
14026     {
14027       if (GET_MODE (operands[0]) != SImode)
14028         FAIL;
14029       emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
14030     }
14031   DONE;
14032 }")
14033
14034 (define_expand "ctrsi"
14035   [(parallel [(set (pc)
14036                    (if_then_else (ne (match_operand:SI 0 "register_operand" "")
14037                                      (const_int 1))
14038                                  (label_ref (match_operand 1 "" ""))
14039                                  (pc)))
14040               (set (match_dup 0)
14041                    (plus:SI (match_dup 0)
14042                             (const_int -1)))
14043               (clobber (match_scratch:CC 2 ""))
14044               (clobber (match_scratch:SI 3 ""))])]
14045   "! TARGET_POWERPC64"
14046   "")
14047
14048 (define_expand "ctrdi"
14049   [(parallel [(set (pc)
14050                    (if_then_else (ne (match_operand:DI 0 "register_operand" "")
14051                                      (const_int 1))
14052                                  (label_ref (match_operand 1 "" ""))
14053                                  (pc)))
14054               (set (match_dup 0)
14055                    (plus:DI (match_dup 0)
14056                             (const_int -1)))
14057               (clobber (match_scratch:CC 2 ""))
14058               (clobber (match_scratch:DI 3 ""))])]
14059   "TARGET_POWERPC64"
14060   "")
14061
14062 ;; We need to be able to do this for any operand, including MEM, or we
14063 ;; will cause reload to blow up since we don't allow output reloads on
14064 ;; JUMP_INSNs.
14065 ;; For the length attribute to be calculated correctly, the
14066 ;; label MUST be operand 0.
14067
14068 (define_insn "*ctrsi_internal1"
14069   [(set (pc)
14070         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
14071                           (const_int 1))
14072                       (label_ref (match_operand 0 "" ""))
14073                       (pc)))
14074    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14075         (plus:SI (match_dup 1)
14076                  (const_int -1)))
14077    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14078    (clobber (match_scratch:SI 4 "=X,X,r"))]
14079   "! TARGET_POWERPC64"
14080   "*
14081 {
14082   if (which_alternative != 0)
14083     return \"#\";
14084   else if (get_attr_length (insn) == 4)
14085     return \"{bdn|bdnz} %l0\";
14086   else
14087     return \"bdz $+8\;b %l0\";
14088 }"
14089   [(set_attr "type" "branch")
14090    (set_attr "length" "*,12,16")])
14091
14092 (define_insn "*ctrsi_internal2"
14093   [(set (pc)
14094         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
14095                           (const_int 1))
14096                       (pc)
14097                       (label_ref (match_operand 0 "" ""))))
14098    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14099         (plus:SI (match_dup 1)
14100                  (const_int -1)))
14101    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14102    (clobber (match_scratch:SI 4 "=X,X,r"))]
14103   "! TARGET_POWERPC64"
14104   "*
14105 {
14106   if (which_alternative != 0)
14107     return \"#\";
14108   else if (get_attr_length (insn) == 4)
14109     return \"bdz %l0\";
14110   else
14111     return \"{bdn|bdnz} $+8\;b %l0\";
14112 }"
14113   [(set_attr "type" "branch")
14114    (set_attr "length" "*,12,16")])
14115
14116 (define_insn "*ctrdi_internal1"
14117   [(set (pc)
14118         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
14119                           (const_int 1))
14120                       (label_ref (match_operand 0 "" ""))
14121                       (pc)))
14122    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14123         (plus:DI (match_dup 1)
14124                  (const_int -1)))
14125    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14126    (clobber (match_scratch:DI 4 "=X,X,r"))]
14127   "TARGET_POWERPC64"
14128   "*
14129 {
14130   if (which_alternative != 0)
14131     return \"#\";
14132   else if (get_attr_length (insn) == 4)
14133     return \"{bdn|bdnz} %l0\";
14134   else
14135     return \"bdz $+8\;b %l0\";
14136 }"
14137   [(set_attr "type" "branch")
14138    (set_attr "length" "*,12,16")])
14139
14140 (define_insn "*ctrdi_internal2"
14141   [(set (pc)
14142         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
14143                           (const_int 1))
14144                       (pc)
14145                       (label_ref (match_operand 0 "" ""))))
14146    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14147         (plus:DI (match_dup 1)
14148                  (const_int -1)))
14149    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14150    (clobber (match_scratch:DI 4 "=X,X,r"))]
14151   "TARGET_POWERPC64"
14152   "*
14153 {
14154   if (which_alternative != 0)
14155     return \"#\";
14156   else if (get_attr_length (insn) == 4)
14157     return \"bdz %l0\";
14158   else
14159     return \"{bdn|bdnz} $+8\;b %l0\";
14160 }"
14161   [(set_attr "type" "branch")
14162    (set_attr "length" "*,12,16")])
14163
14164 ;; Similar, but we can use GE since we have a REG_NONNEG.
14165
14166 (define_insn "*ctrsi_internal3"
14167   [(set (pc)
14168         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
14169                           (const_int 0))
14170                       (label_ref (match_operand 0 "" ""))
14171                       (pc)))
14172    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14173         (plus:SI (match_dup 1)
14174                  (const_int -1)))
14175    (clobber (match_scratch:CC 3 "=X,&x,&X"))
14176    (clobber (match_scratch:SI 4 "=X,X,r"))]
14177   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
14178   "*
14179 {
14180   if (which_alternative != 0)
14181     return \"#\";
14182   else if (get_attr_length (insn) == 4)
14183     return \"{bdn|bdnz} %l0\";
14184   else
14185     return \"bdz $+8\;b %l0\";
14186 }"
14187   [(set_attr "type" "branch")
14188    (set_attr "length" "*,12,16")])
14189
14190 (define_insn "*ctrsi_internal4"
14191   [(set (pc)
14192         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
14193                           (const_int 0))
14194                       (pc)
14195                       (label_ref (match_operand 0 "" ""))))
14196    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14197         (plus:SI (match_dup 1)
14198                  (const_int -1)))
14199    (clobber (match_scratch:CC 3 "=X,&x,&X"))
14200    (clobber (match_scratch:SI 4 "=X,X,r"))]
14201   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
14202   "*
14203 {
14204   if (which_alternative != 0)
14205     return \"#\";
14206   else if (get_attr_length (insn) == 4)
14207     return \"bdz %l0\";
14208   else
14209     return \"{bdn|bdnz} $+8\;b %l0\";
14210 }"
14211   [(set_attr "type" "branch")
14212    (set_attr "length" "*,12,16")])
14213
14214 (define_insn "*ctrdi_internal3"
14215   [(set (pc)
14216         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
14217                           (const_int 0))
14218                       (label_ref (match_operand 0 "" ""))
14219                       (pc)))
14220    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14221         (plus:DI (match_dup 1)
14222                  (const_int -1)))
14223    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14224    (clobber (match_scratch:DI 4 "=X,X,r"))]
14225   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
14226   "*
14227 {
14228   if (which_alternative != 0)
14229     return \"#\";
14230   else if (get_attr_length (insn) == 4)
14231     return \"{bdn|bdnz} %l0\";
14232   else
14233     return \"bdz $+8\;b %l0\";
14234 }"
14235   [(set_attr "type" "branch")
14236    (set_attr "length" "*,12,16")])
14237
14238 (define_insn "*ctrdi_internal4"
14239   [(set (pc)
14240         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
14241                           (const_int 0))
14242                       (pc)
14243                       (label_ref (match_operand 0 "" ""))))
14244    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14245         (plus:DI (match_dup 1)
14246                  (const_int -1)))
14247    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14248    (clobber (match_scratch:DI 4 "=X,X,r"))]
14249   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
14250   "*
14251 {
14252   if (which_alternative != 0)
14253     return \"#\";
14254   else if (get_attr_length (insn) == 4)
14255     return \"bdz %l0\";
14256   else
14257     return \"{bdn|bdnz} $+8\;b %l0\";
14258 }"
14259   [(set_attr "type" "branch")
14260    (set_attr "length" "*,12,16")])
14261
14262 ;; Similar but use EQ
14263
14264 (define_insn "*ctrsi_internal5"
14265   [(set (pc)
14266         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
14267                           (const_int 1))
14268                       (label_ref (match_operand 0 "" ""))
14269                       (pc)))
14270    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14271         (plus:SI (match_dup 1)
14272                  (const_int -1)))
14273    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14274    (clobber (match_scratch:SI 4 "=X,X,r"))]
14275   "! TARGET_POWERPC64"
14276   "*
14277 {
14278   if (which_alternative != 0)
14279     return \"#\";
14280   else if (get_attr_length (insn) == 4)
14281     return \"bdz %l0\";
14282   else
14283     return \"{bdn|bdnz} $+8\;b %l0\";
14284 }"
14285   [(set_attr "type" "branch")
14286    (set_attr "length" "*,12,16")])
14287
14288 (define_insn "*ctrsi_internal6"
14289   [(set (pc)
14290         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
14291                           (const_int 1))
14292                       (pc)
14293                       (label_ref (match_operand 0 "" ""))))
14294    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
14295         (plus:SI (match_dup 1)
14296                  (const_int -1)))
14297    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14298    (clobber (match_scratch:SI 4 "=X,X,r"))]
14299   "! TARGET_POWERPC64"
14300   "*
14301 {
14302   if (which_alternative != 0)
14303     return \"#\";
14304   else if (get_attr_length (insn) == 4)
14305     return \"{bdn|bdnz} %l0\";
14306   else
14307     return \"bdz $+8\;b %l0\";
14308 }"
14309   [(set_attr "type" "branch")
14310    (set_attr "length" "*,12,16")])
14311
14312 (define_insn "*ctrdi_internal5"
14313   [(set (pc)
14314         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
14315                           (const_int 1))
14316                       (label_ref (match_operand 0 "" ""))
14317                       (pc)))
14318    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14319         (plus:DI (match_dup 1)
14320                  (const_int -1)))
14321    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14322    (clobber (match_scratch:DI 4 "=X,X,r"))]
14323   "TARGET_POWERPC64"
14324   "*
14325 {
14326   if (which_alternative != 0)
14327     return \"#\";
14328   else if (get_attr_length (insn) == 4)
14329     return \"bdz %l0\";
14330   else
14331     return \"{bdn|bdnz} $+8\;b %l0\";
14332 }"
14333   [(set_attr "type" "branch")
14334    (set_attr "length" "*,12,16")])
14335
14336 (define_insn "*ctrdi_internal6"
14337   [(set (pc)
14338         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
14339                           (const_int 1))
14340                       (pc)
14341                       (label_ref (match_operand 0 "" ""))))
14342    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
14343         (plus:DI (match_dup 1)
14344                  (const_int -1)))
14345    (clobber (match_scratch:CC 3 "=X,&x,&x"))
14346    (clobber (match_scratch:DI 4 "=X,X,r"))]
14347   "TARGET_POWERPC64"
14348   "*
14349 {
14350   if (which_alternative != 0)
14351     return \"#\";
14352   else if (get_attr_length (insn) == 4)
14353     return \"{bdn|bdnz} %l0\";
14354   else
14355     return \"bdz $+8\;b %l0\";
14356 }"
14357   [(set_attr "type" "branch")
14358    (set_attr "length" "*,12,16")])
14359
14360 ;; Now the splitters if we could not allocate the CTR register
14361
14362 (define_split
14363   [(set (pc)
14364         (if_then_else (match_operator 2 "comparison_operator"
14365                                       [(match_operand:SI 1 "gpc_reg_operand" "")
14366                                        (const_int 1)])
14367                       (match_operand 5 "" "")
14368                       (match_operand 6 "" "")))
14369    (set (match_operand:SI 0 "gpc_reg_operand" "")
14370         (plus:SI (match_dup 1)
14371                  (const_int -1)))
14372    (clobber (match_scratch:CC 3 ""))
14373    (clobber (match_scratch:SI 4 ""))]
14374   "! TARGET_POWERPC64 && reload_completed"
14375   [(parallel [(set (match_dup 3)
14376                    (compare:CC (plus:SI (match_dup 1)
14377                                         (const_int -1))
14378                                (const_int 0)))
14379               (set (match_dup 0)
14380                    (plus:SI (match_dup 1)
14381                             (const_int -1)))])
14382    (set (pc) (if_then_else (match_dup 7)
14383                            (match_dup 5)
14384                            (match_dup 6)))]
14385   "
14386 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14387                          const0_rtx); }")
14388
14389 (define_split
14390   [(set (pc)
14391         (if_then_else (match_operator 2 "comparison_operator"
14392                                       [(match_operand:SI 1 "gpc_reg_operand" "")
14393                                        (const_int 1)])
14394                       (match_operand 5 "" "")
14395                       (match_operand 6 "" "")))
14396    (set (match_operand:SI 0 "nonimmediate_operand" "")
14397         (plus:SI (match_dup 1) (const_int -1)))
14398    (clobber (match_scratch:CC 3 ""))
14399    (clobber (match_scratch:SI 4 ""))]
14400   "! TARGET_POWERPC64 && reload_completed
14401    && ! gpc_reg_operand (operands[0], SImode)"
14402   [(parallel [(set (match_dup 3)
14403                    (compare:CC (plus:SI (match_dup 1)
14404                                         (const_int -1))
14405                                (const_int 0)))
14406               (set (match_dup 4)
14407                    (plus:SI (match_dup 1)
14408                             (const_int -1)))])
14409    (set (match_dup 0)
14410         (match_dup 4))
14411    (set (pc) (if_then_else (match_dup 7)
14412                            (match_dup 5)
14413                            (match_dup 6)))]
14414   "
14415 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14416                          const0_rtx); }")
14417 (define_split
14418   [(set (pc)
14419         (if_then_else (match_operator 2 "comparison_operator"
14420                                       [(match_operand:DI 1 "gpc_reg_operand" "")
14421                                        (const_int 1)])
14422                       (match_operand 5 "" "")
14423                       (match_operand 6 "" "")))
14424    (set (match_operand:DI 0 "gpc_reg_operand" "")
14425         (plus:DI (match_dup 1)
14426                  (const_int -1)))
14427    (clobber (match_scratch:CC 3 ""))
14428    (clobber (match_scratch:DI 4 ""))]
14429   "TARGET_POWERPC64 && reload_completed"
14430   [(parallel [(set (match_dup 3)
14431                    (compare:CC (plus:DI (match_dup 1)
14432                                         (const_int -1))
14433                                (const_int 0)))
14434               (set (match_dup 0)
14435                    (plus:DI (match_dup 1)
14436                             (const_int -1)))])
14437    (set (pc) (if_then_else (match_dup 7)
14438                            (match_dup 5)
14439                            (match_dup 6)))]
14440   "
14441 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14442                          const0_rtx); }")
14443
14444 (define_split
14445   [(set (pc)
14446         (if_then_else (match_operator 2 "comparison_operator"
14447                                       [(match_operand:DI 1 "gpc_reg_operand" "")
14448                                        (const_int 1)])
14449                       (match_operand 5 "" "")
14450                       (match_operand 6 "" "")))
14451    (set (match_operand:DI 0 "nonimmediate_operand" "")
14452         (plus:DI (match_dup 1) (const_int -1)))
14453    (clobber (match_scratch:CC 3 ""))
14454    (clobber (match_scratch:DI 4 ""))]
14455   "TARGET_POWERPC64 && reload_completed
14456    && ! gpc_reg_operand (operands[0], DImode)"
14457   [(parallel [(set (match_dup 3)
14458                    (compare:CC (plus:DI (match_dup 1)
14459                                         (const_int -1))
14460                                (const_int 0)))
14461               (set (match_dup 4)
14462                    (plus:DI (match_dup 1)
14463                             (const_int -1)))])
14464    (set (match_dup 0)
14465         (match_dup 4))
14466    (set (pc) (if_then_else (match_dup 7)
14467                            (match_dup 5)
14468                            (match_dup 6)))]
14469   "
14470 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
14471                          const0_rtx); }")
14472
14473 \f
14474 (define_insn "trap"
14475   [(trap_if (const_int 1) (const_int 0))]
14476   ""
14477   "{t 31,0,0|trap}")
14478
14479 (define_expand "conditional_trap"
14480   [(trap_if (match_operator 0 "trap_comparison_operator"
14481                             [(match_dup 2) (match_dup 3)])
14482             (match_operand 1 "const_int_operand" ""))]
14483   ""
14484   "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
14485    operands[2] = rs6000_compare_op0;
14486    operands[3] = rs6000_compare_op1;")
14487
14488 (define_insn ""
14489   [(trap_if (match_operator 0 "trap_comparison_operator"
14490                             [(match_operand:SI 1 "register_operand" "r")
14491                              (match_operand:SI 2 "reg_or_short_operand" "rI")])
14492             (const_int 0))]
14493   ""
14494   "{t|tw}%V0%I2 %1,%2")
14495
14496 (define_insn ""
14497   [(trap_if (match_operator 0 "trap_comparison_operator"
14498                             [(match_operand:DI 1 "register_operand" "r")
14499                              (match_operand:DI 2 "reg_or_short_operand" "rI")])
14500             (const_int 0))]
14501   "TARGET_POWERPC64"
14502   "td%V0%I2 %1,%2")
14503 \f
14504 ;; Insns related to generating the function prologue and epilogue.
14505
14506 (define_expand "prologue"
14507   [(use (const_int 0))]
14508   "TARGET_SCHED_PROLOG"
14509   "
14510 {
14511       rs6000_emit_prologue ();
14512       DONE;
14513 }")
14514
14515 (define_insn "movesi_from_cr"
14516   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
14517         (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71) 
14518                     (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)] 19))]
14519   ""
14520   "mfcr %0"
14521   [(set_attr "type" "cr_logical")])
14522
14523 (define_insn "*stmw"
14524  [(match_parallel 0 "stmw_operation"
14525                   [(set (match_operand:SI 1 "memory_operand" "=m")
14526                         (match_operand:SI 2 "gpc_reg_operand" "r"))])]
14527  "TARGET_MULTIPLE"
14528  "{stm|stmw} %2,%1")
14529  
14530 (define_insn "*save_fpregs_si"
14531  [(match_parallel 0 "any_operand"
14532                   [(clobber (match_operand:SI 1 "register_operand" "=l"))
14533                    (use (match_operand:SI 2 "call_operand" "s"))
14534                    (set (match_operand:DF 3 "memory_operand" "=m")
14535                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14536  "TARGET_32BIT"
14537  "bl %z2")
14538
14539 (define_insn "*save_fpregs_di"
14540  [(match_parallel 0 "any_operand"
14541                   [(clobber (match_operand:DI 1 "register_operand" "=l"))
14542                    (use (match_operand:DI 2 "call_operand" "s"))
14543                    (set (match_operand:DF 3 "memory_operand" "=m")
14544                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
14545  "TARGET_64BIT"
14546  "bl %z2")
14547
14548 ; These are to explain that changes to the stack pointer should
14549 ; not be moved over stores to stack memory.
14550 (define_insn "stack_tie"
14551   [(set (match_operand:BLK 0 "memory_operand" "+m")
14552         (unspec:BLK [(match_dup 0)] 5))]
14553   ""
14554   ""
14555   [(set_attr "length" "0")])
14556
14557
14558 (define_expand "epilogue"
14559   [(use (const_int 0))]
14560   "TARGET_SCHED_PROLOG"
14561   "
14562 {
14563       rs6000_emit_epilogue (FALSE);
14564       DONE;
14565 }")
14566
14567 ; On some processors, doing the mtcrf one CC register at a time is
14568 ; faster (like on the 604e).  On others, doing them all at once is
14569 ; faster; for instance, on the 601 and 750.
14570
14571 (define_expand "movsi_to_cr_one"
14572   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14573         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14574                     (match_dup 2)] 20))]
14575   ""
14576   "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
14577
14578 (define_insn "*movsi_to_cr"
14579   [(match_parallel 0 "mtcrf_operation"
14580                    [(set (match_operand:CC 1 "cc_reg_operand" "=y")
14581                          (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
14582                                      (match_operand 3 "immediate_operand" "n")]
14583                          20))])]
14584  ""
14585  "*
14586 {
14587   int mask = 0;
14588   int i;
14589   for (i = 0; i < XVECLEN (operands[0], 0); i++)
14590     mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
14591   operands[4] = GEN_INT (mask);
14592   return \"mtcrf %4,%2\";
14593 }"
14594   [(set_attr "type" "cr_logical")])
14595
14596 (define_insn ""
14597   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
14598         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
14599                     (match_operand 2 "immediate_operand" "n")] 20))]
14600   "GET_CODE (operands[0]) == REG 
14601    && CR_REGNO_P (REGNO (operands[0]))
14602    && GET_CODE (operands[2]) == CONST_INT
14603    && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
14604   "mtcrf %R0,%1"
14605   [(set_attr "type" "cr_logical")])
14606
14607 ; The load-multiple instructions have similar properties.
14608 ; Note that "load_multiple" is a name known to the machine-independent
14609 ; code that actually corresponds to the powerpc load-string.
14610
14611 (define_insn "*lmw"
14612   [(match_parallel 0 "lmw_operation"
14613                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
14614                          (match_operand:SI 2 "memory_operand" "m"))])]
14615   "TARGET_MULTIPLE"
14616   "{lm|lmw} %1,%2")
14617  
14618 (define_insn "*return_internal_si"
14619   [(return)
14620    (use (match_operand:SI 0 "register_operand" "lc"))]
14621   "TARGET_32BIT"
14622   "b%T0"
14623   [(set_attr "type" "jmpreg")])
14624
14625 (define_insn "*return_internal_di"
14626   [(return)
14627    (use (match_operand:DI 0 "register_operand" "lc"))]
14628   "TARGET_64BIT"
14629   "b%T0"
14630   [(set_attr "type" "jmpreg")])
14631
14632 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
14633 ; stuff was in GCC.  Oh, and "any_operand" is a bit flexible...
14634
14635 (define_insn "*return_and_restore_fpregs_si"
14636  [(match_parallel 0 "any_operand"
14637                   [(return)
14638                    (use (match_operand:SI 1 "register_operand" "l"))
14639                    (use (match_operand:SI 2 "call_operand" "s"))
14640                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14641                         (match_operand:DF 4 "memory_operand" "m"))])]
14642  "TARGET_32BIT"
14643  "b %z2")
14644
14645 (define_insn "*return_and_restore_fpregs_di"
14646  [(match_parallel 0 "any_operand"
14647                   [(return)
14648                    (use (match_operand:DI 1 "register_operand" "l"))
14649                    (use (match_operand:DI 2 "call_operand" "s"))
14650                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
14651                         (match_operand:DF 4 "memory_operand" "m"))])]
14652  "TARGET_64BIT"
14653  "b %z2")
14654
14655 ; This is used in compiling the unwind routines.
14656 (define_expand "eh_return"
14657   [(use (match_operand 0 "general_operand" ""))
14658    (use (match_operand 1 "general_operand" ""))]
14659   ""
14660   "
14661 {
14662 #if TARGET_AIX
14663     rs6000_emit_eh_toc_restore (operands[0]);
14664 #endif
14665   if (TARGET_32BIT)
14666     emit_insn (gen_eh_set_lr_si (operands[1]));
14667   else
14668     emit_insn (gen_eh_set_lr_di (operands[1]));
14669   emit_move_insn (EH_RETURN_STACKADJ_RTX, operands[0]);
14670   DONE;
14671 }")
14672
14673 ; We can't expand this before we know where the link register is stored.
14674 (define_insn "eh_set_lr_si"
14675   [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 9)
14676    (clobber (match_scratch:SI 1 "=&b"))]
14677   "TARGET_32BIT"
14678   "#")
14679
14680 (define_insn "eh_set_lr_di"
14681   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")] 9)
14682    (clobber (match_scratch:DI 1 "=&b"))]
14683   "TARGET_64BIT"
14684   "#")
14685
14686 (define_split
14687   [(unspec_volatile [(match_operand 0 "register_operand" "")] 9)
14688    (clobber (match_scratch 1 ""))]
14689   "reload_completed"
14690   [(const_int 0)]
14691   "
14692 {
14693   rs6000_stack_t *info = rs6000_stack_info ();
14694
14695   if (info->lr_save_p)
14696     {
14697       rtx frame_rtx = stack_pointer_rtx;
14698       int sp_offset = 0;
14699       rtx tmp;
14700
14701       if (frame_pointer_needed
14702           || current_function_calls_alloca
14703           || info->total_size > 32767)
14704         {
14705           emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
14706           frame_rtx = operands[1];
14707         }
14708       else if (info->push_p)
14709         sp_offset = info->total_size;
14710
14711       tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
14712       tmp = gen_rtx_MEM (Pmode, tmp);
14713       emit_move_insn (tmp, operands[0]);
14714     }
14715   else
14716     emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
14717   DONE;
14718 }")
14719
14720 (define_insn "prefetch"
14721   [(prefetch (match_operand:V4SI 0 "address_operand" "p")
14722              (match_operand:SI 1 "const_int_operand" "n")
14723              (match_operand:SI 2 "const_int_operand" "n"))]
14724   "TARGET_POWERPC"
14725   "*
14726 {
14727   if (GET_CODE (operands[0]) == REG)
14728     return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14729   return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14730 }"
14731   [(set_attr "type" "load")])
14732
14733 (include "altivec.md")
14734 (include "spe.md")