OSDN Git Service

2002-04-12 Jan Hubicka <jh@suse.cz>
[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 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 ;; 19           movesi_from_cr
36 ;; 20           movesi_to_cr
37 \f
38 ;; Define an insn type attribute.  This is used in function unit delay
39 ;; computations.
40 (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"
41   (const_string "integer"))
42
43 ;; Length (in bytes).
44 ; '(pc)' in the following doesn't include the instruction itself; it is 
45 ; calculated as if the instruction had zero size.
46 (define_attr "length" ""
47   (if_then_else (eq_attr "type" "branch")
48                 (if_then_else (and (ge (minus (match_dup 0) (pc))
49                                        (const_int -32768))
50                                    (lt (minus (match_dup 0) (pc))
51                                        (const_int 32764)))
52                               (const_int 4)
53                               (const_int 8))
54                 (const_int 4)))
55
56 ;; Processor type -- this attribute must exactly match the processor_type
57 ;; enumeration in rs6000.h.
58
59 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450"
60   (const (symbol_ref "rs6000_cpu_attr")))
61
62 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
63 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
64
65 ; Load/Store Unit -- pure PowerPC only
66 ; (POWER and 601 use Integer Unit)
67 (define_function_unit "lsu" 1 0
68   (and (eq_attr "type" "load")
69        (eq_attr "cpu" "rs64a,mpccore,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400"))
70   2 1)
71
72 (define_function_unit "lsu" 1 0
73   (and (eq_attr "type" "load,vecload")
74        (eq_attr "cpu" "ppc7450"))
75   3 1)
76
77 (define_function_unit "lsu" 1 0
78   (and (eq_attr "type" "store,fpstore")
79        (eq_attr "cpu" "rs64a,mpccore,ppc603,ppc604,ppc604e,ppc620,ppc630"))
80   1 1)
81
82 (define_function_unit "lsu" 1 0
83   (and (eq_attr "type" "store,fpstore")
84        (eq_attr "cpu" "ppc750,ppc7400"))
85   2 1)
86
87 (define_function_unit "lsu" 1 0
88   (and (eq_attr "type" "store,vecstore")
89        (eq_attr "cpu" "ppc7450"))
90   3 1)
91
92 (define_function_unit "lsu" 1 0
93   (and (eq_attr "type" "fpstore")
94        (eq_attr "cpu" "ppc7450"))
95   3 3)
96
97 (define_function_unit "lsu" 1 0
98   (and (eq_attr "type" "fpload")
99        (eq_attr "cpu" "mpccore,ppc603,ppc750,ppc7400"))
100   2 1)
101
102 (define_function_unit "lsu" 1 0
103   (and (eq_attr "type" "fpload")
104        (eq_attr "cpu" "ppc7450"))
105   4 1)
106
107 (define_function_unit "lsu" 1 0
108   (and (eq_attr "type" "fpload")
109        (eq_attr "cpu" "rs64a,ppc604,ppc604e,ppc620,ppc630"))
110   3 1)
111
112 (define_function_unit "iu" 1 0
113   (and (eq_attr "type" "load")
114        (eq_attr "cpu" "rios1,ppc403,ppc405,ppc601"))
115   2 1)
116
117 (define_function_unit "iu" 1 0
118   (and (eq_attr "type" "store,fpstore")
119        (eq_attr "cpu" "rios1,ppc403,ppc405,ppc601"))
120   1 1)
121
122 (define_function_unit "fpu" 1 0
123   (and (eq_attr "type" "fpstore")
124        (eq_attr "cpu" "rios1,ppc601"))
125   0 1)
126
127 (define_function_unit "iu" 1 0
128   (and (eq_attr "type" "fpload")
129        (eq_attr "cpu" "rios1"))
130   2 1)
131
132 (define_function_unit "iu" 1 0
133   (and (eq_attr "type" "fpload")
134        (eq_attr "cpu" "ppc601"))
135   3 1)
136
137 (define_function_unit "iu2" 2 0
138   (and (eq_attr "type" "load,fpload")
139        (eq_attr "cpu" "rios2"))
140   2 1)
141
142 (define_function_unit "iu2" 2 0
143   (and (eq_attr "type" "store,fpstore")
144        (eq_attr "cpu" "rios2"))
145   1 1)
146
147 ; Integer Unit (RIOS1, PPC601, PPC603, RS64a)
148 (define_function_unit "iu" 1 0
149   (and (eq_attr "type" "integer")
150        (eq_attr "cpu" "rios1,rs64a,mpccore,ppc403,ppc405,ppc601,ppc603"))
151   1 1)
152
153 (define_function_unit "iu" 1 0
154   (and (eq_attr "type" "cr_logical")
155        (eq_attr "cpu" "mpccore,ppc403,ppc405,ppc601"))
156   1 1)
157
158 (define_function_unit "iu" 1 0
159   (and (eq_attr "type" "imul,imul2,imul3")
160        (eq_attr "cpu" "ppc403"))
161   4 4)
162
163 (define_function_unit "iu" 1 0
164   (and (eq_attr "type" "imul")
165        (eq_attr "cpu" "ppc405"))
166   4 3)
167
168 (define_function_unit "iu" 1 0
169   (and (eq_attr "type" "imul2,imul3")
170        (eq_attr "cpu" "ppc405"))
171   3 2)
172
173 (define_function_unit "iu" 1 0
174   (and (eq_attr "type" "imul")
175        (eq_attr "cpu" "rios1"))
176   5 5)
177
178 (define_function_unit "iu" 1 0
179   (and (eq_attr "type" "imul2")
180        (eq_attr "cpu" "rios1"))
181   4 4)
182
183 (define_function_unit "iu" 1 0
184   (and (eq_attr "type" "imul3")
185        (eq_attr "cpu" "rios1"))
186   3 3)
187
188 (define_function_unit "iu" 1 0
189   (and (eq_attr "type" "imul,imul2,imul3")
190        (eq_attr "cpu" "ppc601,ppc603"))
191   5 5)
192
193 (define_function_unit "iu" 1 0
194   (and (eq_attr "type" "imul")
195        (eq_attr "cpu" "rs64a"))
196   20 20)
197
198 (define_function_unit "iu" 1 0
199   (and (eq_attr "type" "imul2")
200        (eq_attr "cpu" "rs64a"))
201   12 12)
202
203 (define_function_unit "iu" 1 0
204   (and (eq_attr "type" "imul3")
205        (eq_attr "cpu" "rs64a"))
206   8 8)
207
208 (define_function_unit "iu" 1 0
209   (and (eq_attr "type" "lmul")
210        (eq_attr "cpu" "rs64a"))
211   34 34)
212
213 (define_function_unit "iu" 1 0
214   (and (eq_attr "type" "idiv")
215        (eq_attr "cpu" "rios1"))
216   19 19)
217
218 (define_function_unit "iu" 1 0
219   (and (eq_attr "type" "idiv")
220        (eq_attr "cpu" "rs64a"))
221   66 66)
222
223 (define_function_unit "iu" 1 0
224   (and (eq_attr "type" "ldiv")
225        (eq_attr "cpu" "rs64a"))
226   66 66)
227
228 (define_function_unit "iu" 1 0
229   (and (eq_attr "type" "idiv")
230        (eq_attr "cpu" "ppc403"))
231   33 33)
232
233 (define_function_unit "iu" 1 0
234   (and (eq_attr "type" "idiv")
235        (eq_attr "cpu" "ppc405"))
236   35 35)
237
238 (define_function_unit "iu" 1 0
239   (and (eq_attr "type" "idiv")
240        (eq_attr "cpu" "ppc601"))
241   36 36)
242
243 (define_function_unit "iu" 1 0
244   (and (eq_attr "type" "idiv")
245        (eq_attr "cpu" "ppc603"))
246   37 36)
247
248 ; RIOS2 has two integer units: a primary one which can perform all
249 ; operations and a secondary one which is fed in lock step with the first
250 ; and can perform "simple" integer operations.  
251 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
252 ; for the complex insns. 
253 (define_function_unit "iu2" 2 0
254   (and (eq_attr "type" "integer")
255        (eq_attr "cpu" "rios2"))
256   1 1)
257
258 (define_function_unit "iu2" 2 0
259   (and (eq_attr "type" "imul,imul2,imul3")
260        (eq_attr "cpu" "rios2"))
261   2 2)
262
263 (define_function_unit "iu2" 2 0
264   (and (eq_attr "type" "idiv")
265        (eq_attr "cpu" "rios2"))
266   13 13)
267
268 (define_function_unit "imuldiv" 1 0
269   (and (eq_attr "type" "imul,imul2,imul3")
270        (eq_attr "cpu" "rios2"))
271   2 2)
272
273 (define_function_unit "imuldiv" 1 0
274   (and (eq_attr "type" "idiv")
275        (eq_attr "cpu" "rios2"))
276   13 13)
277
278 ; MPCCORE has separate IMUL/IDIV unit for multicycle instructions
279 ; Divide latency varies greatly from 2-11, use 6 as average
280 (define_function_unit "imuldiv" 1 0
281   (and (eq_attr "type" "imul,imul2,imul3")
282        (eq_attr "cpu" "mpccore"))
283   2 1)
284
285 (define_function_unit "imuldiv" 1 0
286   (and (eq_attr "type" "idiv")
287        (eq_attr "cpu" "mpccore"))
288   6 6)
289
290 ; PPC604{,e} has two units that perform integer operations
291 ; and one unit for divide/multiply operations (and move
292 ; from/to spr).
293 (define_function_unit "iu2" 2 0
294   (and (eq_attr "type" "integer")
295        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc630"))
296   1 1)
297
298 (define_function_unit "imuldiv" 1 0
299   (and (eq_attr "type" "imul,imul2,imul3")
300        (eq_attr "cpu" "ppc604"))
301   4 2)
302
303 (define_function_unit "imuldiv" 1 0
304   (and (eq_attr "type" "imul,imul2,imul3")
305        (eq_attr "cpu" "ppc604e"))
306   2 1)
307
308 (define_function_unit "imuldiv" 1 0
309   (and (eq_attr "type" "imul")
310        (eq_attr "cpu" "ppc620,ppc630"))
311   5 3)
312
313 (define_function_unit "imuldiv" 1 0
314   (and (eq_attr "type" "imul2")
315        (eq_attr "cpu" "ppc620,ppc630"))
316   4 3)
317
318 (define_function_unit "imuldiv" 1 0
319   (and (eq_attr "type" "imul3")
320        (eq_attr "cpu" "ppc620,ppc630"))
321   3 3)
322
323 (define_function_unit "imuldiv" 1 0
324   (and (eq_attr "type" "lmul")
325        (eq_attr "cpu" "ppc620,ppc630"))
326   7 5)
327
328 (define_function_unit "imuldiv" 1 0
329   (and (eq_attr "type" "idiv")
330        (eq_attr "cpu" "ppc604,ppc604e"))
331   20 19)
332
333 (define_function_unit "imuldiv" 1 0
334   (and (eq_attr "type" "idiv")
335        (eq_attr "cpu" "ppc620"))
336   37 36)
337
338 (define_function_unit "imuldiv" 1 0
339   (and (eq_attr "type" "idiv")
340        (eq_attr "cpu" "ppc630"))
341   21 20)
342
343 (define_function_unit "imuldiv" 1 0
344   (and (eq_attr "type" "ldiv")
345        (eq_attr "cpu" "ppc620,ppc630"))
346   37 36)
347
348 ; PPC7450 has 3 integer units (for most integer insns) and one mul/div
349 ; unit, which also does CR-logical insns and move to/from SPR.
350 ; It also has 4 vector units, one for each type of vector instruction.
351 ; However, we can only dispatch 2 instructions per cycle. 
352 ; We model this as saying that dispatching two of the same type of instruction
353 ; in a row incurs a single cycle delay.
354 (define_function_unit "iu3" 3 0
355   (and (eq_attr "type" "integer")
356        (eq_attr "cpu" "ppc7450"))
357   1 1)
358
359 (define_function_unit "imuldiv" 1 0
360   (and (eq_attr "type" "imul")
361        (eq_attr "cpu" "ppc7450"))
362   4 2)
363
364 (define_function_unit "imuldiv" 1 0
365   (and (eq_attr "type" "imul2,imul3")
366        (eq_attr "cpu" "ppc7450"))
367   3 1)
368
369 (define_function_unit "imuldiv" 1 0
370   (and (eq_attr "type" "idiv")
371        (eq_attr "cpu" "ppc7450"))
372   23 23)
373
374 (define_function_unit "imuldiv" 1 0
375   (and (eq_attr "type" "cr_logical")
376        (eq_attr "cpu" "ppc7450"))
377   1 1)
378 (define_function_unit "vec_alu2" 2 0
379   (and (eq_attr "type" "vecsimple")
380        (eq_attr "cpu" "ppc7450"))
381   1 2 [(eq_attr "type" "vecsimple")])
382 (define_function_unit "vec_alu2" 2 0
383   (and (eq_attr "type" "vecsimple")
384        (eq_attr "cpu" "ppc7450"))
385   1 1 [(eq_attr "type" "!vecsimple")])
386 (define_function_unit "vec_alu2" 2 0
387   (and (eq_attr "type" "veccomplex")
388        (eq_attr "cpu" "ppc7450"))
389   4 2 [(eq_attr "type" "veccomplex")])
390 (define_function_unit "vec_alu2" 2 0
391   (and (eq_attr "type" "veccomplex")
392        (eq_attr "cpu" "ppc7450"))
393   4 1 [(eq_attr "type" "!veccomplex")])
394 (define_function_unit "vec_alu2" 2 0
395   (and (eq_attr "type" "veccmp")
396        (eq_attr "cpu" "ppc7450"))
397   2 2 [(eq_attr "type" "veccmp")])
398 (define_function_unit "vec_alu2" 2 0
399   (and (eq_attr "type" "veccmp")
400        (eq_attr "cpu" "ppc7450"))
401   2 1 [(eq_attr "type" "!veccmp")])
402 (define_function_unit "vec_alu2" 2 0
403   (and (eq_attr "type" "vecfloat")
404        (eq_attr "cpu" "ppc7450"))
405   4 2 [(eq_attr "type" "vecfloat")])
406 (define_function_unit "vec_alu2" 2 0
407   (and (eq_attr "type" "vecfloat")
408        (eq_attr "cpu" "ppc7450"))
409   4 1 [(eq_attr "type" "!vecfloat")])
410 (define_function_unit "vec_alu2" 2 0
411   (and (eq_attr "type" "vecperm")
412        (eq_attr "cpu" "ppc7450"))
413   2 2 [(eq_attr "type" "vecperm")])
414 (define_function_unit "vec_alu2" 2 0
415   (and (eq_attr "type" "vecperm")
416        (eq_attr "cpu" "ppc7450"))
417   2 1 [(eq_attr "type" "!vecperm")])
418
419 ; PPC750 has two integer units: a primary one which can perform all
420 ; operations and a secondary one which is fed in lock step with the first
421 ; and can perform "simple" integer operations.  
422 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
423 ; for the complex insns. 
424 (define_function_unit "iu2" 2 0
425   (and (eq_attr "type" "integer")
426        (eq_attr "cpu" "ppc750,ppc7400"))
427   1 1)
428
429 (define_function_unit "iu2" 2 0
430   (and (eq_attr "type" "imul")
431        (eq_attr "cpu" "ppc750,ppc7400"))
432   4 4)
433
434 (define_function_unit "iu2" 2 0
435   (and (eq_attr "type" "imul2")
436        (eq_attr "cpu" "ppc750,ppc7400"))
437   3 2)
438
439 (define_function_unit "iu2" 2 0
440   (and (eq_attr "type" "imul3")
441        (eq_attr "cpu" "ppc750,ppc7400"))
442   2 1)
443
444 (define_function_unit "iu2" 2 0
445   (and (eq_attr "type" "idiv")
446        (eq_attr "cpu" "ppc750,ppc7400"))
447   19 19)
448
449 (define_function_unit "imuldiv" 1 0
450   (and (eq_attr "type" "imul")
451        (eq_attr "cpu" "ppc750,ppc7400"))
452   4 4)
453
454 (define_function_unit "imuldiv" 1 0
455   (and (eq_attr "type" "imul2")
456        (eq_attr "cpu" "ppc750,ppc7400"))
457   3 2)
458
459 (define_function_unit "imuldiv" 1 0
460   (and (eq_attr "type" "imul3")
461        (eq_attr "cpu" "ppc750,ppc7400"))
462   2 1)
463
464 (define_function_unit "imuldiv" 1 0
465   (and (eq_attr "type" "idiv")
466        (eq_attr "cpu" "ppc750,ppc7400"))
467   19 19)
468
469 ; CR-logical operations are execute-serialized, that is they don't
470 ; start (and block the function unit) until all preceding operations
471 ; have finished.  They don't block dispatch of other insns, though.
472 ; I've imitated this by giving them longer latency.
473 (define_function_unit "sru" 1 0 
474   (and (eq_attr "type" "cr_logical")
475        (eq_attr "cpu" "ppc603,ppc750,ppc7400"))
476   3 2)
477
478 ; compare is done on integer unit, but feeds insns which
479 ; execute on the branch unit.
480 (define_function_unit "iu" 1 0   
481   (and (eq_attr "type" "compare")
482        (eq_attr "cpu" "rios1"))
483   4 1)
484
485 (define_function_unit "iu" 1 0   
486   (and (eq_attr "type" "delayed_compare")
487        (eq_attr "cpu" "rios1"))
488   5 1)
489
490 (define_function_unit "iu" 1 0
491   (and (eq_attr "type" "compare,delayed_compare")
492        (eq_attr "cpu" "rs64a,mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630"))
493   3 1)
494
495 ; some extra cycles added by TARGET_SCHED_ADJUST_COST between compare
496 ; and a following branch, to reduce mispredicts
497 (define_function_unit "iu3" 3 0
498   (and (eq_attr "type" "compare,delayed_compare")
499        (eq_attr "cpu" "ppc7450"))
500   1 1)
501
502 (define_function_unit "iu2" 2 0   
503   (and (eq_attr "type" "compare,delayed_compare")
504        (eq_attr "cpu" "rios2"))
505   3 1)
506
507 (define_function_unit "iu2" 2 0
508   (and (eq_attr "type" "compare,delayed_compare")
509        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400"))
510   1 1)
511
512 ; fp compare uses fp unit
513 (define_function_unit "fpu" 1 0
514   (and (eq_attr "type" "fpcompare")
515        (eq_attr "cpu" "rios1"))
516   9 1)
517
518 ; rios1 and rios2 have different fpcompare delays
519 (define_function_unit "fpu2" 2 0
520   (and (eq_attr "type" "fpcompare")
521        (eq_attr "cpu" "rios2,ppc630"))
522   5 1)
523
524 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
525 ; the integer unit
526 ; here we do not define delays, just occupy the unit. The dependencies
527 ; will be assigned by the fpcompare definition in the fpu.
528 (define_function_unit "iu" 1 0
529   (and (eq_attr "type" "fpcompare")
530        (eq_attr "cpu" "ppc601,ppc603"))
531   0 2)
532
533 ; fp compare uses fp unit
534 (define_function_unit "fpu" 1 0
535   (and (eq_attr "type" "fpcompare")
536        (eq_attr "cpu" "rs64a,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630"))
537   5 1)
538
539 (define_function_unit "fpu" 1 0
540   (and (eq_attr "type" "fpcompare")
541        (eq_attr "cpu"  "ppc750,ppc7400,ppc7450"))
542   3 1)
543
544 (define_function_unit "fpu" 1 0
545   (and (eq_attr "type" "fpcompare")
546        (eq_attr "cpu" "mpccore"))
547   1 1)
548
549 (define_function_unit "bpu" 1 0
550   (and (eq_attr "type" "mtjmpr")
551        (eq_attr "cpu" "rios1,rios2,rs64a"))
552   5 1)
553
554 (define_function_unit "bpu" 1 0
555   (and (eq_attr "type" "mtjmpr")
556        (eq_attr "cpu" "mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630"))
557   4 1)
558
559 (define_function_unit "sru" 1 0
560   (and (eq_attr "type" "mtjmpr")
561        (eq_attr "cpu" "ppc750,ppc7400"))
562   2 2)
563
564 (define_function_unit "imuldiv" 1 0
565   (and (eq_attr "type" "mtjmpr")
566        (eq_attr "cpu" "ppc7450"))
567   2 2)
568
569 (define_function_unit "bpu" 1 0
570   (and (eq_attr "type" "cr_logical")
571        (eq_attr "cpu" "rios1,rios2,ppc604"))
572   4 1)
573   
574 (define_function_unit "cru" 1 0
575   (and (eq_attr "type" "cr_logical")
576        (eq_attr "cpu" "ppc604e,ppc620,ppc630,rs64a"))
577   1 1)
578
579 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
580 (define_function_unit "bpu" 1 0
581   (eq_attr "type" "jmpreg")
582   1 1)
583
584 (define_function_unit "bpu" 1 0
585   (eq_attr "type" "branch")
586   1 1)
587
588 ; Floating Point Unit
589 (define_function_unit "fpu" 1 0
590   (and (eq_attr "type" "fp,dmul")
591        (eq_attr "cpu" "rios1"))
592   2 1)
593
594 (define_function_unit "fpu" 1 0
595   (and (eq_attr "type" "fp")
596        (eq_attr "cpu" "rs64a,mpccore"))
597   4 2)
598
599 (define_function_unit "fpu" 1 0
600   (and (eq_attr "type" "fp")
601        (eq_attr "cpu" "ppc601"))
602   4 1)
603
604 (define_function_unit "fpu" 1 0
605   (and (eq_attr "type" "fp")
606        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620,ppc750,ppc7400"))
607   3 1)
608
609 (define_function_unit "fpu" 1 0
610   (and (eq_attr "type" "fp,dmul")
611        (eq_attr "cpu" "ppc7450"))
612   5 1)
613
614 (define_function_unit "fpu" 1 0
615   (and (eq_attr "type" "dmul")
616        (eq_attr "cpu" "rs64a"))
617   7 2)
618
619 (define_function_unit "fpu" 1 0
620   (and (eq_attr "type" "dmul")
621        (eq_attr "cpu" "mpccore"))
622   5 5)
623
624 (define_function_unit "fpu" 1 0
625   (and (eq_attr "type" "dmul")
626        (eq_attr "cpu" "ppc601"))
627   5 2)
628
629 ; is this true?
630 (define_function_unit "fpu" 1 0
631   (and (eq_attr "type" "dmul")
632        (eq_attr "cpu" "ppc603,ppc750"))
633   4 2)
634
635 (define_function_unit "fpu" 1 0
636   (and (eq_attr "type" "dmul")
637        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc7400"))
638   3 1)
639
640 (define_function_unit "fpu" 1 0
641   (and (eq_attr "type" "sdiv,ddiv")
642        (eq_attr "cpu" "rios1"))
643   19 19)
644
645 (define_function_unit "fpu" 1 0
646   (and (eq_attr "type" "sdiv")
647        (eq_attr "cpu" "rs64a"))
648   31 31)
649
650 (define_function_unit "fpu" 1 0
651   (and (eq_attr "type" "sdiv")
652        (eq_attr "cpu" "ppc601,ppc750,ppc7400"))
653   17 17)
654
655 (define_function_unit "fpu" 1 0
656   (and (eq_attr "type" "sdiv")
657        (eq_attr "cpu" "ppc7450"))
658   21 21)
659
660 (define_function_unit "fpu" 1 0
661   (and (eq_attr "type" "sdiv")
662        (eq_attr "cpu" "mpccore"))
663   10 10)
664
665 (define_function_unit "fpu" 1 0
666   (and (eq_attr "type" "sdiv")
667        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620"))
668   18 18)
669
670 (define_function_unit "fpu" 1 0
671   (and (eq_attr "type" "ddiv")
672        (eq_attr "cpu" "mpccore"))
673   17 17)
674
675 (define_function_unit "fpu" 1 0
676   (and (eq_attr "type" "ddiv")
677        (eq_attr "cpu" "rs64a,ppc601,ppc750,ppc604,ppc604e,ppc620,ppc7400"))
678   31 31)
679
680 (define_function_unit "fpu" 1 0
681   (and (eq_attr "type" "ddiv")
682        (eq_attr "cpu" "ppc7450"))
683   35 35)
684
685 (define_function_unit "fpu" 1 0
686   (and (eq_attr "type" "ddiv")
687        (eq_attr "cpu" "ppc603"))
688   33 33)
689
690 (define_function_unit "fpu" 1 0
691   (and (eq_attr "type" "ssqrt")
692        (eq_attr "cpu" "ppc620"))
693   31 31)
694
695 (define_function_unit "fpu" 1 0
696   (and (eq_attr "type" "dsqrt")
697        (eq_attr "cpu" "ppc620"))
698   31 31)
699
700 ; RIOS2 has two symmetric FPUs.
701 (define_function_unit "fpu2" 2 0
702   (and (eq_attr "type" "fp")
703        (eq_attr "cpu" "rios2"))
704   2 1)
705
706 (define_function_unit "fpu2" 2 0
707   (and (eq_attr "type" "fp")
708        (eq_attr "cpu" "ppc630"))
709   3 1)
710
711 (define_function_unit "fpu2" 2 0
712   (and (eq_attr "type" "dmul")
713        (eq_attr "cpu" "rios2"))
714   2 1)
715
716 (define_function_unit "fpu2" 2 0
717   (and (eq_attr "type" "dmul")
718        (eq_attr "cpu" "ppc630"))
719   3 1)
720
721 (define_function_unit "fpu2" 2 0
722   (and (eq_attr "type" "sdiv,ddiv")
723        (eq_attr "cpu" "rios2"))
724   17 17)
725
726 (define_function_unit "fpu2" 2 0
727   (and (eq_attr "type" "sdiv")
728        (eq_attr "cpu" "ppc630"))
729   17 17)
730
731 (define_function_unit "fpu2" 2 0
732   (and (eq_attr "type" "ddiv")
733        (eq_attr "cpu" "ppc630"))
734   21 21)
735
736 (define_function_unit "fpu2" 2 0
737   (and (eq_attr "type" "ssqrt,dsqrt")
738        (eq_attr "cpu" "rios2"))
739   26 26)
740
741 (define_function_unit "fpu2" 2 0
742   (and (eq_attr "type" "ssqrt")
743        (eq_attr "cpu" "ppc630"))
744   18 18)
745
746 (define_function_unit "fpu2" 2 0
747   (and (eq_attr "type" "dsqrt")
748        (eq_attr "cpu" "ppc630"))
749   26 26)
750
751 \f
752 ;; Start with fixed-point load and store insns.  Here we put only the more
753 ;; complex forms.  Basic data transfer is done later.
754
755 (define_expand "zero_extendqidi2"
756   [(set (match_operand:DI 0 "gpc_reg_operand" "")
757         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
758   "TARGET_POWERPC64"
759   "")
760
761 (define_insn ""
762   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
763         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
764   "TARGET_POWERPC64"
765   "@
766    lbz%U1%X1 %0,%1
767    rldicl %0,%1,0,56"
768   [(set_attr "type" "load,*")])
769
770 (define_insn ""
771   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
772         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
773                     (const_int 0)))
774    (clobber (match_scratch:DI 2 "=r,r"))]
775   "TARGET_POWERPC64"
776   "@
777    rldicl. %2,%1,0,56
778    #"
779   [(set_attr "type" "compare")
780    (set_attr "length" "4,8")])
781
782 (define_split
783   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
784         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
785                     (const_int 0)))
786    (clobber (match_scratch:DI 2 ""))]
787   "TARGET_POWERPC64 && reload_completed"
788   [(set (match_dup 2)
789         (zero_extend:DI (match_dup 1)))
790    (set (match_dup 0)
791         (compare:CC (match_dup 2)
792                     (const_int 0)))]
793   "")
794
795 (define_insn ""
796   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
797         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
798                     (const_int 0)))
799    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
800         (zero_extend:DI (match_dup 1)))]
801   "TARGET_POWERPC64"
802   "@
803    rldicl. %0,%1,0,56
804    #"
805   [(set_attr "type" "compare")
806    (set_attr "length" "4,8")])
807
808 (define_split
809   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
810         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
811                     (const_int 0)))
812    (set (match_operand:DI 0 "gpc_reg_operand" "")
813         (zero_extend:DI (match_dup 1)))]
814   "TARGET_POWERPC64 && reload_completed"
815   [(set (match_dup 0)
816         (zero_extend:DI (match_dup 1)))
817    (set (match_dup 2)
818         (compare:CC (match_dup 0)
819                     (const_int 0)))]
820   "")
821
822 (define_insn "extendqidi2"
823   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
824         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
825   "TARGET_POWERPC64"
826   "extsb %0,%1")
827
828 (define_insn ""
829   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
830         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
831                     (const_int 0)))
832    (clobber (match_scratch:DI 2 "=r,r"))]
833   "TARGET_POWERPC64"
834   "@
835    extsb. %2,%1
836    #"
837   [(set_attr "type" "compare")
838    (set_attr "length" "4,8")])
839
840 (define_split
841   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
842         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
843                     (const_int 0)))
844    (clobber (match_scratch:DI 2 ""))]
845   "TARGET_POWERPC64 && reload_completed"
846   [(set (match_dup 2)
847         (sign_extend:DI (match_dup 1)))
848    (set (match_dup 0)
849         (compare:CC (match_dup 2)
850                     (const_int 0)))]
851   "")
852
853 (define_insn ""
854   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
855         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
856                     (const_int 0)))
857    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
858         (sign_extend:DI (match_dup 1)))]
859   "TARGET_POWERPC64"
860   "@
861    extsb. %0,%1
862    #"
863   [(set_attr "type" "compare")
864    (set_attr "length" "4,8")])
865
866 (define_split
867   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
868         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
869                     (const_int 0)))
870    (set (match_operand:DI 0 "gpc_reg_operand" "")
871         (sign_extend:DI (match_dup 1)))]
872   "TARGET_POWERPC64 && reload_completed"
873   [(set (match_dup 0)
874         (sign_extend:DI (match_dup 1)))
875    (set (match_dup 2)
876         (compare:CC (match_dup 0)
877                     (const_int 0)))]
878   "")
879
880 (define_expand "zero_extendhidi2"
881   [(set (match_operand:DI 0 "gpc_reg_operand" "")
882         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
883   "TARGET_POWERPC64"
884   "")
885
886 (define_insn ""
887   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
888         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
889   "TARGET_POWERPC64"
890   "@
891    lhz%U1%X1 %0,%1
892    rldicl %0,%1,0,48"
893   [(set_attr "type" "load,*")])
894
895 (define_insn ""
896   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
897         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
898                     (const_int 0)))
899    (clobber (match_scratch:DI 2 "=r,r"))]
900   "TARGET_POWERPC64"
901   "@
902    rldicl. %2,%1,0,48
903    #"
904   [(set_attr "type" "compare")
905    (set_attr "length" "4,8")])
906
907 (define_split
908   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
909         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
910                     (const_int 0)))
911    (clobber (match_scratch:DI 2 ""))]
912   "TARGET_POWERPC64 && reload_completed"
913   [(set (match_dup 2)
914         (zero_extend:DI (match_dup 1)))
915    (set (match_dup 0)
916         (compare:CC (match_dup 2)
917                     (const_int 0)))]
918   "")
919
920 (define_insn ""
921   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
922         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
923                     (const_int 0)))
924    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
925         (zero_extend:DI (match_dup 1)))]
926   "TARGET_POWERPC64"
927   "@
928    rldicl. %0,%1,0,48
929    #"
930   [(set_attr "type" "compare")
931    (set_attr "length" "4,8")])
932
933 (define_split
934   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
935         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
936                     (const_int 0)))
937    (set (match_operand:DI 0 "gpc_reg_operand" "")
938         (zero_extend:DI (match_dup 1)))]
939   "TARGET_POWERPC64 && reload_completed"
940   [(set (match_dup 0)
941         (zero_extend:DI (match_dup 1)))
942    (set (match_dup 2)
943         (compare:CC (match_dup 0)
944                     (const_int 0)))]
945   "")
946
947 (define_expand "extendhidi2"
948   [(set (match_operand:DI 0 "gpc_reg_operand" "")
949         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
950   "TARGET_POWERPC64"
951   "")
952
953 (define_insn ""
954   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
955         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
956   "TARGET_POWERPC64"
957   "@
958    lha%U1%X1 %0,%1
959    extsh %0,%1"
960   [(set_attr "type" "load,*")])
961
962 (define_insn ""
963   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
964         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
965                     (const_int 0)))
966    (clobber (match_scratch:DI 2 "=r,r"))]
967   "TARGET_POWERPC64"
968   "@
969    extsh. %2,%1
970    #"
971   [(set_attr "type" "compare")
972    (set_attr "length" "4,8")])
973
974 (define_split
975   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
976         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
977                     (const_int 0)))
978    (clobber (match_scratch:DI 2 ""))]
979   "TARGET_POWERPC64 && reload_completed"
980   [(set (match_dup 2)
981         (sign_extend:DI (match_dup 1)))
982    (set (match_dup 0)
983         (compare:CC (match_dup 2)
984                     (const_int 0)))]
985   "")
986
987 (define_insn ""
988   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
989         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
990                     (const_int 0)))
991    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
992         (sign_extend:DI (match_dup 1)))]
993   "TARGET_POWERPC64"
994   "@
995    extsh. %0,%1
996    #"
997   [(set_attr "type" "compare")
998    (set_attr "length" "4,8")])
999
1000 (define_split
1001   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1002         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1003                     (const_int 0)))
1004    (set (match_operand:DI 0 "gpc_reg_operand" "")
1005         (sign_extend:DI (match_dup 1)))]
1006   "TARGET_POWERPC64 && reload_completed"
1007   [(set (match_dup 0)
1008         (sign_extend:DI (match_dup 1)))
1009    (set (match_dup 2)
1010         (compare:CC (match_dup 0)
1011                     (const_int 0)))]
1012   "")
1013
1014 (define_expand "zero_extendsidi2"
1015   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1016         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1017   "TARGET_POWERPC64"
1018   "")
1019
1020 (define_insn ""
1021   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1022         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
1023   "TARGET_POWERPC64"
1024   "@
1025    lwz%U1%X1 %0,%1
1026    rldicl %0,%1,0,32"
1027   [(set_attr "type" "load,*")])
1028
1029 (define_insn ""
1030   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1031         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1032                     (const_int 0)))
1033    (clobber (match_scratch:DI 2 "=r,r"))]
1034   "TARGET_POWERPC64"
1035   "@
1036    rldicl. %2,%1,0,32
1037    #"
1038   [(set_attr "type" "compare")
1039    (set_attr "length" "4,8")])
1040
1041 (define_split
1042   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1043         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1044                     (const_int 0)))
1045    (clobber (match_scratch:DI 2 ""))]
1046   "TARGET_POWERPC64 && reload_completed"
1047   [(set (match_dup 2)
1048         (zero_extend:DI (match_dup 1)))
1049    (set (match_dup 0)
1050         (compare:CC (match_dup 2)
1051                     (const_int 0)))]
1052   "")
1053
1054 (define_insn ""
1055   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1056         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1057                     (const_int 0)))
1058    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1059         (zero_extend:DI (match_dup 1)))]
1060   "TARGET_POWERPC64"
1061   "@
1062    rldicl. %0,%1,0,32
1063    #"
1064   [(set_attr "type" "compare")
1065    (set_attr "length" "4,8")])
1066
1067 (define_split
1068   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1069         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1070                     (const_int 0)))
1071    (set (match_operand:DI 0 "gpc_reg_operand" "")
1072         (zero_extend:DI (match_dup 1)))]
1073   "TARGET_POWERPC64 && reload_completed"
1074   [(set (match_dup 0)
1075         (zero_extend:DI (match_dup 1)))
1076    (set (match_dup 2)
1077         (compare:CC (match_dup 0)
1078                     (const_int 0)))]
1079   "")
1080
1081 (define_expand "extendsidi2"
1082   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1083         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1084   "TARGET_POWERPC64"
1085   "")
1086
1087 (define_insn ""
1088   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1089         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
1090   "TARGET_POWERPC64"
1091   "@
1092    lwa%U1%X1 %0,%1
1093    extsw %0,%1"
1094   [(set_attr "type" "load,*")])
1095
1096 (define_insn ""
1097   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1098         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1099                     (const_int 0)))
1100    (clobber (match_scratch:DI 2 "=r,r"))]
1101   "TARGET_POWERPC64"
1102   "@
1103    extsw. %2,%1
1104    #"
1105   [(set_attr "type" "compare")
1106    (set_attr "length" "4,8")])
1107
1108 (define_split
1109   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1110         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1111                     (const_int 0)))
1112    (clobber (match_scratch:DI 2 ""))]
1113   "TARGET_POWERPC64 && reload_completed"
1114   [(set (match_dup 2)
1115         (sign_extend:DI (match_dup 1)))
1116    (set (match_dup 0)
1117         (compare:CC (match_dup 2)
1118                     (const_int 0)))]
1119   "")
1120
1121 (define_insn ""
1122   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1123         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1124                     (const_int 0)))
1125    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1126         (sign_extend:DI (match_dup 1)))]
1127   "TARGET_POWERPC64"
1128   "@
1129    extsw. %0,%1
1130    #"
1131   [(set_attr "type" "compare")
1132    (set_attr "length" "4,8")])
1133
1134 (define_split
1135   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1136         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1137                     (const_int 0)))
1138    (set (match_operand:DI 0 "gpc_reg_operand" "")
1139         (sign_extend:DI (match_dup 1)))]
1140   "TARGET_POWERPC64 && reload_completed"
1141   [(set (match_dup 0)
1142         (sign_extend:DI (match_dup 1)))
1143    (set (match_dup 2)
1144         (compare:CC (match_dup 0)
1145                     (const_int 0)))]
1146   "")
1147
1148 (define_expand "zero_extendqisi2"
1149   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1150         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1151   ""
1152   "")
1153
1154 (define_insn ""
1155   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1156         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1157   ""
1158   "@
1159    lbz%U1%X1 %0,%1
1160    {rlinm|rlwinm} %0,%1,0,0xff"
1161   [(set_attr "type" "load,*")])
1162
1163 (define_insn ""
1164   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1165         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1166                     (const_int 0)))
1167    (clobber (match_scratch:SI 2 "=r,r"))]
1168   ""
1169   "@
1170    {andil.|andi.} %2,%1,0xff
1171    #"
1172   [(set_attr "type" "compare")
1173    (set_attr "length" "4,8")])
1174
1175 (define_split
1176   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1177         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1178                     (const_int 0)))
1179    (clobber (match_scratch:SI 2 ""))]
1180   "reload_completed"
1181   [(set (match_dup 2)
1182         (zero_extend:SI (match_dup 1)))
1183    (set (match_dup 0)
1184         (compare:CC (match_dup 2)
1185                     (const_int 0)))]
1186   "")
1187
1188 (define_insn ""
1189   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1190         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1191                     (const_int 0)))
1192    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1193         (zero_extend:SI (match_dup 1)))]
1194   ""
1195   "@
1196    {andil.|andi.} %0,%1,0xff
1197    #"
1198   [(set_attr "type" "compare")
1199    (set_attr "length" "4,8")])
1200
1201 (define_split
1202   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1203         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1204                     (const_int 0)))
1205    (set (match_operand:SI 0 "gpc_reg_operand" "")
1206         (zero_extend:SI (match_dup 1)))]
1207   "reload_completed"
1208   [(set (match_dup 0)
1209         (zero_extend:SI (match_dup 1)))
1210    (set (match_dup 2)
1211         (compare:CC (match_dup 0)
1212                     (const_int 0)))]
1213   "")
1214
1215 (define_expand "extendqisi2"
1216   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1217    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1218   ""
1219   "
1220 {
1221   if (TARGET_POWERPC)
1222     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
1223   else if (TARGET_POWER)
1224     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
1225   else
1226     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
1227   DONE;
1228 }")
1229
1230 (define_insn "extendqisi2_ppc"
1231   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1232         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1233   "TARGET_POWERPC"
1234   "extsb %0,%1")
1235
1236 (define_insn ""
1237   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1238         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1239                     (const_int 0)))
1240    (clobber (match_scratch:SI 2 "=r,r"))]
1241   "TARGET_POWERPC"
1242   "@
1243    extsb. %2,%1
1244    #"
1245   [(set_attr "type" "compare")
1246    (set_attr "length" "4,8")])
1247
1248 (define_split
1249   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1250         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1251                     (const_int 0)))
1252    (clobber (match_scratch:SI 2 ""))]
1253   "TARGET_POWERPC && reload_completed"
1254   [(set (match_dup 2)
1255         (sign_extend:SI (match_dup 1)))
1256    (set (match_dup 0)
1257         (compare:CC (match_dup 2)
1258                     (const_int 0)))]
1259   "")
1260
1261 (define_insn ""
1262   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1263         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1264                     (const_int 0)))
1265    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1266         (sign_extend:SI (match_dup 1)))]
1267   "TARGET_POWERPC"
1268   "@
1269    extsb. %0,%1
1270    #"
1271   [(set_attr "type" "compare")
1272    (set_attr "length" "4,8")])
1273
1274 (define_split
1275   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1276         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1277                     (const_int 0)))
1278    (set (match_operand:SI 0 "gpc_reg_operand" "")
1279         (sign_extend:SI (match_dup 1)))]
1280   "TARGET_POWERPC && reload_completed"
1281   [(set (match_dup 0)
1282         (sign_extend:SI (match_dup 1)))
1283    (set (match_dup 2)
1284         (compare:CC (match_dup 0)
1285                     (const_int 0)))]
1286   "")
1287
1288 (define_expand "extendqisi2_power"
1289   [(parallel [(set (match_dup 2)
1290                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1291                               (const_int 24)))
1292               (clobber (scratch:SI))])
1293    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1294                    (ashiftrt:SI (match_dup 2)
1295                                 (const_int 24)))
1296               (clobber (scratch:SI))])]
1297   "TARGET_POWER"
1298   "
1299 { operands[1] = gen_lowpart (SImode, operands[1]);
1300   operands[2] = gen_reg_rtx (SImode); }")
1301
1302 (define_expand "extendqisi2_no_power"
1303   [(set (match_dup 2)
1304         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1305                    (const_int 24)))
1306    (set (match_operand:SI 0 "gpc_reg_operand" "")
1307         (ashiftrt:SI (match_dup 2)
1308                      (const_int 24)))]
1309   "! TARGET_POWER && ! TARGET_POWERPC"
1310   "
1311 { operands[1] = gen_lowpart (SImode, operands[1]);
1312   operands[2] = gen_reg_rtx (SImode); }")
1313
1314 (define_expand "zero_extendqihi2"
1315   [(set (match_operand:HI 0 "gpc_reg_operand" "")
1316         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1317   ""
1318   "")
1319
1320 (define_insn ""
1321   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1322         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1323   ""
1324   "@
1325    lbz%U1%X1 %0,%1
1326    {rlinm|rlwinm} %0,%1,0,0xff"
1327   [(set_attr "type" "load,*")])
1328
1329 (define_insn ""
1330   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1331         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1332                     (const_int 0)))
1333    (clobber (match_scratch:HI 2 "=r,r"))]
1334   ""
1335   "@
1336    {andil.|andi.} %2,%1,0xff
1337    #"
1338   [(set_attr "type" "compare")
1339    (set_attr "length" "4,8")])
1340
1341 (define_split
1342   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1343         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1344                     (const_int 0)))
1345    (clobber (match_scratch:HI 2 ""))]
1346   "reload_completed"
1347   [(set (match_dup 2)
1348         (zero_extend:HI (match_dup 1)))
1349    (set (match_dup 0)
1350         (compare:CC (match_dup 2)
1351                     (const_int 0)))]
1352   "")
1353
1354 (define_insn ""
1355   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1356         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1357                     (const_int 0)))
1358    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1359         (zero_extend:HI (match_dup 1)))]
1360   ""
1361   "@
1362    {andil.|andi.} %0,%1,0xff
1363    #"
1364   [(set_attr "type" "compare")
1365    (set_attr "length" "4,8")])
1366
1367 (define_split
1368   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1369         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1370                     (const_int 0)))
1371    (set (match_operand:HI 0 "gpc_reg_operand" "")
1372         (zero_extend:HI (match_dup 1)))]
1373   "reload_completed"
1374   [(set (match_dup 0)
1375         (zero_extend:HI (match_dup 1)))
1376    (set (match_dup 2)
1377         (compare:CC (match_dup 0)
1378                     (const_int 0)))]
1379   "")
1380
1381 (define_expand "extendqihi2"
1382   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
1383    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1384   ""
1385   "
1386 {
1387   if (TARGET_POWERPC)
1388     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
1389   else if (TARGET_POWER)
1390     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
1391   else
1392     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
1393   DONE;
1394 }")
1395
1396 (define_insn "extendqihi2_ppc"
1397   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
1398         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1399   "TARGET_POWERPC"
1400   "extsb %0,%1")
1401
1402 (define_insn ""
1403   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1404         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1405                     (const_int 0)))
1406    (clobber (match_scratch:HI 2 "=r,r"))]
1407   "TARGET_POWERPC"
1408   "@
1409    extsb. %2,%1
1410    #"
1411   [(set_attr "type" "compare")
1412    (set_attr "length" "4,8")])
1413
1414 (define_split
1415   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1416         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1417                     (const_int 0)))
1418    (clobber (match_scratch:HI 2 ""))]
1419   "TARGET_POWERPC && reload_completed"
1420   [(set (match_dup 2)
1421         (sign_extend:HI (match_dup 1)))
1422    (set (match_dup 0)
1423         (compare:CC (match_dup 2)
1424                     (const_int 0)))]
1425   "")
1426
1427 (define_insn ""
1428   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1429         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1430                     (const_int 0)))
1431    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1432         (sign_extend:HI (match_dup 1)))]
1433   "TARGET_POWERPC"
1434   "@
1435    extsb. %0,%1
1436    #"
1437   [(set_attr "type" "compare")
1438    (set_attr "length" "4,8")])
1439
1440 (define_split
1441   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1442         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1443                     (const_int 0)))
1444    (set (match_operand:HI 0 "gpc_reg_operand" "")
1445         (sign_extend:HI (match_dup 1)))]
1446   "TARGET_POWERPC && reload_completed"
1447   [(set (match_dup 0)
1448         (sign_extend:HI (match_dup 1)))
1449    (set (match_dup 2)
1450         (compare:CC (match_dup 0)
1451                     (const_int 0)))]
1452   "")
1453
1454 (define_expand "extendqihi2_power"
1455   [(parallel [(set (match_dup 2)
1456                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1457                               (const_int 24)))
1458               (clobber (scratch:SI))])
1459    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
1460                    (ashiftrt:SI (match_dup 2)
1461                                 (const_int 24)))
1462               (clobber (scratch:SI))])]
1463   "TARGET_POWER"
1464   "
1465 { operands[0] = gen_lowpart (SImode, operands[0]);
1466   operands[1] = gen_lowpart (SImode, operands[1]);
1467   operands[2] = gen_reg_rtx (SImode); }")
1468
1469 (define_expand "extendqihi2_no_power"
1470   [(set (match_dup 2)
1471         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1472                    (const_int 24)))
1473    (set (match_operand:HI 0 "gpc_reg_operand" "")
1474         (ashiftrt:SI (match_dup 2)
1475                      (const_int 24)))]
1476   "! TARGET_POWER && ! TARGET_POWERPC"
1477   "
1478 { operands[0] = gen_lowpart (SImode, operands[0]);
1479   operands[1] = gen_lowpart (SImode, operands[1]);
1480   operands[2] = gen_reg_rtx (SImode); }")
1481
1482 (define_expand "zero_extendhisi2"
1483   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1484         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1485   ""
1486   "")
1487
1488 (define_insn ""
1489   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1490         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1491   ""
1492   "@
1493    lhz%U1%X1 %0,%1
1494    {rlinm|rlwinm} %0,%1,0,0xffff"
1495   [(set_attr "type" "load,*")])
1496
1497 (define_insn ""
1498   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1499         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1500                     (const_int 0)))
1501    (clobber (match_scratch:SI 2 "=r,r"))]
1502   ""
1503   "@
1504    {andil.|andi.} %2,%1,0xffff
1505    #"
1506   [(set_attr "type" "compare")
1507    (set_attr "length" "4,8")])
1508
1509 (define_split
1510   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1511         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1512                     (const_int 0)))
1513    (clobber (match_scratch:SI 2 ""))]
1514   "reload_completed"
1515   [(set (match_dup 2)
1516         (zero_extend:SI (match_dup 1)))
1517    (set (match_dup 0)
1518         (compare:CC (match_dup 2)
1519                     (const_int 0)))]
1520   "")
1521
1522 (define_insn ""
1523   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1524         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1525                     (const_int 0)))
1526    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1527         (zero_extend:SI (match_dup 1)))]
1528   ""
1529   "@
1530    {andil.|andi.} %0,%1,0xffff
1531    #"
1532   [(set_attr "type" "compare")
1533    (set_attr "length" "4,8")])
1534
1535 (define_split
1536   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1537         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1538                     (const_int 0)))
1539    (set (match_operand:SI 0 "gpc_reg_operand" "")
1540         (zero_extend:SI (match_dup 1)))]
1541   "reload_completed"
1542   [(set (match_dup 0)
1543         (zero_extend:SI (match_dup 1)))
1544    (set (match_dup 2)
1545         (compare:CC (match_dup 0)
1546                     (const_int 0)))]
1547   "")
1548
1549 (define_expand "extendhisi2"
1550   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1551         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1552   ""
1553   "")
1554
1555 (define_insn ""
1556   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1557         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1558   ""
1559   "@
1560    lha%U1%X1 %0,%1
1561    {exts|extsh} %0,%1"
1562   [(set_attr "type" "load,*")])
1563
1564 (define_insn ""
1565   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1566         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1567                     (const_int 0)))
1568    (clobber (match_scratch:SI 2 "=r,r"))]
1569   ""
1570   "@
1571    {exts.|extsh.} %2,%1
1572    #"
1573   [(set_attr "type" "compare")
1574    (set_attr "length" "4,8")])
1575
1576 (define_split
1577   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1578         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1579                     (const_int 0)))
1580    (clobber (match_scratch:SI 2 ""))]
1581   "reload_completed"
1582   [(set (match_dup 2)
1583         (sign_extend:SI (match_dup 1)))
1584    (set (match_dup 0)
1585         (compare:CC (match_dup 2)
1586                     (const_int 0)))]
1587   "")
1588
1589 (define_insn ""
1590   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1591         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1592                     (const_int 0)))
1593    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1594         (sign_extend:SI (match_dup 1)))]
1595   ""
1596   "@
1597    {exts.|extsh.} %0,%1
1598    #"
1599   [(set_attr "type" "compare")
1600    (set_attr "length" "4,8")])
1601 \f
1602 (define_split
1603   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1604         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1605                     (const_int 0)))
1606    (set (match_operand:SI 0 "gpc_reg_operand" "")
1607         (sign_extend:SI (match_dup 1)))]
1608   "reload_completed"
1609   [(set (match_dup 0)
1610         (sign_extend:SI (match_dup 1)))
1611    (set (match_dup 2)
1612         (compare:CC (match_dup 0)
1613                     (const_int 0)))]
1614   "")
1615
1616 ;; Fixed-point arithmetic insns.
1617
1618 ;; Discourage ai/addic because of carry but provide it in an alternative
1619 ;; allowing register zero as source.
1620 (define_expand "addsi3"
1621   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1622         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1623                  (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1624   ""
1625   "
1626 {
1627   if (GET_CODE (operands[2]) == CONST_INT
1628                 && ! add_operand (operands[2], SImode))
1629     {
1630       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1631                  ? operands[0] : gen_reg_rtx (SImode));
1632
1633       HOST_WIDE_INT val = INTVAL (operands[2]);
1634       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1635       HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1636
1637       /* The ordering here is important for the prolog expander.
1638          When space is allocated from the stack, adding 'low' first may
1639          produce a temporary deallocation (which would be bad).  */
1640       emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
1641       emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
1642       DONE;
1643     }
1644 }")
1645
1646 (define_insn "*addsi3_internal1"
1647   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
1648         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
1649                  (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1650   ""
1651   "@
1652    {cax|add} %0,%1,%2
1653    {cal %0,%2(%1)|addi %0,%1,%2}
1654    {ai|addic} %0,%1,%2
1655    {cau|addis} %0,%1,%v2"
1656   [(set_attr "length" "4,4,4,4")])
1657
1658 (define_insn "addsi3_high"
1659   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1660         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1661                  (high:SI (match_operand 2 "" ""))))]
1662   "TARGET_MACHO && !TARGET_64BIT"
1663   "{cau|addis} %0,%1,ha16(%2)"
1664   [(set_attr "length" "4")])
1665
1666 (define_insn "*addsi3_internal2"
1667   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1668         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1669                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1670                     (const_int 0)))
1671    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1672   "! TARGET_POWERPC64"
1673   "@
1674    {cax.|add.} %3,%1,%2
1675    {ai.|addic.} %3,%1,%2
1676    #
1677    #"
1678   [(set_attr "type" "compare")
1679    (set_attr "length" "4,4,8,8")])
1680
1681 (define_split
1682   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1683         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1684                              (match_operand:SI 2 "reg_or_short_operand" ""))
1685                     (const_int 0)))
1686    (clobber (match_scratch:SI 3 ""))]
1687   "! TARGET_POWERPC64 && reload_completed"
1688   [(set (match_dup 3)
1689         (plus:SI (match_dup 1)
1690                  (match_dup 2)))
1691    (set (match_dup 0)
1692         (compare:CC (match_dup 3)
1693                     (const_int 0)))]
1694   "")
1695
1696 (define_insn "*addsi3_internal3"
1697   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1698         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1699                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1700                     (const_int 0)))
1701    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1702         (plus:SI (match_dup 1)
1703                  (match_dup 2)))]
1704   "! TARGET_POWERPC64"
1705   "@
1706    {cax.|add.} %0,%1,%2
1707    {ai.|addic.} %0,%1,%2
1708    #
1709    #"
1710   [(set_attr "type" "compare")
1711    (set_attr "length" "4,4,8,8")])
1712
1713 (define_split
1714   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1715         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1716                              (match_operand:SI 2 "reg_or_short_operand" ""))
1717                     (const_int 0)))
1718    (set (match_operand:SI 0 "gpc_reg_operand" "")
1719         (plus:SI (match_dup 1) (match_dup 2)))]
1720   "! TARGET_POWERPC64 && reload_completed"
1721   [(set (match_dup 0)
1722         (plus:SI (match_dup 1)
1723                  (match_dup 2)))
1724    (set (match_dup 3)
1725         (compare:CC (match_dup 0)
1726                     (const_int 0)))]
1727   "")
1728
1729 ;; Split an add that we can't do in one insn into two insns, each of which
1730 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
1731 ;; add should be last in case the result gets used in an address.
1732
1733 (define_split
1734   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1735         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1736                  (match_operand:SI 2 "non_add_cint_operand" "")))]
1737   ""
1738   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1739    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1740 "
1741 {
1742   HOST_WIDE_INT val = INTVAL (operands[2]);
1743   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1744   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1745
1746   operands[3] = GEN_INT (rest);
1747   operands[4] = GEN_INT (low);
1748 }")
1749
1750 (define_insn "one_cmplsi2"
1751   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1752         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1753   ""
1754   "nor %0,%1,%1")
1755
1756 (define_insn ""
1757   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1758         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1759                     (const_int 0)))
1760    (clobber (match_scratch:SI 2 "=r,r"))]
1761   "! TARGET_POWERPC64"
1762   "@
1763    nor. %2,%1,%1
1764    #"
1765   [(set_attr "type" "compare")
1766    (set_attr "length" "4,8")])
1767
1768 (define_split
1769   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1770         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1771                     (const_int 0)))
1772    (clobber (match_scratch:SI 2 ""))]
1773   "! TARGET_POWERPC64 && reload_completed"
1774   [(set (match_dup 2)
1775         (not:SI (match_dup 1)))
1776    (set (match_dup 0)
1777         (compare:CC (match_dup 2)
1778                     (const_int 0)))]
1779   "")
1780
1781 (define_insn ""
1782   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1783         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1784                     (const_int 0)))
1785    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1786         (not:SI (match_dup 1)))]
1787   "! TARGET_POWERPC64"
1788   "@
1789    nor. %0,%1,%1
1790    #"
1791   [(set_attr "type" "compare")
1792    (set_attr "length" "4,8")])
1793
1794 (define_split
1795   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1796         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1797                     (const_int 0)))
1798    (set (match_operand:SI 0 "gpc_reg_operand" "")
1799         (not:SI (match_dup 1)))]
1800   "! TARGET_POWERPC64 && reload_completed"
1801   [(set (match_dup 0)
1802         (not:SI (match_dup 1)))
1803    (set (match_dup 2)
1804         (compare:CC (match_dup 0)
1805                     (const_int 0)))]
1806   "")
1807
1808 (define_insn ""
1809   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1810         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1811                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
1812   "! TARGET_POWERPC"
1813   "{sf%I1|subf%I1c} %0,%2,%1")
1814
1815 (define_insn ""
1816   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1817         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1818                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1819   "TARGET_POWERPC"
1820   "@
1821    subf %0,%2,%1
1822    subfic %0,%2,%1")
1823
1824 (define_insn ""
1825   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1826         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1827                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1828                     (const_int 0)))
1829    (clobber (match_scratch:SI 3 "=r,r"))]
1830   "! TARGET_POWERPC"
1831   "@
1832    {sf.|subfc.} %3,%2,%1
1833    #"
1834   [(set_attr "type" "compare")
1835    (set_attr "length" "4,8")])
1836
1837 (define_insn ""
1838   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1839         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1840                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1841                     (const_int 0)))
1842    (clobber (match_scratch:SI 3 "=r,r"))]
1843   "TARGET_POWERPC && ! TARGET_POWERPC64"
1844   "@
1845    subf. %3,%2,%1
1846    #"
1847   [(set_attr "type" "compare")
1848    (set_attr "length" "4,8")])
1849
1850 (define_split
1851   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1852         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1853                               (match_operand:SI 2 "gpc_reg_operand" ""))
1854                     (const_int 0)))
1855    (clobber (match_scratch:SI 3 ""))]
1856   "! TARGET_POWERPC64 && reload_completed"
1857   [(set (match_dup 3)
1858         (minus:SI (match_dup 1)
1859                   (match_dup 2)))
1860    (set (match_dup 0)
1861         (compare:CC (match_dup 3)
1862                     (const_int 0)))]
1863   "")
1864
1865 (define_insn ""
1866   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1867         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1868                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1869                     (const_int 0)))
1870    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1871         (minus:SI (match_dup 1) (match_dup 2)))]
1872   "! TARGET_POWERPC"
1873   "@
1874    {sf.|subfc.} %0,%2,%1
1875    #"
1876   [(set_attr "type" "compare")
1877    (set_attr "length" "4,8")])
1878
1879 (define_insn ""
1880   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1881         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1882                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1883                     (const_int 0)))
1884    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1885         (minus:SI (match_dup 1)
1886                   (match_dup 2)))]
1887   "TARGET_POWERPC && ! TARGET_POWERPC64"
1888   "@
1889    subf. %0,%2,%1
1890    #"
1891   [(set_attr "type" "compare")
1892    (set_attr "length" "4,8")])
1893
1894 (define_split
1895   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1896         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1897                               (match_operand:SI 2 "gpc_reg_operand" ""))
1898                     (const_int 0)))
1899    (set (match_operand:SI 0 "gpc_reg_operand" "")
1900         (minus:SI (match_dup 1)
1901                   (match_dup 2)))]
1902   "! TARGET_POWERPC64 && reload_completed"
1903   [(set (match_dup 0)
1904         (minus:SI (match_dup 1)
1905                   (match_dup 2)))
1906    (set (match_dup 3)
1907         (compare:CC (match_dup 0)
1908                     (const_int 0)))]
1909   "")
1910
1911 (define_expand "subsi3"
1912   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1913         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
1914                   (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1915   ""
1916   "
1917 {
1918   if (GET_CODE (operands[2]) == CONST_INT)
1919     {
1920       emit_insn (gen_addsi3 (operands[0], operands[1],
1921                              negate_rtx (SImode, operands[2])));
1922       DONE;
1923     }
1924 }")
1925
1926 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
1927 ;; instruction and some auxiliary computations.  Then we just have a single
1928 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
1929 ;; combine.
1930
1931 (define_expand "sminsi3"
1932   [(set (match_dup 3)
1933         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1934                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1935                          (const_int 0)
1936                          (minus:SI (match_dup 2) (match_dup 1))))
1937    (set (match_operand:SI 0 "gpc_reg_operand" "")
1938         (minus:SI (match_dup 2) (match_dup 3)))]
1939   "TARGET_POWER"
1940   "
1941 { operands[3] = gen_reg_rtx (SImode); }")
1942
1943 (define_split
1944   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1945         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
1946                  (match_operand:SI 2 "reg_or_short_operand" "")))
1947    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1948   "TARGET_POWER"
1949   [(set (match_dup 3)
1950         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1951                          (const_int 0)
1952                          (minus:SI (match_dup 2) (match_dup 1))))
1953    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
1954   "")
1955
1956 (define_expand "smaxsi3"
1957   [(set (match_dup 3)
1958         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
1959                                 (match_operand:SI 2 "reg_or_short_operand" ""))
1960                          (const_int 0)
1961                          (minus:SI (match_dup 2) (match_dup 1))))
1962    (set (match_operand:SI 0 "gpc_reg_operand" "")
1963         (plus:SI (match_dup 3) (match_dup 1)))]
1964   "TARGET_POWER"
1965   "
1966 { operands[3] = gen_reg_rtx (SImode); }")
1967
1968 (define_split
1969   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1970         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
1971                  (match_operand:SI 2 "reg_or_short_operand" "")))
1972    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
1973   "TARGET_POWER"
1974   [(set (match_dup 3)
1975         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
1976                          (const_int 0)
1977                          (minus:SI (match_dup 2) (match_dup 1))))
1978    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
1979   "")
1980
1981 (define_expand "uminsi3"
1982   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
1983                               (match_dup 5)))
1984    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
1985                               (match_dup 5)))
1986    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
1987                                        (const_int 0)
1988                                        (minus:SI (match_dup 4) (match_dup 3))))
1989    (set (match_operand:SI 0 "gpc_reg_operand" "")
1990         (minus:SI (match_dup 2) (match_dup 3)))]
1991   "TARGET_POWER"
1992   "
1993 {
1994   operands[3] = gen_reg_rtx (SImode);
1995   operands[4] = gen_reg_rtx (SImode);
1996   operands[5] = GEN_INT (-2147483647 - 1);
1997 }")
1998
1999 (define_expand "umaxsi3"
2000   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2001                               (match_dup 5)))
2002    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
2003                               (match_dup 5)))
2004    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2005                                        (const_int 0)
2006                                        (minus:SI (match_dup 4) (match_dup 3))))
2007    (set (match_operand:SI 0 "gpc_reg_operand" "")
2008         (plus:SI (match_dup 3) (match_dup 1)))]
2009   "TARGET_POWER"
2010   "
2011 {
2012   operands[3] = gen_reg_rtx (SImode);
2013   operands[4] = gen_reg_rtx (SImode);
2014   operands[5] = GEN_INT (-2147483647 - 1);
2015 }")
2016
2017 (define_insn ""
2018   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2019         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
2020                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
2021                          (const_int 0)
2022                          (minus:SI (match_dup 2) (match_dup 1))))]
2023   "TARGET_POWER"
2024   "doz%I2 %0,%1,%2")
2025
2026 (define_insn ""
2027   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2028         (compare:CC
2029          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2030                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2031                           (const_int 0)
2032                           (minus:SI (match_dup 2) (match_dup 1)))
2033          (const_int 0)))
2034    (clobber (match_scratch:SI 3 "=r,r"))]
2035   "TARGET_POWER"
2036   "@
2037    doz%I2. %3,%1,%2
2038    #"
2039   [(set_attr "type" "delayed_compare")
2040    (set_attr "length" "4,8")])
2041
2042 (define_split
2043   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2044         (compare:CC
2045          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2046                               (match_operand:SI 2 "reg_or_short_operand" ""))
2047                           (const_int 0)
2048                           (minus:SI (match_dup 2) (match_dup 1)))
2049          (const_int 0)))
2050    (clobber (match_scratch:SI 3 ""))]
2051   "TARGET_POWER && reload_completed"
2052   [(set (match_dup 3)
2053         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2054                           (const_int 0)
2055                           (minus:SI (match_dup 2) (match_dup 1))))
2056    (set (match_dup 0)
2057         (compare:CC (match_dup 3)
2058                     (const_int 0)))]
2059   "")
2060
2061 (define_insn ""
2062   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2063         (compare:CC
2064          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2065                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2066                           (const_int 0)
2067                           (minus:SI (match_dup 2) (match_dup 1)))
2068          (const_int 0)))
2069    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2070         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2071                          (const_int 0)
2072                          (minus:SI (match_dup 2) (match_dup 1))))]
2073   "TARGET_POWER"
2074   "@
2075    doz%I2. %0,%1,%2
2076    #"
2077   [(set_attr "type" "delayed_compare")
2078    (set_attr "length" "4,8")])
2079
2080 (define_split
2081   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2082         (compare:CC
2083          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2084                               (match_operand:SI 2 "reg_or_short_operand" ""))
2085                           (const_int 0)
2086                           (minus:SI (match_dup 2) (match_dup 1)))
2087          (const_int 0)))
2088    (set (match_operand:SI 0 "gpc_reg_operand" "")
2089         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2090                          (const_int 0)
2091                          (minus:SI (match_dup 2) (match_dup 1))))]
2092   "TARGET_POWER && reload_completed"
2093   [(set (match_dup 0)
2094         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2095                          (const_int 0)
2096                          (minus:SI (match_dup 2) (match_dup 1))))
2097    (set (match_dup 3)
2098         (compare:CC (match_dup 0)
2099                     (const_int 0)))]
2100   "")
2101
2102 ;; We don't need abs with condition code because such comparisons should
2103 ;; never be done.
2104 (define_expand "abssi2"
2105   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2106         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2107   ""
2108   "
2109 {
2110   if (! TARGET_POWER)
2111     {
2112       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2113       DONE;
2114     }
2115 }")
2116
2117 (define_insn "abssi2_power"
2118   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2119         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2120   "TARGET_POWER"
2121   "abs %0,%1")
2122
2123 (define_insn "abssi2_nopower"
2124   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2125         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2126    (clobber (match_scratch:SI 2 "=&r,&r"))]
2127   "! TARGET_POWER"
2128   "*
2129 {
2130   return (TARGET_POWERPC)
2131     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%2,%0\"
2132     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%2,%0\";
2133 }"
2134   [(set_attr "length" "12")])
2135
2136 (define_split
2137   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2138         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
2139    (clobber (match_scratch:SI 2 ""))]
2140   "! TARGET_POWER && reload_completed"
2141   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2142    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2143    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2144   "")
2145
2146 (define_insn "*nabs_power"
2147   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2148         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2149   "TARGET_POWER"
2150   "nabs %0,%1")
2151
2152 (define_insn "*nabs_no_power"
2153   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2154         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2155    (clobber (match_scratch:SI 2 "=&r,&r"))]
2156   "! TARGET_POWER"
2157   "*
2158 {
2159   return (TARGET_POWERPC)
2160     ? \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;subf %0,%0,%2\"
2161     : \"{srai|srawi} %2,%1,31\;xor %0,%2,%1\;{sf|subfc} %0,%0,%2\";
2162 }"
2163   [(set_attr "length" "12")])
2164
2165 (define_split
2166   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2167         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" ""))))
2168    (clobber (match_scratch:SI 2 ""))]
2169   "! TARGET_POWER && reload_completed"
2170   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2171    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2172    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2173   "")
2174
2175 (define_insn "negsi2"
2176   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2177         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2178   ""
2179   "neg %0,%1")
2180
2181 (define_insn ""
2182   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2183         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2184                     (const_int 0)))
2185    (clobber (match_scratch:SI 2 "=r,r"))]
2186   "! TARGET_POWERPC64"
2187   "@
2188    neg. %2,%1
2189    #"
2190   [(set_attr "type" "compare")
2191    (set_attr "length" "4,8")])
2192
2193 (define_split
2194   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2195         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2196                     (const_int 0)))
2197    (clobber (match_scratch:SI 2 ""))]
2198   "! TARGET_POWERPC64 && reload_completed"
2199   [(set (match_dup 2)
2200         (neg:SI (match_dup 1)))
2201    (set (match_dup 0)
2202         (compare:CC (match_dup 2)
2203                     (const_int 0)))]
2204   "")
2205
2206 (define_insn ""
2207   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2208         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2209                     (const_int 0)))
2210    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2211         (neg:SI (match_dup 1)))]
2212   "! TARGET_POWERPC64"
2213   "@
2214    neg. %0,%1
2215    #"
2216   [(set_attr "type" "compare")
2217    (set_attr "length" "4,8")])
2218
2219 (define_split
2220   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2221         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2222                     (const_int 0)))
2223    (set (match_operand:SI 0 "gpc_reg_operand" "")
2224         (neg:SI (match_dup 1)))]
2225   "! TARGET_POWERPC64 && reload_completed"
2226   [(set (match_dup 0)
2227         (neg:SI (match_dup 1)))
2228    (set (match_dup 2)
2229         (compare:CC (match_dup 0)
2230                     (const_int 0)))]
2231   "")
2232
2233 (define_insn "ffssi2"
2234   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
2235         (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2236   ""
2237   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
2238   [(set_attr "length" "16")])
2239
2240 (define_expand "mulsi3"
2241   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2242    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2243    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2244   ""
2245   "
2246 {
2247   if (TARGET_POWER)
2248     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2249   else
2250     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2251   DONE;
2252 }")
2253
2254 (define_insn "mulsi3_mq"
2255   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2256         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2257                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2258    (clobber (match_scratch:SI 3 "=q,q"))]
2259   "TARGET_POWER"
2260   "@
2261    {muls|mullw} %0,%1,%2
2262    {muli|mulli} %0,%1,%2"
2263    [(set (attr "type") 
2264       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2265                 (const_string "imul3")
2266              (match_operand:SI 2 "short_cint_operand" "") 
2267                 (const_string "imul2")]
2268         (const_string "imul")))])
2269
2270 (define_insn "mulsi3_no_mq"
2271   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2272         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2273                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2274   "! TARGET_POWER"
2275   "@
2276    {muls|mullw} %0,%1,%2
2277    {muli|mulli} %0,%1,%2"
2278    [(set (attr "type") 
2279       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2280                 (const_string "imul3")
2281              (match_operand:SI 2 "short_cint_operand" "") 
2282                 (const_string "imul2")]
2283         (const_string "imul")))])
2284
2285 (define_insn ""
2286   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2287         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2288                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2289                     (const_int 0)))
2290    (clobber (match_scratch:SI 3 "=r,r"))
2291    (clobber (match_scratch:SI 4 "=q,q"))]
2292   "TARGET_POWER"
2293   "@
2294    {muls.|mullw.} %3,%1,%2
2295    #"
2296   [(set_attr "type" "delayed_compare")
2297    (set_attr "length" "4,8")])
2298
2299 (define_split
2300   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2301         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2302                              (match_operand:SI 2 "gpc_reg_operand" ""))
2303                     (const_int 0)))
2304    (clobber (match_scratch:SI 3 ""))
2305    (clobber (match_scratch:SI 4 ""))]
2306   "TARGET_POWER && reload_completed"
2307   [(parallel [(set (match_dup 3)
2308         (mult:SI (match_dup 1) (match_dup 2)))
2309    (clobber (match_dup 4))])
2310    (set (match_dup 0)
2311         (compare:CC (match_dup 3)
2312                     (const_int 0)))]
2313   "")
2314
2315 (define_insn ""
2316   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2317         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2318                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2319                     (const_int 0)))
2320    (clobber (match_scratch:SI 3 "=r,r"))]
2321   "! TARGET_POWER"
2322   "@
2323    {muls.|mullw.} %3,%1,%2
2324    #"
2325   [(set_attr "type" "delayed_compare")
2326    (set_attr "length" "4,8")])
2327
2328 (define_split
2329   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2330         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2331                              (match_operand:SI 2 "gpc_reg_operand" ""))
2332                     (const_int 0)))
2333    (clobber (match_scratch:SI 3 ""))]
2334   "! TARGET_POWER && reload_completed"
2335   [(set (match_dup 3)
2336         (mult:SI (match_dup 1) (match_dup 2)))
2337    (set (match_dup 0)
2338         (compare:CC (match_dup 3)
2339                     (const_int 0)))]
2340   "")
2341
2342 (define_insn ""
2343   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2344         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2345                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2346                     (const_int 0)))
2347    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2348         (mult:SI (match_dup 1) (match_dup 2)))
2349    (clobber (match_scratch:SI 4 "=q,q"))]
2350   "TARGET_POWER"
2351   "@
2352    {muls.|mullw.} %0,%1,%2
2353    #"
2354   [(set_attr "type" "delayed_compare")
2355    (set_attr "length" "4,8")])
2356
2357 (define_split
2358   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2359         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2360                              (match_operand:SI 2 "gpc_reg_operand" ""))
2361                     (const_int 0)))
2362    (set (match_operand:SI 0 "gpc_reg_operand" "")
2363         (mult:SI (match_dup 1) (match_dup 2)))
2364    (clobber (match_scratch:SI 4 ""))]
2365   "TARGET_POWER && reload_completed"
2366   [(parallel [(set (match_dup 0)
2367         (mult:SI (match_dup 1) (match_dup 2)))
2368    (clobber (match_dup 4))])
2369    (set (match_dup 3)
2370         (compare:CC (match_dup 0)
2371                     (const_int 0)))]
2372   "")
2373
2374 (define_insn ""
2375   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2376         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2377                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2378                     (const_int 0)))
2379    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2380         (mult:SI (match_dup 1) (match_dup 2)))]
2381   "! TARGET_POWER"
2382   "@
2383    {muls.|mullw.} %0,%1,%2
2384    #"
2385   [(set_attr "type" "delayed_compare")
2386    (set_attr "length" "4,8")])
2387
2388 (define_split
2389   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2390         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2391                              (match_operand:SI 2 "gpc_reg_operand" ""))
2392                     (const_int 0)))
2393    (set (match_operand:SI 0 "gpc_reg_operand" "")
2394         (mult:SI (match_dup 1) (match_dup 2)))]
2395   "! TARGET_POWER && reload_completed"
2396   [(set (match_dup 0)
2397         (mult:SI (match_dup 1) (match_dup 2)))
2398    (set (match_dup 3)
2399         (compare:CC (match_dup 0)
2400                     (const_int 0)))]
2401   "")
2402
2403 ;; Operand 1 is divided by operand 2; quotient goes to operand
2404 ;; 0 and remainder to operand 3.
2405 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2406
2407 (define_expand "divmodsi4"
2408   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2409                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2410                            (match_operand:SI 2 "gpc_reg_operand" "")))
2411               (set (match_operand:SI 3 "gpc_reg_operand" "")
2412                    (mod:SI (match_dup 1) (match_dup 2)))])]
2413   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2414   "
2415 {
2416   if (! TARGET_POWER && ! TARGET_POWERPC)
2417     {
2418       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2419       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2420       emit_insn (gen_divss_call ());
2421       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2422       emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2423       DONE;
2424     }
2425 }")
2426
2427 (define_insn ""
2428   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2429         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2430                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2431    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
2432         (mod:SI (match_dup 1) (match_dup 2)))]
2433   "TARGET_POWER"
2434   "divs %0,%1,%2"
2435   [(set_attr "type" "idiv")])
2436
2437 (define_expand "udivsi3"
2438   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2439         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2440                  (match_operand:SI 2 "gpc_reg_operand" "")))]
2441   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2442   "
2443 {
2444   if (! TARGET_POWER && ! TARGET_POWERPC)
2445     {
2446       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2447       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2448       emit_insn (gen_quous_call ());
2449       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2450       DONE;
2451     }
2452   else if (TARGET_POWER)
2453     {
2454       emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2455       DONE;
2456     }
2457 }")
2458
2459 (define_insn "udivsi3_mq"
2460   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2461         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2462                  (match_operand:SI 2 "gpc_reg_operand" "r")))
2463    (clobber (match_scratch:SI 3 "=q"))]
2464   "TARGET_POWERPC && TARGET_POWER"
2465   "divwu %0,%1,%2"
2466   [(set_attr "type" "idiv")])
2467
2468 (define_insn "*udivsi3_no_mq"
2469   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2470         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2471                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
2472   "TARGET_POWERPC && ! TARGET_POWER"
2473   "divwu %0,%1,%2"
2474   [(set_attr "type" "idiv")])
2475
2476 ;; For powers of two we can do srai/aze for divide and then adjust for
2477 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2478 ;; used; for PowerPC, force operands into register and do a normal divide;
2479 ;; for AIX common-mode, use quoss call on register operands.
2480 (define_expand "divsi3"
2481   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2482         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2483                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
2484   ""
2485   "
2486 {
2487   if (GET_CODE (operands[2]) == CONST_INT
2488       && INTVAL (operands[2]) > 0
2489       && exact_log2 (INTVAL (operands[2])) >= 0)
2490     ;
2491   else if (TARGET_POWERPC)
2492     {
2493       operands[2] = force_reg (SImode, operands[2]);
2494       if (TARGET_POWER)
2495         {
2496           emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2497           DONE;
2498         }
2499     }
2500   else if (TARGET_POWER)
2501     FAIL;
2502   else
2503     {
2504       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2505       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2506       emit_insn (gen_quoss_call ());
2507       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2508       DONE;
2509     }
2510 }")
2511
2512 (define_insn "divsi3_mq"
2513   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2514         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2515                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2516    (clobber (match_scratch:SI 3 "=q"))]
2517   "TARGET_POWERPC && TARGET_POWER"
2518   "divw %0,%1,%2"
2519   [(set_attr "type" "idiv")])
2520
2521 (define_insn "*divsi3_no_mq"
2522   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2523         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2524                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
2525   "TARGET_POWERPC && ! TARGET_POWER"
2526   "divw %0,%1,%2"
2527   [(set_attr "type" "idiv")])
2528
2529 (define_expand "modsi3"
2530   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2531    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2532    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2533   ""
2534   "
2535 {
2536   int i;
2537   rtx temp1;
2538   rtx temp2;
2539
2540   if (GET_CODE (operands[2]) != CONST_INT
2541       || INTVAL (operands[2]) <= 0
2542       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2543     FAIL;
2544
2545   temp1 = gen_reg_rtx (SImode);
2546   temp2 = gen_reg_rtx (SImode);
2547
2548   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
2549   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
2550   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
2551   DONE;
2552 }")
2553
2554 (define_insn ""
2555   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2556         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2557                 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
2558   ""
2559   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
2560   [(set_attr "length" "8")])
2561
2562 (define_insn ""
2563   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2564         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2565                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2566                     (const_int 0)))
2567    (clobber (match_scratch:SI 3 "=r,r"))]
2568   ""
2569   "@
2570    {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
2571    #"
2572   [(set_attr "type" "compare")
2573    (set_attr "length" "8,12")])
2574
2575 (define_split
2576   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2577         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2578                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2579                     (const_int 0)))
2580    (clobber (match_scratch:SI 3 ""))]
2581   "reload_completed"
2582   [(set (match_dup 3)
2583         (div:SI (match_dup 1) (match_dup 2)))
2584    (set (match_dup 0)
2585         (compare:CC (match_dup 3)
2586                     (const_int 0)))]
2587   "")
2588
2589 (define_insn ""
2590   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2591         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2592                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2593                     (const_int 0)))
2594    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2595         (div:SI (match_dup 1) (match_dup 2)))]
2596   ""
2597   "@
2598    {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2599    #"
2600   [(set_attr "type" "compare")
2601    (set_attr "length" "8,12")])
2602
2603 (define_split
2604   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2605         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2606                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2607                     (const_int 0)))
2608    (set (match_operand:SI 0 "gpc_reg_operand" "")
2609         (div:SI (match_dup 1) (match_dup 2)))]
2610   "reload_completed"
2611   [(set (match_dup 0)
2612         (div:SI (match_dup 1) (match_dup 2)))
2613    (set (match_dup 3)
2614         (compare:CC (match_dup 0)
2615                     (const_int 0)))]
2616   "")
2617
2618 (define_insn ""
2619   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2620         (udiv:SI
2621          (plus:DI (ashift:DI
2622                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2623                    (const_int 32))
2624                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2625          (match_operand:SI 3 "gpc_reg_operand" "r")))
2626    (set (match_operand:SI 2 "register_operand" "=*q")
2627         (umod:SI
2628          (plus:DI (ashift:DI
2629                    (zero_extend:DI (match_dup 1)) (const_int 32))
2630                   (zero_extend:DI (match_dup 4)))
2631          (match_dup 3)))]
2632   "TARGET_POWER"
2633   "div %0,%1,%3"
2634   [(set_attr "type" "idiv")])
2635
2636 ;; To do unsigned divide we handle the cases of the divisor looking like a
2637 ;; negative number.  If it is a constant that is less than 2**31, we don't
2638 ;; have to worry about the branches.  So make a few subroutines here.
2639 ;;
2640 ;; First comes the normal case.
2641 (define_expand "udivmodsi4_normal"
2642   [(set (match_dup 4) (const_int 0))
2643    (parallel [(set (match_operand:SI 0 "" "")
2644                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2645                                                 (const_int 32))
2646                                      (zero_extend:DI (match_operand:SI 1 "" "")))
2647                             (match_operand:SI 2 "" "")))
2648               (set (match_operand:SI 3 "" "")
2649                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2650                                                 (const_int 32))
2651                                      (zero_extend:DI (match_dup 1)))
2652                             (match_dup 2)))])]
2653   "TARGET_POWER"
2654   "
2655 { operands[4] = gen_reg_rtx (SImode); }")
2656
2657 ;; This handles the branches.
2658 (define_expand "udivmodsi4_tests"
2659   [(set (match_operand:SI 0 "" "") (const_int 0))
2660    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2661    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2662    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2663                            (label_ref (match_operand:SI 4 "" "")) (pc)))
2664    (set (match_dup 0) (const_int 1))
2665    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2666    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2667    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2668                            (label_ref (match_dup 4)) (pc)))]
2669   "TARGET_POWER"
2670   "
2671 { operands[5] = gen_reg_rtx (CCUNSmode);
2672   operands[6] = gen_reg_rtx (CCmode);
2673 }")
2674
2675 (define_expand "udivmodsi4"
2676   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2677                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2678                             (match_operand:SI 2 "reg_or_cint_operand" "")))
2679               (set (match_operand:SI 3 "gpc_reg_operand" "")
2680                    (umod:SI (match_dup 1) (match_dup 2)))])]
2681   ""
2682   "
2683 {
2684   rtx label = 0;
2685
2686   if (! TARGET_POWER)
2687     {
2688       if (! TARGET_POWERPC)
2689         {
2690           emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2691           emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2692           emit_insn (gen_divus_call ());
2693           emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2694           emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2695           DONE;
2696         }
2697       else
2698         FAIL;
2699     }
2700
2701   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2702     {
2703       operands[2] = force_reg (SImode, operands[2]);
2704       label = gen_label_rtx ();
2705       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2706                                   operands[3], label));
2707     }
2708   else
2709     operands[2] = force_reg (SImode, operands[2]);
2710
2711   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2712                                operands[3]));
2713   if (label)
2714     emit_label (label);
2715
2716   DONE;
2717 }")
2718
2719 ;; AIX architecture-independent common-mode multiply (DImode),
2720 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
2721 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2722 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2723 ;; assumed unused if generating common-mode, so ignore.
2724 (define_insn "mulh_call"
2725   [(set (reg:SI 3)
2726         (truncate:SI
2727          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2728                                (sign_extend:DI (reg:SI 4)))
2729                       (const_int 32))))
2730    (clobber (match_scratch:SI 0 "=l"))]
2731   "! TARGET_POWER && ! TARGET_POWERPC"
2732   "bla __mulh"
2733   [(set_attr "type" "imul")])
2734
2735 (define_insn "mull_call"
2736   [(set (reg:DI 3)
2737         (mult:DI (sign_extend:DI (reg:SI 3))
2738                  (sign_extend:DI (reg:SI 4))))
2739    (clobber (match_scratch:SI 0 "=l"))
2740    (clobber (reg:SI 0))]
2741   "! TARGET_POWER && ! TARGET_POWERPC"
2742   "bla __mull"
2743   [(set_attr "type" "imul")])
2744
2745 (define_insn "divss_call"
2746   [(set (reg:SI 3)
2747         (div:SI (reg:SI 3) (reg:SI 4)))
2748    (set (reg:SI 4)
2749         (mod:SI (reg:SI 3) (reg:SI 4)))
2750    (clobber (match_scratch:SI 0 "=l"))
2751    (clobber (reg:SI 0))]
2752   "! TARGET_POWER && ! TARGET_POWERPC"
2753   "bla __divss"
2754   [(set_attr "type" "idiv")])
2755
2756 (define_insn "divus_call"
2757   [(set (reg:SI 3)
2758         (udiv:SI (reg:SI 3) (reg:SI 4)))
2759    (set (reg:SI 4)
2760         (umod:SI (reg:SI 3) (reg:SI 4)))
2761    (clobber (match_scratch:SI 0 "=l"))
2762    (clobber (reg:SI 0))
2763    (clobber (match_scratch:CC 1 "=x"))
2764    (clobber (reg:CC 69))]
2765   "! TARGET_POWER && ! TARGET_POWERPC"
2766   "bla __divus"
2767   [(set_attr "type" "idiv")])
2768
2769 (define_insn "quoss_call"
2770   [(set (reg:SI 3)
2771         (div:SI (reg:SI 3) (reg:SI 4)))
2772    (clobber (match_scratch:SI 0 "=l"))]
2773   "! TARGET_POWER && ! TARGET_POWERPC"
2774   "bla __quoss"
2775   [(set_attr "type" "idiv")])
2776
2777 (define_insn "quous_call"
2778   [(set (reg:SI 3)
2779         (udiv:SI (reg:SI 3) (reg:SI 4)))
2780    (clobber (match_scratch:SI 0 "=l"))
2781    (clobber (reg:SI 0))
2782    (clobber (match_scratch:CC 1 "=x"))
2783    (clobber (reg:CC 69))]
2784   "! TARGET_POWER && ! TARGET_POWERPC"
2785   "bla __quous"
2786   [(set_attr "type" "idiv")])
2787 \f
2788 ;; Logical instructions
2789 ;; The logical instructions are mostly combined by using match_operator,
2790 ;; but the plain AND insns are somewhat different because there is no
2791 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2792 ;; those rotate-and-mask operations.  Thus, the AND insns come first.
2793
2794 (define_insn "andsi3"
2795   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2796         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2797                 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2798    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2799   ""
2800   "@
2801    and %0,%1,%2
2802    {rlinm|rlwinm} %0,%1,0,%m2,%M2
2803    {andil.|andi.} %0,%1,%b2
2804    {andiu.|andis.} %0,%1,%u2")
2805
2806 ;; Note to set cr's other than cr0 we do the and immediate and then
2807 ;; the test again -- this avoids a mcrf which on the higher end
2808 ;; machines causes an execution serialization
2809
2810 (define_insn "*andsi3_internal2"
2811   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2812         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2813                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2814                     (const_int 0)))
2815    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2816    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2817   "! TARGET_POWERPC64"
2818   "@
2819    and. %3,%1,%2
2820    {andil.|andi.} %3,%1,%b2
2821    {andiu.|andis.} %3,%1,%u2
2822    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2823    #
2824    #
2825    #
2826    #"
2827   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2828    (set_attr "length" "4,4,4,4,8,8,8,8")])
2829
2830 (define_split
2831   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2832         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2833                             (match_operand:SI 2 "and_operand" ""))
2834                     (const_int 0)))
2835    (clobber (match_scratch:SI 3 ""))
2836    (clobber (match_scratch:CC 4 ""))]
2837   "! TARGET_POWERPC64 && reload_completed"
2838   [(parallel [(set (match_dup 3)
2839                    (and:SI (match_dup 1)
2840                            (match_dup 2)))
2841               (clobber (match_dup 4))])
2842    (set (match_dup 0)
2843         (compare:CC (match_dup 3)
2844                     (const_int 0)))]
2845   "")
2846
2847 (define_insn "*andsi3_internal3"
2848   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2849         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2850                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2851                     (const_int 0)))
2852    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2853         (and:SI (match_dup 1)
2854                 (match_dup 2)))
2855    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2856   "! TARGET_POWERPC64"
2857   "@
2858    and. %0,%1,%2
2859    {andil.|andi.} %0,%1,%b2
2860    {andiu.|andis.} %0,%1,%u2
2861    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2862    #
2863    #
2864    #
2865    #"
2866   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2867    (set_attr "length" "4,4,4,4,8,8,8,8")])
2868
2869 (define_split
2870   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2871         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2872                             (match_operand:SI 2 "and_operand" ""))
2873                     (const_int 0)))
2874    (set (match_operand:SI 0 "gpc_reg_operand" "")
2875         (and:SI (match_dup 1)
2876                 (match_dup 2)))
2877    (clobber (match_scratch:CC 4 ""))]
2878   "! TARGET_POWERPC64 && reload_completed"
2879   [(parallel [(set (match_dup 0)
2880                    (and:SI (match_dup 1)
2881                            (match_dup 2)))
2882               (clobber (match_dup 4))])
2883    (set (match_dup 3)
2884         (compare:CC (match_dup 0)
2885                     (const_int 0)))]
2886   "")
2887
2888 (define_expand "iorsi3"
2889   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2890         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2891                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2892   ""
2893   "
2894 {
2895   if (GET_CODE (operands[2]) == CONST_INT
2896       && ! logical_operand (operands[2], SImode))
2897     {
2898       HOST_WIDE_INT value = INTVAL (operands[2]);
2899       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2900                  ? operands[0] : gen_reg_rtx (SImode));
2901
2902       emit_insn (gen_iorsi3 (tmp, operands[1],
2903                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2904       emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2905       DONE;
2906     }
2907 }")
2908
2909 (define_expand "xorsi3"
2910   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2911         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2912                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2913   ""
2914   "
2915 {
2916   if (GET_CODE (operands[2]) == CONST_INT
2917       && ! logical_operand (operands[2], SImode))
2918     {
2919       HOST_WIDE_INT value = INTVAL (operands[2]);
2920       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2921                  ? operands[0] : gen_reg_rtx (SImode));
2922
2923       emit_insn (gen_xorsi3 (tmp, operands[1],
2924                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2925       emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2926       DONE;
2927     }
2928 }")
2929
2930 (define_insn "*boolsi3_internal1"
2931   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
2932         (match_operator:SI 3 "boolean_or_operator"
2933          [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
2934           (match_operand:SI 2 "logical_operand" "r,K,L")]))]
2935   ""
2936   "@
2937    %q3 %0,%1,%2
2938    {%q3il|%q3i} %0,%1,%b2
2939    {%q3iu|%q3is} %0,%1,%u2")
2940
2941 (define_insn "*boolsi3_internal2"
2942   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2943         (compare:CC (match_operator:SI 4 "boolean_or_operator"
2944          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2945           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2946          (const_int 0)))
2947    (clobber (match_scratch:SI 3 "=r,r"))]
2948   "! TARGET_POWERPC64"
2949   "@
2950    %q4. %3,%1,%2
2951    #"
2952   [(set_attr "type" "compare")
2953    (set_attr "length" "4,8")])
2954
2955 (define_split
2956   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2957         (compare:CC (match_operator:SI 4 "boolean_operator"
2958          [(match_operand:SI 1 "gpc_reg_operand" "")
2959           (match_operand:SI 2 "gpc_reg_operand" "")])
2960          (const_int 0)))
2961    (clobber (match_scratch:SI 3 ""))]
2962   "! TARGET_POWERPC64 && reload_completed"
2963   [(set (match_dup 3) (match_dup 4))
2964    (set (match_dup 0)
2965         (compare:CC (match_dup 3)
2966                     (const_int 0)))]
2967   "")
2968
2969 (define_insn "*boolsi3_internal3"
2970   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2971         (compare:CC (match_operator:SI 4 "boolean_operator"
2972          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
2973           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
2974          (const_int 0)))
2975    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2976         (match_dup 4))]
2977   "! TARGET_POWERPC64"
2978   "@
2979    %q4. %0,%1,%2
2980    #"
2981   [(set_attr "type" "compare")
2982    (set_attr "length" "4,8")])
2983
2984 (define_split
2985   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2986         (compare:CC (match_operator:SI 4 "boolean_operator"
2987          [(match_operand:SI 1 "gpc_reg_operand" "")
2988           (match_operand:SI 2 "gpc_reg_operand" "")])
2989          (const_int 0)))
2990    (set (match_operand:SI 0 "gpc_reg_operand" "")
2991         (match_dup 4))]
2992   "! TARGET_POWERPC64 && reload_completed"
2993   [(set (match_dup 0) (match_dup 4))
2994    (set (match_dup 3)
2995         (compare:CC (match_dup 0)
2996                     (const_int 0)))]
2997   "")
2998
2999 ;; Split an logical operation that we can't do in one insn into two insns, 
3000 ;; each of which does one 16-bit part.  This is used by combine.
3001
3002 (define_split
3003   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3004         (match_operator:SI 3 "boolean_or_operator"
3005          [(match_operand:SI 1 "gpc_reg_operand" "")
3006           (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3007   ""
3008   [(set (match_dup 0) (match_dup 4))
3009    (set (match_dup 0) (match_dup 5))]
3010 "
3011 {
3012   rtx i;
3013   i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3014   operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
3015                          operands[1], i);
3016   i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3017   operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
3018                          operands[0], i);
3019 }")
3020
3021 (define_insn "*boolcsi3_internal1"
3022   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3023         (match_operator:SI 3 "boolean_operator"
3024          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3025           (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3026   ""
3027   "%q3 %0,%2,%1")
3028
3029 (define_insn "*boolcsi3_internal2"
3030   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3031         (compare:CC (match_operator:SI 4 "boolean_operator"
3032          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3033           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3034          (const_int 0)))
3035    (clobber (match_scratch:SI 3 "=r,r"))]
3036   "! TARGET_POWERPC64"
3037   "@
3038    %q4. %3,%2,%1
3039    #"
3040   [(set_attr "type" "compare")
3041    (set_attr "length" "4,8")])
3042
3043 (define_split
3044   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3045         (compare:CC (match_operator:SI 4 "boolean_operator"
3046          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3047           (match_operand:SI 2 "gpc_reg_operand" "")])
3048          (const_int 0)))
3049    (clobber (match_scratch:SI 3 ""))]
3050   "! TARGET_POWERPC64 && reload_completed"
3051   [(set (match_dup 3) (match_dup 4))
3052    (set (match_dup 0)
3053         (compare:CC (match_dup 3)
3054                     (const_int 0)))]
3055   "")
3056
3057 (define_insn "*boolcsi3_internal3"
3058   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3059         (compare:CC (match_operator:SI 4 "boolean_operator"
3060          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3061           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3062          (const_int 0)))
3063    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3064         (match_dup 4))]
3065   "! TARGET_POWERPC64"
3066   "@
3067    %q4. %0,%2,%1
3068    #"
3069   [(set_attr "type" "compare")
3070    (set_attr "length" "4,8")])
3071
3072 (define_split
3073   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3074         (compare:CC (match_operator:SI 4 "boolean_operator"
3075          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3076           (match_operand:SI 2 "gpc_reg_operand" "")])
3077          (const_int 0)))
3078    (set (match_operand:SI 0 "gpc_reg_operand" "")
3079         (match_dup 4))]
3080   "! TARGET_POWERPC64 && reload_completed"
3081   [(set (match_dup 0) (match_dup 4))
3082    (set (match_dup 3)
3083         (compare:CC (match_dup 0)
3084                     (const_int 0)))]
3085   "")
3086
3087 (define_insn "*boolccsi3_internal1"
3088   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3089         (match_operator:SI 3 "boolean_operator"
3090          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3091           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3092   ""
3093   "%q3 %0,%1,%2")
3094
3095 (define_insn "*boolccsi3_internal2"
3096   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3097         (compare:CC (match_operator:SI 4 "boolean_operator"
3098          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3099           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3100          (const_int 0)))
3101    (clobber (match_scratch:SI 3 "=r,r"))]
3102   "! TARGET_POWERPC64"
3103   "@
3104    %q4. %3,%1,%2
3105    #"
3106   [(set_attr "type" "compare")
3107    (set_attr "length" "4,8")])
3108
3109 (define_split
3110   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3111         (compare:CC (match_operator:SI 4 "boolean_operator"
3112          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3113           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3114          (const_int 0)))
3115    (clobber (match_scratch:SI 3 ""))]
3116   "! TARGET_POWERPC64 && reload_completed"
3117   [(set (match_dup 3) (match_dup 4))
3118    (set (match_dup 0)
3119         (compare:CC (match_dup 3)
3120                     (const_int 0)))]
3121   "")
3122
3123 (define_insn "*boolccsi3_internal3"
3124   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3125         (compare:CC (match_operator:SI 4 "boolean_operator"
3126          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3127           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3128          (const_int 0)))
3129    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3130         (match_dup 4))]
3131   "! TARGET_POWERPC64"
3132   "@
3133    %q4. %0,%1,%2
3134    #"
3135   [(set_attr "type" "compare")
3136    (set_attr "length" "4,8")])
3137
3138 (define_split
3139   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3140         (compare:CC (match_operator:SI 4 "boolean_operator"
3141          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3142           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3143          (const_int 0)))
3144    (set (match_operand:SI 0 "gpc_reg_operand" "")
3145         (match_dup 4))]
3146   "! TARGET_POWERPC64 && reload_completed"
3147   [(set (match_dup 0) (match_dup 4))
3148    (set (match_dup 3)
3149         (compare:CC (match_dup 0)
3150                     (const_int 0)))]
3151   "")
3152
3153 ;; maskir insn.  We need four forms because things might be in arbitrary
3154 ;; orders.  Don't define forms that only set CR fields because these
3155 ;; would modify an input register.
3156
3157 (define_insn "*maskir_internal1"
3158   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3159         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3160                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3161                 (and:SI (match_dup 2)
3162                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3163   "TARGET_POWER"
3164   "maskir %0,%3,%2")
3165
3166 (define_insn "*maskir_internal2"
3167   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3168         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3169                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3170                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3171                         (match_dup 2))))]
3172   "TARGET_POWER"
3173   "maskir %0,%3,%2")
3174
3175 (define_insn "*maskir_internal3"
3176   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3177         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3178                         (match_operand:SI 3 "gpc_reg_operand" "r"))
3179                 (and:SI (not:SI (match_dup 2))
3180                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3181   "TARGET_POWER"
3182   "maskir %0,%3,%2")
3183
3184 (define_insn "*maskir_internal4"
3185   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3186         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3187                         (match_operand:SI 2 "gpc_reg_operand" "r"))
3188                 (and:SI (not:SI (match_dup 2))
3189                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3190   "TARGET_POWER"
3191   "maskir %0,%3,%2")
3192
3193 (define_insn "*maskir_internal5"
3194   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3195         (compare:CC
3196          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3197                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3198                  (and:SI (match_dup 2)
3199                          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3200          (const_int 0)))
3201    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3202         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3203                 (and:SI (match_dup 2) (match_dup 3))))]
3204   "TARGET_POWER"
3205   "@
3206    maskir. %0,%3,%2
3207    #"
3208   [(set_attr "type" "compare")
3209    (set_attr "length" "4,8")])
3210
3211 (define_split
3212   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3213         (compare:CC
3214          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3215                          (match_operand:SI 1 "gpc_reg_operand" ""))
3216                  (and:SI (match_dup 2)
3217                          (match_operand:SI 3 "gpc_reg_operand" "")))
3218          (const_int 0)))
3219    (set (match_operand:SI 0 "gpc_reg_operand" "")
3220         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3221                 (and:SI (match_dup 2) (match_dup 3))))]
3222   "TARGET_POWER && reload_completed"
3223   [(set (match_dup 0)
3224         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3225                 (and:SI (match_dup 2) (match_dup 3))))
3226    (set (match_dup 4)
3227         (compare:CC (match_dup 0)
3228                     (const_int 0)))]
3229   "")
3230
3231 (define_insn "*maskir_internal6"
3232   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3233         (compare:CC
3234          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3235                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3236                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3237                          (match_dup 2)))
3238          (const_int 0)))
3239    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3240         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3241                 (and:SI (match_dup 3) (match_dup 2))))]
3242   "TARGET_POWER"
3243   "@
3244    maskir. %0,%3,%2
3245    #"
3246   [(set_attr "type" "compare")
3247    (set_attr "length" "4,8")])
3248
3249 (define_split
3250   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3251         (compare:CC
3252          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3253                          (match_operand:SI 1 "gpc_reg_operand" ""))
3254                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3255                          (match_dup 2)))
3256          (const_int 0)))
3257    (set (match_operand:SI 0 "gpc_reg_operand" "")
3258         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3259                 (and:SI (match_dup 3) (match_dup 2))))]
3260   "TARGET_POWER && reload_completed"
3261   [(set (match_dup 0)
3262         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3263                 (and:SI (match_dup 3) (match_dup 2))))
3264    (set (match_dup 4)
3265         (compare:CC (match_dup 0)
3266                     (const_int 0)))]
3267   "")
3268
3269 (define_insn "*maskir_internal7"
3270   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3271         (compare:CC
3272          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3273                          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3274                  (and:SI (not:SI (match_dup 2))
3275                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3276          (const_int 0)))
3277    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3278         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3279                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3280   "TARGET_POWER"
3281   "@
3282    maskir. %0,%3,%2
3283    #"
3284   [(set_attr "type" "compare")
3285    (set_attr "length" "4,8")])
3286
3287 (define_split
3288   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3289         (compare:CC
3290          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3291                          (match_operand:SI 3 "gpc_reg_operand" ""))
3292                  (and:SI (not:SI (match_dup 2))
3293                          (match_operand:SI 1 "gpc_reg_operand" "")))
3294          (const_int 0)))
3295    (set (match_operand:SI 0 "gpc_reg_operand" "")
3296         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3297                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3298   "TARGET_POWER && reload_completed"
3299   [(set (match_dup 0)
3300         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3301                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3302    (set (match_dup 4)
3303         (compare:CC (match_dup 0)
3304                     (const_int 0)))]
3305   "")
3306
3307 (define_insn "*maskir_internal8"
3308   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3309         (compare:CC
3310          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3311                          (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3312                  (and:SI (not:SI (match_dup 2))
3313                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3314          (const_int 0)))
3315    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3316         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3317                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3318   "TARGET_POWER"
3319   "@
3320    maskir. %0,%3,%2
3321    #"
3322   [(set_attr "type" "compare")
3323    (set_attr "length" "4,8")])
3324 \f
3325 (define_split
3326   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3327         (compare:CC
3328          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3329                          (match_operand:SI 2 "gpc_reg_operand" ""))
3330                  (and:SI (not:SI (match_dup 2))
3331                          (match_operand:SI 1 "gpc_reg_operand" "")))
3332          (const_int 0)))
3333    (set (match_operand:SI 0 "gpc_reg_operand" "")
3334         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3335                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3336   "TARGET_POWER && reload_completed"
3337   [(set (match_dup 0)
3338         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3339                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3340    (set (match_dup 4)
3341         (compare:CC (match_dup 0)
3342                     (const_int 0)))]
3343   "")
3344
3345 ;; Rotate and shift insns, in all their variants.  These support shifts,
3346 ;; field inserts and extracts, and various combinations thereof.
3347 (define_expand "insv"
3348   [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3349                        (match_operand:SI 1 "const_int_operand" "")
3350                        (match_operand:SI 2 "const_int_operand" ""))
3351         (match_operand 3 "gpc_reg_operand" ""))]
3352   ""
3353   "
3354 {
3355   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3356      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3357      compiler if the address of the structure is taken later.  */
3358   if (GET_CODE (operands[0]) == SUBREG
3359       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3360     FAIL;
3361
3362   if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3363     emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3364   else
3365     emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3366   DONE;
3367 }")
3368
3369 (define_insn "insvsi"
3370   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3371                          (match_operand:SI 1 "const_int_operand" "i")
3372                          (match_operand:SI 2 "const_int_operand" "i"))
3373         (match_operand:SI 3 "gpc_reg_operand" "r"))]
3374   ""
3375   "*
3376 {
3377   int start = INTVAL (operands[2]) & 31;
3378   int size = INTVAL (operands[1]) & 31;
3379
3380   operands[4] = GEN_INT (32 - start - size);
3381   operands[1] = GEN_INT (start + size - 1);
3382   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3383 }")
3384
3385 (define_insn "*insvsi_internal1"
3386   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3387                          (match_operand:SI 1 "const_int_operand" "i")
3388                          (match_operand:SI 2 "const_int_operand" "i"))
3389         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3390                    (match_operand:SI 4 "const_int_operand" "i")))]
3391   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3392   "*
3393 {
3394   int shift = INTVAL (operands[4]) & 31;
3395   int start = INTVAL (operands[2]) & 31;
3396   int size = INTVAL (operands[1]) & 31;
3397
3398   operands[4] = GEN_INT (shift - start - size);
3399   operands[1] = GEN_INT (start + size - 1);
3400   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3401 }")
3402
3403 (define_insn "*insvsi_internal2"
3404   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3405                          (match_operand:SI 1 "const_int_operand" "i")
3406                          (match_operand:SI 2 "const_int_operand" "i"))
3407         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3408                      (match_operand:SI 4 "const_int_operand" "i")))]
3409   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3410   "*
3411 {
3412   int shift = INTVAL (operands[4]) & 31;
3413   int start = INTVAL (operands[2]) & 31;
3414   int size = INTVAL (operands[1]) & 31;
3415
3416   operands[4] = GEN_INT (32 - shift - start - size);
3417   operands[1] = GEN_INT (start + size - 1);
3418   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3419 }")
3420
3421 (define_insn "*insvsi_internal3"
3422   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3423                          (match_operand:SI 1 "const_int_operand" "i")
3424                          (match_operand:SI 2 "const_int_operand" "i"))
3425         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3426                      (match_operand:SI 4 "const_int_operand" "i")))]
3427   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3428   "*
3429 {
3430   int shift = INTVAL (operands[4]) & 31;
3431   int start = INTVAL (operands[2]) & 31;
3432   int size = INTVAL (operands[1]) & 31;
3433
3434   operands[4] = GEN_INT (32 - shift - start - size);
3435   operands[1] = GEN_INT (start + size - 1);
3436   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3437 }")
3438
3439 (define_insn "*insvsi_internal4"
3440   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3441                          (match_operand:SI 1 "const_int_operand" "i")
3442                          (match_operand:SI 2 "const_int_operand" "i"))
3443         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3444                          (match_operand:SI 4 "const_int_operand" "i")
3445                          (match_operand:SI 5 "const_int_operand" "i")))]
3446   "INTVAL (operands[4]) >= INTVAL (operands[1])"
3447   "*
3448 {
3449   int extract_start = INTVAL (operands[5]) & 31;
3450   int extract_size = INTVAL (operands[4]) & 31;
3451   int insert_start = INTVAL (operands[2]) & 31;
3452   int insert_size = INTVAL (operands[1]) & 31;
3453
3454 /* Align extract field with insert field */
3455   operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3456   operands[1] = GEN_INT (insert_start + insert_size - 1);
3457   return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3458 }")
3459
3460 (define_insn "insvdi"
3461   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3462                          (match_operand:SI 1 "const_int_operand" "i")
3463                          (match_operand:SI 2 "const_int_operand" "i"))
3464         (match_operand:DI 3 "gpc_reg_operand" "r"))]
3465   "TARGET_POWERPC64"
3466   "*
3467 {
3468   int start = INTVAL (operands[2]) & 63;
3469   int size = INTVAL (operands[1]) & 63;
3470
3471   operands[1] = GEN_INT (64 - start - size);
3472   return \"rldimi %0,%3,%H1,%H2\";
3473 }")
3474
3475 (define_expand "extzv"
3476   [(set (match_operand 0 "gpc_reg_operand" "")
3477         (zero_extract (match_operand 1 "gpc_reg_operand" "")
3478                        (match_operand:SI 2 "const_int_operand" "")
3479                        (match_operand:SI 3 "const_int_operand" "")))]
3480   ""
3481   "
3482 {
3483   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3484      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3485      compiler if the address of the structure is taken later.  */
3486   if (GET_CODE (operands[0]) == SUBREG
3487       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3488     FAIL;
3489
3490   if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3491     emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3492   else
3493     emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3494   DONE;
3495 }")
3496
3497 (define_insn "extzvsi"
3498   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3499         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3500                          (match_operand:SI 2 "const_int_operand" "i")
3501                          (match_operand:SI 3 "const_int_operand" "i")))]
3502   ""
3503   "*
3504 {
3505   int start = INTVAL (operands[3]) & 31;
3506   int size = INTVAL (operands[2]) & 31;
3507
3508   if (start + size >= 32)
3509     operands[3] = const0_rtx;
3510   else
3511     operands[3] = GEN_INT (start + size);
3512   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3513 }")
3514
3515 (define_insn "*extzvsi_internal1"
3516   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3517         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3518                          (match_operand:SI 2 "const_int_operand" "i,i")
3519                          (match_operand:SI 3 "const_int_operand" "i,i"))
3520                     (const_int 0)))
3521    (clobber (match_scratch:SI 4 "=r,r"))]
3522   "! TARGET_POWERPC64"
3523   "*
3524 {
3525   int start = INTVAL (operands[3]) & 31;
3526   int size = INTVAL (operands[2]) & 31;
3527
3528   /* Force split for non-cc0 compare.  */
3529   if (which_alternative == 1)
3530      return \"#\";
3531
3532   /* If the bitfield being tested fits in the upper or lower half of a
3533      word, it is possible to use andiu. or andil. to test it.  This is
3534      useful because the condition register set-use delay is smaller for
3535      andi[ul]. than for rlinm.  This doesn't work when the starting bit
3536      position is 0 because the LT and GT bits may be set wrong.  */
3537
3538   if ((start > 0 && start + size <= 16) || start >= 16)
3539     {
3540       operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3541                               - (1 << (16 - (start & 15) - size))));
3542       if (start < 16)
3543         return \"{andiu.|andis.} %4,%1,%3\";
3544       else
3545         return \"{andil.|andi.} %4,%1,%3\";
3546     }
3547
3548   if (start + size >= 32)
3549     operands[3] = const0_rtx;
3550   else
3551     operands[3] = GEN_INT (start + size);
3552   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3553 }"
3554   [(set_attr "type" "compare")
3555    (set_attr "length" "4,8")])
3556
3557 (define_split
3558   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3559         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3560                          (match_operand:SI 2 "const_int_operand" "")
3561                          (match_operand:SI 3 "const_int_operand" ""))
3562                     (const_int 0)))
3563    (clobber (match_scratch:SI 4 ""))]
3564   "! TARGET_POWERPC64 && reload_completed"
3565   [(set (match_dup 4)
3566         (zero_extract:SI (match_dup 1) (match_dup 2)
3567                          (match_dup 3)))
3568    (set (match_dup 0)
3569         (compare:CC (match_dup 4)
3570                     (const_int 0)))]
3571   "")
3572
3573 (define_insn "*extzvsi_internal2"
3574   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3575         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3576                          (match_operand:SI 2 "const_int_operand" "i,i")
3577                          (match_operand:SI 3 "const_int_operand" "i,i"))
3578                     (const_int 0)))
3579    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3580         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3581   "! TARGET_POWERPC64"
3582   "*
3583 {
3584   int start = INTVAL (operands[3]) & 31;
3585   int size = INTVAL (operands[2]) & 31;
3586
3587   /* Force split for non-cc0 compare.  */
3588   if (which_alternative == 1)
3589      return \"#\";
3590
3591   if (start >= 16 && start + size == 32)
3592     {
3593       operands[3] = GEN_INT ((1 << (32 - start)) - 1);
3594       return \"{andil.|andi.} %0,%1,%3\";
3595     }
3596
3597   if (start + size >= 32)
3598     operands[3] = const0_rtx;
3599   else
3600     operands[3] = GEN_INT (start + size);
3601   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3602 }"
3603   [(set_attr "type" "delayed_compare")
3604    (set_attr "length" "4,8")])
3605
3606 (define_split
3607   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3608         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3609                          (match_operand:SI 2 "const_int_operand" "")
3610                          (match_operand:SI 3 "const_int_operand" ""))
3611                     (const_int 0)))
3612    (set (match_operand:SI 0 "gpc_reg_operand" "")
3613         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3614   "! TARGET_POWERPC64 && reload_completed"
3615   [(set (match_dup 0)
3616         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3617    (set (match_dup 4)
3618         (compare:CC (match_dup 0)
3619                     (const_int 0)))]
3620   "")
3621
3622 (define_insn "extzvdi"
3623   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3624         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3625                          (match_operand:SI 2 "const_int_operand" "i")
3626                          (match_operand:SI 3 "const_int_operand" "i")))]
3627   "TARGET_POWERPC64"
3628   "*
3629 {
3630   int start = INTVAL (operands[3]) & 63;
3631   int size = INTVAL (operands[2]) & 63;
3632
3633   if (start + size >= 64)
3634     operands[3] = const0_rtx;
3635   else
3636     operands[3] = GEN_INT (start + size);
3637   operands[2] = GEN_INT (64 - size);
3638   return \"rldicl %0,%1,%3,%2\";
3639 }")
3640
3641 (define_insn "*extzvdi_internal1"
3642   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3643         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3644                          (match_operand:SI 2 "const_int_operand" "i")
3645                          (match_operand:SI 3 "const_int_operand" "i"))
3646                     (const_int 0)))
3647    (clobber (match_scratch:DI 4 "=r"))]
3648   "TARGET_POWERPC64"
3649   "*
3650 {
3651   int start = INTVAL (operands[3]) & 63;
3652   int size = INTVAL (operands[2]) & 63;
3653
3654   if (start + size >= 64)
3655     operands[3] = const0_rtx;
3656   else
3657     operands[3] = GEN_INT (start + size);
3658   operands[2] = GEN_INT (64 - size);
3659   return \"rldicl. %4,%1,%3,%2\";
3660 }")
3661
3662 (define_insn "*extzvdi_internal2"
3663   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3664         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3665                          (match_operand:SI 2 "const_int_operand" "i")
3666                          (match_operand:SI 3 "const_int_operand" "i"))
3667                     (const_int 0)))
3668    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3669         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3670   "TARGET_POWERPC64"
3671   "*
3672 {
3673   int start = INTVAL (operands[3]) & 63;
3674   int size = INTVAL (operands[2]) & 63;
3675
3676   if (start + size >= 64)
3677     operands[3] = const0_rtx;
3678   else
3679     operands[3] = GEN_INT (start + size);
3680   operands[2] = GEN_INT (64 - size);
3681   return \"rldicl. %0,%1,%3,%2\";
3682 }")
3683
3684 (define_insn "rotlsi3"
3685   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3686         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3687                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3688   ""
3689   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3690
3691 (define_insn "*rotlsi3_internal2"
3692   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3693         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3694                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3695                     (const_int 0)))
3696    (clobber (match_scratch:SI 3 "=r,r"))]
3697   "! TARGET_POWERPC64"
3698   "@
3699    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3700    #"
3701   [(set_attr "type" "delayed_compare")
3702    (set_attr "length" "4,8")])
3703
3704 (define_split
3705   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3706         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3707                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3708                     (const_int 0)))
3709    (clobber (match_scratch:SI 3 ""))]
3710   "! TARGET_POWERPC64 && reload_completed"
3711   [(set (match_dup 3)
3712         (rotate:SI (match_dup 1) (match_dup 2)))
3713    (set (match_dup 0)
3714         (compare:CC (match_dup 3)
3715                     (const_int 0)))]
3716   "")
3717
3718 (define_insn "*rotlsi3_internal3"
3719   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3720         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3721                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3722                     (const_int 0)))
3723    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3724         (rotate:SI (match_dup 1) (match_dup 2)))]
3725   "! TARGET_POWERPC64"
3726   "@
3727    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3728    #"
3729   [(set_attr "type" "delayed_compare")
3730    (set_attr "length" "4,8")])
3731
3732 (define_split
3733   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3734         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3735                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3736                     (const_int 0)))
3737    (set (match_operand:SI 0 "gpc_reg_operand" "")
3738         (rotate:SI (match_dup 1) (match_dup 2)))]
3739   "! TARGET_POWERPC64 && reload_completed"
3740   [(set (match_dup 0)
3741         (rotate:SI (match_dup 1) (match_dup 2)))
3742    (set (match_dup 3)
3743         (compare:CC (match_dup 0)
3744                     (const_int 0)))]
3745   "")
3746
3747 (define_insn "*rotlsi3_internal4"
3748   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3749         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3750                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
3751                 (match_operand:SI 3 "mask_operand" "T")))]
3752   ""
3753   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
3754
3755 (define_insn "*rotlsi3_internal5"
3756   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3757         (compare:CC (and:SI
3758                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3759                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3760                      (match_operand:SI 3 "mask_operand" "T,T"))
3761                     (const_int 0)))
3762    (clobber (match_scratch:SI 4 "=r,r"))]
3763   "! TARGET_POWERPC64"
3764   "@
3765    {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3766    #"
3767   [(set_attr "type" "delayed_compare")
3768    (set_attr "length" "4,8")])
3769
3770 (define_split
3771   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3772         (compare:CC (and:SI
3773                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3774                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3775                      (match_operand:SI 3 "mask_operand" ""))
3776                     (const_int 0)))
3777    (clobber (match_scratch:SI 4 ""))]
3778   "! TARGET_POWERPC64 && reload_completed"
3779   [(set (match_dup 4)
3780         (and:SI (rotate:SI (match_dup 1)
3781                                 (match_dup 2))
3782                      (match_dup 3)))
3783    (set (match_dup 0)
3784         (compare:CC (match_dup 4)
3785                     (const_int 0)))]
3786   "")
3787
3788 (define_insn "*rotlsi3_internal6"
3789   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3790         (compare:CC (and:SI
3791                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3792                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3793                      (match_operand:SI 3 "mask_operand" "T,T"))
3794                     (const_int 0)))
3795    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3796         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3797   "! TARGET_POWERPC64"
3798   "@
3799    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3800    #"
3801   [(set_attr "type" "delayed_compare")
3802    (set_attr "length" "4,8")])
3803
3804 (define_split
3805   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3806         (compare:CC (and:SI
3807                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3808                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3809                      (match_operand:SI 3 "mask_operand" ""))
3810                     (const_int 0)))
3811    (set (match_operand:SI 0 "gpc_reg_operand" "")
3812         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3813   "! TARGET_POWERPC64 && reload_completed"
3814   [(set (match_dup 0)
3815         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3816    (set (match_dup 4)
3817         (compare:CC (match_dup 0)
3818                     (const_int 0)))]
3819   "")
3820
3821 (define_insn "*rotlsi3_internal7"
3822   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3823         (zero_extend:SI
3824          (subreg:QI
3825           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3826                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3827   ""
3828   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
3829
3830 (define_insn "*rotlsi3_internal8"
3831   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3832         (compare:CC (zero_extend:SI
3833                      (subreg:QI
3834                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3835                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3836                     (const_int 0)))
3837    (clobber (match_scratch:SI 3 "=r,r"))]
3838   ""
3839   "@
3840    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3841    #"
3842   [(set_attr "type" "delayed_compare")
3843    (set_attr "length" "4,8")])
3844
3845 (define_split
3846   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3847         (compare:CC (zero_extend:SI
3848                      (subreg:QI
3849                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3850                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3851                     (const_int 0)))
3852    (clobber (match_scratch:SI 3 ""))]
3853   "reload_completed"
3854   [(set (match_dup 3)
3855         (zero_extend:SI (subreg:QI
3856                       (rotate:SI (match_dup 1)
3857                                  (match_dup 2)) 0)))
3858    (set (match_dup 0)
3859         (compare:CC (match_dup 3)
3860                     (const_int 0)))]
3861   "")
3862
3863 (define_insn "*rotlsi3_internal9"
3864   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3865         (compare:CC (zero_extend:SI
3866                      (subreg:QI
3867                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3868                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3869                     (const_int 0)))
3870    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3871         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3872   ""
3873   "@
3874    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3875    #"
3876   [(set_attr "type" "delayed_compare")
3877    (set_attr "length" "4,8")])
3878
3879 (define_split
3880   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3881         (compare:CC (zero_extend:SI
3882                      (subreg:QI
3883                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3884                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3885                     (const_int 0)))
3886    (set (match_operand:SI 0 "gpc_reg_operand" "")
3887         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3888   "reload_completed"
3889   [(set (match_dup 0)
3890         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3891    (set (match_dup 3)
3892         (compare:CC (match_dup 0)
3893                     (const_int 0)))]
3894   "")
3895
3896 (define_insn "*rotlsi3_internal10"
3897   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3898         (zero_extend:SI
3899          (subreg:HI
3900           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3901                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3902   ""
3903   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
3904
3905 (define_insn "*rotlsi3_internal11"
3906   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3907         (compare:CC (zero_extend:SI
3908                      (subreg:HI
3909                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3910                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3911                     (const_int 0)))
3912    (clobber (match_scratch:SI 3 "=r,r"))]
3913   ""
3914   "@
3915    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3916    #"
3917   [(set_attr "type" "delayed_compare")
3918    (set_attr "length" "4,8")])
3919
3920 (define_split
3921   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3922         (compare:CC (zero_extend:SI
3923                      (subreg:HI
3924                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3925                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3926                     (const_int 0)))
3927    (clobber (match_scratch:SI 3 ""))]
3928   "reload_completed"
3929   [(set (match_dup 3)
3930         (zero_extend:SI (subreg:HI
3931                       (rotate:SI (match_dup 1)
3932                                  (match_dup 2)) 0)))
3933    (set (match_dup 0)
3934         (compare:CC (match_dup 3)
3935                     (const_int 0)))]
3936   "")
3937
3938 (define_insn "*rotlsi3_internal12"
3939   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3940         (compare:CC (zero_extend:SI
3941                      (subreg:HI
3942                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3943                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3944                     (const_int 0)))
3945    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3946         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3947   ""
3948   "@
3949    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
3950    #"
3951   [(set_attr "type" "delayed_compare")
3952    (set_attr "length" "4,8")])
3953
3954 (define_split
3955   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3956         (compare:CC (zero_extend:SI
3957                      (subreg:HI
3958                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3959                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3960                     (const_int 0)))
3961    (set (match_operand:SI 0 "gpc_reg_operand" "")
3962         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3963   "reload_completed"
3964   [(set (match_dup 0)
3965         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3966    (set (match_dup 3)
3967         (compare:CC (match_dup 0)
3968                     (const_int 0)))]
3969   "")
3970
3971 ;; Note that we use "sle." instead of "sl." so that we can set
3972 ;; SHIFT_COUNT_TRUNCATED.
3973
3974 (define_expand "ashlsi3"
3975   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
3976    (use (match_operand:SI 1 "gpc_reg_operand" ""))
3977    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
3978   ""
3979   "
3980 {
3981   if (TARGET_POWER)
3982     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
3983   else
3984     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
3985   DONE;
3986 }")
3987
3988 (define_insn "ashlsi3_power"
3989   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3990         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3991                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
3992    (clobber (match_scratch:SI 3 "=q,X"))]
3993   "TARGET_POWER"
3994   "@
3995    sle %0,%1,%2
3996    {sli|slwi} %0,%1,%h2")
3997
3998 (define_insn "ashlsi3_no_power"
3999   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4000         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4001                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4002   "! TARGET_POWER"
4003   "{sl|slw}%I2 %0,%1,%h2")
4004
4005 (define_insn ""
4006   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4007         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4008                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4009                     (const_int 0)))
4010    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4011    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4012   "TARGET_POWER"
4013   "@
4014    sle. %3,%1,%2
4015    {sli.|slwi.} %3,%1,%h2
4016    #
4017    #"
4018   [(set_attr "type" "delayed_compare")
4019    (set_attr "length" "4,4,8,8")])
4020
4021 (define_split
4022   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4023         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4024                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4025                     (const_int 0)))
4026    (clobber (match_scratch:SI 3 ""))
4027    (clobber (match_scratch:SI 4 ""))]
4028   "TARGET_POWER && reload_completed"
4029   [(parallel [(set (match_dup 3)
4030         (ashift:SI (match_dup 1) (match_dup 2)))
4031    (clobber (match_dup 4))])
4032    (set (match_dup 0)
4033         (compare:CC (match_dup 3)
4034                     (const_int 0)))]
4035   "")
4036
4037 (define_insn ""
4038   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4039         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4040                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4041                     (const_int 0)))
4042    (clobber (match_scratch:SI 3 "=r,r"))]
4043   "! TARGET_POWER && ! TARGET_POWERPC64"
4044   "@
4045    {sl|slw}%I2. %3,%1,%h2
4046    #"
4047   [(set_attr "type" "delayed_compare")
4048    (set_attr "length" "4,8")])
4049
4050 (define_split
4051   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4052         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4053                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4054                     (const_int 0)))
4055    (clobber (match_scratch:SI 3 ""))]
4056   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4057   [(set (match_dup 3)
4058         (ashift:SI (match_dup 1) (match_dup 2)))
4059    (set (match_dup 0)
4060         (compare:CC (match_dup 3)
4061                     (const_int 0)))]
4062   "")
4063
4064 (define_insn ""
4065   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4066         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4067                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4068                     (const_int 0)))
4069    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4070         (ashift:SI (match_dup 1) (match_dup 2)))
4071    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4072   "TARGET_POWER"
4073   "@
4074    sle. %0,%1,%2
4075    {sli.|slwi.} %0,%1,%h2
4076    #
4077    #"
4078   [(set_attr "type" "delayed_compare")
4079    (set_attr "length" "4,4,8,8")])
4080
4081 (define_split
4082   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4083         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4084                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4085                     (const_int 0)))
4086    (set (match_operand:SI 0 "gpc_reg_operand" "")
4087         (ashift:SI (match_dup 1) (match_dup 2)))
4088    (clobber (match_scratch:SI 4 ""))]
4089   "TARGET_POWER && reload_completed"
4090   [(parallel [(set (match_dup 0)
4091         (ashift:SI (match_dup 1) (match_dup 2)))
4092    (clobber (match_dup 4))])
4093    (set (match_dup 3)
4094         (compare:CC (match_dup 0)
4095                     (const_int 0)))]
4096   "")
4097
4098 (define_insn ""
4099   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4100         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4101                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4102                     (const_int 0)))
4103    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4104         (ashift:SI (match_dup 1) (match_dup 2)))]
4105   "! TARGET_POWER && ! TARGET_POWERPC64"
4106   "@
4107    {sl|slw}%I2. %0,%1,%h2
4108    #"
4109   [(set_attr "type" "delayed_compare")
4110    (set_attr "length" "4,8")])
4111
4112 (define_split
4113   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4114         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4115                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4116                     (const_int 0)))
4117    (set (match_operand:SI 0 "gpc_reg_operand" "")
4118         (ashift:SI (match_dup 1) (match_dup 2)))]
4119   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4120   [(set (match_dup 0)
4121         (ashift:SI (match_dup 1) (match_dup 2)))
4122    (set (match_dup 3)
4123         (compare:CC (match_dup 0)
4124                     (const_int 0)))]
4125   "")
4126
4127 (define_insn ""
4128   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4129         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4130                            (match_operand:SI 2 "const_int_operand" "i"))
4131                 (match_operand:SI 3 "mask_operand" "T")))]
4132   "includes_lshift_p (operands[2], operands[3])"
4133   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
4134
4135 (define_insn ""
4136   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4137         (compare:CC
4138          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4139                             (match_operand:SI 2 "const_int_operand" "i,i"))
4140                  (match_operand:SI 3 "mask_operand" "T,T"))
4141          (const_int 0)))
4142    (clobber (match_scratch:SI 4 "=r,r"))]
4143   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3])"
4144   "@
4145    {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
4146    #"
4147   [(set_attr "type" "delayed_compare")
4148    (set_attr "length" "4,8")])
4149
4150 (define_split
4151   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4152         (compare:CC
4153          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4154                             (match_operand:SI 2 "const_int_operand" ""))
4155                  (match_operand:SI 3 "mask_operand" ""))
4156          (const_int 0)))
4157    (clobber (match_scratch:SI 4 ""))]
4158   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3]) && reload_completed"
4159   [(set (match_dup 4)
4160         (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4161                  (match_dup 3)))
4162    (set (match_dup 0)
4163         (compare:CC (match_dup 4)
4164                     (const_int 0)))]
4165   "")
4166
4167 (define_insn ""
4168   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4169         (compare:CC
4170          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4171                             (match_operand:SI 2 "const_int_operand" "i,i"))
4172                  (match_operand:SI 3 "mask_operand" "T,T"))
4173          (const_int 0)))
4174    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4175         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4176   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3])"
4177   "@
4178    {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4179    #"
4180   [(set_attr "type" "delayed_compare")
4181    (set_attr "length" "4,8")])
4182
4183 (define_split
4184   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4185         (compare:CC
4186          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4187                             (match_operand:SI 2 "const_int_operand" ""))
4188                  (match_operand:SI 3 "mask_operand" ""))
4189          (const_int 0)))
4190    (set (match_operand:SI 0 "gpc_reg_operand" "")
4191         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4192   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3]) && reload_completed"
4193   [(set (match_dup 0)
4194         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4195    (set (match_dup 4)
4196         (compare:CC (match_dup 0)
4197                     (const_int 0)))]
4198   "")
4199
4200 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
4201 ;; "sli x,x,0".
4202 (define_expand "lshrsi3"
4203   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4204    (use (match_operand:SI 1 "gpc_reg_operand" ""))
4205    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4206   ""
4207   "
4208 {
4209   if (TARGET_POWER)
4210     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
4211   else
4212     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
4213   DONE;
4214 }")
4215
4216 (define_insn "lshrsi3_power"
4217   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4218         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4219                      (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
4220    (clobber (match_scratch:SI 3 "=q,X,X"))]
4221   "TARGET_POWER"
4222   "@
4223   sre %0,%1,%2
4224   mr %0,%1
4225   {s%A2i|s%A2wi} %0,%1,%h2")
4226
4227 (define_insn "lshrsi3_no_power"
4228   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4229         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4230                      (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
4231   "! TARGET_POWER"
4232   "@
4233   mr %0,%1
4234   {sr|srw}%I2 %0,%1,%h2")
4235
4236 (define_insn ""
4237   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4238         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4239                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4240                     (const_int 0)))
4241    (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
4242    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4243   "TARGET_POWER"
4244   "@
4245   sre. %3,%1,%2
4246   mr. %1,%1
4247   {s%A2i.|s%A2wi.} %3,%1,%h2
4248   #
4249   #
4250   #"
4251   [(set_attr "type" "delayed_compare")
4252    (set_attr "length" "4,4,4,8,8,8")])
4253
4254 (define_split
4255   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4256         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4257                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4258                     (const_int 0)))
4259    (clobber (match_scratch:SI 3 ""))
4260    (clobber (match_scratch:SI 4 ""))]
4261   "TARGET_POWER && reload_completed"
4262   [(parallel [(set (match_dup 3)
4263         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4264    (clobber (match_dup 4))])
4265    (set (match_dup 0)
4266         (compare:CC (match_dup 3)
4267                     (const_int 0)))]
4268   "")
4269
4270 (define_insn ""
4271   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4272         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4273                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4274                     (const_int 0)))
4275    (clobber (match_scratch:SI 3 "=X,r,X,r"))]
4276   "! TARGET_POWER && ! TARGET_POWERPC64"
4277   "@
4278    mr. %1,%1
4279    {sr|srw}%I2. %3,%1,%h2
4280    #
4281    #"
4282   [(set_attr "type" "delayed_compare")
4283    (set_attr "length" "4,4,8,8")])
4284
4285 (define_split
4286   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4287         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4288                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4289                     (const_int 0)))
4290    (clobber (match_scratch:SI 3 ""))]
4291   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4292   [(set (match_dup 3)
4293         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4294    (set (match_dup 0)
4295         (compare:CC (match_dup 3)
4296                     (const_int 0)))]
4297   "")
4298
4299 (define_insn ""
4300   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4301         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4302                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4303                     (const_int 0)))
4304    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
4305         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4306    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4307   "TARGET_POWER"
4308   "@
4309   sre. %0,%1,%2
4310   mr. %0,%1
4311   {s%A2i.|s%A2wi.} %0,%1,%h2
4312   #
4313   #
4314   #"
4315   [(set_attr "type" "delayed_compare")
4316    (set_attr "length" "4,4,4,8,8,8")])
4317
4318 (define_split
4319   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4320         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4321                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4322                     (const_int 0)))
4323    (set (match_operand:SI 0 "gpc_reg_operand" "")
4324         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4325    (clobber (match_scratch:SI 4 ""))]
4326   "TARGET_POWER && reload_completed"
4327   [(parallel [(set (match_dup 0)
4328         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4329    (clobber (match_dup 4))])
4330    (set (match_dup 3)
4331         (compare:CC (match_dup 0)
4332                     (const_int 0)))]
4333   "")
4334
4335 (define_insn ""
4336   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4337         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4338                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4339                     (const_int 0)))
4340    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4341         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4342   "! TARGET_POWER && ! TARGET_POWERPC64"
4343   "@
4344    mr. %0,%1
4345    {sr|srw}%I2. %0,%1,%h2
4346    #
4347    #"
4348   [(set_attr "type" "delayed_compare")
4349    (set_attr "length" "4,4,8,8")])
4350
4351 (define_split
4352   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4353         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4354                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4355                     (const_int 0)))
4356    (set (match_operand:SI 0 "gpc_reg_operand" "")
4357         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4358   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4359   [(set (match_dup 0)
4360         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4361    (set (match_dup 3)
4362         (compare:CC (match_dup 0)
4363                     (const_int 0)))]
4364   "")
4365
4366 (define_insn ""
4367   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4368         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4369                              (match_operand:SI 2 "const_int_operand" "i"))
4370                 (match_operand:SI 3 "mask_operand" "T")))]
4371   "includes_rshift_p (operands[2], operands[3])"
4372   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
4373
4374 (define_insn ""
4375   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4376         (compare:CC
4377          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4378                               (match_operand:SI 2 "const_int_operand" "i,i"))
4379                  (match_operand:SI 3 "mask_operand" "T,T"))
4380          (const_int 0)))
4381    (clobber (match_scratch:SI 4 "=r,r"))]
4382   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3])"
4383   "@
4384    {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4385    #"
4386   [(set_attr "type" "delayed_compare")
4387    (set_attr "length" "4,8")])
4388
4389 (define_split
4390   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4391         (compare:CC
4392          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4393                               (match_operand:SI 2 "const_int_operand" ""))
4394                  (match_operand:SI 3 "mask_operand" ""))
4395          (const_int 0)))
4396    (clobber (match_scratch:SI 4 ""))]
4397   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3]) && reload_completed"
4398   [(set (match_dup 4)
4399         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4400                  (match_dup 3)))
4401    (set (match_dup 0)
4402         (compare:CC (match_dup 4)
4403                     (const_int 0)))]
4404   "")
4405
4406 (define_insn ""
4407   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4408         (compare:CC
4409          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4410                               (match_operand:SI 2 "const_int_operand" "i,i"))
4411                  (match_operand:SI 3 "mask_operand" "T,T"))
4412          (const_int 0)))
4413    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4414         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4415   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3])"
4416   "@
4417    {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4418    #"
4419   [(set_attr "type" "delayed_compare")
4420    (set_attr "length" "4,8")])
4421
4422 (define_split
4423   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4424         (compare:CC
4425          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4426                               (match_operand:SI 2 "const_int_operand" ""))
4427                  (match_operand:SI 3 "mask_operand" ""))
4428          (const_int 0)))
4429    (set (match_operand:SI 0 "gpc_reg_operand" "")
4430         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4431   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3]) && reload_completed"
4432   [(set (match_dup 0)
4433         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4434    (set (match_dup 4)
4435         (compare:CC (match_dup 0)
4436                     (const_int 0)))]
4437   "")
4438
4439 (define_insn ""
4440   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4441         (zero_extend:SI
4442          (subreg:QI
4443           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4444                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4445   "includes_rshift_p (operands[2], GEN_INT (255))"
4446   "{rlinm|rlwinm} %0,%1,%s2,0xff")
4447
4448 (define_insn ""
4449   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4450         (compare:CC
4451          (zero_extend:SI
4452           (subreg:QI
4453            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4454                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4455          (const_int 0)))
4456    (clobber (match_scratch:SI 3 "=r,r"))]
4457   "includes_rshift_p (operands[2], GEN_INT (255))"
4458   "@
4459    {rlinm.|rlwinm.} %3,%1,%s2,0xff
4460    #"
4461   [(set_attr "type" "delayed_compare")
4462    (set_attr "length" "4,8")])
4463
4464 (define_split
4465   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4466         (compare:CC
4467          (zero_extend:SI
4468           (subreg:QI
4469            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4470                         (match_operand:SI 2 "const_int_operand" "")) 0))
4471          (const_int 0)))
4472    (clobber (match_scratch:SI 3 ""))]
4473   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4474   [(set (match_dup 3)
4475         (zero_extend:SI (subreg:QI
4476            (lshiftrt:SI (match_dup 1)
4477                         (match_dup 2)) 0)))
4478    (set (match_dup 0)
4479         (compare:CC (match_dup 3)
4480                     (const_int 0)))]
4481   "")
4482
4483 (define_insn ""
4484   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4485         (compare:CC
4486          (zero_extend:SI
4487           (subreg:QI
4488            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4489                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4490          (const_int 0)))
4491    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4492         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4493   "includes_rshift_p (operands[2], GEN_INT (255))"
4494   "@
4495    {rlinm.|rlwinm.} %0,%1,%s2,0xff
4496    #"
4497   [(set_attr "type" "delayed_compare")
4498    (set_attr "length" "4,8")])
4499
4500 (define_split
4501   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4502         (compare:CC
4503          (zero_extend:SI
4504           (subreg:QI
4505            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4506                         (match_operand:SI 2 "const_int_operand" "")) 0))
4507          (const_int 0)))
4508    (set (match_operand:SI 0 "gpc_reg_operand" "")
4509         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4510   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4511   [(set (match_dup 0)
4512         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4513    (set (match_dup 3)
4514         (compare:CC (match_dup 0)
4515                     (const_int 0)))]
4516   "")
4517
4518 (define_insn ""
4519   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4520         (zero_extend:SI
4521          (subreg:HI
4522           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4523                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4524   "includes_rshift_p (operands[2], GEN_INT (65535))"
4525   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4526
4527 (define_insn ""
4528   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4529         (compare:CC
4530          (zero_extend:SI
4531           (subreg:HI
4532            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4533                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4534          (const_int 0)))
4535    (clobber (match_scratch:SI 3 "=r,r"))]
4536   "includes_rshift_p (operands[2], GEN_INT (65535))"
4537   "@
4538    {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4539    #"
4540   [(set_attr "type" "delayed_compare")
4541    (set_attr "length" "4,8")])
4542
4543 (define_split
4544   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4545         (compare:CC
4546          (zero_extend:SI
4547           (subreg:HI
4548            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4549                         (match_operand:SI 2 "const_int_operand" "")) 0))
4550          (const_int 0)))
4551    (clobber (match_scratch:SI 3 ""))]
4552   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4553   [(set (match_dup 3)
4554         (zero_extend:SI (subreg:HI
4555            (lshiftrt:SI (match_dup 1)
4556                         (match_dup 2)) 0)))
4557    (set (match_dup 0)
4558         (compare:CC (match_dup 3)
4559                     (const_int 0)))]
4560   "")
4561
4562 (define_insn ""
4563   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4564         (compare:CC
4565          (zero_extend:SI
4566           (subreg:HI
4567            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4568                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4569          (const_int 0)))
4570    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4571         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4572   "includes_rshift_p (operands[2], GEN_INT (65535))"
4573   "@
4574    {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4575    #"
4576   [(set_attr "type" "delayed_compare")
4577    (set_attr "length" "4,8")])
4578
4579 (define_split
4580   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4581         (compare:CC
4582          (zero_extend:SI
4583           (subreg:HI
4584            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4585                         (match_operand:SI 2 "const_int_operand" "")) 0))
4586          (const_int 0)))
4587    (set (match_operand:SI 0 "gpc_reg_operand" "")
4588         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4589   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4590   [(set (match_dup 0)
4591         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4592    (set (match_dup 3)
4593         (compare:CC (match_dup 0)
4594                     (const_int 0)))]
4595   "")
4596
4597 (define_insn ""
4598   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4599                          (const_int 1)
4600                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4601         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4602                      (const_int 31)))]
4603   "TARGET_POWER"
4604   "rrib %0,%1,%2")
4605
4606 (define_insn ""
4607   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4608                          (const_int 1)
4609                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4610         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4611                      (const_int 31)))]
4612   "TARGET_POWER"
4613   "rrib %0,%1,%2")
4614
4615 (define_insn ""
4616   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4617                          (const_int 1)
4618                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4619         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4620                          (const_int 1)
4621                          (const_int 0)))]
4622   "TARGET_POWER"
4623   "rrib %0,%1,%2")
4624
4625 (define_expand "ashrsi3"
4626   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4627         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4628                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4629   ""
4630   "
4631 {
4632   if (TARGET_POWER)
4633     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4634   else
4635     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4636   DONE;
4637 }")
4638
4639 (define_insn "ashrsi3_power"
4640   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4641         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4642                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4643    (clobber (match_scratch:SI 3 "=q,X"))]
4644   "TARGET_POWER"
4645   "@
4646    srea %0,%1,%2
4647    {srai|srawi} %0,%1,%h2")
4648
4649 (define_insn "ashrsi3_no_power"
4650   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4651         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4652                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4653   "! TARGET_POWER"
4654   "{sra|sraw}%I2 %0,%1,%h2")
4655
4656 (define_insn ""
4657   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4658         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4659                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4660                     (const_int 0)))
4661    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4662    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4663   "TARGET_POWER"
4664   "@
4665    srea. %3,%1,%2
4666    {srai.|srawi.} %3,%1,%h2
4667    #
4668    #"
4669   [(set_attr "type" "delayed_compare")
4670    (set_attr "length" "4,4,8,8")])
4671
4672 (define_split
4673   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4674         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4675                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4676                     (const_int 0)))
4677    (clobber (match_scratch:SI 3 ""))
4678    (clobber (match_scratch:SI 4 ""))]
4679   "TARGET_POWER && reload_completed"
4680   [(parallel [(set (match_dup 3)
4681         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4682    (clobber (match_dup 4))])
4683    (set (match_dup 0)
4684         (compare:CC (match_dup 3)
4685                     (const_int 0)))]
4686   "")
4687
4688 (define_insn ""
4689   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4690         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4691                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4692                     (const_int 0)))
4693    (clobber (match_scratch:SI 3 "=r,r"))]
4694   "! TARGET_POWER"
4695   "@
4696    {sra|sraw}%I2. %3,%1,%h2
4697    #"
4698   [(set_attr "type" "delayed_compare")
4699    (set_attr "length" "4,8")])
4700
4701 (define_split
4702   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4703         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4704                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4705                     (const_int 0)))
4706    (clobber (match_scratch:SI 3 ""))]
4707   "! TARGET_POWER && reload_completed"
4708   [(set (match_dup 3)
4709         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4710    (set (match_dup 0)
4711         (compare:CC (match_dup 3)
4712                     (const_int 0)))]
4713   "")
4714
4715 (define_insn ""
4716   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4717         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4718                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4719                     (const_int 0)))
4720    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4721         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4722    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4723   "TARGET_POWER"
4724   "@
4725    srea. %0,%1,%2
4726    {srai.|srawi.} %0,%1,%h2
4727    #
4728    #"
4729   [(set_attr "type" "delayed_compare")
4730    (set_attr "length" "4,4,8,8")])
4731
4732 (define_split
4733   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4734         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4735                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4736                     (const_int 0)))
4737    (set (match_operand:SI 0 "gpc_reg_operand" "")
4738         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4739    (clobber (match_scratch:SI 4 ""))]
4740   "TARGET_POWER && reload_completed"
4741   [(parallel [(set (match_dup 0)
4742         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4743    (clobber (match_dup 4))])
4744    (set (match_dup 3)
4745         (compare:CC (match_dup 0)
4746                     (const_int 0)))]
4747   "")
4748
4749 (define_insn ""
4750   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4751         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4752                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4753                     (const_int 0)))
4754    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4755         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4756   "! TARGET_POWER"
4757   "@
4758    {sra|sraw}%I2. %0,%1,%h2
4759    #"
4760   [(set_attr "type" "delayed_compare")
4761    (set_attr "length" "4,8")])
4762 \f
4763 (define_split
4764   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4765         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4766                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4767                     (const_int 0)))
4768    (set (match_operand:SI 0 "gpc_reg_operand" "")
4769         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4770   "! TARGET_POWER && reload_completed"
4771   [(set (match_dup 0)
4772         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4773    (set (match_dup 3)
4774         (compare:CC (match_dup 0)
4775                     (const_int 0)))]
4776   "")
4777
4778 ;; Floating-point insns, excluding normal data motion.
4779 ;;
4780 ;; PowerPC has a full set of single-precision floating point instructions.
4781 ;;
4782 ;; For the POWER architecture, we pretend that we have both SFmode and
4783 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
4784 ;; The only conversions we will do will be when storing to memory.  In that
4785 ;; case, we will use the "frsp" instruction before storing.
4786 ;;
4787 ;; Note that when we store into a single-precision memory location, we need to
4788 ;; use the frsp insn first.  If the register being stored isn't dead, we
4789 ;; need a scratch register for the frsp.  But this is difficult when the store
4790 ;; is done by reload.  It is not incorrect to do the frsp on the register in
4791 ;; this case, we just lose precision that we would have otherwise gotten but
4792 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
4793
4794 (define_insn "extendsfdf2"
4795   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4796         (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4797   "TARGET_HARD_FLOAT"
4798   "*
4799 {
4800   if (REGNO (operands[0]) == REGNO (operands[1]))
4801     return \"\";
4802   else
4803     return \"fmr %0,%1\";
4804 }"
4805   [(set_attr "type" "fp")])
4806
4807 (define_insn "truncdfsf2"
4808   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4809         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4810   "TARGET_HARD_FLOAT"
4811   "frsp %0,%1"
4812   [(set_attr "type" "fp")])
4813
4814 (define_insn "aux_truncdfsf2"
4815   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4816         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
4817   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4818   "frsp %0,%1"
4819   [(set_attr "type" "fp")])
4820
4821 (define_insn "negsf2"
4822   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4823         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4824   "TARGET_HARD_FLOAT"
4825   "fneg %0,%1"
4826   [(set_attr "type" "fp")])
4827
4828 (define_insn "abssf2"
4829   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4830         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4831   "TARGET_HARD_FLOAT"
4832   "fabs %0,%1"
4833   [(set_attr "type" "fp")])
4834
4835 (define_insn ""
4836   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4837         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
4838   "TARGET_HARD_FLOAT"
4839   "fnabs %0,%1"
4840   [(set_attr "type" "fp")])
4841
4842 (define_expand "addsf3"
4843   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4844         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4845                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4846   "TARGET_HARD_FLOAT"
4847   "")
4848
4849 (define_insn ""
4850   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4851         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4852                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4853   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4854   "fadds %0,%1,%2"
4855   [(set_attr "type" "fp")])
4856
4857 (define_insn ""
4858   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4859         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4860                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4861   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4862   "{fa|fadd} %0,%1,%2"
4863   [(set_attr "type" "fp")])
4864
4865 (define_expand "subsf3"
4866   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4867         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4868                   (match_operand:SF 2 "gpc_reg_operand" "")))]
4869   "TARGET_HARD_FLOAT"
4870   "")
4871
4872 (define_insn ""
4873   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4874         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4875                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4876   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4877   "fsubs %0,%1,%2"
4878   [(set_attr "type" "fp")])
4879
4880 (define_insn ""
4881   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4882         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4883                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4884   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4885   "{fs|fsub} %0,%1,%2"
4886   [(set_attr "type" "fp")])
4887
4888 (define_expand "mulsf3"
4889   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4890         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4891                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4892   "TARGET_HARD_FLOAT"
4893   "")
4894
4895 (define_insn ""
4896   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4897         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4898                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4899   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4900   "fmuls %0,%1,%2"
4901   [(set_attr "type" "fp")])
4902
4903 (define_insn ""
4904   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4905         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4906                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4907   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4908   "{fm|fmul} %0,%1,%2"
4909   [(set_attr "type" "dmul")])
4910
4911 (define_expand "divsf3"
4912   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4913         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4914                 (match_operand:SF 2 "gpc_reg_operand" "")))]
4915   "TARGET_HARD_FLOAT"
4916   "")
4917
4918 (define_insn ""
4919   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4920         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4921                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4922   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4923   "fdivs %0,%1,%2"
4924   [(set_attr "type" "sdiv")])
4925
4926 (define_insn ""
4927   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4928         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4929                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
4930   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4931   "{fd|fdiv} %0,%1,%2"
4932   [(set_attr "type" "ddiv")])
4933
4934 (define_insn ""
4935   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4936         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4937                           (match_operand:SF 2 "gpc_reg_operand" "f"))
4938                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
4939   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4940   "fmadds %0,%1,%2,%3"
4941   [(set_attr "type" "fp")])
4942
4943 (define_insn ""
4944   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4945         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4946                           (match_operand:SF 2 "gpc_reg_operand" "f"))
4947                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
4948   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4949   "{fma|fmadd} %0,%1,%2,%3"
4950   [(set_attr "type" "dmul")])
4951
4952 (define_insn ""
4953   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4954         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4955                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4956                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
4957   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4958   "fmsubs %0,%1,%2,%3"
4959   [(set_attr "type" "fp")])
4960
4961 (define_insn ""
4962   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4963         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4964                            (match_operand:SF 2 "gpc_reg_operand" "f"))
4965                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
4966   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4967   "{fms|fmsub} %0,%1,%2,%3"
4968   [(set_attr "type" "dmul")])
4969
4970 (define_insn ""
4971   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4972         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4973                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
4974                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4975   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4976   "fnmadds %0,%1,%2,%3"
4977   [(set_attr "type" "fp")])
4978
4979 (define_insn ""
4980   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4981         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4982                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
4983                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4984   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4985   "{fnma|fnmadd} %0,%1,%2,%3"
4986   [(set_attr "type" "dmul")])
4987
4988 (define_insn ""
4989   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4990         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4991                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
4992                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
4993   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
4994   "fnmsubs %0,%1,%2,%3"
4995   [(set_attr "type" "fp")])
4996
4997 (define_insn ""
4998   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4999         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5000                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
5001                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5002   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5003   "{fnms|fnmsub} %0,%1,%2,%3"
5004   [(set_attr "type" "dmul")])
5005
5006 (define_expand "sqrtsf2"
5007   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5008         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5009   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
5010   "")
5011
5012 (define_insn ""
5013   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5014         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5015   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
5016   "fsqrts %0,%1"
5017   [(set_attr "type" "ssqrt")])
5018
5019 (define_insn ""
5020   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5021         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5022   "TARGET_POWER2 && TARGET_HARD_FLOAT"
5023   "fsqrt %0,%1"
5024   [(set_attr "type" "dsqrt")])
5025
5026 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5027 ;; fsel instruction and some auxiliary computations.  Then we just have a
5028 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5029 ;; combine.
5030 (define_expand "maxsf3"
5031   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5032         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5033                              (match_operand:SF 2 "gpc_reg_operand" ""))
5034                          (match_dup 1)
5035                          (match_dup 2)))]
5036   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5037   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5038
5039 (define_expand "minsf3"
5040   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5041         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5042                              (match_operand:SF 2 "gpc_reg_operand" ""))
5043                          (match_dup 2)
5044                          (match_dup 1)))]
5045   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5046   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5047
5048 (define_split
5049   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5050         (match_operator:SF 3 "min_max_operator"
5051          [(match_operand:SF 1 "gpc_reg_operand" "")
5052           (match_operand:SF 2 "gpc_reg_operand" "")]))]
5053   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5054   [(const_int 0)]
5055   "
5056 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5057                       operands[1], operands[2]);
5058   DONE;
5059 }")
5060
5061 (define_expand "movsfcc"
5062    [(set (match_operand:SF 0 "gpc_reg_operand" "")
5063          (if_then_else:SF (match_operand 1 "comparison_operator" "")
5064                           (match_operand:SF 2 "gpc_reg_operand" "")
5065                           (match_operand:SF 3 "gpc_reg_operand" "")))]
5066   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5067   "
5068 {
5069   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5070     DONE;
5071   else
5072     FAIL;
5073 }")
5074
5075 (define_insn "*fselsfsf4"
5076   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5077         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5078                              (match_operand:SF 4 "zero_fp_constant" "F"))
5079                          (match_operand:SF 2 "gpc_reg_operand" "f")
5080                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5081   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5082   "fsel %0,%1,%2,%3"
5083   [(set_attr "type" "fp")])
5084
5085 (define_insn "*fseldfsf4"
5086   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5087         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5088                              (match_operand:DF 4 "zero_fp_constant" "F"))
5089                          (match_operand:SF 2 "gpc_reg_operand" "f")
5090                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5091   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5092   "fsel %0,%1,%2,%3"
5093   [(set_attr "type" "fp")])
5094
5095 (define_insn "negdf2"
5096   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5097         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5098   "TARGET_HARD_FLOAT"
5099   "fneg %0,%1"
5100   [(set_attr "type" "fp")])
5101
5102 (define_insn "absdf2"
5103   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5104         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5105   "TARGET_HARD_FLOAT"
5106   "fabs %0,%1"
5107   [(set_attr "type" "fp")])
5108
5109 (define_insn ""
5110   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5111         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
5112   "TARGET_HARD_FLOAT"
5113   "fnabs %0,%1"
5114   [(set_attr "type" "fp")])
5115
5116 (define_insn "adddf3"
5117   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5118         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5119                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5120   "TARGET_HARD_FLOAT"
5121   "{fa|fadd} %0,%1,%2"
5122   [(set_attr "type" "fp")])
5123
5124 (define_insn "subdf3"
5125   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5126         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5127                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
5128   "TARGET_HARD_FLOAT"
5129   "{fs|fsub} %0,%1,%2"
5130   [(set_attr "type" "fp")])
5131
5132 (define_insn "muldf3"
5133   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5134         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5135                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5136   "TARGET_HARD_FLOAT"
5137   "{fm|fmul} %0,%1,%2"
5138   [(set_attr "type" "dmul")])
5139
5140 (define_insn "divdf3"
5141   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5142         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5143                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5144   "TARGET_HARD_FLOAT"
5145   "{fd|fdiv} %0,%1,%2"
5146   [(set_attr "type" "ddiv")])
5147
5148 (define_insn ""
5149   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5150         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5151                           (match_operand:DF 2 "gpc_reg_operand" "f"))
5152                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
5153   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5154   "{fma|fmadd} %0,%1,%2,%3"
5155   [(set_attr "type" "dmul")])
5156
5157 (define_insn ""
5158   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5159         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5160                            (match_operand:DF 2 "gpc_reg_operand" "f"))
5161                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
5162   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5163   "{fms|fmsub} %0,%1,%2,%3"
5164   [(set_attr "type" "dmul")])
5165
5166 (define_insn ""
5167   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5168         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5169                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
5170                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5171   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5172   "{fnma|fnmadd} %0,%1,%2,%3"
5173   [(set_attr "type" "dmul")])
5174
5175 (define_insn ""
5176   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5177         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5178                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
5179                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5180   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5181   "{fnms|fnmsub} %0,%1,%2,%3"
5182   [(set_attr "type" "dmul")])
5183
5184 (define_insn "sqrtdf2"
5185   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5186         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5187   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
5188   "fsqrt %0,%1"
5189   [(set_attr "type" "dsqrt")])
5190
5191 ;; The conditional move instructions allow us to perform max and min
5192 ;; operations even when 
5193
5194 (define_expand "maxdf3"
5195   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5196         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5197                              (match_operand:DF 2 "gpc_reg_operand" ""))
5198                          (match_dup 1)
5199                          (match_dup 2)))]
5200   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5201   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5202
5203 (define_expand "mindf3"
5204   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5205         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5206                              (match_operand:DF 2 "gpc_reg_operand" ""))
5207                          (match_dup 2)
5208                          (match_dup 1)))]
5209   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5210   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5211
5212 (define_split
5213   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5214         (match_operator:DF 3 "min_max_operator"
5215          [(match_operand:DF 1 "gpc_reg_operand" "")
5216           (match_operand:DF 2 "gpc_reg_operand" "")]))]
5217   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5218   [(const_int 0)]
5219   "
5220 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5221                       operands[1], operands[2]);
5222   DONE;
5223 }")
5224
5225 (define_expand "movdfcc"
5226    [(set (match_operand:DF 0 "gpc_reg_operand" "")
5227          (if_then_else:DF (match_operand 1 "comparison_operator" "")
5228                           (match_operand:DF 2 "gpc_reg_operand" "")
5229                           (match_operand:DF 3 "gpc_reg_operand" "")))]
5230   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5231   "
5232 {
5233   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5234     DONE;
5235   else
5236     FAIL;
5237 }")
5238
5239 (define_insn "*fseldfdf4"
5240   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5241         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5242                              (match_operand:DF 4 "zero_fp_constant" "F"))
5243                          (match_operand:DF 2 "gpc_reg_operand" "f")
5244                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5245   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5246   "fsel %0,%1,%2,%3"
5247   [(set_attr "type" "fp")])
5248
5249 (define_insn "*fselsfdf4"
5250   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5251         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5252                              (match_operand:SF 4 "zero_fp_constant" "F"))
5253                          (match_operand:DF 2 "gpc_reg_operand" "f")
5254                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5255   "TARGET_PPC_GFXOPT"
5256   "fsel %0,%1,%2,%3"
5257   [(set_attr "type" "fp")])
5258 \f
5259 ;; Conversions to and from floating-point.
5260
5261 ; For each of these conversions, there is a define_expand, a define_insn
5262 ; with a '#' template, and a define_split (with C code).  The idea is
5263 ; to allow constant folding with the template of the define_insn,
5264 ; then to have the insns split later (between sched1 and final).
5265
5266 (define_expand "floatsidf2"
5267   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5268                    (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5269               (use (match_dup 2))
5270               (use (match_dup 3))
5271               (clobber (match_dup 4))
5272               (clobber (match_dup 5))
5273               (clobber (match_dup 6))])]
5274   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5275   "
5276 {
5277   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5278   operands[3] = force_reg (DFmode, rs6000_float_const (\"4503601774854144\", DFmode));
5279   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5280   operands[5] = gen_reg_rtx (DFmode);
5281   operands[6] = gen_reg_rtx (SImode);
5282 }")
5283
5284 (define_insn "*floatsidf2_internal"
5285   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5286         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5287    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5288    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5289    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5290    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))
5291    (clobber (match_operand:SI 6 "gpc_reg_operand" "=r"))]
5292   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5293   "#"
5294   [(set_attr "length" "24")])
5295
5296 (define_split
5297   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5298         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5299    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5300    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5301    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5302    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5303    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5304   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5305   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5306         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5307    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5308    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5309    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5310    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5311    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5312   "
5313 {
5314   rtx lowword, highword;
5315   if (GET_CODE (operands[4]) != MEM)
5316     abort();
5317   highword = XEXP (operands[4], 0);
5318   lowword = plus_constant (highword, 4);
5319   if (! WORDS_BIG_ENDIAN)
5320     {
5321       rtx tmp;
5322       tmp = highword; highword = lowword; lowword = tmp;
5323     }
5324
5325   emit_insn (gen_xorsi3 (operands[6], operands[1], 
5326                          GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5327   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5328   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5329   emit_move_insn (operands[5], operands[4]);
5330   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5331   DONE;
5332 }")
5333
5334 (define_expand "floatunssidf2"
5335   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5336                    (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5337               (use (match_dup 2))
5338               (use (match_dup 3))
5339               (clobber (match_dup 4))
5340               (clobber (match_dup 5))])]
5341   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5342   "
5343 {
5344   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5345   operands[3] = force_reg (DFmode, rs6000_float_const (\"4503599627370496\", DFmode));
5346   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5347   operands[5] = gen_reg_rtx (DFmode);
5348 }")
5349
5350 (define_insn "*floatunssidf2_internal"
5351   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5352         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5353    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5354    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5355    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5356    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))]
5357   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5358   "#"
5359   [(set_attr "length" "20")])
5360
5361 (define_split
5362   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5363         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5364    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5365    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5366    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5367    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5368   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5369   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5370         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5371    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5372    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5373    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5374    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5375   "
5376 {
5377   rtx lowword, highword;
5378   if (GET_CODE (operands[4]) != MEM)
5379     abort();
5380   highword = XEXP (operands[4], 0);
5381   lowword = plus_constant (highword, 4);
5382   if (! WORDS_BIG_ENDIAN)
5383     {
5384       rtx tmp;
5385       tmp = highword; highword = lowword; lowword = tmp;
5386     }
5387
5388   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5389   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5390   emit_move_insn (operands[5], operands[4]);
5391   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5392   DONE;
5393 }")
5394
5395 (define_expand "fix_truncdfsi2"
5396   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5397                    (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5398               (clobber (match_dup 2))
5399               (clobber (match_dup 3))])]
5400   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5401   "
5402 {
5403   operands[2] = gen_reg_rtx (DImode);
5404   operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5405 }")
5406
5407 (define_insn "*fix_truncdfsi2_internal"
5408   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5409         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5410    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5411    (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5412   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5413   "#"
5414   [(set_attr "length" "16")])
5415
5416 (define_split
5417   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5418         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5419    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5420    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5421   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5422   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5423         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5424    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5425    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5426   "
5427 {
5428   rtx lowword;
5429   if (GET_CODE (operands[3]) != MEM)
5430     abort();
5431   lowword = XEXP (operands[3], 0);
5432   if (WORDS_BIG_ENDIAN)
5433     lowword = plus_constant (lowword, 4);
5434
5435   emit_insn (gen_fctiwz (operands[2], operands[1]));
5436   emit_move_insn (operands[3], operands[2]);
5437   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5438   DONE;
5439 }")
5440
5441 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] 10))
5442 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5443 ; because the first makes it clear that operand 0 is not live
5444 ; before the instruction.
5445 (define_insn "fctiwz"
5446   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
5447         (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))] 10))]
5448   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5449   "{fcirz|fctiwz} %0,%1"
5450   [(set_attr "type" "fp")])
5451
5452 (define_insn "floatdidf2"
5453   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5454         (float:DF (match_operand:DI 1 "gpc_reg_operand" "f")))]
5455   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5456   "fcfid %0,%1"
5457   [(set_attr "type" "fp")])
5458
5459 (define_insn "fix_truncdfdi2"
5460   [(set (match_operand:DI 0 "gpc_reg_operand" "=f")
5461         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5462   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5463   "fctidz %0,%1"
5464   [(set_attr "type" "fp")])
5465 \f
5466 ;; Define the DImode operations that can be done in a small number
5467 ;; of instructions.  The & constraints are to prevent the register
5468 ;; allocator from allocating registers that overlap with the inputs
5469 ;; (for example, having an input in 7,8 and an output in 6,7).  We
5470 ;; also allow for the output being the same as one of the inputs.
5471
5472 (define_insn "*adddi3_noppc64"
5473   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5474         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5475                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5476   "! TARGET_POWERPC64"
5477   "*
5478 {
5479   if (WORDS_BIG_ENDIAN)
5480     return (GET_CODE (operands[2])) != CONST_INT
5481             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5482             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5483   else
5484     return (GET_CODE (operands[2])) != CONST_INT
5485             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5486             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5487 }"
5488   [(set_attr "length" "8")])
5489
5490 (define_insn "*subdi3_noppc64"
5491   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5492         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5493                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5494   "! TARGET_POWERPC64"
5495   "*
5496 {
5497   if (WORDS_BIG_ENDIAN)
5498     return (GET_CODE (operands[1]) != CONST_INT)
5499             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5500             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5501   else
5502     return (GET_CODE (operands[1]) != CONST_INT)
5503             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5504             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5505 }"
5506   [(set_attr "length" "8")])
5507
5508 (define_insn "*negdi2_noppc64"
5509   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5510         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
5511   "! TARGET_POWERPC64"
5512   "*
5513 {
5514   return (WORDS_BIG_ENDIAN)
5515     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5516     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5517 }"
5518   [(set_attr "length" "8")])
5519
5520 (define_expand "mulsidi3"
5521   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5522         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5523                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5524   "! TARGET_POWERPC64"
5525   "
5526 {
5527   if (! TARGET_POWER && ! TARGET_POWERPC)
5528     {
5529       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5530       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5531       emit_insn (gen_mull_call ());
5532       if (WORDS_BIG_ENDIAN)
5533         emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
5534       else
5535         {
5536           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
5537                           gen_rtx_REG (SImode, 3));
5538           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
5539                           gen_rtx_REG (SImode, 4));
5540         }
5541       DONE;
5542     }
5543   else if (TARGET_POWER)
5544     {
5545       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5546       DONE;
5547     }
5548 }")
5549
5550 (define_insn "mulsidi3_mq"
5551   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5552         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5553                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5554    (clobber (match_scratch:SI 3 "=q"))]
5555   "TARGET_POWER"
5556   "mul %0,%1,%2\;mfmq %L0"
5557   [(set_attr "type" "imul")
5558    (set_attr "length" "8")])
5559
5560 (define_insn "*mulsidi3_no_mq"
5561   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5562         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5563                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5564   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5565   "*
5566 {
5567   return (WORDS_BIG_ENDIAN)
5568     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5569     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5570 }"
5571   [(set_attr "type" "imul")
5572    (set_attr "length" "8")])
5573
5574 (define_split
5575   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5576         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5577                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5578   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5579   [(set (match_dup 3)
5580         (truncate:SI
5581          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5582                                (sign_extend:DI (match_dup 2)))
5583                       (const_int 32))))
5584    (set (match_dup 4)
5585         (mult:SI (match_dup 1)
5586                  (match_dup 2)))]
5587   "
5588 {
5589   int endian = (WORDS_BIG_ENDIAN == 0);
5590   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5591   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5592 }")
5593
5594 (define_expand "umulsidi3"
5595   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5596         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5597                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5598   "TARGET_POWERPC && ! TARGET_POWERPC64"
5599   "
5600 {
5601   if (TARGET_POWER)
5602     {
5603       emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5604       DONE;
5605     }
5606 }")
5607
5608 (define_insn "umulsidi3_mq"
5609   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5610         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5611                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5612    (clobber (match_scratch:SI 3 "=q"))]
5613   "TARGET_POWERPC && TARGET_POWER"
5614   "*
5615 {
5616   return (WORDS_BIG_ENDIAN)
5617     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5618     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5619 }"
5620   [(set_attr "type" "imul")
5621    (set_attr "length" "8")])
5622
5623 (define_insn "*umulsidi3_no_mq"
5624   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5625         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5626                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5627   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5628   "*
5629 {
5630   return (WORDS_BIG_ENDIAN)
5631     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5632     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5633 }"
5634   [(set_attr "type" "imul")
5635    (set_attr "length" "8")])
5636
5637 (define_split
5638   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5639         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5640                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5641   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5642   [(set (match_dup 3)
5643         (truncate:SI
5644          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5645                                (zero_extend:DI (match_dup 2)))
5646                       (const_int 32))))
5647    (set (match_dup 4)
5648         (mult:SI (match_dup 1)
5649                  (match_dup 2)))]
5650   "
5651 {
5652   int endian = (WORDS_BIG_ENDIAN == 0);
5653   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5654   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5655 }")
5656
5657 (define_expand "smulsi3_highpart"
5658   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5659         (truncate:SI
5660          (lshiftrt:DI (mult:DI (sign_extend:DI
5661                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5662                                (sign_extend:DI
5663                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5664                       (const_int 32))))]
5665   ""
5666   "
5667 {
5668   if (! TARGET_POWER && ! TARGET_POWERPC)
5669     {
5670       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5671       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5672       emit_insn (gen_mulh_call ());
5673       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
5674       DONE;
5675     }
5676   else if (TARGET_POWER)
5677     {
5678       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5679       DONE;
5680     }
5681 }")
5682
5683 (define_insn "smulsi3_highpart_mq"
5684   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5685         (truncate:SI
5686          (lshiftrt:DI (mult:DI (sign_extend:DI
5687                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5688                                (sign_extend:DI
5689                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5690                       (const_int 32))))
5691    (clobber (match_scratch:SI 3 "=q"))]
5692   "TARGET_POWER"
5693   "mul %0,%1,%2"
5694   [(set_attr "type" "imul")])
5695
5696 (define_insn "*smulsi3_highpart_no_mq"
5697   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5698         (truncate:SI
5699          (lshiftrt:DI (mult:DI (sign_extend:DI
5700                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5701                                (sign_extend:DI
5702                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5703                       (const_int 32))))]
5704   "TARGET_POWERPC && ! TARGET_POWER"
5705   "mulhw %0,%1,%2"
5706   [(set_attr "type" "imul")])
5707
5708 (define_expand "umulsi3_highpart"
5709   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5710         (truncate:SI
5711          (lshiftrt:DI (mult:DI (zero_extend:DI
5712                                 (match_operand:SI 1 "gpc_reg_operand" ""))
5713                                (zero_extend:DI
5714                                 (match_operand:SI 2 "gpc_reg_operand" "")))
5715                       (const_int 32))))]
5716   "TARGET_POWERPC"
5717   "
5718 {
5719   if (TARGET_POWER)
5720     {
5721       emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5722       DONE;
5723     }
5724 }")
5725
5726 (define_insn "umulsi3_highpart_mq"
5727   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5728         (truncate:SI
5729          (lshiftrt:DI (mult:DI (zero_extend:DI
5730                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5731                                (zero_extend:DI
5732                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5733                       (const_int 32))))
5734    (clobber (match_scratch:SI 3 "=q"))]
5735   "TARGET_POWERPC && TARGET_POWER"
5736   "mulhwu %0,%1,%2"
5737   [(set_attr "type" "imul")])
5738
5739 (define_insn "*umulsi3_highpart_no_mq"
5740   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5741         (truncate:SI
5742          (lshiftrt:DI (mult:DI (zero_extend:DI
5743                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5744                                (zero_extend:DI
5745                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5746                       (const_int 32))))]
5747   "TARGET_POWERPC && ! TARGET_POWER"
5748   "mulhwu %0,%1,%2"
5749   [(set_attr "type" "imul")])
5750
5751 ;; If operands 0 and 2 are in the same register, we have a problem.  But
5752 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
5753 ;; why we have the strange constraints below.
5754 (define_insn "ashldi3_power"
5755   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5756         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5757                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5758    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5759   "TARGET_POWER"
5760   "@
5761    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5762    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5763    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5764    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5765   [(set_attr "length" "8")])
5766
5767 (define_insn "lshrdi3_power"
5768   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5769         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5770                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5771    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5772   "TARGET_POWER"
5773   "@
5774    {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
5775    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5776    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5777    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5778   [(set_attr "length" "8")])
5779
5780 ;; Shift by a variable amount is too complex to be worth open-coding.  We
5781 ;; just handle shifts by constants.
5782 (define_insn "ashrdi3_power"
5783   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5784         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5785                      (match_operand:SI 2 "const_int_operand" "M,i")))
5786    (clobber (match_scratch:SI 3 "=X,q"))]
5787   "TARGET_POWER"
5788   "@
5789    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5790    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5791   [(set_attr "length" "8")])
5792 \f
5793 ;; PowerPC64 DImode operations.
5794
5795 (define_expand "adddi3"
5796   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5797         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5798                  (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
5799   ""
5800   "
5801 {
5802   if (! TARGET_POWERPC64)
5803     {
5804       if (non_short_cint_operand (operands[2], DImode))
5805         FAIL;
5806     }
5807   else
5808     if (GET_CODE (operands[2]) == CONST_INT
5809         && ! add_operand (operands[2], DImode))
5810       {
5811         rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
5812                    ? operands[0] : gen_reg_rtx (DImode));
5813
5814         HOST_WIDE_INT val = INTVAL (operands[2]);
5815         HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5816         HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5817
5818         if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5819           FAIL;
5820
5821         /* The ordering here is important for the prolog expander.
5822            When space is allocated from the stack, adding 'low' first may
5823            produce a temporary deallocation (which would be bad).  */
5824         emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
5825         emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5826         DONE;
5827       }
5828 }")
5829
5830 ;; Discourage ai/addic because of carry but provide it in an alternative
5831 ;; allowing register zero as source.
5832
5833 (define_insn "*adddi3_internal1"
5834   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5835         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
5836                  (match_operand:DI 2 "add_operand" "r,I,I,L")))]
5837   "TARGET_POWERPC64"
5838   "@
5839    add %0,%1,%2
5840    addi %0,%1,%2
5841    addic %0,%1,%2
5842    addis %0,%1,%v2")
5843
5844 (define_insn "*adddi3_internal2"
5845   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
5846         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5847                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5848                     (const_int 0)))
5849    (clobber (match_scratch:DI 3 "=r,r,r,r"))]
5850   "TARGET_POWERPC64"
5851   "@
5852    add. %3,%1,%2
5853    addic. %3,%1,%2
5854    #
5855    #"
5856   [(set_attr "type" "compare")
5857    (set_attr "length" "4,4,8,8")])
5858
5859 (define_split
5860   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5861         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5862                              (match_operand:DI 2 "reg_or_short_operand" ""))
5863                     (const_int 0)))
5864    (clobber (match_scratch:DI 3 ""))]
5865   "TARGET_POWERPC64 && reload_completed"
5866   [(set (match_dup 3)
5867         (plus:DI (match_dup 1) (match_dup 2)))
5868    (set (match_dup 0)
5869         (compare:CC (match_dup 3)
5870                     (const_int 0)))]
5871   "")
5872
5873 (define_insn "*adddi3_internal3"
5874   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
5875         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
5876                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
5877                     (const_int 0)))
5878    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
5879         (plus:DI (match_dup 1) (match_dup 2)))]
5880   "TARGET_POWERPC64"
5881   "@
5882    add. %0,%1,%2
5883    addic. %0,%1,%2
5884    #
5885    #"
5886   [(set_attr "type" "compare")
5887    (set_attr "length" "4,4,8,8")])
5888
5889 (define_split
5890   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
5891         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5892                              (match_operand:DI 2 "reg_or_short_operand" ""))
5893                     (const_int 0)))
5894    (set (match_operand:DI 0 "gpc_reg_operand" "")
5895         (plus:DI (match_dup 1) (match_dup 2)))]
5896   "TARGET_POWERPC64 && reload_completed"
5897   [(set (match_dup 0)
5898         (plus:DI (match_dup 1) (match_dup 2)))
5899    (set (match_dup 3)
5900         (compare:CC (match_dup 0)
5901                     (const_int 0)))]
5902   "")
5903
5904 ;; Split an add that we can't do in one insn into two insns, each of which
5905 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
5906 ;; add should be last in case the result gets used in an address.
5907
5908 (define_split
5909   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5910         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5911                  (match_operand:DI 2 "non_add_cint_operand" "")))]
5912   "TARGET_POWERPC64"
5913   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
5914    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
5915 "
5916 {
5917   HOST_WIDE_INT val = INTVAL (operands[2]);
5918   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5919   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5920
5921   operands[4] = GEN_INT (low);
5922   if (CONST_OK_FOR_LETTER_P (rest, 'L'))
5923     operands[3] = GEN_INT (rest);
5924   else if (! no_new_pseudos)
5925     {
5926       operands[3] = gen_reg_rtx (DImode);
5927       emit_move_insn (operands[3], operands[2]);
5928       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
5929       DONE;
5930     }
5931   else
5932     FAIL;
5933 }")
5934
5935 (define_insn "one_cmpldi2"
5936   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5937         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
5938   "TARGET_POWERPC64"
5939   "nor %0,%1,%1")
5940
5941 (define_insn ""
5942   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
5943         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5944                     (const_int 0)))
5945    (clobber (match_scratch:DI 2 "=r,r"))]
5946   "TARGET_POWERPC64"
5947   "@
5948    nor. %2,%1,%1
5949    #"
5950   [(set_attr "type" "compare")
5951    (set_attr "length" "4,8")])
5952
5953 (define_split
5954   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
5955         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5956                     (const_int 0)))
5957    (clobber (match_scratch:DI 2 ""))]
5958   "TARGET_POWERPC64 && reload_completed"
5959   [(set (match_dup 2)
5960         (not:DI (match_dup 1)))
5961    (set (match_dup 0)
5962         (compare:CC (match_dup 2)
5963                     (const_int 0)))]
5964   "")
5965
5966 (define_insn ""
5967   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
5968         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
5969                     (const_int 0)))
5970    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5971         (not:DI (match_dup 1)))]
5972   "TARGET_POWERPC64"
5973   "@
5974    nor. %0,%1,%1
5975    #"
5976   [(set_attr "type" "compare")
5977    (set_attr "length" "4,8")])
5978
5979 (define_split
5980   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
5981         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
5982                     (const_int 0)))
5983    (set (match_operand:DI 0 "gpc_reg_operand" "")
5984         (not:DI (match_dup 1)))]
5985   "TARGET_POWERPC64 && reload_completed"
5986   [(set (match_dup 0)
5987         (not:DI (match_dup 1)))
5988    (set (match_dup 2)
5989         (compare:CC (match_dup 0)
5990                     (const_int 0)))]
5991   "")
5992
5993 (define_insn ""
5994   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
5995         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
5996                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
5997   "TARGET_POWERPC64"
5998   "@
5999    subf %0,%2,%1
6000    subfic %0,%2,%1")
6001
6002 (define_insn ""
6003   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6004         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6005                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6006                     (const_int 0)))
6007    (clobber (match_scratch:DI 3 "=r,r"))]
6008   "TARGET_POWERPC64"
6009   "@
6010    subf. %3,%2,%1
6011    #"
6012   [(set_attr "type" "compare")
6013    (set_attr "length" "4,8")])
6014
6015 (define_split
6016   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6017         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6018                               (match_operand:DI 2 "gpc_reg_operand" ""))
6019                     (const_int 0)))
6020    (clobber (match_scratch:DI 3 ""))]
6021   "TARGET_POWERPC64 && reload_completed"
6022   [(set (match_dup 3)
6023         (minus:DI (match_dup 1) (match_dup 2)))
6024    (set (match_dup 0)
6025         (compare:CC (match_dup 3)
6026                     (const_int 0)))]
6027   "")
6028
6029 (define_insn ""
6030   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6031         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6032                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6033                     (const_int 0)))
6034    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6035         (minus:DI (match_dup 1) (match_dup 2)))]
6036   "TARGET_POWERPC64"
6037   "@
6038    subf. %0,%2,%1
6039    #"
6040   [(set_attr "type" "compare")
6041    (set_attr "length" "4,8")])
6042
6043 (define_split
6044   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6045         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6046                               (match_operand:DI 2 "gpc_reg_operand" ""))
6047                     (const_int 0)))
6048    (set (match_operand:DI 0 "gpc_reg_operand" "")
6049         (minus:DI (match_dup 1) (match_dup 2)))]
6050   "TARGET_POWERPC64 && reload_completed"
6051   [(set (match_dup 0)
6052         (minus:DI (match_dup 1) (match_dup 2)))
6053    (set (match_dup 3)
6054         (compare:CC (match_dup 0)
6055                     (const_int 0)))]
6056   "")
6057
6058 (define_expand "subdi3"
6059   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6060         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
6061                   (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
6062   ""
6063   "
6064 {
6065   if (GET_CODE (operands[2]) == CONST_INT)
6066     {
6067       emit_insn (gen_adddi3 (operands[0], operands[1],
6068                              negate_rtx (DImode, operands[2])));
6069       DONE;
6070     }
6071 }")
6072
6073 (define_insn "absdi2"
6074   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6075         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
6076    (clobber (match_scratch:DI 2 "=&r,&r"))]
6077   "TARGET_POWERPC64"
6078   "sradi %2,%1,63\;xor %0,%2,%1\;subf %0,%2,%0"
6079   [(set_attr "length" "12")])
6080
6081 (define_split
6082   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6083         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
6084    (clobber (match_scratch:DI 2 ""))]
6085   "TARGET_POWERPC64 && reload_completed"
6086   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6087    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6088    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
6089   "")
6090
6091 (define_insn "*nabsdi2"
6092   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6093         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
6094    (clobber (match_scratch:DI 2 "=&r,&r"))]
6095   "TARGET_POWERPC64"
6096   "sradi %2,%1,63\;xor %0,%2,%1\;subf %0,%0,%2"
6097   [(set_attr "length" "12")])
6098
6099 (define_split
6100   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6101         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" ""))))
6102    (clobber (match_scratch:DI 2 ""))]
6103   "TARGET_POWERPC64 && reload_completed"
6104   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6105    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6106    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
6107   "")
6108
6109 (define_expand "negdi2"
6110   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6111         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
6112   ""
6113   "")
6114
6115 (define_insn ""
6116   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6117         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6118   "TARGET_POWERPC64"
6119   "neg %0,%1")
6120
6121 (define_insn ""
6122   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6123         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6124                     (const_int 0)))
6125    (clobber (match_scratch:DI 2 "=r,r"))]
6126   "TARGET_POWERPC64"
6127   "@
6128    neg. %2,%1
6129    #"
6130   [(set_attr "type" "compare")
6131    (set_attr "length" "4,8")])
6132
6133 (define_split
6134   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6135         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6136                     (const_int 0)))
6137    (clobber (match_scratch:DI 2 ""))]
6138   "TARGET_POWERPC64 && reload_completed"
6139   [(set (match_dup 2)
6140         (neg:DI (match_dup 1)))
6141    (set (match_dup 0)
6142         (compare:CC (match_dup 2)
6143                     (const_int 0)))]
6144   "")
6145
6146 (define_insn ""
6147   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6148         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6149                     (const_int 0)))
6150    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6151         (neg:DI (match_dup 1)))]
6152   "TARGET_POWERPC64"
6153   "@
6154    neg. %0,%1
6155    #"
6156   [(set_attr "type" "compare")
6157    (set_attr "length" "4,8")])
6158
6159 (define_split
6160   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6161         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6162                     (const_int 0)))
6163    (set (match_operand:DI 0 "gpc_reg_operand" "")
6164         (neg:DI (match_dup 1)))]
6165   "TARGET_POWERPC64 && reload_completed"
6166   [(set (match_dup 0)
6167         (neg:DI (match_dup 1)))
6168    (set (match_dup 2)
6169         (compare:CC (match_dup 0)
6170                     (const_int 0)))]
6171   "")
6172
6173 (define_insn "ffsdi2"
6174   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6175         (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6176   "TARGET_POWERPC64"
6177   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
6178   [(set_attr "length" "16")])
6179
6180 (define_insn "muldi3"
6181   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6182         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6183                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6184   "TARGET_POWERPC64"
6185   "mulld %0,%1,%2"
6186    [(set_attr "type" "lmul")])
6187
6188 (define_insn "smuldi3_highpart"
6189   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6190         (truncate:DI
6191          (lshiftrt:TI (mult:TI (sign_extend:TI
6192                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6193                                (sign_extend:TI
6194                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6195                       (const_int 64))))]
6196   "TARGET_POWERPC64"
6197   "mulhd %0,%1,%2"
6198   [(set_attr "type" "lmul")])
6199
6200 (define_insn "umuldi3_highpart"
6201   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6202         (truncate:DI
6203          (lshiftrt:TI (mult:TI (zero_extend:TI
6204                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6205                                (zero_extend:TI
6206                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6207                       (const_int 64))))]
6208   "TARGET_POWERPC64"
6209   "mulhdu %0,%1,%2"
6210   [(set_attr "type" "lmul")])
6211
6212 (define_expand "divdi3"
6213   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6214         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6215                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6216   "TARGET_POWERPC64"
6217   "
6218 {
6219   if (GET_CODE (operands[2]) == CONST_INT
6220       && INTVAL (operands[2]) > 0
6221       && exact_log2 (INTVAL (operands[2])) >= 0)
6222     ;
6223   else
6224     operands[2] = force_reg (DImode, operands[2]);
6225 }")
6226
6227 (define_expand "moddi3"
6228   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6229    (use (match_operand:DI 1 "gpc_reg_operand" ""))
6230    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6231   "TARGET_POWERPC64"
6232   "
6233 {
6234   int i;
6235   rtx temp1;
6236   rtx temp2;
6237
6238   if (GET_CODE (operands[2]) != CONST_INT
6239       || INTVAL (operands[2]) <= 0
6240       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
6241     FAIL;
6242
6243   temp1 = gen_reg_rtx (DImode);
6244   temp2 = gen_reg_rtx (DImode);
6245
6246   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6247   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6248   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6249   DONE;
6250 }")
6251
6252 (define_insn ""
6253   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6254         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6255                 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6256   "TARGET_POWERPC64"
6257   "sradi %0,%1,%p2\;addze %0,%0"
6258   [(set_attr "length" "8")])
6259
6260 (define_insn ""
6261   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6262         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6263                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6264                     (const_int 0)))
6265    (clobber (match_scratch:DI 3 "=r,r"))]
6266   "TARGET_POWERPC64"
6267   "@
6268    sradi %3,%1,%p2\;addze. %3,%3
6269    #"
6270   [(set_attr "type" "compare")
6271    (set_attr "length" "8,12")])
6272
6273 (define_split
6274   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6275         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6276                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6277                     (const_int 0)))
6278    (clobber (match_scratch:DI 3 ""))]
6279   "TARGET_POWERPC64 && reload_completed"
6280   [(set (match_dup 3)
6281         (div:DI (match_dup 1) (match_dup 2)))
6282    (set (match_dup 0)
6283         (compare:CC (match_dup 3)
6284                     (const_int 0)))]
6285   "")
6286
6287 (define_insn ""
6288   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6289         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6290                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6291                     (const_int 0)))
6292    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6293         (div:DI (match_dup 1) (match_dup 2)))]
6294   "TARGET_POWERPC64"
6295   "@
6296    sradi %0,%1,%p2\;addze. %0,%0
6297    #"
6298   [(set_attr "type" "compare")
6299    (set_attr "length" "8,12")])
6300
6301 (define_split
6302   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6303         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6304                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6305                     (const_int 0)))
6306    (set (match_operand:DI 0 "gpc_reg_operand" "")
6307         (div:DI (match_dup 1) (match_dup 2)))]
6308   "TARGET_POWERPC64 && reload_completed"
6309   [(set (match_dup 0)
6310         (div:DI (match_dup 1) (match_dup 2)))
6311    (set (match_dup 3)
6312         (compare:CC (match_dup 0)
6313                     (const_int 0)))]
6314   "")
6315
6316 (define_insn ""
6317   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6318         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6319                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6320   "TARGET_POWERPC64"
6321   "divd %0,%1,%2"
6322   [(set_attr "type" "ldiv")])
6323
6324 (define_insn "udivdi3"
6325   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6326         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6327                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6328   "TARGET_POWERPC64"
6329   "divdu %0,%1,%2"
6330   [(set_attr "type" "ldiv")])
6331
6332 (define_insn "rotldi3"
6333   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6334         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6335                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6336   "TARGET_POWERPC64"
6337   "rld%I2cl %0,%1,%H2,0")
6338
6339 (define_insn "*rotldi3_internal2"
6340   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6341         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6342                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6343                     (const_int 0)))
6344    (clobber (match_scratch:DI 3 "=r,r"))]
6345   "TARGET_POWERPC64"
6346   "@
6347    rld%I2cl. %3,%1,%H2,0
6348    #"
6349   [(set_attr "type" "delayed_compare")
6350    (set_attr "length" "4,8")])
6351
6352 (define_split
6353   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6354         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6355                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6356                     (const_int 0)))
6357    (clobber (match_scratch:DI 3 ""))]
6358   "TARGET_POWERPC64 && reload_completed"
6359   [(set (match_dup 3)
6360         (rotate:DI (match_dup 1) (match_dup 2)))
6361    (set (match_dup 0)
6362         (compare:CC (match_dup 3)
6363                     (const_int 0)))]
6364   "")
6365
6366 (define_insn "*rotldi3_internal3"
6367   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6368         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6369                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6370                     (const_int 0)))
6371    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6372         (rotate:DI (match_dup 1) (match_dup 2)))]
6373   "TARGET_POWERPC64"
6374   "@
6375    rld%I2cl. %0,%1,%H2,0
6376    #"
6377   [(set_attr "type" "delayed_compare")
6378    (set_attr "length" "4,8")])
6379
6380 (define_split
6381   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6382         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6383                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6384                     (const_int 0)))
6385    (set (match_operand:DI 0 "gpc_reg_operand" "")
6386         (rotate:DI (match_dup 1) (match_dup 2)))]
6387   "TARGET_POWERPC64 && reload_completed"
6388   [(set (match_dup 0)
6389         (rotate:DI (match_dup 1) (match_dup 2)))
6390    (set (match_dup 3)
6391         (compare:CC (match_dup 0)
6392                     (const_int 0)))]
6393   "")
6394
6395 (define_insn "*rotldi3_internal4"
6396   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6397         (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6398                            (match_operand:DI 2 "reg_or_cint_operand" "ri"))
6399                 (match_operand:DI 3 "mask64_operand" "S")))]
6400   "TARGET_POWERPC64"
6401   "rld%I2c%B3 %0,%1,%H2,%S3")
6402
6403 (define_insn "*rotldi3_internal5"
6404   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6405         (compare:CC (and:DI
6406                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6407                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6408                      (match_operand:DI 3 "mask64_operand" "S,S"))
6409                     (const_int 0)))
6410    (clobber (match_scratch:DI 4 "=r,r"))]
6411   "TARGET_POWERPC64"
6412   "@
6413    rld%I2c%B3. %4,%1,%H2,%S3
6414    #"
6415   [(set_attr "type" "delayed_compare")
6416    (set_attr "length" "4,8")])
6417
6418 (define_split
6419   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6420         (compare:CC (and:DI
6421                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6422                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6423                      (match_operand:DI 3 "mask64_operand" ""))
6424                     (const_int 0)))
6425    (clobber (match_scratch:DI 4 ""))]
6426   "TARGET_POWERPC64 && reload_completed"
6427   [(set (match_dup 4)
6428         (and:DI (rotate:DI (match_dup 1)
6429                                 (match_dup 2))
6430                      (match_dup 3)))
6431    (set (match_dup 0)
6432         (compare:CC (match_dup 4)
6433                     (const_int 0)))]
6434   "")
6435
6436 (define_insn "*rotldi3_internal6"
6437   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6438         (compare:CC (and:DI
6439                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6440                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6441                      (match_operand:DI 3 "mask64_operand" "S,S"))
6442                     (const_int 0)))
6443    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6444         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6445   "TARGET_POWERPC64"
6446   "@
6447    rld%I2c%B3. %0,%1,%H2,%S3
6448    #"
6449   [(set_attr "type" "delayed_compare")
6450    (set_attr "length" "4,8")])
6451
6452 (define_split
6453   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6454         (compare:CC (and:DI
6455                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6456                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6457                      (match_operand:DI 3 "mask64_operand" ""))
6458                     (const_int 0)))
6459    (set (match_operand:DI 0 "gpc_reg_operand" "")
6460         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6461   "TARGET_POWERPC64 && reload_completed"
6462   [(set (match_dup 0)
6463         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6464    (set (match_dup 4)
6465         (compare:CC (match_dup 0)
6466                     (const_int 0)))]
6467   "")
6468
6469 (define_insn "*rotldi3_internal7"
6470   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6471         (zero_extend:DI
6472          (subreg:QI
6473           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6474                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6475   "TARGET_POWERPC64"
6476   "rld%I2cl %0,%1,%H2,56")
6477
6478 (define_insn "*rotldi3_internal8"
6479   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6480         (compare:CC (zero_extend:DI
6481                      (subreg:QI
6482                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6483                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6484                     (const_int 0)))
6485    (clobber (match_scratch:DI 3 "=r,r"))]
6486   "TARGET_POWERPC64"
6487   "@
6488    rld%I2cl. %3,%1,%H2,56
6489    #"
6490   [(set_attr "type" "delayed_compare")
6491    (set_attr "length" "4,8")])
6492
6493 (define_split
6494   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6495         (compare:CC (zero_extend:DI
6496                      (subreg:QI
6497                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6498                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6499                     (const_int 0)))
6500    (clobber (match_scratch:DI 3 ""))]
6501   "TARGET_POWERPC64 && reload_completed"
6502   [(set (match_dup 3)
6503         (zero_extend:DI (subreg:QI
6504                       (rotate:DI (match_dup 1)
6505                                  (match_dup 2)) 0)))
6506    (set (match_dup 0)
6507         (compare:CC (match_dup 3)
6508                     (const_int 0)))]
6509   "")
6510
6511 (define_insn "*rotldi3_internal9"
6512   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6513         (compare:CC (zero_extend:DI
6514                      (subreg:QI
6515                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6516                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6517                     (const_int 0)))
6518    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6519         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6520   "TARGET_POWERPC64"
6521   "@
6522    rld%I2cl. %0,%1,%H2,56
6523    #"
6524   [(set_attr "type" "delayed_compare")
6525    (set_attr "length" "4,8")])
6526
6527 (define_split
6528   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6529         (compare:CC (zero_extend:DI
6530                      (subreg:QI
6531                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6532                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6533                     (const_int 0)))
6534    (set (match_operand:DI 0 "gpc_reg_operand" "")
6535         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6536   "TARGET_POWERPC64 && reload_completed"
6537   [(set (match_dup 0)
6538         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6539    (set (match_dup 3)
6540         (compare:CC (match_dup 0)
6541                     (const_int 0)))]
6542   "")
6543
6544 (define_insn "*rotldi3_internal10"
6545   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6546         (zero_extend:DI
6547          (subreg:HI
6548           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6549                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6550   "TARGET_POWERPC64"
6551   "rld%I2cl %0,%1,%H2,48")
6552
6553 (define_insn "*rotldi3_internal11"
6554   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6555         (compare:CC (zero_extend:DI
6556                      (subreg:HI
6557                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6558                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6559                     (const_int 0)))
6560    (clobber (match_scratch:DI 3 "=r,r"))]
6561   "TARGET_POWERPC64"
6562   "@
6563    rld%I2cl. %3,%1,%H2,48
6564    #"
6565   [(set_attr "type" "delayed_compare")
6566    (set_attr "length" "4,8")])
6567
6568 (define_split
6569   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6570         (compare:CC (zero_extend:DI
6571                      (subreg:HI
6572                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6573                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6574                     (const_int 0)))
6575    (clobber (match_scratch:DI 3 ""))]
6576   "TARGET_POWERPC64 && reload_completed"
6577   [(set (match_dup 3)
6578         (zero_extend:DI (subreg:HI
6579                       (rotate:DI (match_dup 1)
6580                                  (match_dup 2)) 0)))
6581    (set (match_dup 0)
6582         (compare:CC (match_dup 3)
6583                     (const_int 0)))]
6584   "")
6585
6586 (define_insn "*rotldi3_internal12"
6587   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6588         (compare:CC (zero_extend:DI
6589                      (subreg:HI
6590                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6591                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6592                     (const_int 0)))
6593    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6594         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6595   "TARGET_POWERPC64"
6596   "@
6597    rld%I2cl. %0,%1,%H2,48
6598    #"
6599   [(set_attr "type" "delayed_compare")
6600    (set_attr "length" "4,8")])
6601
6602 (define_split
6603   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6604         (compare:CC (zero_extend:DI
6605                      (subreg:HI
6606                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6607                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6608                     (const_int 0)))
6609    (set (match_operand:DI 0 "gpc_reg_operand" "")
6610         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6611   "TARGET_POWERPC64 && reload_completed"
6612   [(set (match_dup 0)
6613         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6614    (set (match_dup 3)
6615         (compare:CC (match_dup 0)
6616                     (const_int 0)))]
6617   "")
6618
6619 (define_insn "*rotldi3_internal13"
6620   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6621         (zero_extend:DI
6622          (subreg:SI
6623           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6624                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6625   "TARGET_POWERPC64"
6626   "rld%I2cl %0,%1,%H2,32")
6627
6628 (define_insn "*rotldi3_internal14"
6629   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6630         (compare:CC (zero_extend:DI
6631                      (subreg:SI
6632                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6633                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6634                     (const_int 0)))
6635    (clobber (match_scratch:DI 3 "=r,r"))]
6636   "TARGET_POWERPC64"
6637   "@
6638    rld%I2cl. %3,%1,%H2,32
6639    #"
6640   [(set_attr "type" "delayed_compare")
6641    (set_attr "length" "4,8")])
6642
6643 (define_split
6644   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6645         (compare:CC (zero_extend:DI
6646                      (subreg:SI
6647                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6648                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6649                     (const_int 0)))
6650    (clobber (match_scratch:DI 3 ""))]
6651   "TARGET_POWERPC64 && reload_completed"
6652   [(set (match_dup 3)
6653         (zero_extend:DI (subreg:SI
6654                       (rotate:DI (match_dup 1)
6655                                  (match_dup 2)) 0)))
6656    (set (match_dup 0)
6657         (compare:CC (match_dup 3)
6658                     (const_int 0)))]
6659   "")
6660
6661 (define_insn "*rotldi3_internal15"
6662   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6663         (compare:CC (zero_extend:DI
6664                      (subreg:SI
6665                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6666                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6667                     (const_int 0)))
6668    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6669         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6670   "TARGET_POWERPC64"
6671   "@
6672    rld%I2cl. %0,%1,%H2,32
6673    #"
6674   [(set_attr "type" "delayed_compare")
6675    (set_attr "length" "4,8")])
6676
6677 (define_split
6678   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6679         (compare:CC (zero_extend:DI
6680                      (subreg:SI
6681                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6682                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6683                     (const_int 0)))
6684    (set (match_operand:DI 0 "gpc_reg_operand" "")
6685         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6686   "TARGET_POWERPC64 && reload_completed"
6687   [(set (match_dup 0)
6688         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6689    (set (match_dup 3)
6690         (compare:CC (match_dup 0)
6691                     (const_int 0)))]
6692   "")
6693
6694 (define_expand "ashldi3"
6695   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6696         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6697                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
6698   "TARGET_POWERPC64 || TARGET_POWER"
6699   "
6700 {
6701   if (TARGET_POWERPC64)
6702     ;
6703   else if (TARGET_POWER)
6704     {
6705       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6706       DONE;
6707     }
6708   else
6709     FAIL;
6710 }")
6711
6712 (define_insn "*ashldi3_internal1"
6713   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6714         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6715                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6716   "TARGET_POWERPC64"
6717   "sld%I2 %0,%1,%H2"
6718   [(set_attr "length" "8")])
6719   
6720 (define_insn "*ashldi3_internal2"
6721   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6722         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6723                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6724                     (const_int 0)))
6725    (clobber (match_scratch:DI 3 "=r,r"))]
6726   "TARGET_POWERPC64"
6727   "@
6728    sld%I2. %3,%1,%H2
6729    #"
6730   [(set_attr "type" "delayed_compare")
6731    (set_attr "length" "4,8")])
6732   
6733 (define_split
6734   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6735         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6736                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6737                     (const_int 0)))
6738    (clobber (match_scratch:DI 3 ""))]
6739   "TARGET_POWERPC64 && reload_completed"
6740   [(set (match_dup 3)
6741         (ashift:DI (match_dup 1) (match_dup 2)))
6742    (set (match_dup 0)
6743         (compare:CC (match_dup 3)
6744                     (const_int 0)))]
6745   "")
6746
6747 (define_insn "*ashldi3_internal3"
6748   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6749         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6750                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6751                     (const_int 0)))
6752    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6753         (ashift:DI (match_dup 1) (match_dup 2)))]
6754   "TARGET_POWERPC64"
6755   "@
6756    sld%I2. %0,%1,%H2
6757    #"
6758   [(set_attr "type" "delayed_compare")
6759    (set_attr "length" "4,8")])
6760
6761 (define_split
6762   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6763         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6764                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6765                     (const_int 0)))
6766    (set (match_operand:DI 0 "gpc_reg_operand" "")
6767         (ashift:DI (match_dup 1) (match_dup 2)))]
6768   "TARGET_POWERPC64 && reload_completed"
6769   [(set (match_dup 0)
6770         (ashift:DI (match_dup 1) (match_dup 2)))
6771    (set (match_dup 3)
6772         (compare:CC (match_dup 0)
6773                     (const_int 0)))]
6774   "")
6775
6776 (define_insn "*ashldi3_internal4"
6777   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6778         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6779                            (match_operand:SI 2 "const_int_operand" "i"))
6780                 (match_operand:DI 3 "const_int_operand" "n")))]
6781   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6782   "rldic %0,%1,%H2,%W3")
6783
6784 (define_insn "ashldi3_internal5"
6785   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6786         (compare:CC
6787          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6788                             (match_operand:SI 2 "const_int_operand" "i,i"))
6789                  (match_operand:DI 3 "const_int_operand" "n,n"))
6790          (const_int 0)))
6791    (clobber (match_scratch:DI 4 "=r,r"))]
6792   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6793   "@
6794    rldic. %4,%1,%H2,%W3
6795    #"
6796   [(set_attr "type" "delayed_compare")
6797    (set_attr "length" "4,8")])
6798
6799 (define_split
6800   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6801         (compare:CC
6802          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6803                             (match_operand:SI 2 "const_int_operand" ""))
6804                  (match_operand:DI 3 "const_int_operand" ""))
6805          (const_int 0)))
6806    (clobber (match_scratch:DI 4 ""))]
6807   "TARGET_POWERPC64 && reload_completed
6808    && includes_rldic_lshift_p (operands[2], operands[3])"
6809   [(set (match_dup 4)
6810         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6811                 (match_dup 3)))
6812    (set (match_dup 0)
6813         (compare:CC (match_dup 4)
6814                     (const_int 0)))]
6815   "")
6816
6817 (define_insn "*ashldi3_internal6"
6818   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6819         (compare:CC
6820          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6821                             (match_operand:SI 2 "const_int_operand" "i,i"))
6822                     (match_operand:DI 3 "const_int_operand" "n,n"))
6823          (const_int 0)))
6824    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6825         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6826   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6827   "@
6828    rldic. %0,%1,%H2,%W3
6829    #"
6830   [(set_attr "type" "delayed_compare")
6831    (set_attr "length" "4,8")])
6832
6833 (define_split
6834   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6835         (compare:CC
6836          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6837                             (match_operand:SI 2 "const_int_operand" ""))
6838                  (match_operand:DI 3 "const_int_operand" ""))
6839          (const_int 0)))
6840    (set (match_operand:DI 0 "gpc_reg_operand" "")
6841         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6842   "TARGET_POWERPC64 && reload_completed
6843    && includes_rldic_lshift_p (operands[2], operands[3])"
6844   [(set (match_dup 0)
6845         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6846                 (match_dup 3)))
6847    (set (match_dup 4)
6848         (compare:CC (match_dup 0)
6849                     (const_int 0)))]
6850   "")
6851
6852 (define_insn "*ashldi3_internal7"
6853   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6854         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6855                            (match_operand:SI 2 "const_int_operand" "i"))
6856                 (match_operand:DI 3 "mask64_operand" "S")))]
6857   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6858   "rldicr %0,%1,%H2,%S3")
6859
6860 (define_insn "ashldi3_internal8"
6861   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6862         (compare:CC
6863          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6864                             (match_operand:SI 2 "const_int_operand" "i,i"))
6865                  (match_operand:DI 3 "mask64_operand" "S,S"))
6866          (const_int 0)))
6867    (clobber (match_scratch:DI 4 "=r,r"))]
6868   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6869   "@
6870    rldicr. %4,%1,%H2,%S3
6871    #"
6872   [(set_attr "type" "delayed_compare")
6873    (set_attr "length" "4,8")])
6874
6875 (define_split
6876   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6877         (compare:CC
6878          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6879                             (match_operand:SI 2 "const_int_operand" ""))
6880                  (match_operand:DI 3 "mask64_operand" ""))
6881          (const_int 0)))
6882    (clobber (match_scratch:DI 4 ""))]
6883   "TARGET_POWERPC64 && reload_completed
6884    && includes_rldicr_lshift_p (operands[2], operands[3])"
6885   [(set (match_dup 4)
6886         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6887                 (match_dup 3)))
6888    (set (match_dup 0)
6889         (compare:CC (match_dup 4)
6890                     (const_int 0)))]
6891   "")
6892
6893 (define_insn "*ashldi3_internal9"
6894   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6895         (compare:CC
6896          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6897                             (match_operand:SI 2 "const_int_operand" "i,i"))
6898                     (match_operand:DI 3 "mask64_operand" "S,S"))
6899          (const_int 0)))
6900    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6901         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6902   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
6903   "@
6904    rldicr. %0,%1,%H2,%S3
6905    #"
6906   [(set_attr "type" "delayed_compare")
6907    (set_attr "length" "4,8")])
6908
6909 (define_split
6910   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6911         (compare:CC
6912          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6913                             (match_operand:SI 2 "const_int_operand" ""))
6914                  (match_operand:DI 3 "mask64_operand" ""))
6915          (const_int 0)))
6916    (set (match_operand:DI 0 "gpc_reg_operand" "")
6917         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6918   "TARGET_POWERPC64 && reload_completed
6919    && includes_rldicr_lshift_p (operands[2], operands[3])"
6920   [(set (match_dup 0)
6921         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6922                 (match_dup 3)))
6923    (set (match_dup 4)
6924         (compare:CC (match_dup 0)
6925                     (const_int 0)))]
6926   "")
6927
6928 (define_expand "lshrdi3"
6929   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6930         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6931                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
6932   "TARGET_POWERPC64 || TARGET_POWER"
6933   "
6934 {
6935   if (TARGET_POWERPC64)
6936     ;
6937   else if (TARGET_POWER)
6938     {
6939       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
6940       DONE;
6941     }
6942   else
6943     FAIL;
6944 }")
6945
6946 (define_insn "*lshrdi3_internal1"
6947   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6948         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6949                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6950   "TARGET_POWERPC64"
6951   "srd%I2 %0,%1,%H2")
6952
6953 (define_insn "*lshrdi3_internal2"
6954   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6955         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6956                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6957                     (const_int 0)))
6958    (clobber (match_scratch:DI 3 "=r,r"))]
6959   "TARGET_POWERPC64"
6960   "@
6961    srd%I2. %3,%1,%H2
6962    #"
6963   [(set_attr "type" "delayed_compare")
6964    (set_attr "length" "4,8")])
6965
6966 (define_split
6967   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6968         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6969                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
6970                     (const_int 0)))
6971    (clobber (match_scratch:DI 3 ""))]
6972   "TARGET_POWERPC64 && reload_completed"
6973   [(set (match_dup 3)
6974         (lshiftrt:DI (match_dup 1) (match_dup 2)))
6975    (set (match_dup 0)
6976         (compare:CC (match_dup 3)
6977                     (const_int 0)))]
6978   "")
6979
6980 (define_insn "*lshrdi3_internal3"
6981   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6982         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6983                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6984                     (const_int 0)))
6985    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6986         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
6987   "TARGET_POWERPC64"
6988   "@
6989    srd%I2. %0,%1,%H2
6990    #"
6991   [(set_attr "type" "delayed_compare")
6992    (set_attr "length" "4,8")])
6993
6994 (define_split
6995   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6996         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
6997                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
6998                     (const_int 0)))
6999    (set (match_operand:DI 0 "gpc_reg_operand" "")
7000         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7001   "TARGET_POWERPC64 && reload_completed"
7002   [(set (match_dup 0)
7003         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7004    (set (match_dup 3)
7005         (compare:CC (match_dup 0)
7006                     (const_int 0)))]
7007   "")
7008
7009 (define_expand "ashrdi3"
7010   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7011         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7012                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7013   "TARGET_POWERPC64 || TARGET_POWER"
7014   "
7015 {
7016   if (TARGET_POWERPC64)
7017     ;
7018   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7019     {
7020       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7021       DONE;
7022     }
7023   else
7024     FAIL;
7025 }")
7026
7027 (define_insn "*ashrdi3_internal1"
7028   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7029         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7030                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7031   "TARGET_POWERPC64"
7032   "srad%I2 %0,%1,%H2")
7033
7034 (define_insn "*ashrdi3_internal2"
7035   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7036         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7037                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7038                     (const_int 0)))
7039    (clobber (match_scratch:DI 3 "=r,r"))]
7040   "TARGET_POWERPC64"
7041   "@
7042    srad%I2. %3,%1,%H2
7043    #"
7044   [(set_attr "type" "delayed_compare")
7045    (set_attr "length" "4,8")])
7046
7047 (define_split
7048   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7049         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7050                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7051                     (const_int 0)))
7052    (clobber (match_scratch:DI 3 ""))]
7053   "TARGET_POWERPC64 && reload_completed"
7054   [(set (match_dup 3)
7055         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7056    (set (match_dup 0)
7057         (compare:CC (match_dup 3)
7058                     (const_int 0)))]
7059   "")
7060
7061 (define_insn "*ashrdi3_internal3"
7062   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7063         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7064                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7065                     (const_int 0)))
7066    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7067         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7068   "TARGET_POWERPC64"
7069   "@
7070    srad%I2. %0,%1,%H2
7071    #"
7072   [(set_attr "type" "delayed_compare")
7073    (set_attr "length" "4,8")])
7074
7075 (define_split
7076   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7077         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7078                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7079                     (const_int 0)))
7080    (set (match_operand:DI 0 "gpc_reg_operand" "")
7081         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7082   "TARGET_POWERPC64 && reload_completed"
7083   [(set (match_dup 0)
7084         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7085    (set (match_dup 3)
7086         (compare:CC (match_dup 0)
7087                     (const_int 0)))]
7088   "")
7089
7090 (define_insn "anddi3"
7091   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7092         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
7093                 (match_operand:DI 2 "and64_operand" "?r,S,K,J")))
7094    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
7095   "TARGET_POWERPC64"
7096   "@
7097    and %0,%1,%2
7098    rldic%B2 %0,%1,0,%S2
7099    andi. %0,%1,%b2
7100    andis. %0,%1,%u2")
7101
7102 (define_insn "*anddi3_internal2"
7103   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,?y,??y,??y")
7104         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,")
7105                             (match_operand:DI 2 "and64_operand" "r,S,K,J,r,S,K,J"))
7106                     (const_int 0)))
7107    (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r"))
7108    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,x,x"))]
7109   "TARGET_POWERPC64"
7110   "@
7111    and. %3,%1,%2
7112    rldic%B2. %3,%1,0,%S2
7113    andi. %3,%1,%b2
7114    andis. %3,%1,%u2
7115    #
7116    #
7117    #
7118    #"
7119   [(set_attr "type" "compare,delayed_compare,compare,compare,compare,delayed_compare,compare,compare")
7120    (set_attr "length" "4,4,4,4,8,8,8,8")])
7121
7122 (define_split
7123   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7124         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7125                             (match_operand:DI 2 "and64_operand" ""))
7126                     (const_int 0)))
7127    (clobber (match_scratch:DI 3 ""))
7128    (clobber (match_scratch:CC 4 ""))]
7129   "TARGET_POWERPC64 && reload_completed"
7130   [(parallel [(set (match_dup 3)
7131                    (and:DI (match_dup 1)
7132                            (match_dup 2)))
7133               (clobber (match_dup 4))])
7134    (set (match_dup 0)
7135         (compare:CC (match_dup 3)
7136                     (const_int 0)))]
7137   "")
7138
7139 (define_insn "*anddi3_internal3"
7140   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,?y,??y,??y")
7141         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
7142                             (match_operand:DI 2 "and64_operand" "r,S,K,J,r,S,K,J"))
7143                     (const_int 0)))
7144    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
7145         (and:DI (match_dup 1) (match_dup 2)))
7146    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,x,x"))]
7147   "TARGET_POWERPC64"
7148   "@
7149    and. %0,%1,%2
7150    rldic%B2. %0,%1,0,%S2
7151    andi. %0,%1,%b2
7152    andis. %0,%1,%u2
7153    #
7154    #
7155    #
7156    #"
7157   [(set_attr "type" "compare,delayed_compare,compare,compare,compare,delayed_compare,compare,compare")
7158    (set_attr "length" "4,4,4,4,8,8,8,8")])
7159
7160 (define_split
7161   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7162         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7163                             (match_operand:DI 2 "and64_operand" ""))
7164                     (const_int 0)))
7165    (set (match_operand:DI 0 "gpc_reg_operand" "")
7166         (and:DI (match_dup 1) (match_dup 2)))
7167    (clobber (match_scratch:CC 4 ""))]
7168   "TARGET_POWERPC64 && reload_completed"
7169   [(parallel [(set (match_dup 0)
7170                     (and:DI (match_dup 1) (match_dup 2)))
7171                (clobber (match_dup 4))])
7172    (set (match_dup 3)
7173         (compare:CC (match_dup 0)
7174                     (const_int 0)))]
7175   "")
7176
7177 (define_expand "iordi3"
7178   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7179         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7180                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7181   "TARGET_POWERPC64"
7182   "
7183 {
7184   if (non_logical_cint_operand (operands[2], DImode))
7185     {
7186       HOST_WIDE_INT value;
7187       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7188                  ? operands[0] : gen_reg_rtx (DImode));
7189
7190       if (GET_CODE (operands[2]) == CONST_INT)
7191         {
7192           value = INTVAL (operands[2]);
7193           emit_insn (gen_iordi3 (tmp, operands[1],
7194                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7195         }
7196       else
7197         {
7198           value = CONST_DOUBLE_LOW (operands[2]);
7199           emit_insn (gen_iordi3 (tmp, operands[1],
7200                                  immed_double_const (value
7201                                                      & (~ (HOST_WIDE_INT) 0xffff),
7202                                                      0, DImode)));
7203         }
7204
7205       emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7206       DONE;
7207     }
7208 }")
7209
7210 (define_expand "xordi3"
7211   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7212         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7213                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7214   "TARGET_POWERPC64"
7215   "
7216 {
7217   if (non_logical_cint_operand (operands[2], DImode))
7218     {
7219       HOST_WIDE_INT value;
7220       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7221                  ? operands[0] : gen_reg_rtx (DImode));
7222
7223       if (GET_CODE (operands[2]) == CONST_INT)
7224         {
7225           value = INTVAL (operands[2]);
7226           emit_insn (gen_xordi3 (tmp, operands[1],
7227                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7228         }
7229       else
7230         {
7231           value = CONST_DOUBLE_LOW (operands[2]);
7232           emit_insn (gen_xordi3 (tmp, operands[1],
7233                                  immed_double_const (value
7234                                                      & (~ (HOST_WIDE_INT) 0xffff),
7235                                                      0, DImode)));
7236         }
7237
7238       emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7239       DONE;
7240     }
7241 }")
7242
7243 (define_insn "*booldi3_internal1"
7244   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7245         (match_operator:DI 3 "boolean_or_operator"
7246          [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7247           (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7248   "TARGET_POWERPC64"
7249   "@
7250    %q3 %0,%1,%2
7251    %q3i %0,%1,%b2
7252    %q3is %0,%1,%u2")
7253
7254 (define_insn "*booldi3_internal2"
7255   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7256         (compare:CC (match_operator:DI 4 "boolean_or_operator"
7257          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7258           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7259          (const_int 0)))
7260    (clobber (match_scratch:DI 3 "=r,r"))]
7261   "TARGET_POWERPC64"
7262   "@
7263    %q4. %3,%1,%2
7264    #"
7265   [(set_attr "type" "compare")
7266    (set_attr "length" "4,8")])
7267
7268 (define_split
7269   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7270         (compare:CC (match_operator:DI 4 "boolean_operator"
7271          [(match_operand:DI 1 "gpc_reg_operand" "")
7272           (match_operand:DI 2 "gpc_reg_operand" "")])
7273          (const_int 0)))
7274    (clobber (match_scratch:DI 3 ""))]
7275   "TARGET_POWERPC64 && reload_completed"
7276   [(set (match_dup 3) (match_dup 4))
7277    (set (match_dup 0)
7278         (compare:CC (match_dup 3)
7279                     (const_int 0)))]
7280   "")
7281
7282 (define_insn "*booldi3_internal3"
7283   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7284         (compare:CC (match_operator:DI 4 "boolean_operator"
7285          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7286           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7287          (const_int 0)))
7288    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7289         (match_dup 4))]
7290   "TARGET_POWERPC64"
7291   "@
7292    %q4. %0,%1,%2
7293    #"
7294   [(set_attr "type" "compare")
7295    (set_attr "length" "4,8")])
7296
7297 (define_split
7298   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7299         (compare:CC (match_operator:DI 4 "boolean_operator"
7300          [(match_operand:DI 1 "gpc_reg_operand" "")
7301           (match_operand:DI 2 "gpc_reg_operand" "")])
7302          (const_int 0)))
7303    (set (match_operand:DI 0 "gpc_reg_operand" "")
7304         (match_dup 4))]
7305   "TARGET_POWERPC64 && reload_completed"
7306   [(set (match_dup 0) (match_dup 4))
7307    (set (match_dup 3)
7308         (compare:CC (match_dup 0)
7309                     (const_int 0)))]
7310   "")
7311
7312 ;; Split an logical operation that we can't do in one insn into two insns, 
7313 ;; each of which does one 16-bit part.  This is used by combine.
7314
7315 (define_split
7316   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7317         (match_operator:DI 3 "boolean_or_operator"
7318          [(match_operand:DI 1 "gpc_reg_operand" "")
7319           (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7320   "TARGET_POWERPC64"
7321   [(set (match_dup 0) (match_dup 4))
7322    (set (match_dup 0) (match_dup 5))]
7323 "
7324 {
7325   rtx i3,i4;
7326   
7327   if (GET_CODE (operands[2]) == CONST_DOUBLE)
7328     {
7329       HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7330       i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7331                                         0, DImode);
7332       i4 = GEN_INT (value & 0xffff);
7333     }
7334   else
7335     {
7336       i3 = GEN_INT (INTVAL (operands[2])
7337                              & (~ (HOST_WIDE_INT) 0xffff));
7338       i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7339     }
7340   operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
7341                          operands[1], i3);
7342   operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
7343                          operands[0], i4);
7344 }")
7345
7346 (define_insn "*boolcdi3_internal1"
7347   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7348         (match_operator:DI 3 "boolean_operator"
7349          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7350           (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7351   "TARGET_POWERPC64"
7352   "%q3 %0,%2,%1")
7353
7354 (define_insn "*boolcdi3_internal2"
7355   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7356         (compare:CC (match_operator:DI 4 "boolean_operator"
7357          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7358           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7359          (const_int 0)))
7360    (clobber (match_scratch:DI 3 "=r,r"))]
7361   "TARGET_POWERPC64"
7362   "@
7363    %q4. %3,%2,%1
7364    #"
7365   [(set_attr "type" "compare")
7366    (set_attr "length" "4,8")])
7367
7368 (define_split
7369   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7370         (compare:CC (match_operator:DI 4 "boolean_operator"
7371          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7372           (match_operand:DI 2 "gpc_reg_operand" "")])
7373          (const_int 0)))
7374    (clobber (match_scratch:DI 3 ""))]
7375   "TARGET_POWERPC64 && reload_completed"
7376   [(set (match_dup 3) (match_dup 4))
7377    (set (match_dup 0)
7378         (compare:CC (match_dup 3)
7379                     (const_int 0)))]
7380   "")
7381
7382 (define_insn "*boolcdi3_internal3"
7383   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7384         (compare:CC (match_operator:DI 4 "boolean_operator"
7385          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7386           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7387          (const_int 0)))
7388    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7389         (match_dup 4))]
7390   "TARGET_POWERPC64"
7391   "@
7392    %q4. %0,%2,%1
7393    #"
7394   [(set_attr "type" "compare")
7395    (set_attr "length" "4,8")])
7396
7397 (define_split
7398   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7399         (compare:CC (match_operator:DI 4 "boolean_operator"
7400          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7401           (match_operand:DI 2 "gpc_reg_operand" "")])
7402          (const_int 0)))
7403    (set (match_operand:DI 0 "gpc_reg_operand" "")
7404         (match_dup 4))]
7405   "TARGET_POWERPC64 && reload_completed"
7406   [(set (match_dup 0) (match_dup 4))
7407    (set (match_dup 3)
7408         (compare:CC (match_dup 0)
7409                     (const_int 0)))]
7410   "")
7411
7412 (define_insn "*boolccdi3_internal1"
7413   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7414         (match_operator:DI 3 "boolean_operator"
7415          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7416           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7417   "TARGET_POWERPC64"
7418   "%q3 %0,%1,%2")
7419
7420 (define_insn "*boolccdi3_internal2"
7421   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7422         (compare:CC (match_operator:DI 4 "boolean_operator"
7423          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7424           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7425          (const_int 0)))
7426    (clobber (match_scratch:DI 3 "=r,r"))]
7427   "TARGET_POWERPC64"
7428   "@
7429    %q4. %3,%1,%2
7430    #"
7431   [(set_attr "type" "compare")
7432    (set_attr "length" "4,8")])
7433
7434 (define_split
7435   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7436         (compare:CC (match_operator:DI 4 "boolean_operator"
7437          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7438           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7439          (const_int 0)))
7440    (clobber (match_scratch:DI 3 ""))]
7441   "TARGET_POWERPC64 && reload_completed"
7442   [(set (match_dup 3) (match_dup 4))
7443    (set (match_dup 0)
7444         (compare:CC (match_dup 3)
7445                     (const_int 0)))]
7446   "")
7447
7448 (define_insn "*boolccdi3_internal3"
7449   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7450         (compare:CC (match_operator:DI 4 "boolean_operator"
7451          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7452           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7453          (const_int 0)))
7454    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7455         (match_dup 4))]
7456   "TARGET_POWERPC64"
7457   "@
7458    %q4. %0,%1,%2
7459    #"
7460   [(set_attr "type" "compare")
7461    (set_attr "length" "4,8")])
7462
7463 (define_split
7464   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7465         (compare:CC (match_operator:DI 4 "boolean_operator"
7466          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7467           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7468          (const_int 0)))
7469    (set (match_operand:DI 0 "gpc_reg_operand" "")
7470         (match_dup 4))]
7471   "TARGET_POWERPC64 && reload_completed"
7472   [(set (match_dup 0) (match_dup 4))
7473    (set (match_dup 3)
7474         (compare:CC (match_dup 0)
7475                     (const_int 0)))]
7476   "")
7477 \f
7478 ;; Now define ways of moving data around.
7479
7480 ;; Elf specific ways of loading addresses for non-PIC code.
7481 ;; The output of this could be r0, but we make a very strong
7482 ;; preference for a base register because it will usually
7483 ;; be needed there.
7484 (define_insn "elf_high"
7485   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7486         (high:SI (match_operand 1 "" "")))]
7487   "TARGET_ELF && ! TARGET_64BIT"
7488   "{liu|lis} %0,%1@ha")
7489
7490 (define_insn "elf_low"
7491   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7492         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7493                    (match_operand 2 "" "")))]
7494    "TARGET_ELF && ! TARGET_64BIT"
7495    "@
7496     {cal|la} %0,%2@l(%1)
7497     {ai|addic} %0,%1,%K2")
7498
7499 ;; Mach-O PIC trickery.
7500 (define_insn "macho_high"
7501   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7502         (high:SI (match_operand 1 "" "")))]
7503   "TARGET_MACHO && ! TARGET_64BIT"
7504   "{liu|lis} %0,ha16(%1)")
7505
7506 (define_insn "macho_low"
7507   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7508         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7509                    (match_operand 2 "" "")))]
7510    "TARGET_MACHO && ! TARGET_64BIT"
7511    "@
7512     {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
7513     {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
7514
7515 ;; Set up a register with a value from the GOT table
7516
7517 (define_expand "movsi_got"
7518   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7519         (unspec:SI [(match_operand:SI 1 "got_operand" "")
7520                     (match_dup 2)] 8))]
7521   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7522   "
7523 {
7524   if (GET_CODE (operands[1]) == CONST)
7525     {
7526       rtx offset = const0_rtx;
7527       HOST_WIDE_INT value;
7528
7529       operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7530       value = INTVAL (offset);
7531       if (value != 0)
7532         {
7533           rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7534           emit_insn (gen_movsi_got (tmp, operands[1]));
7535           emit_insn (gen_addsi3 (operands[0], tmp, offset));
7536           DONE;
7537         }
7538     }
7539
7540   operands[2] = rs6000_got_register (operands[1]);
7541 }")
7542
7543 (define_insn "*movsi_got_internal"
7544   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7545         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7546                     (match_operand:SI 2 "gpc_reg_operand" "b")] 8))]
7547   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7548   "{l|lwz} %0,%a1@got(%2)"
7549   [(set_attr "type" "load")])
7550
7551 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7552 ;; didn't get allocated to a hard register.
7553 (define_split 
7554   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7555         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7556                     (match_operand:SI 2 "memory_operand" "")] 8))]
7557   "DEFAULT_ABI == ABI_V4
7558     && flag_pic == 1
7559     && (reload_in_progress || reload_completed)"
7560   [(set (match_dup 0) (match_dup 2))
7561    (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)] 8))]
7562   "")
7563
7564 ;; For SI, we special-case integers that can't be loaded in one insn.  We
7565 ;; do the load 16-bits at a time.  We could do this by loading from memory,
7566 ;; and this is even supposed to be faster, but it is simpler not to get
7567 ;; integers in the TOC.
7568 (define_expand "movsi"
7569   [(set (match_operand:SI 0 "general_operand" "")
7570         (match_operand:SI 1 "any_operand" ""))]
7571   ""
7572   "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
7573
7574 (define_insn "movsi_low"
7575   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7576         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7577                            (match_operand 2 "" ""))))]
7578   "TARGET_MACHO && ! TARGET_64BIT"
7579   "{l|lwz} %0,lo16(%2)(%1)"
7580   [(set_attr "type" "load")
7581    (set_attr "length" "4")])
7582
7583 (define_insn "movsi_low_st"
7584   [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7585                            (match_operand 2 "" "")))
7586         (match_operand:SI 0 "gpc_reg_operand" "r"))]
7587   "TARGET_MACHO && ! TARGET_64BIT"
7588   "{st|stw} %0,lo16(%2)(%1)"
7589   [(set_attr "type" "store")
7590    (set_attr "length" "4")])
7591
7592 (define_insn "movdf_low"
7593   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
7594         (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7595                            (match_operand 2 "" ""))))]
7596   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7597   "*
7598 {
7599   switch (which_alternative)
7600     {
7601       case 0:
7602         return \"lfd %0,lo16(%2)(%1)\";
7603       case 1:
7604         {
7605           rtx operands2[4];
7606           operands2[0] = operands[0];
7607           operands2[1] = operands[1];
7608           operands2[2] = operands[2];
7609           operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
7610           output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
7611           /* We cannot rely on ha16(low half)==ha16(high half), alas,
7612              although in practice it almost always is.  */
7613           output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
7614           return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
7615         }
7616       default:
7617         abort();
7618     }
7619 }"
7620   [(set_attr "type" "load")
7621    (set_attr "length" "4,12")])
7622
7623 (define_insn "movdf_low_st"
7624   [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7625                            (match_operand 2 "" "")))
7626         (match_operand:DF 0 "gpc_reg_operand" "f"))]
7627   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7628   "stfd %0,lo16(%2)(%1)"
7629   [(set_attr "type" "store")
7630    (set_attr "length" "4")])
7631
7632 (define_insn "movsf_low"
7633   [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
7634         (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7635                            (match_operand 2 "" ""))))]
7636   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7637   "@
7638    lfs %0,lo16(%2)(%1)
7639    {l|lwz} %0,lo16(%2)(%1)"
7640   [(set_attr "type" "load")
7641    (set_attr "length" "4")])
7642
7643 (define_insn "movsf_low_st"
7644   [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7645                            (match_operand 2 "" "")))
7646         (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
7647   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7648   "@
7649    stfs %0,lo16(%2)(%1)
7650    {st|stw} %0,lo16(%2)(%1)"
7651   [(set_attr "type" "store")
7652    (set_attr "length" "4")])
7653
7654 (define_insn "*movsi_internal1"
7655   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7656         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7657   "gpc_reg_operand (operands[0], SImode)
7658    || gpc_reg_operand (operands[1], SImode)"
7659   "@
7660    mr %0,%1
7661    {cal|la} %0,%a1
7662    {l%U1%X1|lwz%U1%X1} %0,%1
7663    {st%U0%X0|stw%U0%X0} %1,%0
7664    {lil|li} %0,%1
7665    {liu|lis} %0,%v1
7666    #
7667    {cal|la} %0,%a1
7668    mf%1 %0
7669    mt%0 %1
7670    mt%0 %1
7671    mt%0 %1
7672    cror 0,0,0"
7673   [(set_attr "type" "*,*,load,store,*,*,*,*,*,*,mtjmpr,*,*")
7674    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7675
7676 ;; Split a load of a large constant into the appropriate two-insn
7677 ;; sequence.
7678
7679 (define_split
7680   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7681         (match_operand:SI 1 "const_int_operand" ""))]
7682   "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7683    && (INTVAL (operands[1]) & 0xffff) != 0"
7684   [(set (match_dup 0)
7685         (match_dup 2))
7686    (set (match_dup 0)
7687         (ior:SI (match_dup 0)
7688                 (match_dup 3)))]
7689   "
7690 {
7691   operands[2] = GEN_INT (INTVAL (operands[1]) & (~ (HOST_WIDE_INT) 0xffff));
7692   operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
7693 }")
7694
7695 (define_insn "*movsi_internal2"
7696   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
7697         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r,r")
7698                     (const_int 0)))
7699    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
7700   "! TARGET_POWERPC64"
7701   "@
7702    mr. %0,%1
7703    #"
7704   [(set_attr "type" "compare")
7705    (set_attr "length" "4,8")])
7706 \f
7707 (define_split
7708   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7709         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7710                     (const_int 0)))
7711    (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
7712   "! TARGET_POWERPC64 && reload_completed"
7713   [(set (match_dup 0) (match_dup 1))
7714    (set (match_dup 2)
7715         (compare:CC (match_dup 0)
7716                     (const_int 0)))]
7717   "")
7718
7719 (define_expand "movhi"
7720   [(set (match_operand:HI 0 "general_operand" "")
7721         (match_operand:HI 1 "any_operand" ""))]
7722   ""
7723   "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
7724
7725 (define_insn ""
7726   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7727         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7728   "gpc_reg_operand (operands[0], HImode)
7729    || gpc_reg_operand (operands[1], HImode)"
7730   "@
7731    mr %0,%1
7732    lhz%U1%X1 %0,%1
7733    sth%U0%X0 %1,%0
7734    {lil|li} %0,%w1
7735    mf%1 %0
7736    mt%0 %1
7737    mt%0 %1
7738    cror 0,0,0"
7739   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7740
7741 (define_expand "movqi"
7742   [(set (match_operand:QI 0 "general_operand" "")
7743         (match_operand:QI 1 "any_operand" ""))]
7744   ""
7745   "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
7746
7747 (define_insn ""
7748   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7749         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7750   "gpc_reg_operand (operands[0], QImode)
7751    || gpc_reg_operand (operands[1], QImode)"
7752   "@
7753    mr %0,%1
7754    lbz%U1%X1 %0,%1
7755    stb%U0%X0 %1,%0
7756    {lil|li} %0,%1
7757    mf%1 %0
7758    mt%0 %1
7759    mt%0 %1
7760    cror 0,0,0"
7761   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7762 \f
7763 ;; Here is how to move condition codes around.  When we store CC data in
7764 ;; an integer register or memory, we store just the high-order 4 bits.
7765 ;; This lets us not shift in the most common case of CR0.
7766 (define_expand "movcc"
7767   [(set (match_operand:CC 0 "nonimmediate_operand" "")
7768         (match_operand:CC 1 "nonimmediate_operand" ""))]
7769   ""
7770   "")
7771
7772 (define_insn "*movcc_internal1"
7773   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
7774         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
7775   "register_operand (operands[0], CCmode)
7776    || register_operand (operands[1], CCmode)"
7777   "@
7778    mcrf %0,%1
7779    mtcrf 128,%1
7780    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7781    mfcr %0
7782    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7783    mr %0,%1
7784    {l%U1%X1|lwz%U1%X1} %0,%1
7785    {st%U0%U1|stw%U0%U1} %1,%0"
7786   [(set_attr "type" "*,*,*,compare,*,*,load,store")
7787    (set_attr "length" "*,*,12,*,8,*,*,*")])
7788 \f
7789 ;; For floating-point, we normally deal with the floating-point registers
7790 ;; unless -msoft-float is used.  The sole exception is that parameter passing
7791 ;; can produce floating-point values in fixed-point registers.  Unless the
7792 ;; value is a simple constant or already in memory, we deal with this by
7793 ;; allocating memory and copying the value explicitly via that memory location.
7794 (define_expand "movsf"
7795   [(set (match_operand:SF 0 "nonimmediate_operand" "")
7796         (match_operand:SF 1 "any_operand" ""))]
7797   ""
7798   "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7799
7800 (define_split
7801   [(set (match_operand:SF 0 "gpc_reg_operand" "")
7802         (match_operand:SF 1 "const_double_operand" ""))]
7803   "reload_completed
7804    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7805        || (GET_CODE (operands[0]) == SUBREG
7806            && GET_CODE (SUBREG_REG (operands[0])) == REG
7807            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7808   [(set (match_dup 2) (match_dup 3))]
7809   "
7810 {
7811   long l;
7812   REAL_VALUE_TYPE rv;
7813
7814   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7815   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7816
7817   if (! TARGET_POWERPC64)
7818     operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7819   else
7820     operands[2] = gen_lowpart (SImode, operands[0]);
7821
7822   operands[3] = gen_int_mode (l, SImode);
7823 }")
7824
7825 (define_insn "*movsf_hardfloat"
7826   [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!r,!r")
7827         (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,G,Fn"))]
7828   "(gpc_reg_operand (operands[0], SFmode)
7829    || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
7830   "@
7831    mr %0,%1
7832    {l%U1%X1|lwz%U1%X1} %0,%1
7833    {st%U0%X0|stw%U0%X0} %1,%0
7834    fmr %0,%1
7835    lfs%U1%X1 %0,%1
7836    stfs%U0%X0 %1,%0
7837    #
7838    #"
7839   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*")
7840    (set_attr "length" "4,4,4,4,4,4,4,8")])
7841
7842 (define_insn "*movsf_softfloat"
7843   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,r")
7844         (match_operand:SF 1 "input_operand" "r,m,r,I,L,R,G,Fn"))]
7845   "(gpc_reg_operand (operands[0], SFmode)
7846    || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
7847   "@
7848    mr %0,%1
7849    {l%U1%X1|lwz%U1%X1} %0,%1
7850    {st%U0%X0|stw%U0%X0} %1,%0
7851    {lil|li} %0,%1
7852    {liu|lis} %0,%v1
7853    {cal|la} %0,%a1
7854    #
7855    #"
7856   [(set_attr "type" "*,load,store,*,*,*,*,*")
7857    (set_attr "length" "4,4,4,4,4,4,4,8")])
7858
7859 \f
7860 (define_expand "movdf"
7861   [(set (match_operand:DF 0 "nonimmediate_operand" "")
7862         (match_operand:DF 1 "any_operand" ""))]
7863   ""
7864   "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
7865
7866 (define_split
7867   [(set (match_operand:DF 0 "gpc_reg_operand" "")
7868         (match_operand:DF 1 "const_int_operand" ""))]
7869   "! TARGET_POWERPC64 && reload_completed
7870    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7871        || (GET_CODE (operands[0]) == SUBREG
7872            && GET_CODE (SUBREG_REG (operands[0])) == REG
7873            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7874   [(set (match_dup 2) (match_dup 4))
7875    (set (match_dup 3) (match_dup 1))]
7876   "
7877 {
7878   int endian = (WORDS_BIG_ENDIAN == 0);
7879   HOST_WIDE_INT value = INTVAL (operands[1]);
7880
7881   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7882   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7883 #if HOST_BITS_PER_WIDE_INT == 32
7884   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
7885 #else
7886   operands[4] = GEN_INT (value >> 32);
7887   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
7888 #endif
7889 }")
7890
7891 (define_split
7892   [(set (match_operand:DF 0 "gpc_reg_operand" "")
7893         (match_operand:DF 1 "const_double_operand" ""))]
7894   "! TARGET_POWERPC64 && reload_completed
7895    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7896        || (GET_CODE (operands[0]) == SUBREG
7897            && GET_CODE (SUBREG_REG (operands[0])) == REG
7898            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7899   [(set (match_dup 2) (match_dup 4))
7900    (set (match_dup 3) (match_dup 5))]
7901   "
7902 {
7903   int endian = (WORDS_BIG_ENDIAN == 0);
7904   long l[2];
7905   REAL_VALUE_TYPE rv;
7906
7907   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7908   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7909
7910   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
7911   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
7912   operands[4] = gen_int_mode (l[endian], SImode);
7913   operands[5] = gen_int_mode (l[1 - endian], SImode);
7914 }")
7915
7916 (define_split
7917   [(set (match_operand:DF 0 "gpc_reg_operand" "")
7918         (match_operand:DF 1 "easy_fp_constant" ""))]
7919   "TARGET_POWERPC64 && reload_completed
7920    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7921        || (GET_CODE (operands[0]) == SUBREG
7922            && GET_CODE (SUBREG_REG (operands[0])) == REG
7923            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7924   [(set (match_dup 2) (match_dup 3))]
7925   "
7926 {
7927   int endian = (WORDS_BIG_ENDIAN == 0);
7928   long l[2];
7929   REAL_VALUE_TYPE rv;
7930   HOST_WIDE_INT val;
7931
7932   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7933   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
7934
7935   operands[2] = gen_lowpart (DImode, operands[0]);
7936   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
7937 #if HOST_BITS_PER_WIDE_INT >= 64
7938   val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32 |
7939         ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
7940
7941   operands[3] = immed_double_const (val, -(val < 0), DImode);
7942 #else
7943   operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
7944 #endif
7945 }")
7946
7947 ;; Don't have reload use general registers to load a constant.  First,
7948 ;; it might not work if the output operand is the equivalent of
7949 ;; a non-offsettable memref, but also it is less efficient than loading
7950 ;; the constant into an FP register, since it will probably be used there.
7951 ;; The "??" is a kludge until we can figure out a more reasonable way
7952 ;; of handling these non-offsettable values.
7953 (define_insn "*movdf_hardfloat32"
7954   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
7955         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
7956   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
7957    && (gpc_reg_operand (operands[0], DFmode)
7958        || gpc_reg_operand (operands[1], DFmode))"
7959   "*
7960 {
7961   switch (which_alternative)
7962     {
7963     default:
7964       abort ();
7965     case 0:
7966       /* We normally copy the low-numbered register first.  However, if
7967          the first register operand 0 is the same as the second register
7968          of operand 1, we must copy in the opposite order.  */
7969       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
7970         return \"mr %L0,%L1\;mr %0,%1\";
7971       else
7972         return \"mr %0,%1\;mr %L0,%L1\";
7973     case 1:
7974       if (offsettable_memref_p (operands[1])
7975           || (GET_CODE (operands[1]) == MEM
7976               && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
7977                   || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
7978                   || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
7979         {
7980           /* If the low-address word is used in the address, we must load
7981              it last.  Otherwise, load it first.  Note that we cannot have
7982              auto-increment in that case since the address register is
7983              known to be dead.  */
7984           if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
7985                                  operands[1], 0))
7986             return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
7987           else
7988             return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
7989         }
7990       else
7991         {
7992           rtx addreg;
7993
7994           addreg = find_addr_reg (XEXP (operands[1], 0));
7995           if (refers_to_regno_p (REGNO (operands[0]),
7996                                  REGNO (operands[0]) + 1,
7997                                  operands[1], 0))
7998             {
7999               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8000               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8001               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8002               return \"{lx|lwzx} %0,%1\";
8003             }
8004           else
8005             {
8006               output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
8007               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8008               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8009               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8010               return \"\";
8011             }
8012         }
8013     case 2:
8014       if (offsettable_memref_p (operands[0])
8015           || (GET_CODE (operands[0]) == MEM
8016               && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8017                   || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8018                   || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
8019         return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8020       else
8021         {
8022           rtx addreg;
8023
8024           addreg = find_addr_reg (XEXP (operands[0], 0));
8025           output_asm_insn (\"{stx|stwx} %1,%0\", operands);
8026           output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8027           output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
8028           output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8029           return \"\";
8030         }
8031     case 3:
8032     case 4:
8033     case 5:
8034       return \"#\";
8035     case 6:
8036       return \"fmr %0,%1\";
8037     case 7:
8038       return \"lfd%U1%X1 %0,%1\";
8039     case 8:
8040       return \"stfd%U0%X0 %1,%0\";
8041     }
8042 }"
8043   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8044    (set_attr "length" "8,16,16,8,12,16,*,*,*")])
8045
8046 (define_insn "*movdf_softfloat32"
8047   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8048         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8049   "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
8050    && (gpc_reg_operand (operands[0], DFmode)
8051        || gpc_reg_operand (operands[1], DFmode))"
8052   "*
8053 {
8054   switch (which_alternative)
8055     {
8056     default:
8057       abort ();
8058     case 0:
8059       /* We normally copy the low-numbered register first.  However, if
8060          the first register operand 0 is the same as the second register of
8061          operand 1, we must copy in the opposite order.  */
8062       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8063         return \"mr %L0,%L1\;mr %0,%1\";
8064       else
8065         return \"mr %0,%1\;mr %L0,%L1\";
8066     case 1:
8067       /* If the low-address word is used in the address, we must load
8068          it last.  Otherwise, load it first.  Note that we cannot have
8069          auto-increment in that case since the address register is
8070          known to be dead.  */
8071       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8072                              operands[1], 0))
8073         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8074       else
8075         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8076     case 2:
8077       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8078     case 3:
8079     case 4:
8080     case 5:
8081       return \"#\";
8082     }
8083 }"
8084   [(set_attr "type" "*,load,store,*,*,*")
8085    (set_attr "length" "8,8,8,8,12,16")])
8086
8087 (define_insn "*movdf_hardfloat64"
8088   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
8089         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
8090   "TARGET_POWERPC64 && TARGET_HARD_FLOAT
8091    && (gpc_reg_operand (operands[0], DFmode)
8092        || gpc_reg_operand (operands[1], DFmode))"
8093   "@
8094    mr %0,%1
8095    ld%U1%X1 %0,%1
8096    std%U0%X0 %1,%0
8097    #
8098    #
8099    #
8100    fmr %0,%1
8101    lfd%U1%X1 %0,%1
8102    stfd%U0%X0 %1,%0"
8103   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8104    (set_attr "length" "4,4,4,8,12,16,4,4,4")])
8105
8106 (define_insn "*movdf_softfloat64"
8107   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8108         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8109   "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
8110    && (gpc_reg_operand (operands[0], DFmode)
8111        || gpc_reg_operand (operands[1], DFmode))"
8112   "@
8113    mr %0,%1
8114    ld%U1%X1 %0,%1
8115    std%U0%X0 %1,%0
8116    #
8117    #
8118    #"
8119   [(set_attr "type" "*,load,store,*,*,*")
8120    (set_attr "length" "*,*,*,8,12,16")])
8121 \f
8122 (define_expand "movtf"
8123   [(set (match_operand:TF 0 "general_operand" "")
8124         (match_operand:TF 1 "any_operand" ""))]
8125   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8126   "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8127
8128 (define_insn "*movtf_internal"
8129   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
8130         (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
8131   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128
8132    && (gpc_reg_operand (operands[0], TFmode)
8133        || gpc_reg_operand (operands[1], TFmode))"
8134   "*
8135 {
8136   switch (which_alternative)
8137     {
8138     default:
8139       abort ();
8140     case 0:
8141       /* We normally copy the low-numbered register first.  However, if
8142          the first register operand 0 is the same as the second register of
8143          operand 1, we must copy in the opposite order.  */
8144       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8145         return \"fmr %L0,%L1\;fmr %0,%1\";
8146       else
8147         return \"fmr %0,%1\;fmr %L0,%L1\";
8148     case 1:
8149       return \"lfd %0,%1\;lfd %L0,%L1\";
8150     case 2:
8151       return \"stfd %1,%0\;stfd %L1,%L0\";
8152     case 3:
8153     case 4:
8154     case 5:
8155       return \"#\";
8156     }
8157 }"
8158   [(set_attr "type" "fp,fpload,fpstore,*,*,*")
8159    (set_attr "length" "8,8,8,12,16,20")])
8160
8161 (define_split
8162   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8163         (match_operand:TF 1 "const_double_operand" ""))]
8164   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8165   [(set (match_dup 3) (match_dup 1))
8166    (set (match_dup 0)
8167         (float_extend:TF (match_dup 3)))]
8168   "
8169 {
8170   operands[2] = operand_subword (operands[1], 0, 0, DFmode);
8171   operands[3] = gen_reg_rtx (DFmode);
8172 }")
8173
8174 (define_insn_and_split "extenddftf2"
8175   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8176         (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
8177   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8178   "#"
8179   ""
8180   [(set (match_dup 2) (match_dup 3))]
8181   "
8182 {
8183   operands[2] = gen_rtx_REG (DFmode, REGNO (operands[0] + 1));
8184   operands[3] = CONST0_RTX (DFmode);
8185 }")
8186
8187 (define_insn_and_split "extendsftf2"
8188   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8189         (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
8190   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8191   "#"
8192   ""
8193   [(set (match_dup 2) (match_dup 3))]
8194   "
8195 {
8196   operands[2] = gen_rtx_REG (SFmode, REGNO (operands[0] + 1));
8197   operands[3] = CONST0_RTX (SFmode);
8198 }")
8199
8200 (define_insn "trunctfdf2"
8201   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8202         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8203   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8204   "fadd %0,%1,%L1"
8205   [(set_attr "type" "fp")
8206    (set_attr "length" "8")])
8207
8208 (define_insn_and_split "trunctfsf2"
8209   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8210         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8211   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8212   "#"
8213   ""
8214   [(set (match_dup 2)
8215         (float_truncate:DF (match_dup 1)))
8216    (set (match_dup 0)
8217         (float_truncate:SF (match_dup 2)))]
8218   "
8219 {
8220   operands[2] = gen_reg_rtx (DFmode);
8221 }")
8222
8223 (define_expand "floatditf2"
8224   [(set (match_dup 2)
8225         (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))
8226    (set (match_operand:TF 0 "gpc_reg_operand" "")
8227         (float_extend:TF (match_dup 2)))]
8228   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8229    && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8230   "{ operands[2] = gen_reg_rtx (DFmode); }")
8231
8232 (define_expand "floatsitf2"
8233   [(set (match_dup 2)
8234         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
8235    (set (match_operand:TF 0 "gpc_reg_operand" "")
8236         (float_extend:TF (match_dup 2)))]
8237   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8238   "{ operands[2] = gen_reg_rtx (DFmode); }")
8239
8240 (define_expand "fix_trunctfdi2"
8241   [(set (match_dup 2)
8242         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8243    (set (match_operand:DI 0 "gpc_reg_operand" "")
8244         (fix:SI (match_dup 2)))]
8245   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8246    && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8247   "{ operands[2] = gen_reg_rtx (DFmode); }")
8248
8249 (define_expand "fix_trunctfsi2"
8250   [(set (match_dup 2)
8251         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8252    (set (match_operand:SI 0 "gpc_reg_operand" "")
8253         (fix:SI (match_dup 2)))]
8254   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8255   "{ operands[2] = gen_reg_rtx (DFmode); }")
8256
8257 (define_insn "negtf2"
8258   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8259         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8260   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8261   "*
8262 {
8263   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8264     return \"fneg %L0,%L1\;fneg %0,%1\";
8265   else
8266     return \"fneg %0,%1\;fneg %L0,%L1\";
8267 }"
8268   [(set_attr "type" "fp")
8269    (set_attr "length" "8")])
8270
8271 (define_insn "abstf2"
8272   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8273         (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8274   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8275   "*
8276 {
8277   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8278     return \"fabs %L0,%L1\;fabs %0,%1\";
8279   else
8280     return \"fabs %0,%1\;fabs %L0,%L1\";
8281 }"
8282   [(set_attr "type" "fp")
8283    (set_attr "length" "8")])
8284
8285 (define_insn ""
8286   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8287         (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
8288   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8289   "*
8290 {
8291   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8292     return \"fnabs %L0,%L1\;fnabs %0,%1\";
8293   else
8294     return \"fnabs %0,%1\;fnabs %L0,%L1\";
8295 }"
8296   [(set_attr "type" "fp")
8297    (set_attr "length" "8")])
8298 \f
8299 ;; Next come the multi-word integer load and store and the load and store
8300 ;; multiple insns.
8301 (define_expand "movdi"
8302   [(set (match_operand:DI 0 "general_operand" "")
8303         (match_operand:DI 1 "any_operand" ""))]
8304   ""
8305   "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
8306
8307 (define_insn "*movdi_internal32"
8308   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
8309         (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
8310   "! TARGET_POWERPC64
8311    && (gpc_reg_operand (operands[0], DImode)
8312        || gpc_reg_operand (operands[1], DImode))"
8313   "*
8314 {
8315   switch (which_alternative)
8316     {
8317     default:
8318       abort ();
8319     case 0:
8320       /* We normally copy the low-numbered register first.  However, if
8321          the first register operand 0 is the same as the second register of
8322          operand 1, we must copy in the opposite order.  */
8323       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8324         return \"mr %L0,%L1\;mr %0,%1\";
8325       else
8326         return \"mr %0,%1\;mr %L0,%L1\";
8327     case 1:
8328       /* If the low-address word is used in the address, we must load it
8329          last.  Otherwise, load it first.  Note that we cannot have
8330          auto-increment in that case since the address register is known to be
8331          dead.  */
8332       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8333                              operands[1], 0))
8334         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8335       else
8336         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8337     case 2:
8338       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8339     case 3:
8340       return \"fmr %0,%1\";
8341     case 4:
8342       return \"lfd%U1%X1 %0,%1\";
8343     case 5:
8344       return \"stfd%U0%X0 %1,%0\";
8345     case 6:
8346     case 7:
8347     case 8:
8348     case 9:
8349     case 10:
8350       return \"#\";
8351     }
8352 }"
8353   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
8354    (set_attr "length" "8,8,8,*,*,*,8,12,8,12,16")])
8355
8356 (define_split
8357   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8358         (match_operand:DI 1 "const_int_operand" ""))]
8359   "! TARGET_POWERPC64 && reload_completed"
8360   [(set (match_dup 2) (match_dup 4))
8361    (set (match_dup 3) (match_dup 1))]
8362   "
8363 {
8364   HOST_WIDE_INT value = INTVAL (operands[1]);
8365   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8366                                        DImode);
8367   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8368                                        DImode);
8369 #if HOST_BITS_PER_WIDE_INT == 32
8370   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8371 #else
8372   operands[4] = GEN_INT (value >> 32);
8373   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8374 #endif
8375 }")
8376
8377 (define_split
8378   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8379         (match_operand:DI 1 "const_double_operand" ""))]
8380   "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
8381   [(set (match_dup 2) (match_dup 4))
8382    (set (match_dup 3) (match_dup 5))]
8383   "
8384 {
8385   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8386                                        DImode);
8387   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8388                                        DImode);
8389   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8390   operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
8391 }")
8392
8393 (define_insn "*movdi_internal64"
8394   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,f,f,m,r,*h,*h")
8395         (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
8396   "TARGET_POWERPC64
8397    && (gpc_reg_operand (operands[0], DImode)
8398        || gpc_reg_operand (operands[1], DImode))"
8399   "@
8400    mr %0,%1
8401    ld%U1%X1 %0,%1
8402    std%U0%X0 %1,%0
8403    li %0,%1
8404    lis %0,%v1
8405    #
8406    {cal|la} %0,%a1
8407    fmr %0,%1
8408    lfd%U1%X1 %0,%1
8409    stfd%U0%X0 %1,%0
8410    mf%1 %0
8411    mt%0 %1
8412    cror 0,0,0"
8413   [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
8414    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8415
8416 ;; immediate value valid for a single instruction hiding in a const_double
8417 (define_insn ""
8418   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8419         (match_operand:DI 1 "const_double_operand" "F"))]
8420   "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8421    && GET_CODE (operands[1]) == CONST_DOUBLE
8422    && num_insns_constant (operands[1], DImode) == 1"
8423   "*
8424 {
8425   return ((unsigned HOST_WIDE_INT)
8426           (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8427          ? \"li %0,%1\" : \"lis %0,%v1\";
8428 }")
8429
8430 ;; Generate all one-bits and clear left or right.
8431 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8432 (define_split
8433   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8434         (match_operand:DI 1 "mask64_operand" ""))]
8435   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8436   [(set (match_dup 0) (const_int -1))
8437    (set (match_dup 0)
8438         (and:DI (rotate:DI (match_dup 0)
8439                            (const_int 0))
8440                 (match_dup 1)))]
8441   "")
8442
8443 ;; Split a load of a large constant into the appropriate five-instruction
8444 ;; sequence.  Handle anything in a constant number of insns.
8445 ;; When non-easy constants can go in the TOC, this should use
8446 ;; easy_fp_constant predicate.
8447 (define_split
8448   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8449         (match_operand:DI 1 "const_int_operand" ""))]
8450   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8451   [(set (match_dup 0) (match_dup 2))
8452    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8453   "
8454 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8455
8456   if (tem == operands[0])
8457     DONE;
8458   else
8459     FAIL;
8460 }")
8461
8462 (define_split
8463   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8464         (match_operand:DI 1 "const_double_operand" ""))]
8465   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8466   [(set (match_dup 0) (match_dup 2))
8467    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8468   "
8469 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8470
8471   if (tem == operands[0])
8472     DONE;
8473   else
8474     FAIL;
8475 }")
8476
8477 ;; Split a load of a large constant into the appropriate five-instruction
8478 (define_insn "*movdi_internal2"
8479   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
8480         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r,r")
8481                     (const_int 0)))
8482    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
8483   "TARGET_POWERPC64"
8484   "@
8485    mr. %0,%1
8486    #"
8487   [(set_attr "type" "compare")
8488    (set_attr "length" "4,8")])
8489
8490 (define_split
8491   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8492         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8493                     (const_int 0)))
8494    (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8495   "TARGET_POWERPC64 && reload_completed"
8496   [(set (match_dup 0) (match_dup 1))
8497    (set (match_dup 2)
8498         (compare:CC (match_dup 0)
8499                     (const_int 0)))]
8500   "")
8501 \f
8502 ;; TImode is similar, except that we usually want to compute the address into
8503 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
8504 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8505 (define_expand "movti"
8506   [(parallel [(set (match_operand:TI 0 "general_operand" "")
8507                    (match_operand:TI 1 "general_operand" ""))
8508               (clobber (scratch:SI))])]
8509   "TARGET_STRING || TARGET_POWERPC64"
8510   "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
8511
8512 ;; We say that MQ is clobbered in the last alternative because the first
8513 ;; alternative would never get used otherwise since it would need a reload
8514 ;; while the 2nd alternative would not.  We put memory cases first so they
8515 ;; are preferred.  Otherwise, we'd try to reload the output instead of
8516 ;; giving the SCRATCH mq.
8517 (define_insn "*movti_power"
8518   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
8519         (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
8520    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
8521   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
8522    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8523   "*
8524 {
8525   switch (which_alternative)
8526     {
8527     default:
8528       abort ();
8529
8530     case 0:
8531       return \"{stsi|stswi} %1,%P0,16\";
8532
8533     case 1:
8534       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8535
8536     case 2:
8537       /* Normally copy registers with lowest numbered register copied first.
8538          But copy in the other order if the first register of the output
8539          is the second, third, or fourth register in the input.  */
8540       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8541           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8542         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8543       else
8544         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8545     case 3:
8546       /* If the address is not used in the output, we can use lsi.  Otherwise,
8547          fall through to generating four loads.  */
8548       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
8549         return \"{lsi|lswi} %0,%P1,16\";
8550       /* ... fall through ...  */
8551     case 4:
8552       /* If the address register is the same as the register for the lowest-
8553          addressed word, load it last.  Similarly for the next two words.
8554          Otherwise load lowest address to highest.  */
8555       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8556                              operands[1], 0))
8557         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8558       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8559                                   REGNO (operands[0]) + 2, operands[1], 0))
8560         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8561       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8562                                   REGNO (operands[0]) + 3, operands[1], 0))
8563         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8564       else
8565         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8566     }
8567 }"
8568   [(set_attr "type" "store,store,*,load,load")
8569    (set_attr "length" "*,16,16,*,16")])
8570
8571 (define_insn "*movti_string"
8572   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
8573         (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
8574    (clobber (match_scratch:SI 2 "=X,X,X"))]
8575   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
8576    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8577   "*
8578 {
8579   switch (which_alternative)
8580     {
8581     default:
8582       abort ();
8583
8584     case 0:
8585       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8586
8587     case 1:
8588       /* Normally copy registers with lowest numbered register copied first.
8589          But copy in the other order if the first register of the output
8590          is the second, third, or fourth register in the input.  */
8591       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8592           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8593         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8594       else
8595         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8596     case 2:
8597       /* If the address register is the same as the register for the lowest-
8598          addressed word, load it last.  Similarly for the next two words.
8599          Otherwise load lowest address to highest.  */
8600       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8601                              operands[1], 0))
8602         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8603       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8604                                   REGNO (operands[0]) + 2, operands[1], 0))
8605         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8606       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8607                                   REGNO (operands[0]) + 3, operands[1], 0))
8608         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8609       else
8610         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8611     }
8612 }"
8613   [(set_attr "type" "store,*,load")
8614    (set_attr "length" "16,16,16")])
8615
8616 (define_insn "*movti_ppc64"
8617   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
8618         (match_operand:TI 1 "input_operand" "r,m,r"))]
8619   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8620    || gpc_reg_operand (operands[1], TImode))"
8621   "*
8622 {
8623   switch (which_alternative)
8624     {
8625     default:
8626       abort ();
8627     case 0:
8628       /* We normally copy the low-numbered register first.  However, if
8629          the first register operand 0 is the same as the second register of
8630          operand 1, we must copy in the opposite order.  */
8631       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8632         return \"mr %L0,%L1\;mr %0,%1\";
8633       else
8634         return \"mr %0,%1\;mr %L0,%L1\";
8635     case 1:
8636       /* If the low-address word is used in the address, we must load it
8637          last.  Otherwise, load it first.  Note that we cannot have
8638          auto-increment in that case since the address register is known to be
8639          dead.  */
8640       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8641                              operands[1], 0))
8642         return \"ld %L0,%L1\;ld %0,%1\";
8643       else
8644         return \"ld%U1 %0,%1\;ld %L0,%L1\";
8645     case 2:
8646       return \"std%U0 %1,%0\;std %L1,%L0\";
8647     }
8648 }"
8649   [(set_attr "type" "*,load,store")
8650    (set_attr "length" "8,8,8")])
8651 \f
8652 (define_expand "load_multiple"
8653   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8654                           (match_operand:SI 1 "" ""))
8655                      (use (match_operand:SI 2 "" ""))])]
8656   "TARGET_STRING && !TARGET_POWERPC64"
8657   "
8658 {
8659   int regno;
8660   int count;
8661   rtx op1;
8662   int i;
8663
8664   /* Support only loading a constant number of fixed-point registers from
8665      memory and only bother with this if more than two; the machine
8666      doesn't support more than eight.  */
8667   if (GET_CODE (operands[2]) != CONST_INT
8668       || INTVAL (operands[2]) <= 2
8669       || INTVAL (operands[2]) > 8
8670       || GET_CODE (operands[1]) != MEM
8671       || GET_CODE (operands[0]) != REG
8672       || REGNO (operands[0]) >= 32)
8673     FAIL;
8674
8675   count = INTVAL (operands[2]);
8676   regno = REGNO (operands[0]);
8677
8678   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8679   op1 = replace_equiv_address (operands[1],
8680                                force_reg (SImode, XEXP (operands[1], 0)));
8681
8682   for (i = 0; i < count; i++)
8683     XVECEXP (operands[3], 0, i)
8684       = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8685                      adjust_address (op1, SImode, i * 4));
8686 }")
8687
8688 (define_insn ""
8689   [(match_parallel 0 "load_multiple_operation"
8690                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
8691                          (mem:SI (match_operand:SI 2 "gpc_reg_operand" "b")))])]
8692   "TARGET_STRING"
8693   "*
8694 {
8695   /* We have to handle the case where the pseudo used to contain the address
8696      is assigned to one of the output registers.  */
8697   int i, j;
8698   int words = XVECLEN (operands[0], 0);
8699   rtx xop[10];
8700
8701   if (XVECLEN (operands[0], 0) == 1)
8702     return \"{l|lwz} %1,0(%2)\";
8703
8704   for (i = 0; i < words; i++)
8705     if (refers_to_regno_p (REGNO (operands[1]) + i,
8706                            REGNO (operands[1]) + i + 1, operands[2], 0))
8707       {
8708         if (i == words-1)
8709           {
8710             xop[0] = operands[1];
8711             xop[1] = operands[2];
8712             xop[2] = GEN_INT (4 * (words-1));
8713             output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
8714             return \"\";
8715           }
8716         else if (i == 0)
8717           {
8718             xop[0] = operands[1];
8719             xop[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
8720             xop[2] = GEN_INT (4 * (words-1));
8721             output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
8722             return \"\";
8723           }
8724         else
8725           {
8726             for (j = 0; j < words; j++)
8727               if (j != i)
8728                 {
8729                   xop[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + j);
8730                   xop[1] = operands[2];
8731                   xop[2] = GEN_INT (j * 4);
8732                   output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
8733                 }
8734             xop[0] = operands[2];
8735             xop[1] = GEN_INT (i * 4);
8736             output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
8737             return \"\";
8738           }
8739       }
8740
8741   return \"{lsi|lswi} %1,%2,%N0\";
8742 }"
8743   [(set_attr "type" "load")
8744    (set_attr "length" "32")])
8745
8746 \f
8747 (define_expand "store_multiple"
8748   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8749                           (match_operand:SI 1 "" ""))
8750                      (clobber (scratch:SI))
8751                      (use (match_operand:SI 2 "" ""))])]
8752   "TARGET_STRING && !TARGET_POWERPC64"
8753   "
8754 {
8755   int regno;
8756   int count;
8757   rtx to;
8758   rtx op0;
8759   int i;
8760
8761   /* Support only storing a constant number of fixed-point registers to
8762      memory and only bother with this if more than two; the machine
8763      doesn't support more than eight.  */
8764   if (GET_CODE (operands[2]) != CONST_INT
8765       || INTVAL (operands[2]) <= 2
8766       || INTVAL (operands[2]) > 8
8767       || GET_CODE (operands[0]) != MEM
8768       || GET_CODE (operands[1]) != REG
8769       || REGNO (operands[1]) >= 32)
8770     FAIL;
8771
8772   count = INTVAL (operands[2]);
8773   regno = REGNO (operands[1]);
8774
8775   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8776   to = force_reg (SImode, XEXP (operands[0], 0));
8777   op0 = replace_equiv_address (operands[0], to);
8778
8779   XVECEXP (operands[3], 0, 0)
8780     = gen_rtx_SET (VOIDmode, adjust_address (op0, SImode, 0), operands[1]);
8781   XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8782                                                  gen_rtx_SCRATCH (SImode));
8783
8784   for (i = 1; i < count; i++)
8785     XVECEXP (operands[3], 0, i + 1)
8786       = gen_rtx_SET (VOIDmode,
8787                      adjust_address (op0, SImode, i * 4),
8788                      gen_rtx_REG (SImode, regno + i));
8789 }")
8790
8791 (define_insn ""
8792   [(match_parallel 0 "store_multiple_operation"
8793                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
8794                          (match_operand:SI 2 "gpc_reg_operand" "r"))
8795                     (clobber (match_scratch:SI 3 "=q"))])]
8796   "TARGET_STRING && TARGET_POWER"
8797   "{stsi|stswi} %2,%P1,%O0"
8798   [(set_attr "type" "store")])
8799
8800 (define_insn ""
8801   [(match_parallel 0 "store_multiple_operation"
8802                    [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8803                          (match_operand:SI 2 "gpc_reg_operand" "r"))
8804                     (clobber (match_scratch:SI 3 "X"))])]
8805   "TARGET_STRING && ! TARGET_POWER"
8806   "{stsi|stswi} %2,%1,%O0"
8807   [(set_attr "type" "store")])
8808
8809 \f
8810 ;; String/block move insn.
8811 ;; Argument 0 is the destination
8812 ;; Argument 1 is the source
8813 ;; Argument 2 is the length
8814 ;; Argument 3 is the alignment
8815
8816 (define_expand "movstrsi"
8817   [(parallel [(set (match_operand:BLK 0 "" "")
8818                    (match_operand:BLK 1 "" ""))
8819               (use (match_operand:SI 2 "" ""))
8820               (use (match_operand:SI 3 "" ""))])]
8821   ""
8822   "
8823 {
8824   if (expand_block_move (operands))
8825     DONE;
8826   else
8827     FAIL;
8828 }")
8829
8830 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
8831 ;; register allocator doesn't have a clue about allocating 8 word registers.
8832 ;; rD/rS = r5 is preferred, efficient form.
8833 (define_expand "movstrsi_8reg"
8834   [(parallel [(set (match_operand 0 "" "")
8835                    (match_operand 1 "" ""))
8836               (use (match_operand 2 "" ""))
8837               (use (match_operand 3 "" ""))
8838               (clobber (reg:SI  5))
8839               (clobber (reg:SI  6))
8840               (clobber (reg:SI  7))
8841               (clobber (reg:SI  8))
8842               (clobber (reg:SI  9))
8843               (clobber (reg:SI 10))
8844               (clobber (reg:SI 11))
8845               (clobber (reg:SI 12))
8846               (clobber (match_scratch:SI 4 ""))])]
8847   "TARGET_STRING"
8848   "")
8849
8850 (define_insn ""
8851   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8852         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8853    (use (match_operand:SI 2 "immediate_operand" "i"))
8854    (use (match_operand:SI 3 "immediate_operand" "i"))
8855    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8856    (clobber (reg:SI  6))
8857    (clobber (reg:SI  7))
8858    (clobber (reg:SI  8))
8859    (clobber (reg:SI  9))
8860    (clobber (reg:SI 10))
8861    (clobber (reg:SI 11))
8862    (clobber (reg:SI 12))
8863    (clobber (match_scratch:SI 5 "=q"))]
8864   "TARGET_STRING && TARGET_POWER
8865    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8866        || INTVAL (operands[2]) == 0)
8867    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8868    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8869    && REGNO (operands[4]) == 5"
8870   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8871   [(set_attr "type" "load")
8872    (set_attr "length" "8")])
8873
8874 (define_insn ""
8875   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8876         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8877    (use (match_operand:SI 2 "immediate_operand" "i"))
8878    (use (match_operand:SI 3 "immediate_operand" "i"))
8879    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8880    (clobber (reg:SI  6))
8881    (clobber (reg:SI  7))
8882    (clobber (reg:SI  8))
8883    (clobber (reg:SI  9))
8884    (clobber (reg:SI 10))
8885    (clobber (reg:SI 11))
8886    (clobber (reg:SI 12))
8887    (clobber (match_scratch:SI 5 "X"))]
8888   "TARGET_STRING && ! TARGET_POWER
8889    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8890        || INTVAL (operands[2]) == 0)
8891    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8892    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8893    && REGNO (operands[4]) == 5"
8894   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8895   [(set_attr "type" "load")
8896    (set_attr "length" "8")])
8897
8898 (define_insn ""
8899   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
8900         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
8901    (use (match_operand:SI 2 "immediate_operand" "i"))
8902    (use (match_operand:SI 3 "immediate_operand" "i"))
8903    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8904    (clobber (reg:SI  6))
8905    (clobber (reg:SI  7))
8906    (clobber (reg:SI  8))
8907    (clobber (reg:SI  9))
8908    (clobber (reg:SI 10))
8909    (clobber (reg:SI 11))
8910    (clobber (reg:SI 12))
8911    (clobber (match_scratch:SI 5 "X"))]
8912   "TARGET_STRING && TARGET_POWERPC64
8913    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
8914        || INTVAL (operands[2]) == 0)
8915    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
8916    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
8917    && REGNO (operands[4]) == 5"
8918   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8919   [(set_attr "type" "load")
8920    (set_attr "length" "8")])
8921
8922 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
8923 ;; register allocator doesn't have a clue about allocating 6 word registers.
8924 ;; rD/rS = r5 is preferred, efficient form.
8925 (define_expand "movstrsi_6reg"
8926   [(parallel [(set (match_operand 0 "" "")
8927                    (match_operand 1 "" ""))
8928               (use (match_operand 2 "" ""))
8929               (use (match_operand 3 "" ""))
8930               (clobber (reg:SI  5))
8931               (clobber (reg:SI  6))
8932               (clobber (reg:SI  7))
8933               (clobber (reg:SI  8))
8934               (clobber (reg:SI  9))
8935               (clobber (reg:SI 10))
8936               (clobber (match_scratch:SI 4 ""))])]
8937   "TARGET_STRING"
8938   "")
8939
8940 (define_insn ""
8941   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8942         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8943    (use (match_operand:SI 2 "immediate_operand" "i"))
8944    (use (match_operand:SI 3 "immediate_operand" "i"))
8945    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8946    (clobber (reg:SI  6))
8947    (clobber (reg:SI  7))
8948    (clobber (reg:SI  8))
8949    (clobber (reg:SI  9))
8950    (clobber (reg:SI 10))
8951    (clobber (match_scratch:SI 5 "=q"))]
8952   "TARGET_STRING && TARGET_POWER
8953    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
8954    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8955    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8956    && REGNO (operands[4]) == 5"
8957   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8958   [(set_attr "type" "load")
8959    (set_attr "length" "8")])
8960
8961 (define_insn ""
8962   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
8963         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
8964    (use (match_operand:SI 2 "immediate_operand" "i"))
8965    (use (match_operand:SI 3 "immediate_operand" "i"))
8966    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8967    (clobber (reg:SI  6))
8968    (clobber (reg:SI  7))
8969    (clobber (reg:SI  8))
8970    (clobber (reg:SI  9))
8971    (clobber (reg:SI 10))
8972    (clobber (match_scratch:SI 5 "X"))]
8973   "TARGET_STRING && ! TARGET_POWER
8974    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
8975    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8976    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8977    && REGNO (operands[4]) == 5"
8978   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
8979   [(set_attr "type" "load")
8980    (set_attr "length" "8")])
8981
8982 (define_insn ""
8983   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
8984         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
8985    (use (match_operand:SI 2 "immediate_operand" "i"))
8986    (use (match_operand:SI 3 "immediate_operand" "i"))
8987    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
8988    (clobber (reg:SI  6))
8989    (clobber (reg:SI  7))
8990    (clobber (reg:SI  8))
8991    (clobber (reg:SI  9))
8992    (clobber (reg:SI 10))
8993    (clobber (match_scratch:SI 5 "X"))]
8994   "TARGET_STRING && TARGET_POWERPC64
8995    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
8996    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
8997    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
8998    && REGNO (operands[4]) == 5"
8999   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9000   [(set_attr "type" "load")
9001    (set_attr "length" "8")])
9002
9003 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9004 ;; problems with TImode.
9005 ;; rD/rS = r5 is preferred, efficient form.
9006 (define_expand "movstrsi_4reg"
9007   [(parallel [(set (match_operand 0 "" "")
9008                    (match_operand 1 "" ""))
9009               (use (match_operand 2 "" ""))
9010               (use (match_operand 3 "" ""))
9011               (clobber (reg:SI 5))
9012               (clobber (reg:SI 6))
9013               (clobber (reg:SI 7))
9014               (clobber (reg:SI 8))
9015               (clobber (match_scratch:SI 4 ""))])]
9016   "TARGET_STRING"
9017   "")
9018
9019 (define_insn ""
9020   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9021         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9022    (use (match_operand:SI 2 "immediate_operand" "i"))
9023    (use (match_operand:SI 3 "immediate_operand" "i"))
9024    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9025    (clobber (reg:SI 6))
9026    (clobber (reg:SI 7))
9027    (clobber (reg:SI 8))
9028    (clobber (match_scratch:SI 5 "=q"))]
9029   "TARGET_STRING && TARGET_POWER
9030    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9031    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9032    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9033    && REGNO (operands[4]) == 5"
9034   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9035   [(set_attr "type" "load")
9036    (set_attr "length" "8")])
9037
9038 (define_insn ""
9039   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9040         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9041    (use (match_operand:SI 2 "immediate_operand" "i"))
9042    (use (match_operand:SI 3 "immediate_operand" "i"))
9043    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9044    (clobber (reg:SI 6))
9045    (clobber (reg:SI 7))
9046    (clobber (reg:SI 8))
9047    (clobber (match_scratch:SI 5 "X"))]
9048   "TARGET_STRING && ! TARGET_POWER
9049    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9050    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9051    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9052    && REGNO (operands[4]) == 5"
9053   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9054   [(set_attr "type" "load")
9055    (set_attr "length" "8")])
9056
9057 (define_insn ""
9058   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9059         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9060    (use (match_operand:SI 2 "immediate_operand" "i"))
9061    (use (match_operand:SI 3 "immediate_operand" "i"))
9062    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9063    (clobber (reg:SI 6))
9064    (clobber (reg:SI 7))
9065    (clobber (reg:SI 8))
9066    (clobber (match_scratch:SI 5 "X"))]
9067   "TARGET_STRING && TARGET_POWERPC64
9068    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9069    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9070    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9071    && REGNO (operands[4]) == 5"
9072   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9073   [(set_attr "type" "load")
9074    (set_attr "length" "8")])
9075
9076 ;; Move up to 8 bytes at a time.
9077 (define_expand "movstrsi_2reg"
9078   [(parallel [(set (match_operand 0 "" "")
9079                    (match_operand 1 "" ""))
9080               (use (match_operand 2 "" ""))
9081               (use (match_operand 3 "" ""))
9082               (clobber (match_scratch:DI 4 ""))
9083               (clobber (match_scratch:SI 5 ""))])]
9084   "TARGET_STRING && ! TARGET_POWERPC64"
9085   "")
9086
9087 (define_insn ""
9088   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9089         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9090    (use (match_operand:SI 2 "immediate_operand" "i"))
9091    (use (match_operand:SI 3 "immediate_operand" "i"))
9092    (clobber (match_scratch:DI 4 "=&r"))
9093    (clobber (match_scratch:SI 5 "=q"))]
9094   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9095    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9096   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9097   [(set_attr "type" "load")
9098    (set_attr "length" "8")])
9099
9100 (define_insn ""
9101   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9102         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9103    (use (match_operand:SI 2 "immediate_operand" "i"))
9104    (use (match_operand:SI 3 "immediate_operand" "i"))
9105    (clobber (match_scratch:DI 4 "=&r"))
9106    (clobber (match_scratch:SI 5 "X"))]
9107   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9108    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9109   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9110   [(set_attr "type" "load")
9111    (set_attr "length" "8")])
9112
9113 ;; Move up to 4 bytes at a time.
9114 (define_expand "movstrsi_1reg"
9115   [(parallel [(set (match_operand 0 "" "")
9116                    (match_operand 1 "" ""))
9117               (use (match_operand 2 "" ""))
9118               (use (match_operand 3 "" ""))
9119               (clobber (match_scratch:SI 4 ""))
9120               (clobber (match_scratch:SI 5 ""))])]
9121   "TARGET_STRING"
9122   "")
9123
9124 (define_insn ""
9125   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9126         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9127    (use (match_operand:SI 2 "immediate_operand" "i"))
9128    (use (match_operand:SI 3 "immediate_operand" "i"))
9129    (clobber (match_scratch:SI 4 "=&r"))
9130    (clobber (match_scratch:SI 5 "=q"))]
9131   "TARGET_STRING && TARGET_POWER
9132    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9133   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9134   [(set_attr "type" "load")
9135    (set_attr "length" "8")])
9136
9137 (define_insn ""
9138   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9139         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9140    (use (match_operand:SI 2 "immediate_operand" "i"))
9141    (use (match_operand:SI 3 "immediate_operand" "i"))
9142    (clobber (match_scratch:SI 4 "=&r"))
9143    (clobber (match_scratch:SI 5 "X"))]
9144   "TARGET_STRING && ! TARGET_POWER
9145    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9146   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9147   [(set_attr "type" "load")
9148    (set_attr "length" "8")])
9149
9150 (define_insn ""
9151   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9152         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9153    (use (match_operand:SI 2 "immediate_operand" "i"))
9154    (use (match_operand:SI 3 "immediate_operand" "i"))
9155    (clobber (match_scratch:SI 4 "=&r"))
9156    (clobber (match_scratch:SI 5 "X"))]
9157   "TARGET_STRING && TARGET_POWERPC64
9158    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9159   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9160   [(set_attr "type" "load")
9161    (set_attr "length" "8")])
9162
9163 \f
9164 ;; Define insns that do load or store with update.  Some of these we can
9165 ;; get by using pre-decrement or pre-increment, but the hardware can also
9166 ;; do cases where the increment is not the size of the object.
9167 ;;
9168 ;; In all these cases, we use operands 0 and 1 for the register being
9169 ;; incremented because those are the operands that local-alloc will
9170 ;; tie and these are the pair most likely to be tieable (and the ones
9171 ;; that will benefit the most).
9172
9173 (define_insn "*movdi_update1"
9174   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9175         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9176                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9177    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9178         (plus:DI (match_dup 1) (match_dup 2)))]
9179   "TARGET_POWERPC64 && TARGET_UPDATE"
9180   "@
9181    ldux %3,%0,%2
9182    ldu %3,%2(%0)"
9183   [(set_attr "type" "load")])
9184
9185 (define_insn "*movdi_update2"
9186   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9187         (sign_extend:DI
9188          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9189                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
9190    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9191         (plus:DI (match_dup 1) (match_dup 2)))]
9192   "TARGET_POWERPC64"
9193   "lwaux %3,%0,%2"
9194   [(set_attr "type" "load")])
9195
9196 (define_insn "movdi_update"
9197   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9198                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
9199         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9200    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9201         (plus:DI (match_dup 1) (match_dup 2)))]
9202   "TARGET_POWERPC64 && TARGET_UPDATE"
9203   "@
9204    stdux %3,%0,%2
9205    stdu %3,%2(%0)"
9206   [(set_attr "type" "store")])
9207
9208 (define_insn "*movsi_update1"
9209   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9210         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9211                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9212    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9213         (plus:SI (match_dup 1) (match_dup 2)))]
9214   ""
9215   "@
9216    {lux|lwzux} %3,%0,%2
9217    {lu|lwzu} %3,%2(%0)"
9218   [(set_attr "type" "load")])
9219
9220 (define_insn "movsi_update"
9221   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9222                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9223         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9224    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9225         (plus:SI (match_dup 1) (match_dup 2)))]
9226   "TARGET_UPDATE"
9227   "@
9228    {stux|stwux} %3,%0,%2
9229    {stu|stwu} %3,%2(%0)"
9230   [(set_attr "type" "store")])
9231
9232 (define_insn "*movhi_update"
9233   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9234         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9235                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9236    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9237         (plus:SI (match_dup 1) (match_dup 2)))]
9238   "TARGET_UPDATE"
9239   "@
9240    lhzux %3,%0,%2
9241    lhzu %3,%2(%0)"
9242   [(set_attr "type" "load")])
9243
9244 (define_insn "*movhi_update2"
9245   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9246         (zero_extend:SI
9247          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9248                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9249    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9250         (plus:SI (match_dup 1) (match_dup 2)))]
9251   "TARGET_UPDATE"
9252   "@
9253    lhzux %3,%0,%2
9254    lhzu %3,%2(%0)"
9255   [(set_attr "type" "load")])
9256
9257 (define_insn "*movhi_update3"
9258   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9259         (sign_extend:SI
9260          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9261                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9262    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9263         (plus:SI (match_dup 1) (match_dup 2)))]
9264   "TARGET_UPDATE"
9265   "@
9266    lhaux %3,%0,%2
9267    lhau %3,%2(%0)"
9268   [(set_attr "type" "load")])
9269
9270 (define_insn "*movhi_update4"
9271   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9272                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9273         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9274    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9275         (plus:SI (match_dup 1) (match_dup 2)))]
9276   "TARGET_UPDATE"
9277   "@
9278    sthux %3,%0,%2
9279    sthu %3,%2(%0)"
9280   [(set_attr "type" "store")])
9281
9282 (define_insn "*movqi_update1"
9283   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9284         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9285                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9286    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9287         (plus:SI (match_dup 1) (match_dup 2)))]
9288   "TARGET_UPDATE"
9289   "@
9290    lbzux %3,%0,%2
9291    lbzu %3,%2(%0)"
9292   [(set_attr "type" "load")])
9293
9294 (define_insn "*movqi_update2"
9295   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9296         (zero_extend:SI
9297          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9298                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9299    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9300         (plus:SI (match_dup 1) (match_dup 2)))]
9301   "TARGET_UPDATE"
9302   "@
9303    lbzux %3,%0,%2
9304    lbzu %3,%2(%0)"
9305   [(set_attr "type" "load")])
9306
9307 (define_insn "*movqi_update3"
9308   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9309                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9310         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9311    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9312         (plus:SI (match_dup 1) (match_dup 2)))]
9313   "TARGET_UPDATE"
9314   "@
9315    stbux %3,%0,%2
9316    stbu %3,%2(%0)"
9317   [(set_attr "type" "store")])
9318
9319 (define_insn "*movsf_update1"
9320   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9321         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9322                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9323    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9324         (plus:SI (match_dup 1) (match_dup 2)))]
9325   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9326   "@
9327    lfsux %3,%0,%2
9328    lfsu %3,%2(%0)"
9329   [(set_attr "type" "fpload")])
9330
9331 (define_insn "*movsf_update2"
9332   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9333                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9334         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9335    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9336         (plus:SI (match_dup 1) (match_dup 2)))]
9337   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9338   "@
9339    stfsux %3,%0,%2
9340    stfsu %3,%2(%0)"
9341   [(set_attr "type" "fpstore")])
9342
9343 (define_insn "*movsf_update3"
9344   [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9345         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9346                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9347    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9348         (plus:SI (match_dup 1) (match_dup 2)))]
9349   "TARGET_SOFT_FLOAT && TARGET_UPDATE"
9350   "@
9351    {lux|lwzux} %3,%0,%2
9352    {lu|lwzu} %3,%2(%0)"
9353   [(set_attr "type" "load")])
9354
9355 (define_insn "*movsf_update4"
9356   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9357                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9358         (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9359    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9360         (plus:SI (match_dup 1) (match_dup 2)))]
9361   "TARGET_SOFT_FLOAT && TARGET_UPDATE"
9362   "@
9363    {stux|stwux} %3,%0,%2
9364    {stu|stwu} %3,%2(%0)"
9365   [(set_attr "type" "store")])
9366
9367 (define_insn "*movdf_update1"
9368   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9369         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9370                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9371    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9372         (plus:SI (match_dup 1) (match_dup 2)))]
9373   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9374   "@
9375    lfdux %3,%0,%2
9376    lfdu %3,%2(%0)"
9377   [(set_attr "type" "fpload")])
9378
9379 (define_insn "*movdf_update2"
9380   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9381                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9382         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9383    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9384         (plus:SI (match_dup 1) (match_dup 2)))]
9385   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9386   "@
9387    stfdux %3,%0,%2
9388    stfdu %3,%2(%0)"
9389   [(set_attr "type" "fpstore")])
9390
9391 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9392
9393 (define_peephole
9394   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
9395         (match_operand:DF 1 "memory_operand" ""))
9396    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
9397         (match_operand:DF 3 "memory_operand" ""))]
9398   "TARGET_POWER2
9399    && TARGET_HARD_FLOAT
9400    && registers_ok_for_quad_peep (operands[0], operands[2])
9401    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
9402    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
9403   "lfq%U1%X1 %0,%1")
9404
9405 (define_peephole
9406   [(set (match_operand:DF 0 "memory_operand" "")
9407         (match_operand:DF 1 "gpc_reg_operand" "f"))
9408    (set (match_operand:DF 2 "memory_operand" "")
9409         (match_operand:DF 3 "gpc_reg_operand" "f"))]
9410   "TARGET_POWER2
9411    && TARGET_HARD_FLOAT
9412    && registers_ok_for_quad_peep (operands[1], operands[3])
9413    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
9414    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
9415   "stfq%U0%X0 %1,%0")
9416 \f
9417 ;; Next come insns related to the calling sequence.
9418 ;;
9419 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9420 ;; We move the back-chain and decrement the stack pointer.
9421
9422 (define_expand "allocate_stack"
9423   [(set (match_operand 0 "gpc_reg_operand" "=r")
9424         (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9425    (set (reg 1)
9426         (minus (reg 1) (match_dup 1)))]
9427   ""
9428   "
9429 { rtx chain = gen_reg_rtx (Pmode);
9430   rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9431   rtx neg_op0;
9432
9433   emit_move_insn (chain, stack_bot);
9434
9435   /* Check stack bounds if necessary.  */
9436   if (current_function_limit_stack)
9437     {
9438       rtx available;
9439       available = expand_binop (Pmode, sub_optab, 
9440                                 stack_pointer_rtx, stack_limit_rtx,
9441                                 NULL_RTX, 1, OPTAB_WIDEN);
9442       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9443     }
9444
9445   if (GET_CODE (operands[1]) != CONST_INT
9446       || INTVAL (operands[1]) < -32767
9447       || INTVAL (operands[1]) > 32768)
9448     {
9449       neg_op0 = gen_reg_rtx (Pmode);
9450       if (TARGET_32BIT)
9451         emit_insn (gen_negsi2 (neg_op0, operands[1]));
9452       else
9453         emit_insn (gen_negdi2 (neg_op0, operands[1]));
9454     }
9455   else
9456     neg_op0 = GEN_INT (- INTVAL (operands[1]));
9457
9458   if (TARGET_UPDATE)
9459     emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
9460                 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
9461
9462   else
9463     {
9464       emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9465                  (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
9466       emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
9467     }
9468
9469   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9470   DONE;
9471 }")
9472
9473 ;; These patterns say how to save and restore the stack pointer.  We need not
9474 ;; save the stack pointer at function level since we are careful to
9475 ;; preserve the backchain.  At block level, we have to restore the backchain
9476 ;; when we restore the stack pointer.
9477 ;;
9478 ;; For nonlocal gotos, we must save both the stack pointer and its
9479 ;; backchain and restore both.  Note that in the nonlocal case, the
9480 ;; save area is a memory location.
9481
9482 (define_expand "save_stack_function"
9483   [(match_operand 0 "any_operand" "")
9484    (match_operand 1 "any_operand" "")]
9485   ""
9486   "DONE;")
9487
9488 (define_expand "restore_stack_function"
9489   [(match_operand 0 "any_operand" "")
9490    (match_operand 1 "any_operand" "")]
9491   ""
9492   "DONE;")
9493
9494 (define_expand "restore_stack_block"
9495   [(use (match_operand 0 "register_operand" ""))
9496    (set (match_dup 2) (match_dup 3))
9497    (set (match_dup 0) (match_operand 1 "register_operand" ""))
9498    (set (match_dup 3) (match_dup 2))]
9499   ""
9500   "
9501 {
9502   operands[2] = gen_reg_rtx (Pmode);
9503   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
9504 }")
9505
9506 (define_expand "save_stack_nonlocal"
9507   [(match_operand 0 "memory_operand" "")
9508    (match_operand 1 "register_operand" "")]
9509   ""
9510   "
9511 {
9512   rtx temp = gen_reg_rtx (Pmode);
9513
9514   /* Copy the backchain to the first word, sp to the second.  */
9515   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
9516   emit_move_insn (operand_subword (operands[0], 0, 0,
9517                                    (TARGET_32BIT ? DImode : TImode)),
9518                   temp);
9519   emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
9520                   operands[1]);
9521   DONE;
9522 }")
9523
9524 (define_expand "restore_stack_nonlocal"
9525   [(match_operand 0 "register_operand" "")
9526    (match_operand 1 "memory_operand" "")]
9527   ""
9528   "
9529 {
9530   rtx temp = gen_reg_rtx (Pmode);
9531
9532   /* Restore the backchain from the first word, sp from the second.  */
9533   emit_move_insn (temp,
9534                   operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
9535   emit_move_insn (operands[0],
9536                   operand_subword (operands[1], 1, 0,
9537                                    (TARGET_32BIT ? DImode : TImode)));
9538   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
9539   DONE;
9540 }")
9541 \f
9542 ;; TOC register handling.
9543
9544 ;; Code to initialize the TOC register...
9545
9546 (define_insn "load_toc_aix_si"
9547   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9548                    (unspec:SI [(const_int 0)] 7))
9549               (use (reg:SI 2))])]
9550   "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
9551   "*
9552 {
9553   char buf[30];
9554   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9555   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9556   operands[2] = gen_rtx_REG (Pmode, 2);
9557   return \"{l|lwz} %0,%1(%2)\";
9558 }"
9559   [(set_attr "type" "load")])
9560
9561 (define_insn "load_toc_aix_di"
9562   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9563                    (unspec:DI [(const_int 0)] 7))
9564               (use (reg:DI 2))])]
9565   "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9566   "*
9567 {
9568   char buf[30];
9569 #ifdef TARGET_RELOCATABLE
9570   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
9571                                !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
9572 #else
9573   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9574 #endif
9575   if (TARGET_ELF)
9576     strcat (buf, \"@toc\");
9577   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9578   operands[2] = gen_rtx_REG (Pmode, 2);
9579   return \"ld %0,%1(%2)\";
9580 }"
9581   [(set_attr "type" "load")])
9582
9583 (define_insn "load_toc_v4_pic_si"
9584   [(set (match_operand:SI 0 "register_operand" "=l")
9585         (unspec:SI [(const_int 0)] 7))]
9586   "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9587   "bl _GLOBAL_OFFSET_TABLE_@local-4"
9588   [(set_attr "type" "branch")
9589    (set_attr "length" "4")])
9590
9591 (define_insn "load_toc_v4_PIC_1"
9592   [(set (match_operand:SI 0 "register_operand" "=l")
9593         (match_operand:SI 1 "immediate_operand" "s"))
9594    (unspec [(match_dup 1)] 7)]
9595   "TARGET_ELF && flag_pic == 2"
9596   "bl %1\\n%1:"
9597   [(set_attr "type" "branch")
9598    (set_attr "length" "4")])
9599
9600 (define_insn "load_toc_v4_PIC_1b"
9601   [(set (match_operand:SI 0 "register_operand" "=l")
9602         (match_operand:SI 1 "immediate_operand" "s"))
9603    (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")] 6)]
9604   "TARGET_ELF && flag_pic == 2"
9605   "bl %1\\n\\t.long %2-%1+4\\n%1:"
9606   [(set_attr "type" "branch")
9607    (set_attr "length" "8")])
9608
9609 (define_insn "load_toc_v4_PIC_2"
9610   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9611         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9612                    (minus:SI (match_operand:SI 2 "immediate_operand" "s")
9613                              (match_operand:SI 3 "immediate_operand" "s")))))]
9614   "TARGET_ELF && flag_pic == 2"
9615   "{l|lwz} %0,%2-%3(%1)"
9616   [(set_attr "type" "load")])
9617
9618 (define_insn "load_macho_picbase"
9619   [(set (match_operand:SI 0 "register_operand" "=l")
9620         (unspec:SI [(const_int 0)] 15))]
9621   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
9622   "*
9623 {
9624 #if TARGET_MACHO
9625   char *picbase = machopic_function_base_name ();
9626   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
9627 #endif
9628   return \"bcl 20,31,%1\\n%1:\";
9629 }"
9630   [(set_attr "type" "branch")
9631    (set_attr "length" "4")])
9632
9633 ;; If the TOC is shared over a translation unit, as happens with all
9634 ;; the kinds of PIC that we support, we need to restore the TOC
9635 ;; pointer only when jumping over units of translation.
9636
9637 (define_expand "builtin_setjmp_receiver"
9638   [(use (label_ref (match_operand 0 "" "")))]
9639   "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
9640    || (TARGET_TOC && TARGET_MINIMAL_TOC)"
9641   "
9642 {
9643   rs6000_emit_load_toc_table (FALSE);
9644   DONE;
9645 }")
9646 \f
9647 ;; A function pointer under AIX is a pointer to a data area whose first word
9648 ;; contains the actual address of the function, whose second word contains a
9649 ;; pointer to its TOC, and whose third word contains a value to place in the
9650 ;; static chain register (r11).  Note that if we load the static chain, our
9651 ;; "trampoline" need not have any executable code.
9652
9653 (define_expand "call_indirect_aix32"
9654   [(set (match_dup 2)
9655         (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
9656    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9657         (reg:SI 2))
9658    (set (reg:SI 2)
9659         (mem:SI (plus:SI (match_dup 0)
9660                          (const_int 4))))
9661    (set (reg:SI 11)
9662         (mem:SI (plus:SI (match_dup 0)
9663                          (const_int 8))))
9664    (parallel [(call (mem:SI (match_dup 2))
9665                     (match_operand 1 "" ""))
9666               (use (reg:SI 2))
9667               (use (reg:SI 11))
9668               (set (reg:SI 2)
9669                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9670               (clobber (scratch:SI))])]
9671   "TARGET_32BIT"
9672   "
9673 { operands[2] = gen_reg_rtx (SImode); }")
9674
9675 (define_expand "call_indirect_aix64"
9676   [(set (match_dup 2)
9677         (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
9678    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9679         (reg:DI 2))
9680    (set (reg:DI 2)
9681         (mem:DI (plus:DI (match_dup 0)
9682                          (const_int 8))))
9683    (set (reg:DI 11)
9684         (mem:DI (plus:DI (match_dup 0)
9685                          (const_int 16))))
9686    (parallel [(call (mem:SI (match_dup 2))
9687                     (match_operand 1 "" ""))
9688               (use (reg:DI 2))
9689               (use (reg:DI 11))
9690               (set (reg:DI 2)
9691                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9692               (clobber (scratch:SI))])]
9693   "TARGET_64BIT"
9694   "
9695 { operands[2] = gen_reg_rtx (DImode); }")
9696
9697 (define_expand "call_value_indirect_aix32"
9698   [(set (match_dup 3)
9699         (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
9700    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9701         (reg:SI 2))
9702    (set (reg:SI 2)
9703         (mem:SI (plus:SI (match_dup 1)
9704                          (const_int 4))))
9705    (set (reg:SI 11)
9706         (mem:SI (plus:SI (match_dup 1)
9707                          (const_int 8))))
9708    (parallel [(set (match_operand 0 "" "")
9709                    (call (mem:SI (match_dup 3))
9710                          (match_operand 2 "" "")))
9711               (use (reg:SI 2))
9712               (use (reg:SI 11))
9713               (set (reg:SI 2)
9714                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9715               (clobber (scratch:SI))])]
9716   "TARGET_32BIT"
9717   "
9718 { operands[3] = gen_reg_rtx (SImode); }")
9719
9720 (define_expand "call_value_indirect_aix64"
9721   [(set (match_dup 3)
9722         (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
9723    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9724         (reg:DI 2))
9725    (set (reg:DI 2)
9726         (mem:DI (plus:DI (match_dup 1)
9727                          (const_int 8))))
9728    (set (reg:DI 11)
9729         (mem:DI (plus:DI (match_dup 1)
9730                          (const_int 16))))
9731    (parallel [(set (match_operand 0 "" "")
9732                    (call (mem:SI (match_dup 3))
9733                          (match_operand 2 "" "")))
9734               (use (reg:DI 2))
9735               (use (reg:DI 11))
9736               (set (reg:DI 2)
9737                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9738               (clobber (scratch:SI))])]
9739   "TARGET_64BIT"
9740   "
9741 { operands[3] = gen_reg_rtx (DImode); }")
9742
9743 ;; Now the definitions for the call and call_value insns
9744 (define_expand "call"
9745   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
9746                     (match_operand 1 "" ""))
9747               (use (match_operand 2 "" ""))
9748               (clobber (scratch:SI))])]
9749   ""
9750   "
9751 {
9752 #if TARGET_MACHO
9753   if (flag_pic)
9754     operands[0] = machopic_indirect_call_target (operands[0]);
9755 #endif
9756
9757   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
9758     abort ();
9759
9760   operands[0] = XEXP (operands[0], 0);
9761
9762   if (GET_CODE (operands[0]) != SYMBOL_REF
9763       || (INTVAL (operands[2]) & CALL_LONG) != 0)
9764     {
9765       if (INTVAL (operands[2]) & CALL_LONG)
9766         operands[0] = rs6000_longcall_ref (operands[0]);
9767
9768       if (DEFAULT_ABI == ABI_V4
9769           || DEFAULT_ABI == ABI_AIX_NODESC
9770           || DEFAULT_ABI == ABI_DARWIN)
9771         operands[0] = force_reg (Pmode, operands[0]);
9772
9773       else if (DEFAULT_ABI == ABI_AIX)
9774         {
9775           /* AIX function pointers are really pointers to a three word
9776              area.  */
9777           emit_call_insn (TARGET_32BIT
9778                           ? gen_call_indirect_aix32 (force_reg (SImode,
9779                                                                 operands[0]),
9780                                                      operands[1])
9781                           : gen_call_indirect_aix64 (force_reg (DImode,
9782                                                                 operands[0]),
9783                                                      operands[1]));
9784           DONE;
9785         }
9786       else
9787         abort ();
9788     }
9789 }")
9790
9791 (define_expand "call_value"
9792   [(parallel [(set (match_operand 0 "" "")
9793                    (call (mem:SI (match_operand 1 "address_operand" ""))
9794                          (match_operand 2 "" "")))
9795               (use (match_operand 3 "" ""))
9796               (clobber (scratch:SI))])]
9797   ""
9798   "
9799 {
9800 #if TARGET_MACHO
9801   if (flag_pic)
9802     operands[1] = machopic_indirect_call_target (operands[1]);
9803 #endif
9804
9805   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
9806     abort ();
9807
9808   operands[1] = XEXP (operands[1], 0);
9809
9810   if (GET_CODE (operands[1]) != SYMBOL_REF
9811       || (INTVAL (operands[3]) & CALL_LONG) != 0)
9812     {
9813       if (INTVAL (operands[3]) & CALL_LONG)
9814         operands[1] = rs6000_longcall_ref (operands[1]);
9815
9816       if (DEFAULT_ABI == ABI_V4
9817           || DEFAULT_ABI == ABI_AIX_NODESC
9818           || DEFAULT_ABI == ABI_DARWIN)
9819         operands[0] = force_reg (Pmode, operands[0]);
9820
9821       else if (DEFAULT_ABI == ABI_AIX)
9822         {
9823           /* AIX function pointers are really pointers to a three word
9824              area.  */
9825           emit_call_insn (TARGET_32BIT
9826                           ? gen_call_value_indirect_aix32 (operands[0],
9827                                                            force_reg (SImode,
9828                                                                       operands[1]),
9829                                                            operands[2])
9830                           : gen_call_value_indirect_aix64 (operands[0],
9831                                                            force_reg (DImode,
9832                                                                       operands[1]),
9833                                                            operands[2]));
9834           DONE;
9835         }
9836       else
9837         abort ();
9838     }
9839 }")
9840
9841 ;; Call to function in current module.  No TOC pointer reload needed.
9842 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
9843 ;; either the function was not prototyped, or it was prototyped as a
9844 ;; variable argument function.  It is > 0 if FP registers were passed
9845 ;; and < 0 if they were not.
9846
9847 (define_insn "*call_local32"
9848   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
9849          (match_operand 1 "" "g,g"))
9850    (use (match_operand:SI 2 "immediate_operand" "O,n"))
9851    (clobber (match_scratch:SI 3 "=l,l"))]
9852   "(INTVAL (operands[2]) & CALL_LONG) == 0"
9853   "*
9854 {
9855   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9856     output_asm_insn (\"crxor 6,6,6\", operands);
9857
9858   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9859     output_asm_insn (\"creqv 6,6,6\", operands);
9860
9861   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9862 }"
9863   [(set_attr "type" "branch")
9864    (set_attr "length" "4,8")])
9865
9866 (define_insn "*call_local64"
9867   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
9868          (match_operand 1 "" "g,g"))
9869    (use (match_operand:SI 2 "immediate_operand" "O,n"))
9870    (clobber (match_scratch:SI 3 "=l,l"))]
9871   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
9872   "*
9873 {
9874   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
9875     output_asm_insn (\"crxor 6,6,6\", operands);
9876
9877   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
9878     output_asm_insn (\"creqv 6,6,6\", operands);
9879
9880   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
9881 }"
9882   [(set_attr "type" "branch")
9883    (set_attr "length" "4,8")])
9884
9885 (define_insn "*call_value_local32"
9886   [(set (match_operand 0 "" "")
9887         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
9888               (match_operand 2 "" "g,g")))
9889    (use (match_operand:SI 3 "immediate_operand" "O,n"))
9890    (clobber (match_scratch:SI 4 "=l,l"))]
9891   "(INTVAL (operands[3]) & CALL_LONG) == 0"
9892   "*
9893 {
9894   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
9895     output_asm_insn (\"crxor 6,6,6\", operands);
9896
9897   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
9898     output_asm_insn (\"creqv 6,6,6\", operands);
9899
9900   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
9901 }"
9902   [(set_attr "type" "branch")
9903    (set_attr "length" "4,8")])
9904
9905
9906 (define_insn "*call_value_local64"
9907   [(set (match_operand 0 "" "")
9908         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
9909               (match_operand 2 "" "g,g")))
9910    (use (match_operand:SI 3 "immediate_operand" "O,n"))
9911    (clobber (match_scratch:SI 4 "=l,l"))]
9912   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
9913   "*
9914 {
9915   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
9916     output_asm_insn (\"crxor 6,6,6\", operands);
9917
9918   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
9919     output_asm_insn (\"creqv 6,6,6\", operands);
9920
9921   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
9922 }"
9923   [(set_attr "type" "branch")
9924    (set_attr "length" "4,8")])
9925
9926 ;; Call to function which may be in another module.  Restore the TOC
9927 ;; pointer (r2) after the call unless this is System V.
9928 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
9929 ;; either the function was not prototyped, or it was prototyped as a
9930 ;; variable argument function.  It is > 0 if FP registers were passed
9931 ;; and < 0 if they were not.
9932
9933 (define_insn "*call_indirect_nonlocal_aix32"
9934   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
9935          (match_operand 1 "" "g"))
9936    (use (reg:SI 2))
9937    (use (reg:SI 11))
9938    (set (reg:SI 2)
9939         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9940    (clobber (match_scratch:SI 2 "=l"))]
9941   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9942   "b%T0l\;{l|lwz} 2,20(1)"
9943   [(set_attr "type" "jmpreg")
9944    (set_attr "length" "8")])
9945
9946 (define_insn "*call_nonlocal_aix32"
9947   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
9948          (match_operand 1 "" "g"))
9949    (use (match_operand:SI 2 "immediate_operand" "O"))
9950    (clobber (match_scratch:SI 3 "=l"))]
9951   "TARGET_32BIT
9952    && DEFAULT_ABI == ABI_AIX
9953    && (INTVAL (operands[2]) & CALL_LONG) == 0"
9954   "bl %z0\;%."
9955   [(set_attr "type" "branch")
9956    (set_attr "length" "8")])
9957
9958 (define_insn "*call_indirect_nonlocal_aix64"
9959   [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
9960          (match_operand 1 "" "g"))
9961    (use (reg:DI 2))
9962    (use (reg:DI 11))
9963    (set (reg:DI 2)
9964         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9965    (clobber (match_scratch:SI 2 "=l"))]
9966   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
9967   "b%T0l\;ld 2,40(1)"
9968   [(set_attr "type" "jmpreg")
9969    (set_attr "length" "8")])
9970
9971 (define_insn "*call_nonlocal_aix64"
9972   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
9973          (match_operand 1 "" "g"))
9974    (use (match_operand:SI 2 "immediate_operand" "O"))
9975    (clobber (match_scratch:SI 3 "=l"))]
9976   "TARGET_64BIT 
9977    && DEFAULT_ABI == ABI_AIX
9978    && (INTVAL (operands[2]) & CALL_LONG) == 0"
9979   "bl %z0\;%."
9980   [(set_attr "type" "branch")
9981    (set_attr "length" "8")])
9982
9983 (define_insn "*call_value_indirect_nonlocal_aix32"
9984   [(set (match_operand 0 "" "")
9985         (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
9986               (match_operand 2 "" "g")))
9987    (use (reg:SI 2))
9988    (use (reg:SI 11))
9989    (set (reg:SI 2)
9990         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9991    (clobber (match_scratch:SI 3 "=l"))]
9992   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
9993   "b%T1l\;{l|lwz} 2,20(1)"
9994   [(set_attr "type" "jmpreg")
9995    (set_attr "length" "8")])
9996
9997 (define_insn "*call_value_nonlocal_aix32"
9998   [(set (match_operand 0 "" "")
9999         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10000               (match_operand 2 "" "g")))
10001    (use (match_operand:SI 3 "immediate_operand" "O"))
10002    (clobber (match_scratch:SI 4 "=l"))]
10003   "TARGET_32BIT
10004    && DEFAULT_ABI == ABI_AIX
10005    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10006   "bl %z1\;%."
10007   [(set_attr "type" "branch")
10008    (set_attr "length" "8")])
10009
10010 (define_insn "*call_value_indirect_nonlocal_aix64"
10011   [(set (match_operand 0 "" "")
10012         (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10013               (match_operand 2 "" "g")))
10014    (use (reg:DI 2))
10015    (use (reg:DI 11))
10016    (set (reg:DI 2)
10017         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10018    (clobber (match_scratch:SI 3 "=l"))]
10019   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10020   "b%T1l\;ld 2,40(1)"
10021   [(set_attr "type" "jmpreg")
10022    (set_attr "length" "8")])
10023
10024 (define_insn "*call_value_nonlocal_aix64"
10025   [(set (match_operand 0 "" "")
10026         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10027               (match_operand 2 "" "g")))
10028    (use (match_operand:SI 3 "immediate_operand" "O"))
10029    (clobber (match_scratch:SI 4 "=l"))]
10030   "TARGET_64BIT 
10031    && DEFAULT_ABI == ABI_AIX
10032    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10033   "bl %z1\;%."
10034   [(set_attr "type" "branch")
10035    (set_attr "length" "8")])
10036
10037 ;; A function pointer under System V is just a normal pointer
10038 ;; operands[0] is the function pointer
10039 ;; operands[1] is the stack size to clean up
10040 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10041 ;; which indicates how to set cr1
10042
10043 (define_insn "*call_nonlocal_sysv"
10044   [(call (mem:SI (match_operand:SI 0 "call_operand" "cl,cl,s,s"))
10045          (match_operand 1 "" "g,g,g,g"))
10046    (use (match_operand:SI 2 "immediate_operand" "O,n,O,n"))
10047    (clobber (match_scratch:SI 3 "=l,l,l,l"))]
10048   "DEFAULT_ABI == ABI_AIX_NODESC
10049    || DEFAULT_ABI == ABI_V4
10050    || DEFAULT_ABI == ABI_DARWIN"
10051   "*
10052 {
10053   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10054     output_asm_insn (\"crxor 6,6,6\", operands);
10055
10056   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10057     output_asm_insn (\"creqv 6,6,6\", operands);
10058
10059   switch (which_alternative)
10060     {
10061     default:
10062       abort ();
10063     case 0:
10064     case 1:
10065       return \"b%T0l\";
10066     case 2:
10067     case 3:
10068       return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@plt\" : \"bl %z0\";
10069     }
10070 }"
10071   [(set_attr "type" "jmpreg,jmpreg,branch,branch")
10072    (set_attr "length" "4,8,4,8")])
10073
10074 (define_insn "*call_value_nonlocal_sysv"
10075   [(set (match_operand 0 "" "")
10076         (call (mem:SI (match_operand:SI 1 "call_operand" "cl,cl,s,s"))
10077               (match_operand 2 "" "g,g,g,g")))
10078    (use (match_operand:SI 3 "immediate_operand" "O,n,O,n"))
10079    (clobber (match_scratch:SI 4 "=l,l,l,l"))]
10080   "DEFAULT_ABI == ABI_AIX_NODESC
10081    || DEFAULT_ABI == ABI_V4
10082    || DEFAULT_ABI == ABI_DARWIN"
10083   "*
10084 {
10085   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10086     output_asm_insn (\"crxor 6,6,6\", operands);
10087
10088   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10089     output_asm_insn (\"creqv 6,6,6\", operands);
10090
10091   switch (which_alternative)
10092     {
10093     default:
10094       abort ();
10095     case 0:
10096     case 1:
10097       return \"b%T1l\";
10098     case 2:
10099     case 3:
10100       return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@plt\" : \"bl %z1\";
10101     }
10102 }"
10103   [(set_attr "type" "jmpreg,jmpreg,branch,branch")
10104    (set_attr "length" "4,8,4,8")])
10105
10106 ;; Call subroutine returning any type.
10107 (define_expand "untyped_call"
10108   [(parallel [(call (match_operand 0 "" "")
10109                     (const_int 0))
10110               (match_operand 1 "" "")
10111               (match_operand 2 "" "")])]
10112   ""
10113   "
10114 {
10115   int i;
10116
10117   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10118
10119   for (i = 0; i < XVECLEN (operands[2], 0); i++)
10120     {
10121       rtx set = XVECEXP (operands[2], 0, i);
10122       emit_move_insn (SET_DEST (set), SET_SRC (set));
10123     }
10124
10125   /* The optimizer does not know that the call sets the function value
10126      registers we stored in the result block.  We avoid problems by
10127      claiming that all hard registers are used and clobbered at this
10128      point.  */
10129   emit_insn (gen_blockage ());
10130
10131   DONE;
10132 }")
10133
10134 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10135 ;; all of memory.  This blocks insns from being moved across this point.
10136
10137 (define_insn "blockage"
10138   [(unspec_volatile [(const_int 0)] 0)]
10139   ""
10140   "")
10141 \f
10142 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
10143 ;; signed & unsigned, and one type of branch.
10144 ;;
10145 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10146 ;; insns, and branches.  We store the operands of compares until we see
10147 ;; how it is used.
10148 (define_expand "cmpsi"
10149   [(set (cc0)
10150         (compare (match_operand:SI 0 "gpc_reg_operand" "")
10151                  (match_operand:SI 1 "reg_or_short_operand" "")))]
10152   ""
10153   "
10154 {
10155   /* Take care of the possibility that operands[1] might be negative but
10156      this might be a logical operation.  That insn doesn't exist.  */
10157   if (GET_CODE (operands[1]) == CONST_INT
10158       && INTVAL (operands[1]) < 0)
10159     operands[1] = force_reg (SImode, operands[1]);
10160
10161   rs6000_compare_op0 = operands[0];
10162   rs6000_compare_op1 = operands[1];
10163   rs6000_compare_fp_p = 0;
10164   DONE;
10165 }")
10166
10167 (define_expand "cmpdi"
10168   [(set (cc0)
10169         (compare (match_operand:DI 0 "gpc_reg_operand" "")
10170                  (match_operand:DI 1 "reg_or_short_operand" "")))]
10171   "TARGET_POWERPC64"
10172   "
10173 {
10174   /* Take care of the possibility that operands[1] might be negative but
10175      this might be a logical operation.  That insn doesn't exist.  */
10176   if (GET_CODE (operands[1]) == CONST_INT
10177       && INTVAL (operands[1]) < 0)
10178     operands[1] = force_reg (DImode, operands[1]);
10179
10180   rs6000_compare_op0 = operands[0];
10181   rs6000_compare_op1 = operands[1];
10182   rs6000_compare_fp_p = 0;
10183   DONE;
10184 }")
10185
10186 (define_expand "cmpsf"
10187   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
10188                        (match_operand:SF 1 "gpc_reg_operand" "")))]
10189   "TARGET_HARD_FLOAT"
10190   "
10191 {
10192   rs6000_compare_op0 = operands[0];
10193   rs6000_compare_op1 = operands[1];
10194   rs6000_compare_fp_p = 1;
10195   DONE;
10196 }")
10197
10198 (define_expand "cmpdf"
10199   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
10200                        (match_operand:DF 1 "gpc_reg_operand" "")))]
10201   "TARGET_HARD_FLOAT"
10202   "
10203 {
10204   rs6000_compare_op0 = operands[0];
10205   rs6000_compare_op1 = operands[1];
10206   rs6000_compare_fp_p = 1;
10207   DONE;
10208 }")
10209
10210 (define_expand "cmptf"
10211   [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
10212                        (match_operand:TF 1 "gpc_reg_operand" "")))]
10213   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
10214   "
10215 {
10216   rs6000_compare_op0 = operands[0];
10217   rs6000_compare_op1 = operands[1];
10218   rs6000_compare_fp_p = 1;
10219   DONE;
10220 }")
10221
10222 (define_expand "beq"
10223   [(use (match_operand 0 "" ""))]
10224   ""
10225   "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
10226
10227 (define_expand "bne"
10228   [(use (match_operand 0 "" ""))]
10229   ""
10230   "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
10231
10232 (define_expand "bge"
10233   [(use (match_operand 0 "" ""))]
10234   ""
10235   "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
10236
10237 (define_expand "bgt"
10238   [(use (match_operand 0 "" ""))]
10239   ""
10240   "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
10241
10242 (define_expand "ble"
10243   [(use (match_operand 0 "" ""))]
10244   ""
10245   "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
10246
10247 (define_expand "blt"
10248   [(use (match_operand 0 "" ""))]
10249   ""
10250   "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
10251
10252 (define_expand "bgeu"
10253   [(use (match_operand 0 "" ""))]
10254   ""
10255   "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
10256
10257 (define_expand "bgtu"
10258   [(use (match_operand 0 "" ""))]
10259   ""
10260   "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
10261
10262 (define_expand "bleu"
10263   [(use (match_operand 0 "" ""))]
10264   ""
10265   "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
10266
10267 (define_expand "bltu"
10268   [(use (match_operand 0 "" ""))]
10269   ""
10270   "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
10271
10272 (define_expand "bunordered"
10273   [(use (match_operand 0 "" ""))]
10274   ""
10275   "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
10276
10277 (define_expand "bordered"
10278   [(use (match_operand 0 "" ""))]
10279   ""
10280   "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
10281
10282 (define_expand "buneq"
10283   [(use (match_operand 0 "" ""))]
10284   ""
10285   "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
10286
10287 (define_expand "bunge"
10288   [(use (match_operand 0 "" ""))]
10289   ""
10290   "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
10291
10292 (define_expand "bungt"
10293   [(use (match_operand 0 "" ""))]
10294   ""
10295   "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
10296
10297 (define_expand "bunle"
10298   [(use (match_operand 0 "" ""))]
10299   ""
10300   "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
10301
10302 (define_expand "bunlt"
10303   [(use (match_operand 0 "" ""))]
10304   ""
10305   "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
10306
10307 (define_expand "bltgt"
10308   [(use (match_operand 0 "" ""))]
10309   ""
10310   "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
10311
10312 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
10313 ;; For SEQ, likewise, except that comparisons with zero should be done
10314 ;; with an scc insns.  However, due to the order that combine see the
10315 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
10316 ;; the cases we don't want to handle.
10317 (define_expand "seq"
10318   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10319   ""
10320   "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
10321
10322 (define_expand "sne"
10323   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10324   ""
10325   "
10326
10327   if (! rs6000_compare_fp_p)
10328     FAIL;
10329
10330   rs6000_emit_sCOND (NE, operands[0]); 
10331   DONE;
10332 }")
10333
10334 ;; A > 0 is best done using the portable sequence, so fail in that case.
10335 (define_expand "sgt"
10336   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10337   ""
10338   "
10339 {
10340   if (! rs6000_compare_fp_p
10341       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10342     FAIL;
10343
10344   rs6000_emit_sCOND (GT, operands[0]); 
10345   DONE;
10346 }")
10347
10348 ;; A < 0 is best done in the portable way for A an integer.
10349 (define_expand "slt"
10350   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10351   ""
10352   "
10353 {
10354   if (! rs6000_compare_fp_p 
10355       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10356     FAIL;
10357
10358   rs6000_emit_sCOND (LT, operands[0]); 
10359   DONE;
10360 }")
10361
10362 ;; A >= 0 is best done the portable way for A an integer.
10363 (define_expand "sge"
10364   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10365   ""
10366   "
10367 {
10368   if (! rs6000_compare_fp_p
10369       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10370     FAIL;
10371
10372   rs6000_emit_sCOND (GE, operands[0]);
10373   DONE;
10374 }")
10375
10376 ;; A <= 0 is best done the portable way for A an integer.
10377 (define_expand "sle"
10378   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10379   ""
10380   "
10381 {
10382   if (! rs6000_compare_fp_p
10383       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10384     FAIL;
10385
10386   rs6000_emit_sCOND (LE, operands[0]); 
10387   DONE;
10388 }")
10389
10390 (define_expand "sgtu"
10391   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10392   ""
10393   "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
10394
10395 (define_expand "sltu"
10396   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10397   ""
10398   "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
10399
10400 (define_expand "sgeu"
10401   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10402   ""
10403   "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
10404
10405 (define_expand "sleu"
10406   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10407   ""
10408   "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
10409 \f
10410 ;; Here are the actual compare insns.
10411 (define_insn "*cmpsi_internal1"
10412   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10413         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10414                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
10415   ""
10416   "{cmp%I2|cmpw%I2} %0,%1,%2"
10417   [(set_attr "type" "compare")])
10418
10419 (define_insn "*cmpdi_internal1"
10420   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10421         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
10422                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
10423   "TARGET_POWERPC64"
10424   "cmpd%I2 %0,%1,%2"
10425   [(set_attr "type" "compare")])
10426
10427 ;; If we are comparing a register for equality with a large constant,
10428 ;; we can do this with an XOR followed by a compare.  But we need a scratch
10429 ;; register for the result of the XOR.
10430
10431 (define_split
10432   [(set (match_operand:CC 0 "cc_reg_operand" "")
10433         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10434                     (match_operand:SI 2 "non_short_cint_operand" "")))
10435    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
10436   "find_single_use (operands[0], insn, 0)
10437    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
10438        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
10439   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
10440    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
10441   "
10442 {
10443   /* Get the constant we are comparing against, C,  and see what it looks like
10444      sign-extended to 16 bits.  Then see what constant could be XOR'ed
10445      with C to get the sign-extended value.  */
10446
10447   HOST_WIDE_INT c = INTVAL (operands[2]);
10448   HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
10449   HOST_WIDE_INT xorv = c ^ sextc;
10450
10451   operands[4] = GEN_INT (xorv);
10452   operands[5] = GEN_INT (sextc);
10453 }")
10454
10455 (define_insn "*cmpsi_internal2"
10456   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10457         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10458                        (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
10459   ""
10460   "{cmpl%I2|cmplw%I2} %0,%1,%b2"
10461   [(set_attr "type" "compare")])
10462
10463 (define_insn "*cmpdi_internal2"
10464   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10465         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
10466                        (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
10467   ""
10468   "cmpld%I2 %0,%1,%b2"
10469   [(set_attr "type" "compare")])
10470
10471 ;; The following two insns don't exist as single insns, but if we provide
10472 ;; them, we can swap an add and compare, which will enable us to overlap more
10473 ;; of the required delay between a compare and branch.  We generate code for
10474 ;; them by splitting.
10475
10476 (define_insn ""
10477   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
10478         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10479                     (match_operand:SI 2 "short_cint_operand" "i")))
10480    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10481         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10482   ""
10483   "#"
10484   [(set_attr "length" "8")])
10485
10486 (define_insn ""
10487   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
10488         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10489                        (match_operand:SI 2 "u_short_cint_operand" "i")))
10490    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10491         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10492   ""
10493   "#"
10494   [(set_attr "length" "8")])
10495
10496 (define_split
10497   [(set (match_operand:CC 3 "cc_reg_operand" "")
10498         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10499                     (match_operand:SI 2 "short_cint_operand" "")))
10500    (set (match_operand:SI 0 "gpc_reg_operand" "")
10501         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10502   ""
10503   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
10504    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10505
10506 (define_split
10507   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
10508         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
10509                        (match_operand:SI 2 "u_short_cint_operand" "")))
10510    (set (match_operand:SI 0 "gpc_reg_operand" "")
10511         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10512   ""
10513   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
10514    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10515
10516 (define_insn "*cmpsf_internal1"
10517   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10518         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
10519                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
10520   "TARGET_HARD_FLOAT"
10521   "fcmpu %0,%1,%2"
10522   [(set_attr "type" "fpcompare")])
10523
10524 (define_insn "*cmpdf_internal1"
10525   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10526         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
10527                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
10528   "TARGET_HARD_FLOAT"
10529   "fcmpu %0,%1,%2"
10530   [(set_attr "type" "fpcompare")])
10531
10532 ;; Only need to compare second words if first words equal
10533 (define_insn "*cmptf_internal1"
10534   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10535         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10536                       (match_operand:TF 2 "gpc_reg_operand" "f")))]
10537   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
10538   "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
10539   [(set_attr "type" "fpcompare")
10540    (set_attr "length" "12")])
10541 \f
10542 ;; Now we have the scc insns.  We can do some combinations because of the
10543 ;; way the machine works.
10544 ;;
10545 ;; Note that this is probably faster if we can put an insn between the
10546 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
10547 ;; cases the insns below which don't use an intermediate CR field will
10548 ;; be used instead.
10549 (define_insn ""
10550   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10551         (match_operator:SI 1 "scc_comparison_operator"
10552                            [(match_operand 2 "cc_reg_operand" "y")
10553                             (const_int 0)]))]
10554   ""
10555   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
10556   [(set_attr "length" "12")])
10557
10558 (define_insn ""
10559   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10560         (match_operator:DI 1 "scc_comparison_operator"
10561                            [(match_operand 2 "cc_reg_operand" "y")
10562                             (const_int 0)]))]
10563   "TARGET_POWERPC64"
10564   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
10565   [(set_attr "length" "12")])
10566
10567 (define_insn ""
10568   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10569         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10570                                        [(match_operand 2 "cc_reg_operand" "y,y")
10571                                         (const_int 0)])
10572                     (const_int 0)))
10573    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
10574         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10575   "! TARGET_POWERPC64"
10576   "@
10577    %D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1
10578    #"
10579   [(set_attr "type" "delayed_compare")
10580    (set_attr "length" "12,16")])
10581
10582 (define_split
10583   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10584         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10585                                        [(match_operand 2 "cc_reg_operand" "")
10586                                         (const_int 0)])
10587                     (const_int 0)))
10588    (set (match_operand:SI 3 "gpc_reg_operand" "")
10589         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10590   "! TARGET_POWERPC64 && reload_completed"
10591   [(set (match_dup 3)
10592         (match_op_dup 1 [(match_dup 2) (const_int 0)]))
10593    (set (match_dup 0)
10594         (compare:CC (match_dup 3)
10595                     (const_int 0)))]
10596   "")
10597
10598 (define_insn ""
10599   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10600         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10601                                       [(match_operand 2 "cc_reg_operand" "y")
10602                                        (const_int 0)])
10603                    (match_operand:SI 3 "const_int_operand" "n")))]
10604   ""
10605   "*
10606 {
10607   int is_bit = ccr_bit (operands[1], 1);
10608   int put_bit = 31 - (INTVAL (operands[3]) & 31);
10609   int count;
10610
10611   if (is_bit >= put_bit)
10612     count = is_bit - put_bit;
10613   else
10614     count = 32 - (put_bit - is_bit);
10615
10616   operands[4] = GEN_INT (count);
10617   operands[5] = GEN_INT (put_bit);
10618
10619   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
10620 }"
10621  [(set_attr "length" "12")])
10622
10623 (define_insn ""
10624   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10625         (compare:CC
10626          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10627                                        [(match_operand 2 "cc_reg_operand" "y,y")
10628                                         (const_int 0)])
10629                     (match_operand:SI 3 "const_int_operand" "n,n"))
10630          (const_int 0)))
10631    (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
10632         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10633                    (match_dup 3)))]
10634   "! TARGET_POWERPC64"
10635   "*
10636 {
10637   int is_bit = ccr_bit (operands[1], 1);
10638   int put_bit = 31 - (INTVAL (operands[3]) & 31);
10639   int count;
10640
10641   /* Force split for non-cc0 compare.  */
10642   if (which_alternative == 1)
10643      return \"#\";
10644
10645   if (is_bit >= put_bit)
10646     count = is_bit - put_bit;
10647   else
10648     count = 32 - (put_bit - is_bit);
10649
10650   operands[5] = GEN_INT (count);
10651   operands[6] = GEN_INT (put_bit);
10652
10653   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
10654 }"
10655   [(set_attr "type" "delayed_compare")
10656    (set_attr "length" "12,16")])
10657
10658 (define_split
10659   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10660         (compare:CC
10661          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10662                                        [(match_operand 2 "cc_reg_operand" "")
10663                                         (const_int 0)])
10664                     (match_operand:SI 3 "const_int_operand" ""))
10665          (const_int 0)))
10666    (set (match_operand:SI 4 "gpc_reg_operand" "")
10667         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10668                    (match_dup 3)))]
10669   "! TARGET_POWERPC64 && reload_completed"
10670   [(set (match_dup 4)
10671         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10672                    (match_dup 3)))
10673    (set (match_dup 0)
10674         (compare:CC (match_dup 4)
10675                     (const_int 0)))]
10676   "")
10677
10678 ;; There is a 3 cycle delay between consecutive mfcr instructions
10679 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
10680
10681 (define_peephole
10682   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10683         (match_operator:SI 1 "scc_comparison_operator"
10684                            [(match_operand 2 "cc_reg_operand" "y")
10685                             (const_int 0)]))
10686    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
10687         (match_operator:SI 4 "scc_comparison_operator"
10688                            [(match_operand 5 "cc_reg_operand" "y")
10689                             (const_int 0)]))]
10690    "REGNO (operands[2]) != REGNO (operands[5])"
10691    "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
10692    [(set_attr "length" "20")])
10693
10694 (define_peephole
10695   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10696         (match_operator:DI 1 "scc_comparison_operator"
10697                            [(match_operand 2 "cc_reg_operand" "y")
10698                             (const_int 0)]))
10699    (set (match_operand:DI 3 "gpc_reg_operand" "=r")
10700         (match_operator:DI 4 "scc_comparison_operator"
10701                            [(match_operand 5 "cc_reg_operand" "y")
10702                             (const_int 0)]))]
10703    "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
10704    "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
10705    [(set_attr "length" "20")])
10706
10707 ;; There are some scc insns that can be done directly, without a compare.
10708 ;; These are faster because they don't involve the communications between
10709 ;; the FXU and branch units.   In fact, we will be replacing all of the
10710 ;; integer scc insns here or in the portable methods in emit_store_flag.
10711 ;;
10712 ;; Also support (neg (scc ..)) since that construct is used to replace
10713 ;; branches, (plus (scc ..) ..) since that construct is common and
10714 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
10715 ;; cases where it is no more expensive than (neg (scc ..)).
10716
10717 ;; Have reload force a constant into a register for the simple insns that
10718 ;; otherwise won't accept constants.  We do this because it is faster than
10719 ;; the cmp/mfcr sequence we would otherwise generate.
10720
10721 (define_insn ""
10722   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
10723         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
10724                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
10725    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
10726   "! TARGET_POWERPC64"
10727   "@
10728    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10729    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
10730    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10731    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10732    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
10733   [(set_attr "length" "12,8,12,12,12")])
10734
10735 (define_insn ""
10736   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
10737         (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
10738                (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
10739    (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
10740   "TARGET_POWERPC64"
10741   "@
10742    xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
10743    subfic %3,%1,0\;adde %0,%3,%1
10744    xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
10745    xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
10746    subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
10747   [(set_attr "length" "12,8,12,12,12")])
10748
10749 (define_insn ""
10750   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10751         (compare:CC
10752          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10753                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
10754          (const_int 0)))
10755    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
10756         (eq:SI (match_dup 1) (match_dup 2)))
10757    (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
10758   "! TARGET_POWERPC64"
10759   "@
10760    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10761    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
10762    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10763    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10764    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10765    #
10766    #
10767    #
10768    #
10769    #"
10770   [(set_attr "type" "compare")
10771    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
10772
10773 (define_split
10774   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
10775         (compare:CC
10776          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
10777                 (match_operand:SI 2 "reg_or_cint_operand" ""))
10778          (const_int 0)))
10779    (set (match_operand:SI 0 "gpc_reg_operand" "")
10780         (eq:SI (match_dup 1) (match_dup 2)))
10781    (clobber (match_scratch:SI 3 ""))]
10782   "! TARGET_POWERPC64 && reload_completed"
10783   [(parallel [(set (match_dup 0)
10784         (eq:SI (match_dup 1) (match_dup 2)))
10785    (clobber (match_dup 3))])
10786    (set (match_dup 4)
10787         (compare:CC (match_dup 0)
10788                     (const_int 0)))]
10789   "")
10790
10791 (define_insn ""
10792   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10793         (compare:CC
10794          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10795                 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
10796          (const_int 0)))
10797    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
10798         (eq:DI (match_dup 1) (match_dup 2)))
10799    (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
10800   "TARGET_POWERPC64"
10801   "@
10802    xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
10803    subfic %3,%1,0\;adde. %0,%3,%1
10804    xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
10805    xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
10806    subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
10807    #
10808    #
10809    #
10810    #
10811    #"
10812   [(set_attr "type" "compare")
10813    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
10814
10815 (define_split
10816   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
10817         (compare:CC
10818          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
10819                 (match_operand:DI 2 "reg_or_cint_operand" ""))
10820          (const_int 0)))
10821    (set (match_operand:DI 0 "gpc_reg_operand" "")
10822         (eq:DI (match_dup 1) (match_dup 2)))
10823    (clobber (match_scratch:DI 3 ""))]
10824   "TARGET_POWERPC64 && reload_completed"
10825   [(parallel [(set (match_dup 0)
10826         (eq:DI (match_dup 1) (match_dup 2)))
10827    (clobber (match_dup 3))])
10828    (set (match_dup 4)
10829         (compare:CC (match_dup 0)
10830                     (const_int 0)))]
10831   "")
10832
10833 ;; We have insns of the form shown by the first define_insn below.  If
10834 ;; there is something inside the comparison operation, we must split it.
10835 (define_split
10836   [(set (match_operand:SI 0 "gpc_reg_operand" "")
10837         (plus:SI (match_operator 1 "comparison_operator"
10838                                  [(match_operand:SI 2 "" "")
10839                                   (match_operand:SI 3
10840                                                     "reg_or_cint_operand" "")])
10841                  (match_operand:SI 4 "gpc_reg_operand" "")))
10842    (clobber (match_operand:SI 5 "register_operand" ""))]
10843   "! gpc_reg_operand (operands[2], SImode)"
10844   [(set (match_dup 5) (match_dup 2))
10845    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
10846                                (match_dup 4)))])
10847
10848 (define_insn ""
10849   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
10850         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
10851                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
10852                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))
10853    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r"))]
10854   "! TARGET_POWERPC64"
10855   "@
10856    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
10857    {sfi|subfic} %4,%1,0\;{aze|addze} %0,%3
10858    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
10859    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
10860    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
10861   [(set_attr "length" "12,8,12,12,12")])
10862
10863 (define_insn ""
10864   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10865         (compare:CC
10866          (plus:SI
10867           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10868                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
10869           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
10870          (const_int 0)))
10871    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
10872   "! TARGET_POWERPC64"
10873   "@
10874    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
10875    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
10876    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
10877    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
10878    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
10879    #
10880    #
10881    #
10882    #
10883    #"
10884   [(set_attr "type" "compare")
10885    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
10886
10887 (define_split
10888   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10889         (compare:CC
10890          (plus:SI
10891           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
10892                  (match_operand:SI 2 "reg_or_cint_operand" ""))
10893           (match_operand:SI 3 "gpc_reg_operand" ""))
10894          (const_int 0)))
10895    (clobber (match_scratch:SI 4 ""))]
10896   "! TARGET_POWERPC64 && reload_completed"
10897   [(set (match_dup 4)
10898         (plus:SI (eq:SI (match_dup 1)
10899                  (match_dup 2))
10900           (match_dup 3)))
10901    (set (match_dup 0)
10902         (compare:CC (match_dup 4)
10903                     (const_int 0)))]
10904   "")
10905
10906 (define_insn ""
10907   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10908         (compare:CC
10909          (plus:SI
10910           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10911                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
10912           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
10913          (const_int 0)))
10914    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
10915         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
10916    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
10917   "! TARGET_POWERPC64"
10918   "@
10919    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
10920    {sfi|subfic} %4,%1,0\;{aze.|addze.} %0,%3
10921    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
10922    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
10923    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
10924    #
10925    #
10926    #
10927    #
10928    #"
10929   [(set_attr "type" "compare")
10930    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
10931
10932 (define_split
10933   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
10934         (compare:CC
10935          (plus:SI
10936           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
10937                  (match_operand:SI 2 "reg_or_cint_operand" ""))
10938           (match_operand:SI 3 "gpc_reg_operand" ""))
10939          (const_int 0)))
10940    (set (match_operand:SI 0 "gpc_reg_operand" "")
10941         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
10942    (clobber (match_scratch:SI 4 ""))]
10943   "! TARGET_POWERPC64 && reload_completed"
10944   [(parallel [(set (match_dup 0)
10945         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
10946    (clobber (match_dup 4))])
10947    (set (match_dup 5)
10948         (compare:CC (match_dup 0)
10949                     (const_int 0)))]
10950   "")
10951
10952 (define_insn ""
10953   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
10954         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
10955                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
10956   "! TARGET_POWERPC64"
10957   "@
10958    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
10959    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
10960    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
10961    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
10962    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
10963    [(set_attr "length" "12,8,12,12,12")])
10964
10965 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
10966 ;; since it nabs/sr is just as fast.
10967 (define_insn "*ne0"
10968   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
10969         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
10970                      (const_int 31)))
10971    (clobber (match_scratch:SI 2 "=&r"))]
10972   "! TARGET_POWER && ! TARGET_POWERPC64"
10973   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
10974   [(set_attr "length" "8")])
10975
10976 (define_insn ""
10977   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10978         (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
10979                      (const_int 63)))
10980    (clobber (match_scratch:DI 2 "=&r"))]
10981   "TARGET_POWERPC64"
10982   "addic %2,%1,-1\;subfe %0,%2,%1"
10983   [(set_attr "length" "8")])
10984
10985 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
10986 (define_insn ""
10987   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10988         (plus:SI (lshiftrt:SI
10989                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
10990                   (const_int 31))
10991                  (match_operand:SI 2 "gpc_reg_operand" "r")))
10992    (clobber (match_scratch:SI 3 "=&r"))]
10993   "! TARGET_POWERPC64"
10994   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
10995   [(set_attr "length" "8")])
10996
10997 (define_insn ""
10998   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10999         (plus:DI (lshiftrt:DI
11000                   (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11001                   (const_int 63))
11002                  (match_operand:DI 2 "gpc_reg_operand" "r")))
11003    (clobber (match_scratch:DI 3 "=&r"))]
11004   "TARGET_POWERPC64"
11005   "addic %3,%1,-1\;addze %0,%2"
11006   [(set_attr "length" "8")])
11007
11008 (define_insn ""
11009   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11010         (compare:CC
11011          (plus:SI (lshiftrt:SI
11012                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11013                    (const_int 31))
11014                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11015          (const_int 0)))
11016    (clobber (match_scratch:SI 3 "=&r,&r"))
11017    (clobber (match_scratch:SI 4 "=X,&r"))]
11018   "! TARGET_POWERPC64"
11019   "@
11020    {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11021    #"
11022   [(set_attr "type" "compare")
11023    (set_attr "length" "8,12")])
11024
11025 (define_split
11026   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11027         (compare:CC
11028          (plus:SI (lshiftrt:SI
11029                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11030                    (const_int 31))
11031                   (match_operand:SI 2 "gpc_reg_operand" ""))
11032          (const_int 0)))
11033    (clobber (match_scratch:SI 3 ""))
11034    (clobber (match_scratch:SI 4 ""))]
11035   "! TARGET_POWERPC64 && reload_completed"
11036   [(parallel [(set (match_dup 3)
11037                   (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11038                                         (const_int 31))
11039                            (match_dup 2)))
11040               (clobber (match_dup 4))])
11041    (set (match_dup 0)
11042         (compare:CC (match_dup 3)
11043                     (const_int 0)))]
11044   "")
11045
11046 (define_insn ""
11047   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11048         (compare:CC
11049          (plus:DI (lshiftrt:DI
11050                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11051                    (const_int 63))
11052                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11053          (const_int 0)))
11054    (clobber (match_scratch:DI 3 "=&r,&r"))]
11055   "TARGET_POWERPC64"
11056   "@
11057    addic %3,%1,-1\;addze. %3,%2
11058    #"
11059   [(set_attr "type" "compare")
11060    (set_attr "length" "8,12")])
11061
11062 (define_split
11063   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11064         (compare:CC
11065          (plus:DI (lshiftrt:DI
11066                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11067                    (const_int 63))
11068                   (match_operand:DI 2 "gpc_reg_operand" ""))
11069          (const_int 0)))
11070    (clobber (match_scratch:DI 3 ""))]
11071   "TARGET_POWERPC64 && reload_completed"
11072   [(set (match_dup 3)
11073         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11074                    (const_int 63))
11075                   (match_dup 2)))
11076    (set (match_dup 0)
11077         (compare:CC (match_dup 3)
11078                     (const_int 0)))]
11079   "")
11080
11081 (define_insn ""
11082   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11083         (compare:CC
11084          (plus:SI (lshiftrt:SI
11085                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11086                    (const_int 31))
11087                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11088          (const_int 0)))
11089    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11090         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11091                  (match_dup 2)))
11092    (clobber (match_scratch:SI 3 "=&r,&r"))]
11093   "! TARGET_POWERPC64"
11094   "@
11095    {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11096    #"
11097   [(set_attr "type" "compare")
11098    (set_attr "length" "8,12")])
11099
11100 (define_split
11101   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11102         (compare:CC
11103          (plus:SI (lshiftrt:SI
11104                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11105                    (const_int 31))
11106                   (match_operand:SI 2 "gpc_reg_operand" ""))
11107          (const_int 0)))
11108    (set (match_operand:SI 0 "gpc_reg_operand" "")
11109         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11110                  (match_dup 2)))
11111    (clobber (match_scratch:SI 3 ""))]
11112   "! TARGET_POWERPC64 && reload_completed"
11113   [(parallel [(set (match_dup 0)
11114         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11115                  (match_dup 2)))
11116    (clobber (match_dup 3))])
11117    (set (match_dup 4)
11118         (compare:CC (match_dup 0)
11119                     (const_int 0)))]
11120   "")
11121
11122 (define_insn ""
11123   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11124         (compare:CC
11125          (plus:DI (lshiftrt:DI
11126                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11127                    (const_int 63))
11128                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11129          (const_int 0)))
11130    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11131         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11132                  (match_dup 2)))
11133    (clobber (match_scratch:DI 3 "=&r,&r"))]
11134   "TARGET_POWERPC64"
11135   "@
11136    addic %3,%1,-1\;addze. %0,%2
11137    #"
11138   [(set_attr "type" "compare")
11139    (set_attr "length" "8,12")])
11140
11141 (define_split
11142   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11143         (compare:CC
11144          (plus:DI (lshiftrt:DI
11145                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11146                    (const_int 63))
11147                   (match_operand:DI 2 "gpc_reg_operand" ""))
11148          (const_int 0)))
11149    (set (match_operand:DI 0 "gpc_reg_operand" "")
11150         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11151                  (match_dup 2)))
11152    (clobber (match_scratch:DI 3 ""))]
11153   "TARGET_POWERPC64 && reload_completed"
11154   [(parallel [(set (match_dup 0)
11155         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11156                  (match_dup 2)))
11157    (clobber (match_dup 3))])
11158    (set (match_dup 4)
11159         (compare:CC (match_dup 0)
11160                     (const_int 0)))]
11161   "")
11162
11163 (define_insn ""
11164   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11165         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11166                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
11167    (clobber (match_scratch:SI 3 "=r,X"))]
11168   "TARGET_POWER"
11169   "@
11170    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
11171    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
11172   [(set_attr "length" "12")])
11173
11174 (define_insn ""
11175   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11176         (compare:CC
11177          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11178                 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11179          (const_int 0)))
11180    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11181         (le:SI (match_dup 1) (match_dup 2)))
11182    (clobber (match_scratch:SI 3 "=r,X,r,X"))]
11183   "TARGET_POWER"
11184   "@
11185    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11186    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
11187    #
11188    #"
11189   [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
11190    (set_attr "length" "12,12,16,16")])
11191
11192 (define_split
11193   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11194         (compare:CC
11195          (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11196                 (match_operand:SI 2 "reg_or_short_operand" ""))
11197          (const_int 0)))
11198    (set (match_operand:SI 0 "gpc_reg_operand" "")
11199         (le:SI (match_dup 1) (match_dup 2)))
11200    (clobber (match_scratch:SI 3 ""))]
11201   "TARGET_POWER && reload_completed"
11202   [(parallel [(set (match_dup 0)
11203         (le:SI (match_dup 1) (match_dup 2)))
11204    (clobber (match_dup 3))])
11205    (set (match_dup 4)
11206         (compare:CC (match_dup 0)
11207                     (const_int 0)))]
11208   "")
11209
11210 (define_insn ""
11211   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11212         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11213                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
11214                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
11215    (clobber (match_scratch:SI 4 "=&r,&r"))]
11216   "TARGET_POWER"
11217   "@
11218    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
11219    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
11220   [(set_attr "length" "12")])
11221
11222 (define_insn ""
11223   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11224         (compare:CC
11225          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11226                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11227                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11228          (const_int 0)))
11229    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11230   "TARGET_POWER"
11231   "@
11232    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11233    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
11234    #
11235    #"
11236   [(set_attr "type" "compare")
11237    (set_attr "length" "12,12,16,16")])
11238
11239 (define_split
11240   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11241         (compare:CC
11242          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11243                          (match_operand:SI 2 "reg_or_short_operand" ""))
11244                   (match_operand:SI 3 "gpc_reg_operand" ""))
11245          (const_int 0)))
11246    (clobber (match_scratch:SI 4 ""))]
11247   "TARGET_POWER && reload_completed"
11248   [(set (match_dup 4)
11249         (plus:SI (le:SI (match_dup 1) (match_dup 2))
11250                   (match_dup 3)))
11251    (set (match_dup 0)
11252         (compare:CC (match_dup 4)
11253                     (const_int 0)))]
11254   "")
11255
11256 (define_insn ""
11257   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
11258         (compare:CC
11259          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11260                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11261                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11262          (const_int 0)))
11263    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11264         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11265    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11266   "TARGET_POWER"
11267   "@
11268    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
11269    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3
11270    #
11271    #"
11272   [(set_attr "type" "compare")
11273    (set_attr "length" "12,12,16,16")])
11274
11275 (define_split
11276   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11277         (compare:CC
11278          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11279                          (match_operand:SI 2 "reg_or_short_operand" ""))
11280                   (match_operand:SI 3 "gpc_reg_operand" ""))
11281          (const_int 0)))
11282    (set (match_operand:SI 0 "gpc_reg_operand" "")
11283         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11284    (clobber (match_scratch:SI 4 ""))]
11285   "TARGET_POWER && reload_completed"
11286   [(parallel [(set (match_dup 0)
11287         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11288    (clobber (match_dup 4))])
11289    (set (match_dup 5)
11290         (compare:CC (match_dup 0)
11291                     (const_int 0)))]
11292   "")
11293
11294 (define_insn ""
11295   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11296         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11297                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
11298   "TARGET_POWER"
11299   "@
11300    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11301    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
11302   [(set_attr "length" "12")])
11303
11304 (define_insn ""
11305   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11306         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11307                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11308   "! TARGET_POWERPC64"
11309   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11310   [(set_attr "length" "12")])
11311
11312 (define_insn ""
11313   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11314         (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
11315                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11316   "TARGET_POWERPC64"
11317   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
11318   [(set_attr "length" "12")])
11319
11320 (define_insn ""
11321   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11322         (compare:CC
11323          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11324                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11325          (const_int 0)))
11326    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11327         (leu:DI (match_dup 1) (match_dup 2)))]
11328   "TARGET_POWERPC64"
11329   "@
11330    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11331    #"
11332   [(set_attr "type" "compare")
11333    (set_attr "length" "12,16")])
11334
11335 (define_split
11336   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11337         (compare:CC
11338          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
11339                  (match_operand:DI 2 "reg_or_short_operand" ""))
11340          (const_int 0)))
11341    (set (match_operand:DI 0 "gpc_reg_operand" "")
11342         (leu:DI (match_dup 1) (match_dup 2)))]
11343   "TARGET_POWERPC64 && reload_completed"
11344   [(set (match_dup 0)
11345         (leu:DI (match_dup 1) (match_dup 2)))
11346    (set (match_dup 3)
11347         (compare:CC (match_dup 0)
11348                     (const_int 0)))]
11349   "")
11350
11351 (define_insn ""
11352   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11353         (compare:CC
11354          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11355                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11356          (const_int 0)))
11357    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11358         (leu:SI (match_dup 1) (match_dup 2)))]
11359   "! TARGET_POWERPC64"
11360   "@
11361    {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11362    #"
11363   [(set_attr "type" "compare")
11364    (set_attr "length" "12,16")])
11365
11366 (define_split
11367   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11368         (compare:CC
11369          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11370                  (match_operand:SI 2 "reg_or_short_operand" ""))
11371          (const_int 0)))
11372    (set (match_operand:SI 0 "gpc_reg_operand" "")
11373         (leu:SI (match_dup 1) (match_dup 2)))]
11374   "! TARGET_POWERPC64 && reload_completed"
11375   [(set (match_dup 0)
11376         (leu:SI (match_dup 1) (match_dup 2)))
11377    (set (match_dup 3)
11378         (compare:CC (match_dup 0)
11379                     (const_int 0)))]
11380   "")
11381
11382 (define_insn ""
11383   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11384         (compare:CC
11385          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11386                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11387          (const_int 0)))
11388    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11389         (leu:DI (match_dup 1) (match_dup 2)))]
11390   "TARGET_POWERPC64"
11391   "@
11392    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11393    #"
11394   [(set_attr "type" "compare")
11395    (set_attr "length" "12,16")])
11396
11397 (define_insn ""
11398   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11399         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11400                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
11401                  (match_operand:SI 3 "gpc_reg_operand" "r")))
11402    (clobber (match_scratch:SI 4 "=&r"))]
11403   "! TARGET_POWERPC64"
11404   "{sf%I2|subf%I2c} %4,%1,%2\;{aze|addze} %0,%3"
11405   [(set_attr "length" "8")])
11406
11407 (define_insn ""
11408   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11409         (compare:CC
11410          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11411                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11412                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11413          (const_int 0)))
11414    (clobber (match_scratch:SI 4 "=&r,&r"))]
11415   "! TARGET_POWERPC64"
11416   "@
11417    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
11418    #"
11419   [(set_attr "type" "compare")
11420    (set_attr "length" "8,12")])
11421
11422 (define_split
11423   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11424         (compare:CC
11425          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11426                           (match_operand:SI 2 "reg_or_short_operand" ""))
11427                   (match_operand:SI 3 "gpc_reg_operand" ""))
11428          (const_int 0)))
11429    (clobber (match_scratch:SI 4 ""))]
11430   "! TARGET_POWERPC64 && reload_completed"
11431   [(set (match_dup 4)
11432         (plus:SI (leu:SI (match_dup 1) (match_dup 2))
11433                   (match_dup 3)))
11434    (set (match_dup 0)
11435         (compare:CC (match_dup 4)
11436                     (const_int 0)))]
11437   "")
11438
11439 (define_insn ""
11440   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11441         (compare:CC
11442          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11443                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11444                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11445          (const_int 0)))
11446    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11447         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11448    (clobber (match_scratch:SI 4 "=&r,&r"))]
11449   "! TARGET_POWERPC64"
11450   "@
11451    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3
11452    #"
11453   [(set_attr "type" "compare")
11454    (set_attr "length" "8,12")])
11455
11456 (define_split
11457   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11458         (compare:CC
11459          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11460                           (match_operand:SI 2 "reg_or_short_operand" ""))
11461                   (match_operand:SI 3 "gpc_reg_operand" ""))
11462          (const_int 0)))
11463    (set (match_operand:SI 0 "gpc_reg_operand" "")
11464         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11465    (clobber (match_scratch:SI 4 ""))]
11466   "! TARGET_POWERPC64 && reload_completed"
11467   [(parallel [(set (match_dup 0)
11468         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11469    (clobber (match_dup 4))])
11470    (set (match_dup 5)
11471         (compare:CC (match_dup 0)
11472                     (const_int 0)))]
11473   "")
11474
11475 (define_insn ""
11476   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11477         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11478                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
11479   "! TARGET_POWERPC64"
11480   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
11481    [(set_attr "length" "12")])
11482
11483 (define_insn ""
11484   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11485         (and:SI (neg:SI
11486                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11487                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
11488                 (match_operand:SI 3 "gpc_reg_operand" "r")))
11489    (clobber (match_scratch:SI 4 "=&r"))]
11490   "! TARGET_POWERPC64"
11491   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
11492   [(set_attr "length" "12")])
11493
11494 (define_insn ""
11495   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11496         (compare:CC
11497          (and:SI (neg:SI
11498                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11499                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11500                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11501          (const_int 0)))
11502    (clobber (match_scratch:SI 4 "=&r,&r"))]
11503   "! TARGET_POWERPC64"
11504   "@
11505    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
11506    #"
11507   [(set_attr "type" "compare")
11508    (set_attr "length" "12,16")])
11509
11510 (define_split
11511   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11512         (compare:CC
11513          (and:SI (neg:SI
11514                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11515                           (match_operand:SI 2 "reg_or_short_operand" "")))
11516                  (match_operand:SI 3 "gpc_reg_operand" ""))
11517          (const_int 0)))
11518    (clobber (match_scratch:SI 4 ""))]
11519   "! TARGET_POWERPC64 && reload_completed"
11520   [(set (match_dup 4)
11521         (and:SI (neg:SI (leu:SI (match_dup 1)
11522                           (match_dup 2)))
11523                  (match_dup 3)))
11524    (set (match_dup 0)
11525         (compare:CC (match_dup 4)
11526                     (const_int 0)))]
11527   "")
11528
11529 (define_insn ""
11530   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11531         (compare:CC
11532          (and:SI (neg:SI
11533                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11534                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11535                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11536          (const_int 0)))
11537    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11538         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11539    (clobber (match_scratch:SI 4 "=&r,&r"))]
11540   "! TARGET_POWERPC64"
11541   "@
11542    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
11543    #"
11544   [(set_attr "type" "compare")
11545    (set_attr "length" "12,16")])
11546
11547 (define_split
11548   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11549         (compare:CC
11550          (and:SI (neg:SI
11551                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11552                           (match_operand:SI 2 "reg_or_short_operand" "")))
11553                  (match_operand:SI 3 "gpc_reg_operand" ""))
11554          (const_int 0)))
11555    (set (match_operand:SI 0 "gpc_reg_operand" "")
11556         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11557    (clobber (match_scratch:SI 4 ""))]
11558   "! TARGET_POWERPC64 && reload_completed"
11559   [(parallel [(set (match_dup 0)
11560         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11561    (clobber (match_dup 4))])
11562    (set (match_dup 5)
11563         (compare:CC (match_dup 0)
11564                     (const_int 0)))]
11565   "")
11566
11567 (define_insn ""
11568   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11569         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11570                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11571   "TARGET_POWER"
11572   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
11573    [(set_attr "length" "12")])
11574
11575 (define_insn ""
11576   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11577         (compare:CC
11578          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11579                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11580          (const_int 0)))
11581    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11582         (lt:SI (match_dup 1) (match_dup 2)))]
11583   "TARGET_POWER"
11584   "@
11585    doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
11586    #"
11587   [(set_attr "type" "delayed_compare")
11588    (set_attr "length" "12,16")])
11589
11590 (define_split
11591   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11592         (compare:CC
11593          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11594                 (match_operand:SI 2 "reg_or_short_operand" ""))
11595          (const_int 0)))
11596    (set (match_operand:SI 0 "gpc_reg_operand" "")
11597         (lt:SI (match_dup 1) (match_dup 2)))]
11598   "TARGET_POWER && reload_completed"
11599   [(set (match_dup 0)
11600         (lt:SI (match_dup 1) (match_dup 2)))
11601    (set (match_dup 3)
11602         (compare:CC (match_dup 0)
11603                     (const_int 0)))]
11604   "")
11605
11606 (define_insn ""
11607   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11608         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11609                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
11610                  (match_operand:SI 3 "gpc_reg_operand" "r")))
11611    (clobber (match_scratch:SI 4 "=&r"))]
11612   "TARGET_POWER"
11613   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
11614   [(set_attr "length" "12")])
11615
11616 (define_insn ""
11617   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11618         (compare:CC
11619          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11620                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11621                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11622          (const_int 0)))
11623    (clobber (match_scratch:SI 4 "=&r,&r"))]
11624   "TARGET_POWER"
11625   "@
11626    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
11627    #"
11628   [(set_attr "type" "compare")
11629    (set_attr "length" "12,16")])
11630
11631 (define_split
11632   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11633         (compare:CC
11634          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11635                          (match_operand:SI 2 "reg_or_short_operand" ""))
11636                   (match_operand:SI 3 "gpc_reg_operand" ""))
11637          (const_int 0)))
11638    (clobber (match_scratch:SI 4 ""))]
11639   "TARGET_POWER && reload_completed"
11640   [(set (match_dup 4)
11641         (plus:SI (lt:SI (match_dup 1) (match_dup 2))
11642                   (match_dup 3)))
11643    (set (match_dup 0)
11644         (compare:CC (match_dup 4)
11645                     (const_int 0)))]
11646   "")
11647
11648 (define_insn ""
11649   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11650         (compare:CC
11651          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11652                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11653                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11654          (const_int 0)))
11655    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11656         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11657    (clobber (match_scratch:SI 4 "=&r,&r"))]
11658   "TARGET_POWER"
11659   "@
11660    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3
11661    #"
11662   [(set_attr "type" "compare")
11663    (set_attr "length" "12,16")])
11664
11665 (define_split
11666   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11667         (compare:CC
11668          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11669                          (match_operand:SI 2 "reg_or_short_operand" ""))
11670                   (match_operand:SI 3 "gpc_reg_operand" ""))
11671          (const_int 0)))
11672    (set (match_operand:SI 0 "gpc_reg_operand" "")
11673         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11674    (clobber (match_scratch:SI 4 ""))]
11675   "TARGET_POWER && reload_completed"
11676   [(parallel [(set (match_dup 0)
11677         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11678    (clobber (match_dup 4))])
11679    (set (match_dup 5)
11680         (compare:CC (match_dup 0)
11681                     (const_int 0)))]
11682   "")
11683
11684 (define_insn ""
11685   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11686         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11687                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
11688   "TARGET_POWER"
11689   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
11690   [(set_attr "length" "12")])
11691
11692 (define_insn ""
11693   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11694         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11695                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
11696   "! TARGET_POWERPC64"
11697   "@
11698    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
11699    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
11700   [(set_attr "length" "12")])
11701
11702 (define_insn ""
11703   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
11704         (compare:CC
11705          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11706                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11707          (const_int 0)))
11708    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11709         (ltu:SI (match_dup 1) (match_dup 2)))]
11710   "! TARGET_POWERPC64"
11711   "@
11712    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
11713    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
11714    #
11715    #"
11716   [(set_attr "type" "compare")
11717    (set_attr "length" "12,12,16,16")])
11718
11719 (define_split
11720   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11721         (compare:CC
11722          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11723                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11724          (const_int 0)))
11725    (set (match_operand:SI 0 "gpc_reg_operand" "")
11726         (ltu:SI (match_dup 1) (match_dup 2)))]
11727   "! TARGET_POWERPC64 && reload_completed"
11728   [(set (match_dup 0)
11729         (ltu:SI (match_dup 1) (match_dup 2)))
11730    (set (match_dup 3)
11731         (compare:CC (match_dup 0)
11732                     (const_int 0)))]
11733   "")
11734
11735 (define_insn ""
11736   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11737         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11738                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
11739                  (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))
11740    (clobber (match_scratch:SI 4 "=&r,&r"))]
11741   "! TARGET_POWERPC64"
11742   "@
11743   {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3
11744   {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
11745  [(set_attr "length" "12")])
11746
11747 (define_insn ""
11748   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11749         (compare:CC
11750          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11751                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11752                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11753          (const_int 0)))
11754    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11755   "! TARGET_POWERPC64"
11756   "@
11757    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
11758    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
11759    #
11760    #"
11761   [(set_attr "type" "compare")
11762    (set_attr "length" "12,12,16,16")])
11763
11764 (define_split
11765   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11766         (compare:CC
11767          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11768                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11769                   (match_operand:SI 3 "gpc_reg_operand" ""))
11770          (const_int 0)))
11771    (clobber (match_scratch:SI 4 ""))]
11772   "! TARGET_POWERPC64 && reload_completed"
11773   [(set (match_dup 4)
11774         (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
11775                   (match_dup 3)))
11776    (set (match_dup 0)
11777         (compare:CC (match_dup 4)
11778                     (const_int 0)))]
11779   "")
11780
11781 (define_insn ""
11782   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
11783         (compare:CC
11784          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11785                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11786                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11787          (const_int 0)))
11788    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11789         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11790    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11791   "! TARGET_POWERPC64"
11792   "@
11793    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
11794    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
11795    #
11796    #"
11797   [(set_attr "type" "compare")
11798    (set_attr "length" "12,12,16,16")])
11799
11800 (define_split
11801   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11802         (compare:CC
11803          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11804                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11805                   (match_operand:SI 3 "gpc_reg_operand" ""))
11806          (const_int 0)))
11807    (set (match_operand:SI 0 "gpc_reg_operand" "")
11808         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11809    (clobber (match_scratch:SI 4 ""))]
11810   "! TARGET_POWERPC64 && reload_completed"
11811   [(parallel [(set (match_dup 0)
11812         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11813    (clobber (match_dup 4))])
11814    (set (match_dup 5)
11815         (compare:CC (match_dup 0)
11816                     (const_int 0)))]
11817   "")
11818
11819 (define_insn ""
11820   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11821         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11822                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
11823   "! TARGET_POWERPC64"
11824   "@
11825    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
11826    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
11827   [(set_attr "length" "8")])
11828
11829 (define_insn ""
11830   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11831         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11832                (match_operand:SI 2 "reg_or_short_operand" "rI")))
11833    (clobber (match_scratch:SI 3 "=r"))]
11834   "TARGET_POWER"
11835   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
11836    [(set_attr "length" "12")])
11837
11838 (define_insn ""
11839   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11840         (compare:CC
11841          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11842                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11843          (const_int 0)))
11844    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11845         (ge:SI (match_dup 1) (match_dup 2)))
11846    (clobber (match_scratch:SI 3 "=r,r"))]
11847   "TARGET_POWER"
11848   "@
11849    doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11850    #"
11851   [(set_attr "type" "compare")
11852    (set_attr "length" "12,16")])
11853
11854 (define_split
11855   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11856         (compare:CC
11857          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
11858                 (match_operand:SI 2 "reg_or_short_operand" ""))
11859          (const_int 0)))
11860    (set (match_operand:SI 0 "gpc_reg_operand" "")
11861         (ge:SI (match_dup 1) (match_dup 2)))
11862    (clobber (match_scratch:SI 3 ""))]
11863   "TARGET_POWER && reload_completed"
11864   [(parallel [(set (match_dup 0)
11865         (ge:SI (match_dup 1) (match_dup 2)))
11866    (clobber (match_dup 3))])
11867    (set (match_dup 4)
11868         (compare:CC (match_dup 0)
11869                     (const_int 0)))]
11870   "")
11871
11872 (define_insn ""
11873   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11874         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11875                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
11876                  (match_operand:SI 3 "gpc_reg_operand" "r")))
11877    (clobber (match_scratch:SI 4 "=&r"))]
11878   "TARGET_POWER"
11879   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
11880   [(set_attr "length" "12")])
11881
11882 (define_insn ""
11883   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11884         (compare:CC
11885          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11886                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11887                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11888          (const_int 0)))
11889    (clobber (match_scratch:SI 4 "=&r,&r"))]
11890   "TARGET_POWER"
11891   "@
11892    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11893    #"
11894   [(set_attr "type" "compare")
11895    (set_attr "length" "12,16")])
11896
11897 (define_split
11898   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11899         (compare:CC
11900          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
11901                          (match_operand:SI 2 "reg_or_short_operand" ""))
11902                   (match_operand:SI 3 "gpc_reg_operand" ""))
11903          (const_int 0)))
11904    (clobber (match_scratch:SI 4 ""))]
11905   "TARGET_POWER && reload_completed"
11906   [(set (match_dup 4)
11907         (plus:SI (ge:SI (match_dup 1) (match_dup 2))
11908                   (match_dup 3)))
11909    (set (match_dup 0)
11910         (compare:CC (match_dup 4)
11911                     (const_int 0)))]
11912   "")
11913
11914 (define_insn ""
11915   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11916         (compare:CC
11917          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11918                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11919                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11920          (const_int 0)))
11921    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11922         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11923    (clobber (match_scratch:SI 4 "=&r,&r"))]
11924   "TARGET_POWER"
11925   "@
11926    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
11927    #"
11928   [(set_attr "type" "compare")
11929    (set_attr "length" "12,16")])
11930
11931 (define_split
11932   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11933         (compare:CC
11934          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
11935                          (match_operand:SI 2 "reg_or_short_operand" ""))
11936                   (match_operand:SI 3 "gpc_reg_operand" ""))
11937          (const_int 0)))
11938    (set (match_operand:SI 0 "gpc_reg_operand" "")
11939         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11940    (clobber (match_scratch:SI 4 ""))]
11941   "TARGET_POWER && reload_completed"
11942   [(parallel [(set (match_dup 0)
11943         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11944    (clobber (match_dup 4))])
11945    (set (match_dup 5)
11946         (compare:CC (match_dup 0)
11947                     (const_int 0)))]
11948   "")
11949
11950 (define_insn ""
11951   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11952         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11953                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
11954   "TARGET_POWER"
11955   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
11956   [(set_attr "length" "12")])
11957
11958 (define_insn ""
11959   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11960         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11961                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
11962   "! TARGET_POWERPC64"
11963   "@
11964    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
11965    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11966   [(set_attr "length" "12")])
11967
11968 (define_insn ""
11969   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11970         (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11971                 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
11972   "TARGET_POWERPC64"
11973   "@
11974    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
11975    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
11976   [(set_attr "length" "12")])
11977
11978 (define_insn ""
11979   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
11980         (compare:CC
11981          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11982                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11983          (const_int 0)))
11984    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11985         (geu:SI (match_dup 1) (match_dup 2)))]
11986   "! TARGET_POWERPC64"
11987   "@
11988    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11989    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11990    #
11991    #"
11992   [(set_attr "type" "compare")
11993    (set_attr "length" "12,12,16,16")])
11994
11995 (define_split
11996   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11997         (compare:CC
11998          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11999                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12000          (const_int 0)))
12001    (set (match_operand:SI 0 "gpc_reg_operand" "")
12002         (geu:SI (match_dup 1) (match_dup 2)))]
12003   "! TARGET_POWERPC64 && reload_completed"
12004   [(set (match_dup 0)
12005         (geu:SI (match_dup 1) (match_dup 2)))
12006    (set (match_dup 3)
12007         (compare:CC (match_dup 0)
12008                     (const_int 0)))]
12009   "")
12010
12011 (define_insn ""
12012   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12013         (compare:CC
12014          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12015                  (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12016          (const_int 0)))
12017    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12018         (geu:DI (match_dup 1) (match_dup 2)))]
12019   "TARGET_POWERPC64"
12020   "@
12021    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12022    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12023    #
12024    #"
12025   [(set_attr "type" "compare")
12026    (set_attr "length" "12,12,16,16")])
12027
12028 (define_split
12029   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12030         (compare:CC
12031          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12032                  (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12033          (const_int 0)))
12034    (set (match_operand:DI 0 "gpc_reg_operand" "")
12035         (geu:DI (match_dup 1) (match_dup 2)))]
12036   "TARGET_POWERPC64 && reload_completed"
12037   [(set (match_dup 0)
12038         (geu:DI (match_dup 1) (match_dup 2)))
12039    (set (match_dup 3)
12040         (compare:CC (match_dup 0)
12041                     (const_int 0)))]
12042   "")
12043
12044 (define_insn ""
12045   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12046         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12047                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12048                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
12049    (clobber (match_scratch:SI 4 "=&r,&r"))]
12050   "! TARGET_POWERPC64"
12051   "@
12052    {sf|subfc} %4,%2,%1\;{aze|addze} %0,%3
12053    {ai|addic} %4,%1,%n2\;{aze|addze} %0,%3"
12054   [(set_attr "length" "8")])
12055
12056 (define_insn ""
12057   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12058         (compare:CC
12059          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12060                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12061                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12062          (const_int 0)))
12063    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12064   "! TARGET_POWERPC64"
12065   "@
12066    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12067    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12068    #
12069    #"
12070   [(set_attr "type" "compare")
12071    (set_attr "length" "8,8,12,12")])
12072
12073 (define_split
12074   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12075         (compare:CC
12076          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12077                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12078                   (match_operand:SI 3 "gpc_reg_operand" ""))
12079          (const_int 0)))
12080    (clobber (match_scratch:SI 4 ""))]
12081   "! TARGET_POWERPC64 && reload_completed"
12082   [(set (match_dup 4)
12083         (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12084                   (match_dup 3)))
12085    (set (match_dup 0)
12086         (compare:CC (match_dup 4)
12087                     (const_int 0)))]
12088   "")
12089
12090 (define_insn ""
12091   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12092         (compare:CC
12093          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12094                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12095                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12096          (const_int 0)))
12097    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12098         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12099    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12100   "! TARGET_POWERPC64"
12101   "@
12102    {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
12103    {ai|addic} %4,%1,%n2\;{aze.|addze.} %0,%3
12104    #
12105    #"
12106   [(set_attr "type" "compare")
12107    (set_attr "length" "8,8,12,12")])
12108
12109 (define_split
12110   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12111         (compare:CC
12112          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12113                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12114                   (match_operand:SI 3 "gpc_reg_operand" ""))
12115          (const_int 0)))
12116    (set (match_operand:SI 0 "gpc_reg_operand" "")
12117         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12118    (clobber (match_scratch:SI 4 ""))]
12119   "! TARGET_POWERPC64 && reload_completed"
12120   [(parallel [(set (match_dup 0)
12121         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12122    (clobber (match_dup 4))])
12123    (set (match_dup 5)
12124         (compare:CC (match_dup 0)
12125                     (const_int 0)))]
12126   "")
12127
12128 (define_insn ""
12129   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12130         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12131                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
12132   "! TARGET_POWERPC64"
12133   "@
12134    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
12135    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
12136   [(set_attr "length" "12")])
12137
12138 (define_insn ""
12139   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12140         (and:SI (neg:SI
12141                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12142                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
12143                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
12144    (clobber (match_scratch:SI 4 "=&r,&r"))]
12145   "! TARGET_POWERPC64"
12146   "@
12147    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
12148    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
12149   [(set_attr "length" "12")])
12150
12151 (define_insn ""
12152   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12153         (compare:CC
12154          (and:SI (neg:SI
12155                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12156                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12157                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12158          (const_int 0)))
12159    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12160   "! TARGET_POWERPC64"
12161   "@
12162    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12163    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12164    #
12165    #"
12166   [(set_attr "type" "compare")
12167    (set_attr "length" "12,12,16,16")])
12168
12169 (define_split
12170   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12171         (compare:CC
12172          (and:SI (neg:SI
12173                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12174                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12175                  (match_operand:SI 3 "gpc_reg_operand" ""))
12176          (const_int 0)))
12177    (clobber (match_scratch:SI 4 ""))]
12178   "! TARGET_POWERPC64 && reload_completed"
12179   [(set (match_dup 4)
12180         (and:SI (neg:SI (geu:SI (match_dup 1)
12181                           (match_dup 2)))
12182                  (match_dup 3)))
12183    (set (match_dup 0)
12184         (compare:CC (match_dup 4)
12185                     (const_int 0)))]
12186   "")
12187
12188 (define_insn ""
12189   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12190         (compare:CC
12191          (and:SI (neg:SI
12192                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12193                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12194                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12195          (const_int 0)))
12196    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12197         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12198    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12199   "! TARGET_POWERPC64"
12200   "@
12201    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
12202    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
12203    #
12204    #"
12205   [(set_attr "type" "compare")
12206    (set_attr "length" "12,12,16,16")])
12207
12208 (define_split
12209   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12210         (compare:CC
12211          (and:SI (neg:SI
12212                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12213                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12214                  (match_operand:SI 3 "gpc_reg_operand" ""))
12215          (const_int 0)))
12216    (set (match_operand:SI 0 "gpc_reg_operand" "")
12217         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12218    (clobber (match_scratch:SI 4 ""))]
12219   "! TARGET_POWERPC64 && reload_completed"
12220   [(parallel [(set (match_dup 0)
12221         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12222    (clobber (match_dup 4))])
12223    (set (match_dup 5)
12224         (compare:CC (match_dup 0)
12225                     (const_int 0)))]
12226   "")
12227
12228 (define_insn ""
12229   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12230         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12231                (const_int 0)))]
12232   "! TARGET_POWERPC64"
12233   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
12234   [(set_attr "length" "12")])
12235
12236 (define_insn ""
12237   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12238         (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12239                (const_int 0)))]
12240   "TARGET_POWERPC64"
12241   "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
12242   [(set_attr "length" "12")])
12243
12244 (define_insn ""
12245   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12246         (compare:CC
12247          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12248                 (const_int 0))
12249          (const_int 0)))
12250    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12251         (gt:SI (match_dup 1) (const_int 0)))]
12252   "! TARGET_POWERPC64"
12253   "@
12254    {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
12255    #"
12256   [(set_attr "type" "delayed_compare")
12257    (set_attr "length" "12,16")])
12258
12259 (define_split
12260   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12261         (compare:CC
12262          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12263                 (const_int 0))
12264          (const_int 0)))
12265    (set (match_operand:SI 0 "gpc_reg_operand" "")
12266         (gt:SI (match_dup 1) (const_int 0)))]
12267   "! TARGET_POWERPC64 && reload_completed"
12268   [(set (match_dup 0)
12269         (gt:SI (match_dup 1) (const_int 0)))
12270    (set (match_dup 2)
12271         (compare:CC (match_dup 0)
12272                     (const_int 0)))]
12273   "")
12274
12275 (define_insn ""
12276   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12277         (compare:CC
12278          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12279                 (const_int 0))
12280          (const_int 0)))
12281    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12282         (gt:DI (match_dup 1) (const_int 0)))]
12283   "TARGET_POWERPC64"
12284   "@
12285    subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
12286    #"
12287   [(set_attr "type" "delayed_compare")
12288    (set_attr "length" "12,16")])
12289
12290 (define_split
12291   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12292         (compare:CC
12293          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12294                 (const_int 0))
12295          (const_int 0)))
12296    (set (match_operand:DI 0 "gpc_reg_operand" "")
12297         (gt:DI (match_dup 1) (const_int 0)))]
12298   "TARGET_POWERPC64 && reload_completed"
12299   [(set (match_dup 0)
12300         (gt:DI (match_dup 1) (const_int 0)))
12301    (set (match_dup 2)
12302         (compare:CC (match_dup 0)
12303                     (const_int 0)))]
12304   "")
12305
12306 (define_insn ""
12307   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12308         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12309                (match_operand:SI 2 "reg_or_short_operand" "r")))]
12310   "TARGET_POWER"
12311   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12312   [(set_attr "length" "12")])
12313
12314 (define_insn ""
12315   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12316         (compare:CC
12317          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12318                 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12319          (const_int 0)))
12320    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12321         (gt:SI (match_dup 1) (match_dup 2)))]
12322   "TARGET_POWER"
12323   "@
12324    doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12325    #"
12326   [(set_attr "type" "delayed_compare")
12327    (set_attr "length" "12,16")])
12328
12329 (define_split
12330   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12331         (compare:CC
12332          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12333                 (match_operand:SI 2 "reg_or_short_operand" ""))
12334          (const_int 0)))
12335    (set (match_operand:SI 0 "gpc_reg_operand" "")
12336         (gt:SI (match_dup 1) (match_dup 2)))]
12337   "TARGET_POWER && reload_completed"
12338   [(set (match_dup 0)
12339         (gt:SI (match_dup 1) (match_dup 2)))
12340    (set (match_dup 3)
12341         (compare:CC (match_dup 0)
12342                     (const_int 0)))]
12343   "")
12344
12345 (define_insn ""
12346   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12347         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12348                         (const_int 0))
12349                  (match_operand:SI 2 "gpc_reg_operand" "r")))
12350    (clobber (match_scratch:SI 3 "=&r"))]
12351   "! TARGET_POWERPC64"
12352   "{a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze|addze} %0,%2"
12353   [(set_attr "length" "12")])
12354
12355 (define_insn ""
12356   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12357         (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12358                         (const_int 0))
12359                  (match_operand:DI 2 "gpc_reg_operand" "r")))
12360    (clobber (match_scratch:DI 3 "=&r"))]
12361   "TARGET_POWERPC64"
12362   "addc %3,%1,%1\;subfe %3,%1,%3\;addze %0,%2"
12363   [(set_attr "length" "12")])
12364
12365 (define_insn ""
12366   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12367         (compare:CC
12368          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12369                          (const_int 0))
12370                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12371          (const_int 0)))
12372    (clobber (match_scratch:SI 3 "=&r,&r"))]
12373   "! TARGET_POWERPC64"
12374   "@
12375    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
12376    #"
12377   [(set_attr "type" "compare")
12378    (set_attr "length" "12,16")])
12379
12380 (define_split
12381   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12382         (compare:CC
12383          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12384                          (const_int 0))
12385                   (match_operand:SI 2 "gpc_reg_operand" ""))
12386          (const_int 0)))
12387    (clobber (match_scratch:SI 3 ""))]
12388   "! TARGET_POWERPC64 && reload_completed"
12389   [(set (match_dup 3)
12390         (plus:SI (gt:SI (match_dup 1) (const_int 0))
12391                   (match_dup 2)))
12392    (set (match_dup 0)
12393         (compare:CC (match_dup 3)
12394                     (const_int 0)))]
12395   "")
12396
12397 (define_insn ""
12398   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12399         (compare:CC
12400          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12401                          (const_int 0))
12402                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12403          (const_int 0)))
12404    (clobber (match_scratch:DI 3 "=&r,&r"))]
12405   "TARGET_POWERPC64"
12406   "@
12407    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12408    #"
12409   [(set_attr "type" "compare")
12410    (set_attr "length" "12,16")])
12411
12412 (define_split
12413   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12414         (compare:CC
12415          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12416                          (const_int 0))
12417                   (match_operand:DI 2 "gpc_reg_operand" ""))
12418          (const_int 0)))
12419    (clobber (match_scratch:DI 3 ""))]
12420   "TARGET_POWERPC64 && reload_completed"
12421   [(set (match_dup 3)
12422         (plus:DI (gt:DI (match_dup 1) (const_int 0))
12423                   (match_dup 2)))
12424    (set (match_dup 0)
12425         (compare:CC (match_dup 3)
12426                     (const_int 0)))]
12427   "")
12428
12429 (define_insn ""
12430   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12431         (compare:CC
12432          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12433                          (const_int 0))
12434                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12435          (const_int 0)))
12436    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12437         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12438    (clobber (match_scratch:SI 3 "=&r,&r"))]
12439   "! TARGET_POWERPC64"
12440   "@
12441    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2
12442    #"
12443   [(set_attr "type" "compare")
12444    (set_attr "length" "12,16")])
12445
12446 (define_split
12447   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12448         (compare:CC
12449          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12450                          (const_int 0))
12451                   (match_operand:SI 2 "gpc_reg_operand" ""))
12452          (const_int 0)))
12453    (set (match_operand:SI 0 "gpc_reg_operand" "")
12454         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12455    (clobber (match_scratch:SI 3 ""))]
12456   "! TARGET_POWERPC64 && reload_completed"
12457   [(parallel [(set (match_dup 0)
12458         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12459    (clobber (match_dup 3))])
12460    (set (match_dup 4)
12461         (compare:CC (match_dup 0)
12462                     (const_int 0)))]
12463   "")
12464
12465 (define_insn ""
12466   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12467         (compare:CC
12468          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12469                          (const_int 0))
12470                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12471          (const_int 0)))
12472    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12473         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12474    (clobber (match_scratch:DI 3 "=&r,&r"))]
12475   "TARGET_POWERPC64"
12476   "@
12477    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %0,%2
12478    #"
12479   [(set_attr "type" "compare")
12480    (set_attr "length" "12,16")])
12481
12482 (define_split
12483   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12484         (compare:CC
12485          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12486                          (const_int 0))
12487                   (match_operand:DI 2 "gpc_reg_operand" ""))
12488          (const_int 0)))
12489    (set (match_operand:DI 0 "gpc_reg_operand" "")
12490         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12491    (clobber (match_scratch:DI 3 ""))]
12492   "TARGET_POWERPC64 && reload_completed"
12493   [(parallel [(set (match_dup 0)
12494         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12495    (clobber (match_dup 3))])
12496    (set (match_dup 4)
12497         (compare:CC (match_dup 0)
12498                     (const_int 0)))]
12499   "")
12500
12501 (define_insn ""
12502   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12503         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12504                         (match_operand:SI 2 "reg_or_short_operand" "r"))
12505                  (match_operand:SI 3 "gpc_reg_operand" "r")))
12506    (clobber (match_scratch:SI 4 "=&r"))]
12507   "TARGET_POWER"
12508   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
12509   [(set_attr "length" "12")])
12510
12511 (define_insn ""
12512   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12513         (compare:CC
12514          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12515                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12516                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12517          (const_int 0)))
12518    (clobber (match_scratch:SI 4 "=&r,&r"))]
12519   "TARGET_POWER"
12520   "@
12521    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12522    #"
12523   [(set_attr "type" "compare")
12524    (set_attr "length" "12,16")])
12525
12526 (define_split
12527   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12528         (compare:CC
12529          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12530                          (match_operand:SI 2 "reg_or_short_operand" ""))
12531                   (match_operand:SI 3 "gpc_reg_operand" ""))
12532          (const_int 0)))
12533    (clobber (match_scratch:SI 4 ""))]
12534   "TARGET_POWER && reload_completed"
12535   [(set (match_dup 4)
12536         (plus:SI (gt:SI (match_dup 1) (match_dup 2))
12537                   (match_dup 3)))
12538    (set (match_dup 0)
12539         (compare:CC (match_dup 4)
12540                     (const_int 0)))]
12541   "")
12542
12543 (define_insn ""
12544   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
12545         (compare:CC
12546          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12547                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12548                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12549          (const_int 0)))
12550    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12551         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12552    (clobber (match_scratch:SI 4 "=&r,&r"))]
12553   "TARGET_POWER"
12554   "@
12555    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3
12556    #"
12557   [(set_attr "type" "compare")
12558    (set_attr "length" "12,16")])
12559
12560 (define_split
12561   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12562         (compare:CC
12563          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12564                          (match_operand:SI 2 "reg_or_short_operand" ""))
12565                   (match_operand:SI 3 "gpc_reg_operand" ""))
12566          (const_int 0)))
12567    (set (match_operand:SI 0 "gpc_reg_operand" "")
12568         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12569    (clobber (match_scratch:SI 4 ""))]
12570   "TARGET_POWER && reload_completed"
12571   [(parallel [(set (match_dup 0)
12572         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12573    (clobber (match_dup 4))])
12574    (set (match_dup 5)
12575         (compare:CC (match_dup 0)
12576                     (const_int 0)))]
12577   "")
12578
12579 (define_insn ""
12580   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12581         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12582                        (const_int 0))))]
12583   "! TARGET_POWERPC64"
12584   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
12585   [(set_attr "length" "12")])
12586
12587 (define_insn ""
12588   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12589         (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12590                        (const_int 0))))]
12591   "TARGET_POWERPC64"
12592   "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
12593   [(set_attr "length" "12")])
12594
12595 (define_insn ""
12596   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12597         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12598                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
12599   "TARGET_POWER"
12600   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12601   [(set_attr "length" "12")])
12602
12603 (define_insn ""
12604   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12605         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12606                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12607   "! TARGET_POWERPC64"
12608   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
12609   [(set_attr "length" "12")])
12610
12611 (define_insn ""
12612   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12613         (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12614                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
12615   "TARGET_POWERPC64"
12616   "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
12617   [(set_attr "length" "12")])
12618
12619 (define_insn ""
12620   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12621         (compare:CC
12622          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12623                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12624          (const_int 0)))
12625    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12626         (gtu:SI (match_dup 1) (match_dup 2)))]
12627   "! TARGET_POWERPC64"
12628   "@
12629    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12630    #"
12631   [(set_attr "type" "compare")
12632    (set_attr "length" "12,16")])
12633
12634 (define_split
12635   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12636         (compare:CC
12637          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12638                  (match_operand:SI 2 "reg_or_short_operand" ""))
12639          (const_int 0)))
12640    (set (match_operand:SI 0 "gpc_reg_operand" "")
12641         (gtu:SI (match_dup 1) (match_dup 2)))]
12642   "! TARGET_POWERPC64 && reload_completed"
12643   [(set (match_dup 0)
12644         (gtu:SI (match_dup 1) (match_dup 2)))
12645    (set (match_dup 3)
12646         (compare:CC (match_dup 0)
12647                     (const_int 0)))]
12648   "")
12649
12650 (define_insn ""
12651   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12652         (compare:CC
12653          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12654                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
12655          (const_int 0)))
12656    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12657         (gtu:DI (match_dup 1) (match_dup 2)))]
12658   "TARGET_POWERPC64"
12659   "@
12660    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
12661    #"
12662   [(set_attr "type" "compare")
12663    (set_attr "length" "12,16")])
12664
12665 (define_split
12666   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12667         (compare:CC
12668          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12669                  (match_operand:DI 2 "reg_or_short_operand" ""))
12670          (const_int 0)))
12671    (set (match_operand:DI 0 "gpc_reg_operand" "")
12672         (gtu:DI (match_dup 1) (match_dup 2)))]
12673   "TARGET_POWERPC64 && reload_completed"
12674   [(set (match_dup 0)
12675         (gtu:DI (match_dup 1) (match_dup 2)))
12676    (set (match_dup 3)
12677         (compare:CC (match_dup 0)
12678                     (const_int 0)))]
12679   "")
12680
12681 (define_insn ""
12682   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12683         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12684                          (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
12685                  (match_operand:SI 3 "reg_or_short_operand" "r,rI")))
12686    (clobber (match_scratch:SI 4 "=&r,&r"))]
12687   "! TARGET_POWERPC64"
12688   "@
12689    {ai|addic} %4,%1,%k2\;{aze|addze} %0,%3
12690    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf%I3|subf%I3c} %0,%4,%3"
12691   [(set_attr "length" "8,12")])
12692
12693 (define_insn ""
12694   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12695         (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12696                          (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
12697                  (match_operand:DI 3 "reg_or_short_operand" "r,rI")))
12698    (clobber (match_scratch:DI 4 "=&r,&r"))]
12699   "TARGET_POWERPC64"
12700   "@
12701    addic %4,%1,%k2\;addze %0,%3
12702    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subf%I3c %0,%4,%3"
12703   [(set_attr "length" "8,12")])
12704
12705 (define_insn ""
12706   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12707         (compare:CC
12708          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12709                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
12710                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12711          (const_int 0)))
12712    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12713   "! TARGET_POWERPC64"
12714   "@
12715    {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
12716    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12717    #
12718    #"
12719   [(set_attr "type" "compare")
12720    (set_attr "length" "8,12,12,16")])
12721
12722 (define_split
12723   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12724         (compare:CC
12725          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12726                           (match_operand:SI 2 "reg_or_short_operand" ""))
12727                   (match_operand:SI 3 "gpc_reg_operand" ""))
12728          (const_int 0)))
12729    (clobber (match_scratch:SI 4 ""))]
12730   "! TARGET_POWERPC64 && reload_completed"
12731   [(set (match_dup 4)
12732         (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
12733                   (match_dup 3)))
12734    (set (match_dup 0)
12735         (compare:CC (match_dup 4)
12736                     (const_int 0)))]
12737   "")
12738
12739 (define_insn ""
12740   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12741         (compare:CC
12742          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12743                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
12744                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
12745          (const_int 0)))
12746    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
12747   "TARGET_POWERPC64"
12748   "@
12749    addic %4,%1,%k2\;addze. %4,%3
12750    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
12751    #
12752    #"
12753   [(set_attr "type" "compare")
12754    (set_attr "length" "8,12,12,16")])
12755
12756 (define_split
12757   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12758         (compare:CC
12759          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12760                           (match_operand:DI 2 "reg_or_short_operand" ""))
12761                   (match_operand:DI 3 "gpc_reg_operand" ""))
12762          (const_int 0)))
12763    (clobber (match_scratch:DI 4 ""))]
12764   "TARGET_POWERPC64 && reload_completed"
12765   [(set (match_dup 4)
12766         (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
12767                   (match_dup 3)))
12768    (set (match_dup 0)
12769         (compare:CC (match_dup 4)
12770                     (const_int 0)))]
12771   "")
12772
12773 (define_insn ""
12774   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12775         (compare:CC
12776          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12777                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
12778                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12779          (const_int 0)))
12780    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12781         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12782    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12783   "! TARGET_POWERPC64"
12784   "@
12785    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
12786    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
12787    #
12788    #"
12789   [(set_attr "type" "compare")
12790    (set_attr "length" "8,12,12,16")])
12791
12792 (define_split
12793   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12794         (compare:CC
12795          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12796                           (match_operand:SI 2 "reg_or_short_operand" ""))
12797                   (match_operand:SI 3 "gpc_reg_operand" ""))
12798          (const_int 0)))
12799    (set (match_operand:SI 0 "gpc_reg_operand" "")
12800         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12801    (clobber (match_scratch:SI 4 ""))]
12802   "! TARGET_POWERPC64 && reload_completed"
12803   [(parallel [(set (match_dup 0)
12804         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12805    (clobber (match_dup 4))])
12806    (set (match_dup 5)
12807         (compare:CC (match_dup 0)
12808                     (const_int 0)))]
12809   "")
12810
12811 (define_insn ""
12812   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12813         (compare:CC
12814          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12815                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
12816                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
12817          (const_int 0)))
12818    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12819         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
12820    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
12821   "TARGET_POWERPC64"
12822   "@
12823    addic %4,%1,%k2\;addze. %0,%3
12824    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %0,%4,%3
12825    #
12826    #"
12827   [(set_attr "type" "compare")
12828    (set_attr "length" "8,12,12,16")])
12829
12830 (define_split
12831   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12832         (compare:CC
12833          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12834                           (match_operand:DI 2 "reg_or_short_operand" ""))
12835                   (match_operand:DI 3 "gpc_reg_operand" ""))
12836          (const_int 0)))
12837    (set (match_operand:DI 0 "gpc_reg_operand" "")
12838         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
12839    (clobber (match_scratch:DI 4 ""))]
12840   "TARGET_POWERPC64 && reload_completed"
12841   [(parallel [(set (match_dup 0)
12842         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
12843    (clobber (match_dup 4))])
12844    (set (match_dup 5)
12845         (compare:CC (match_dup 0)
12846                     (const_int 0)))]
12847   "")
12848
12849 (define_insn ""
12850   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12851         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12852                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12853   "! TARGET_POWERPC64"
12854   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
12855   [(set_attr "length" "8")])
12856
12857 (define_insn ""
12858   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12859         (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12860                         (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
12861   "TARGET_POWERPC64"
12862   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
12863   [(set_attr "length" "8")])
12864 \f
12865 ;; Define both directions of branch and return.  If we need a reload
12866 ;; register, we'd rather use CR0 since it is much easier to copy a
12867 ;; register CC value to there.
12868
12869 (define_insn ""
12870   [(set (pc)
12871         (if_then_else (match_operator 1 "branch_comparison_operator"
12872                                       [(match_operand 2
12873                                                       "cc_reg_operand" "x,?y")
12874                                        (const_int 0)])
12875                       (label_ref (match_operand 0 "" ""))
12876                       (pc)))]
12877   ""
12878   "*
12879 {
12880   return output_cbranch (operands[1], \"%l0\", 0, insn);
12881 }"
12882   [(set_attr "type" "branch")])
12883
12884 (define_insn ""
12885   [(set (pc)
12886         (if_then_else (match_operator 0 "branch_comparison_operator"
12887                                       [(match_operand 1
12888                                                       "cc_reg_operand" "x,?y")
12889                                        (const_int 0)])
12890                       (return)
12891                       (pc)))]
12892   "direct_return ()"
12893   "*
12894 {
12895   return output_cbranch (operands[0], NULL, 0, insn);
12896 }"
12897   [(set_attr "type" "branch")
12898    (set_attr "length" "4")])
12899
12900 (define_insn ""
12901   [(set (pc)
12902         (if_then_else (match_operator 1 "branch_comparison_operator"
12903                                       [(match_operand 2
12904                                                       "cc_reg_operand" "x,?y")
12905                                        (const_int 0)])
12906                       (pc)
12907                       (label_ref (match_operand 0 "" ""))))]
12908   ""
12909   "*
12910 {
12911   return output_cbranch (operands[1], \"%l0\", 1, insn);
12912 }"
12913   [(set_attr "type" "branch")])
12914
12915 (define_insn ""
12916   [(set (pc)
12917         (if_then_else (match_operator 0 "branch_comparison_operator"
12918                                       [(match_operand 1
12919                                                       "cc_reg_operand" "x,?y")
12920                                        (const_int 0)])
12921                       (pc)
12922                       (return)))]
12923   "direct_return ()"
12924   "*
12925 {
12926   return output_cbranch (operands[0], NULL, 1, insn);
12927 }"
12928   [(set_attr "type" "branch")
12929    (set_attr "length" "4")])
12930
12931 ;; Logic on condition register values.
12932
12933 ; This pattern matches things like
12934 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
12935 ;                                          (eq:SI (reg:CCFP 68) (const_int 0)))
12936 ;                                  (const_int 1)))
12937 ; which are generated by the branch logic.
12938
12939 (define_insn ""
12940   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12941         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
12942                         [(match_operator:SI 2 
12943                                       "branch_positive_comparison_operator"
12944                                       [(match_operand 3
12945                                                       "cc_reg_operand" "y")
12946                                        (const_int 0)])
12947                          (match_operator:SI 4 
12948                                       "branch_positive_comparison_operator"
12949                                       [(match_operand 5
12950                                                       "cc_reg_operand" "y")
12951                                        (const_int 0)])])
12952                       (const_int 1)))]
12953   ""
12954   "cr%q1 %E0,%j2,%j4"
12955   [(set_attr "type" "cr_logical")])
12956
12957 ; Why is the constant -1 here, but 1 in the previous pattern?
12958 ; Because ~1 has all but the low bit set.
12959 (define_insn ""
12960   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12961         (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
12962                         [(not:SI (match_operator:SI 2 
12963                                       "branch_positive_comparison_operator"
12964                                       [(match_operand 3
12965                                                       "cc_reg_operand" "y")
12966                                        (const_int 0)]))
12967                          (match_operator:SI 4
12968                                 "branch_positive_comparison_operator"
12969                                 [(match_operand 5
12970                                                 "cc_reg_operand" "y")
12971                                  (const_int 0)])])
12972                       (const_int -1)))]
12973   ""
12974   "cr%q1 %E0,%j2,%j4"
12975   [(set_attr "type" "cr_logical")])
12976
12977 (define_insn ""
12978   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12979         (compare:CCEQ (match_operator:SI 1
12980                                       "branch_positive_comparison_operator"
12981                                       [(match_operand 2
12982                                                       "cc_reg_operand" "y")
12983                                        (const_int 0)])
12984                       (const_int 0)))]
12985   ""
12986   "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
12987   [(set_attr "type" "cr_logical")])
12988
12989 ;; If we are comparing the result of two comparisons, this can be done
12990 ;; using creqv or crxor.
12991
12992 (define_insn_and_split ""
12993   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
12994         (compare:CCEQ (match_operator 1 "branch_comparison_operator"
12995                               [(match_operand 2 "cc_reg_operand" "y")
12996                                (const_int 0)])
12997                       (match_operator 3 "branch_comparison_operator"
12998                               [(match_operand 4 "cc_reg_operand" "y")
12999                                (const_int 0)])))]
13000   ""
13001   "#"
13002   ""
13003   [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13004                                     (match_dup 5)))]
13005   "
13006 {
13007   int positive_1, positive_2;
13008
13009   positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13010   positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13011
13012   if (! positive_1)
13013     operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
13014                                                      GET_CODE (operands[1])),
13015                            SImode,
13016                            operands[2], const0_rtx);
13017   else if (GET_MODE (operands[1]) != SImode)
13018     operands[1] = gen_rtx (GET_CODE (operands[1]),
13019                            SImode,
13020                            operands[2], const0_rtx);
13021
13022   if (! positive_2)
13023     operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
13024                                                      GET_CODE (operands[3])),
13025                            SImode,
13026                            operands[4], const0_rtx);
13027   else if (GET_MODE (operands[3]) != SImode)
13028     operands[3] = gen_rtx (GET_CODE (operands[3]),
13029                            SImode,
13030                            operands[4], const0_rtx);
13031
13032   if (positive_1 == positive_2)
13033     {
13034       operands[1] = gen_rtx_NOT (SImode, operands[1]);
13035       operands[5] = constm1_rtx;
13036     }
13037   else
13038     {
13039       operands[5] = const1_rtx;
13040     }
13041 }")
13042
13043 ;; Unconditional branch and return.
13044
13045 (define_insn "jump"
13046   [(set (pc)
13047         (label_ref (match_operand 0 "" "")))]
13048   ""
13049   "b %l0"
13050   [(set_attr "type" "branch")])
13051
13052 (define_insn "return"
13053   [(return)]
13054   "direct_return ()"
13055   "{br|blr}"
13056   [(set_attr "type" "jmpreg")])
13057
13058 (define_expand "indirect_jump"
13059   [(set (pc) (match_operand 0 "register_operand" ""))]
13060   ""
13061   "
13062 {
13063   if (TARGET_32BIT)
13064     emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13065   else
13066     emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13067   DONE;
13068 }")
13069
13070 (define_insn "indirect_jumpsi"
13071   [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
13072   "TARGET_32BIT"
13073   "@
13074    bctr
13075    {br|blr}"
13076   [(set_attr "type" "jmpreg")])
13077
13078 (define_insn "indirect_jumpdi"
13079   [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
13080   "TARGET_64BIT"
13081   "@
13082    bctr
13083    blr"
13084   [(set_attr "type" "jmpreg")])
13085
13086 ;; Table jump for switch statements:
13087 (define_expand "tablejump"
13088   [(use (match_operand 0 "" ""))
13089    (use (label_ref (match_operand 1 "" "")))]
13090   ""
13091   "
13092 {
13093   if (TARGET_32BIT)
13094     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13095   else
13096     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13097   DONE;
13098 }")
13099
13100 (define_expand "tablejumpsi"
13101   [(set (match_dup 3)
13102         (plus:SI (match_operand:SI 0 "" "")
13103                  (match_dup 2)))
13104    (parallel [(set (pc) (match_dup 3))
13105               (use (label_ref (match_operand 1 "" "")))])]
13106   "TARGET_32BIT"
13107   "
13108 { operands[0] = force_reg (SImode, operands[0]);
13109   operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13110   operands[3] = gen_reg_rtx (SImode);
13111 }")
13112
13113 (define_expand "tablejumpdi"
13114   [(set (match_dup 4) 
13115         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13116    (set (match_dup 3)
13117         (plus:DI (match_dup 4)
13118                  (match_dup 2)))
13119    (parallel [(set (pc) (match_dup 3))
13120               (use (label_ref (match_operand 1 "" "")))])]
13121   "TARGET_64BIT"
13122   "
13123 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13124   operands[3] = gen_reg_rtx (DImode);
13125   operands[4] = gen_reg_rtx (DImode);
13126 }")
13127
13128 (define_insn ""
13129   [(set (pc)
13130         (match_operand:SI 0 "register_operand" "c,*l"))
13131    (use (label_ref (match_operand 1 "" "")))]
13132   "TARGET_32BIT"
13133   "@
13134    bctr
13135    {br|blr}"
13136   [(set_attr "type" "jmpreg")])
13137
13138 (define_insn ""
13139   [(set (pc)
13140         (match_operand:DI 0 "register_operand" "c,*l"))
13141    (use (label_ref (match_operand 1 "" "")))]
13142   "TARGET_64BIT"
13143   "@
13144    bctr
13145    blr"
13146   [(set_attr "type" "jmpreg")])
13147
13148 (define_insn "nop"
13149   [(const_int 0)]
13150   ""
13151   "{cror 0,0,0|nop}")
13152 \f
13153 ;; Define the subtract-one-and-jump insns, starting with the template
13154 ;; so loop.c knows what to generate.
13155
13156 (define_expand "doloop_end"
13157   [(use (match_operand 0 "" ""))        ; loop pseudo
13158    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
13159    (use (match_operand 2 "" ""))        ; max iterations
13160    (use (match_operand 3 "" ""))        ; loop level
13161    (use (match_operand 4 "" ""))]       ; label
13162   ""
13163   "
13164 {
13165   /* Only use this on innermost loops.  */
13166   if (INTVAL (operands[3]) > 1)
13167     FAIL;
13168   if (TARGET_POWERPC64)
13169     {
13170       if (GET_MODE (operands[0]) != DImode)
13171         FAIL;
13172       emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13173     }
13174   else
13175     {
13176       if (GET_MODE (operands[0]) != SImode)
13177         FAIL;
13178       emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13179     }
13180   DONE;
13181 }")
13182
13183 (define_expand "ctrsi"
13184   [(parallel [(set (pc)
13185                    (if_then_else (ne (match_operand:SI 0 "register_operand" "")
13186                                      (const_int 1))
13187                                  (label_ref (match_operand 1 "" ""))
13188                                  (pc)))
13189               (set (match_dup 0)
13190                    (plus:SI (match_dup 0)
13191                             (const_int -1)))
13192               (clobber (match_scratch:CC 2 ""))
13193               (clobber (match_scratch:SI 3 ""))])]
13194   "! TARGET_POWERPC64"
13195   "")
13196
13197 (define_expand "ctrdi"
13198   [(parallel [(set (pc)
13199                    (if_then_else (ne (match_operand:DI 0 "register_operand" "")
13200                                      (const_int 1))
13201                                  (label_ref (match_operand 1 "" ""))
13202                                  (pc)))
13203               (set (match_dup 0)
13204                    (plus:DI (match_dup 0)
13205                             (const_int -1)))
13206               (clobber (match_scratch:CC 2 ""))
13207               (clobber (match_scratch:DI 3 ""))])]
13208   "TARGET_POWERPC64"
13209   "")
13210
13211 ;; We need to be able to do this for any operand, including MEM, or we
13212 ;; will cause reload to blow up since we don't allow output reloads on
13213 ;; JUMP_INSNs.
13214 ;; For the length attribute to be calculated correctly, the
13215 ;; label MUST be operand 0.
13216
13217 (define_insn "*ctrsi_internal1"
13218   [(set (pc)
13219         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13220                           (const_int 1))
13221                       (label_ref (match_operand 0 "" ""))
13222                       (pc)))
13223    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13224         (plus:SI (match_dup 1)
13225                  (const_int -1)))
13226    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13227    (clobber (match_scratch:SI 4 "=X,X,r"))]
13228   "! TARGET_POWERPC64"
13229   "*
13230 {
13231   if (which_alternative != 0)
13232     return \"#\";
13233   else if (get_attr_length (insn) == 4)
13234     return \"{bdn|bdnz} %l0\";
13235   else
13236     return \"bdz $+8\;b %l0\";
13237 }"
13238   [(set_attr "type" "branch")
13239    (set_attr "length" "*,12,16")])
13240
13241 (define_insn "*ctrsi_internal2"
13242   [(set (pc)
13243         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13244                           (const_int 1))
13245                       (pc)
13246                       (label_ref (match_operand 0 "" ""))))
13247    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13248         (plus:SI (match_dup 1)
13249                  (const_int -1)))
13250    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13251    (clobber (match_scratch:SI 4 "=X,X,r"))]
13252   "! TARGET_POWERPC64"
13253   "*
13254 {
13255   if (which_alternative != 0)
13256     return \"#\";
13257   else if (get_attr_length (insn) == 4)
13258     return \"bdz %l0\";
13259   else
13260     return \"{bdn|bdnz} $+8\;b %l0\";
13261 }"
13262   [(set_attr "type" "branch")
13263    (set_attr "length" "*,12,16")])
13264
13265 (define_insn "*ctrdi_internal1"
13266   [(set (pc)
13267         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13268                           (const_int 1))
13269                       (label_ref (match_operand 0 "" ""))
13270                       (pc)))
13271    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13272         (plus:DI (match_dup 1)
13273                  (const_int -1)))
13274    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13275    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13276   "TARGET_POWERPC64"
13277   "*
13278 {
13279   if (which_alternative != 0)
13280     return \"#\";
13281   else if (get_attr_length (insn) == 4)
13282     return \"{bdn|bdnz} %l0\";
13283   else
13284     return \"bdz $+8\;b %l0\";
13285 }"
13286   [(set_attr "type" "branch")
13287    (set_attr "length" "*,12,16,24")])
13288
13289 (define_insn "*ctrdi_internal2"
13290   [(set (pc)
13291         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13292                           (const_int 1))
13293                       (pc)
13294                       (label_ref (match_operand 0 "" ""))))
13295    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13296         (plus:DI (match_dup 1)
13297                  (const_int -1)))
13298    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13299    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13300   "TARGET_POWERPC64"
13301   "*
13302 {
13303   if (which_alternative != 0)
13304     return \"#\";
13305   else if (get_attr_length (insn) == 4)
13306     return \"bdz %l0\";
13307   else
13308     return \"{bdn|bdnz} $+8\;b %l0\";
13309 }"
13310   [(set_attr "type" "branch")
13311    (set_attr "length" "*,12,16,24")])
13312
13313 ;; Similar, but we can use GE since we have a REG_NONNEG.
13314
13315 (define_insn "*ctrsi_internal3"
13316   [(set (pc)
13317         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13318                           (const_int 0))
13319                       (label_ref (match_operand 0 "" ""))
13320                       (pc)))
13321    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13322         (plus:SI (match_dup 1)
13323                  (const_int -1)))
13324    (clobber (match_scratch:CC 3 "=X,&x,&X"))
13325    (clobber (match_scratch:SI 4 "=X,X,r"))]
13326   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13327   "*
13328 {
13329   if (which_alternative != 0)
13330     return \"#\";
13331   else if (get_attr_length (insn) == 4)
13332     return \"{bdn|bdnz} %l0\";
13333   else
13334     return \"bdz $+8\;b %l0\";
13335 }"
13336   [(set_attr "type" "branch")
13337    (set_attr "length" "*,12,16")])
13338
13339 (define_insn "*ctrsi_internal4"
13340   [(set (pc)
13341         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13342                           (const_int 0))
13343                       (pc)
13344                       (label_ref (match_operand 0 "" ""))))
13345    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13346         (plus:SI (match_dup 1)
13347                  (const_int -1)))
13348    (clobber (match_scratch:CC 3 "=X,&x,&X"))
13349    (clobber (match_scratch:SI 4 "=X,X,r"))]
13350   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13351   "*
13352 {
13353   if (which_alternative != 0)
13354     return \"#\";
13355   else if (get_attr_length (insn) == 4)
13356     return \"bdz %l0\";
13357   else
13358     return \"{bdn|bdnz} $+8\;b %l0\";
13359 }"
13360   [(set_attr "type" "branch")
13361    (set_attr "length" "*,12,16")])
13362
13363 (define_insn "*ctrdi_internal3"
13364   [(set (pc)
13365         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13366                           (const_int 0))
13367                       (label_ref (match_operand 0 "" ""))
13368                       (pc)))
13369    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13370         (plus:DI (match_dup 1)
13371                  (const_int -1)))
13372    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13373    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13374   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13375   "*
13376 {
13377   if (which_alternative != 0)
13378     return \"#\";
13379   else if (get_attr_length (insn) == 4)
13380     return \"{bdn|bdnz} %l0\";
13381   else
13382     return \"bdz $+8\;b %l0\";
13383 }"
13384   [(set_attr "type" "branch")
13385    (set_attr "length" "*,12,16,24")])
13386
13387 (define_insn "*ctrdi_internal4"
13388   [(set (pc)
13389         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13390                           (const_int 0))
13391                       (pc)
13392                       (label_ref (match_operand 0 "" ""))))
13393    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13394         (plus:DI (match_dup 1)
13395                  (const_int -1)))
13396    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13397    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13398   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13399   "*
13400 {
13401   if (which_alternative != 0)
13402     return \"#\";
13403   else if (get_attr_length (insn) == 4)
13404     return \"bdz %l0\";
13405   else
13406     return \"{bdn|bdnz} $+8\;b %l0\";
13407 }"
13408   [(set_attr "type" "branch")
13409    (set_attr "length" "*,12,16,24")])
13410
13411 ;; Similar but use EQ
13412
13413 (define_insn "*ctrsi_internal5"
13414   [(set (pc)
13415         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13416                           (const_int 1))
13417                       (label_ref (match_operand 0 "" ""))
13418                       (pc)))
13419    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13420         (plus:SI (match_dup 1)
13421                  (const_int -1)))
13422    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13423    (clobber (match_scratch:SI 4 "=X,X,r"))]
13424   "! TARGET_POWERPC64"
13425   "*
13426 {
13427   if (which_alternative != 0)
13428     return \"#\";
13429   else if (get_attr_length (insn) == 4)
13430     return \"bdz %l0\";
13431   else
13432     return \"{bdn|bdnz} $+8\;b %l0\";
13433 }"
13434   [(set_attr "type" "branch")
13435    (set_attr "length" "*,12,16")])
13436
13437 (define_insn "*ctrsi_internal6"
13438   [(set (pc)
13439         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13440                           (const_int 1))
13441                       (pc)
13442                       (label_ref (match_operand 0 "" ""))))
13443    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13444         (plus:SI (match_dup 1)
13445                  (const_int -1)))
13446    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13447    (clobber (match_scratch:SI 4 "=X,X,r"))]
13448   "! TARGET_POWERPC64"
13449   "*
13450 {
13451   if (which_alternative != 0)
13452     return \"#\";
13453   else if (get_attr_length (insn) == 4)
13454     return \"{bdn|bdnz} %l0\";
13455   else
13456     return \"bdz $+8\;b %l0\";
13457 }"
13458   [(set_attr "type" "branch")
13459    (set_attr "length" "*,12,16")])
13460
13461 (define_insn "*ctrdi_internal5"
13462   [(set (pc)
13463         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13464                           (const_int 1))
13465                       (label_ref (match_operand 0 "" ""))
13466                       (pc)))
13467    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13468         (plus:DI (match_dup 1)
13469                  (const_int -1)))
13470    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13471    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13472   "TARGET_POWERPC64"
13473   "*
13474 {
13475   if (which_alternative != 0)
13476     return \"#\";
13477   else if (get_attr_length (insn) == 4)
13478     return \"bdz %l0\";
13479   else
13480     return \"{bdn|bdnz} $+8\;b %l0\";
13481 }"
13482   [(set_attr "type" "branch")
13483    (set_attr "length" "*,12,16,24")])
13484
13485 (define_insn "*ctrdi_internal6"
13486   [(set (pc)
13487         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r,!*f")
13488                           (const_int 1))
13489                       (pc)
13490                       (label_ref (match_operand 0 "" ""))))
13491    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l,!*f")
13492         (plus:DI (match_dup 1)
13493                  (const_int -1)))
13494    (clobber (match_scratch:CC 3 "=X,&x,&x,&x"))
13495    (clobber (match_scratch:DI 4 "=X,X,r,r"))]
13496   "TARGET_POWERPC64"
13497   "*
13498 {
13499   if (which_alternative != 0)
13500     return \"#\";
13501   else if (get_attr_length (insn) == 4)
13502     return \"{bdn|bdnz} %l0\";
13503   else
13504     return \"bdz $+8\;b %l0\";
13505 }"
13506   [(set_attr "type" "branch")
13507    (set_attr "length" "*,12,16,24")])
13508
13509 ;; Now the splitters if we could not allocate the CTR register
13510
13511 (define_split
13512   [(set (pc)
13513         (if_then_else (match_operator 2 "comparison_operator"
13514                                       [(match_operand:SI 1 "gpc_reg_operand" "")
13515                                        (const_int 1)])
13516                       (match_operand 5 "" "")
13517                       (match_operand 6 "" "")))
13518    (set (match_operand:SI 0 "gpc_reg_operand" "")
13519         (plus:SI (match_dup 1)
13520                  (const_int -1)))
13521    (clobber (match_scratch:CC 3 ""))
13522    (clobber (match_scratch:SI 4 ""))]
13523   "! TARGET_POWERPC64 && reload_completed"
13524   [(parallel [(set (match_dup 3)
13525                    (compare:CC (plus:SI (match_dup 1)
13526                                         (const_int -1))
13527                                (const_int 0)))
13528               (set (match_dup 0)
13529                    (plus:SI (match_dup 1)
13530                             (const_int -1)))])
13531    (set (pc) (if_then_else (match_dup 7)
13532                            (match_dup 5)
13533                            (match_dup 6)))]
13534   "
13535 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13536                          const0_rtx); }")
13537
13538 (define_split
13539   [(set (pc)
13540         (if_then_else (match_operator 2 "comparison_operator"
13541                                       [(match_operand:SI 1 "gpc_reg_operand" "")
13542                                        (const_int 1)])
13543                       (match_operand 5 "" "")
13544                       (match_operand 6 "" "")))
13545    (set (match_operand:SI 0 "nonimmediate_operand" "")
13546         (plus:SI (match_dup 1) (const_int -1)))
13547    (clobber (match_scratch:CC 3 ""))
13548    (clobber (match_scratch:SI 4 ""))]
13549   "! TARGET_POWERPC64 && reload_completed
13550    && ! gpc_reg_operand (operands[0], SImode)"
13551   [(parallel [(set (match_dup 3)
13552                    (compare:CC (plus:SI (match_dup 1)
13553                                         (const_int -1))
13554                                (const_int 0)))
13555               (set (match_dup 4)
13556                    (plus:SI (match_dup 1)
13557                             (const_int -1)))])
13558    (set (match_dup 0)
13559         (match_dup 4))
13560    (set (pc) (if_then_else (match_dup 7)
13561                            (match_dup 5)
13562                            (match_dup 6)))]
13563   "
13564 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13565                          const0_rtx); }")
13566 (define_split
13567   [(set (pc)
13568         (if_then_else (match_operator 2 "comparison_operator"
13569                                       [(match_operand:DI 1 "gpc_reg_operand" "")
13570                                        (const_int 1)])
13571                       (match_operand 5 "" "")
13572                       (match_operand 6 "" "")))
13573    (set (match_operand:DI 0 "gpc_reg_operand" "")
13574         (plus:DI (match_dup 1)
13575                  (const_int -1)))
13576    (clobber (match_scratch:CC 3 ""))
13577    (clobber (match_scratch:DI 4 ""))]
13578   "TARGET_POWERPC64 && reload_completed && INT_REGNO_P (REGNO (operands[0]))"
13579   [(parallel [(set (match_dup 3)
13580                    (compare:CC (plus:DI (match_dup 1)
13581                                         (const_int -1))
13582                                (const_int 0)))
13583               (set (match_dup 0)
13584                    (plus:DI (match_dup 1)
13585                             (const_int -1)))])
13586    (set (pc) (if_then_else (match_dup 7)
13587                            (match_dup 5)
13588                            (match_dup 6)))]
13589   "
13590 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13591                          const0_rtx); }")
13592
13593 (define_split
13594   [(set (pc)
13595         (if_then_else (match_operator 2 "comparison_operator"
13596                                       [(match_operand:DI 1 "gpc_reg_operand" "")
13597                                        (const_int 1)])
13598                       (match_operand 5 "" "")
13599                       (match_operand 6 "" "")))
13600    (set (match_operand:DI 0 "nonimmediate_operand" "")
13601         (plus:DI (match_dup 1) (const_int -1)))
13602    (clobber (match_scratch:CC 3 ""))
13603    (clobber (match_scratch:DI 4 ""))]
13604   "TARGET_POWERPC64 && reload_completed
13605    && ! gpc_reg_operand (operands[0], DImode)"
13606   [(parallel [(set (match_dup 3)
13607                    (compare:CC (plus:DI (match_dup 1)
13608                                         (const_int -1))
13609                                (const_int 0)))
13610               (set (match_dup 4)
13611                    (plus:DI (match_dup 1)
13612                             (const_int -1)))])
13613    (set (match_dup 0)
13614         (match_dup 4))
13615    (set (pc) (if_then_else (match_dup 7)
13616                            (match_dup 5)
13617                            (match_dup 6)))]
13618   "
13619 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13620                          const0_rtx); }")
13621
13622 (define_split
13623   [(set (pc)
13624        (if_then_else (match_operator 2 "comparison_operator"
13625                                      [(match_operand:DI 1 "gpc_reg_operand" "")
13626                                       (const_int 1)])
13627                      (match_operand 5 "" "")
13628                      (match_operand 6 "" "")))
13629    (set (match_operand:DI 0 "gpc_reg_operand" "")
13630        (plus:DI (match_dup 1)
13631                 (const_int -1)))
13632    (clobber (match_scratch:CC 3 ""))
13633    (clobber (match_scratch:DI 4 ""))]
13634   "TARGET_POWERPC64 && reload_completed && FP_REGNO_P (REGNO (operands[0]))"
13635   [(set (match_dup 8)
13636         (match_dup 1))
13637    (set (match_dup 4)
13638         (match_dup 8))
13639    (parallel [(set (match_dup 3)
13640                    (compare:CC (plus:DI (match_dup 4)
13641                                         (const_int -1))
13642                                (const_int 0)))
13643               (set (match_dup 4)
13644                    (plus:DI (match_dup 4)
13645                             (const_int -1)))])
13646    (set (match_dup 8)
13647         (match_dup 4))
13648    (set (match_dup 0)
13649         (match_dup 8))
13650    (set (pc) (if_then_else (match_dup 7)
13651                            (match_dup 5)
13652                            (match_dup 6)))]
13653   "
13654 {
13655   operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13656                          const0_rtx);
13657   operands[8] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
13658 }")
13659
13660 \f
13661 (define_insn "trap"
13662   [(trap_if (const_int 1) (const_int 0))]
13663   ""
13664   "{t 31,0,0|trap}")
13665
13666 (define_expand "conditional_trap"
13667   [(trap_if (match_operator 0 "trap_comparison_operator"
13668                             [(match_dup 2) (match_dup 3)])
13669             (match_operand 1 "const_int_operand" ""))]
13670   ""
13671   "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
13672    operands[2] = rs6000_compare_op0;
13673    operands[3] = rs6000_compare_op1;")
13674
13675 (define_insn ""
13676   [(trap_if (match_operator 0 "trap_comparison_operator"
13677                             [(match_operand:SI 1 "register_operand" "r")
13678                              (match_operand:SI 2 "reg_or_short_operand" "rI")])
13679             (const_int 0))]
13680   ""
13681   "{t|tw}%V0%I2 %1,%2")
13682
13683 (define_insn ""
13684   [(trap_if (match_operator 0 "trap_comparison_operator"
13685                             [(match_operand:DI 1 "register_operand" "r")
13686                              (match_operand:DI 2 "reg_or_short_operand" "rI")])
13687             (const_int 0))]
13688   "TARGET_POWERPC64"
13689   "td%V0%I2 %1,%2")
13690 \f
13691 ;; Insns related to generating the function prologue and epilogue.
13692
13693 (define_expand "prologue"
13694   [(use (const_int 0))]
13695   "TARGET_SCHED_PROLOG"
13696   "
13697 {
13698       rs6000_emit_prologue ();
13699       DONE;
13700 }")
13701
13702 (define_insn "movesi_from_cr"
13703   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13704         (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71) 
13705                     (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)] 19))]
13706   ""
13707   "mfcr %0")
13708
13709 (define_insn "*stmw"
13710  [(match_parallel 0 "stmw_operation"
13711                   [(set (match_operand:SI 1 "memory_operand" "=m")
13712                         (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13713  "TARGET_MULTIPLE"
13714  "{stm|stmw} %2,%1")
13715  
13716 (define_insn "*save_fpregs_si"
13717  [(match_parallel 0 "any_operand"
13718                   [(clobber (match_operand:SI 1 "register_operand" "=l"))
13719                    (use (match_operand:SI 2 "call_operand" "s"))
13720                    (set (match_operand:DF 3 "memory_operand" "=m")
13721                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13722  "TARGET_32BIT"
13723  "bl %z2")
13724
13725 (define_insn "*save_fpregs_di"
13726  [(match_parallel 0 "any_operand"
13727                   [(clobber (match_operand:DI 1 "register_operand" "=l"))
13728                    (use (match_operand:DI 2 "call_operand" "s"))
13729                    (set (match_operand:DF 3 "memory_operand" "=m")
13730                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13731  "TARGET_64BIT"
13732  "bl %z2")
13733
13734 ; These are to explain that changes to the stack pointer should
13735 ; not be moved over stores to stack memory.
13736 (define_insn "stack_tie"
13737   [(set (match_operand:BLK 0 "memory_operand" "+m")
13738         (unspec:BLK [(match_dup 0)] 5))]
13739   ""
13740   ""
13741   [(set_attr "length" "0")])
13742
13743
13744 (define_expand "epilogue"
13745   [(use (const_int 0))]
13746   "TARGET_SCHED_PROLOG"
13747   "
13748 {
13749       rs6000_emit_epilogue (FALSE);
13750       DONE;
13751 }")
13752
13753 ; On some processors, doing the mtcrf one CC register at a time is
13754 ; faster (like on the 604e).  On others, doing them all at once is
13755 ; faster; for instance, on the 601 and 750.
13756
13757 (define_expand "movsi_to_cr_one"
13758  [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13759        (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13760                    (match_dup 2)] 20))]
13761  ""
13762  "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13763
13764 (define_insn "*movsi_to_cr"
13765  [(match_parallel 0 "mtcrf_operation"
13766                   [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13767                         (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13768                                     (match_operand 3 "immediate_operand" "n")]
13769                          20))])]
13770  ""
13771  "*
13772 {
13773   int mask = 0;
13774   int i;
13775   for (i = 0; i < XVECLEN (operands[0], 0); i++)
13776     mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13777   operands[4] = GEN_INT (mask);
13778   return \"mtcrf %4,%2\";
13779 }")
13780
13781 (define_insn ""
13782  [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13783        (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13784                    (match_operand 2 "immediate_operand" "n")] 20))]
13785  "GET_CODE (operands[0]) == REG 
13786   && CR_REGNO_P (REGNO (operands[0]))
13787   && GET_CODE (operands[2]) == CONST_INT
13788   && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13789  "mtcrf %R0,%1")
13790
13791 ; The load-multiple instructions have similar properties.
13792 ; Note that "load_multiple" is a name known to the machine-independent
13793 ; code that actually corresponds to the powerpc load-string.
13794
13795 (define_insn "*lmw"
13796  [(match_parallel 0 "lmw_operation"
13797                   [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13798                         (match_operand:SI 2 "memory_operand" "m"))])]
13799  "TARGET_MULTIPLE"
13800  "{lm|lmw} %1,%2")
13801  
13802 (define_insn "*return_internal_si"
13803   [(return)
13804    (use (match_operand:SI 0 "register_operand" "lc"))]
13805   "TARGET_32BIT"
13806   "b%T0"
13807   [(set_attr "type" "jmpreg")])
13808
13809 (define_insn "*return_internal_di"
13810   [(return)
13811    (use (match_operand:DI 0 "register_operand" "lc"))]
13812   "TARGET_64BIT"
13813   "b%T0"
13814   [(set_attr "type" "jmpreg")])
13815
13816 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13817 ; stuff was in GCC.  Oh, and "any_operand" is a bit flexible...
13818
13819 (define_insn "*return_and_restore_fpregs_si"
13820  [(match_parallel 0 "any_operand"
13821                   [(return)
13822                    (use (match_operand:SI 1 "register_operand" "l"))
13823                    (use (match_operand:SI 2 "call_operand" "s"))
13824                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13825                         (match_operand:DF 4 "memory_operand" "m"))])]
13826  "TARGET_32BIT"
13827  "b %z2")
13828
13829 (define_insn "*return_and_restore_fpregs_di"
13830  [(match_parallel 0 "any_operand"
13831                   [(return)
13832                    (use (match_operand:DI 1 "register_operand" "l"))
13833                    (use (match_operand:DI 2 "call_operand" "s"))
13834                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13835                         (match_operand:DF 4 "memory_operand" "m"))])]
13836  "TARGET_64BIT"
13837  "b %z2")
13838
13839 ; This is used in compiling the unwind routines.
13840 (define_expand "eh_return"
13841   [(use (match_operand 0 "general_operand" ""))
13842    (use (match_operand 1 "general_operand" ""))]
13843   ""
13844   "
13845 {
13846 #if TARGET_AIX
13847     rs6000_emit_eh_toc_restore (operands[0]);
13848 #endif
13849   if (TARGET_32BIT)
13850     emit_insn (gen_eh_set_lr_si (operands[1]));
13851   else
13852     emit_insn (gen_eh_set_lr_di (operands[1]));
13853   emit_move_insn (EH_RETURN_STACKADJ_RTX, operands[0]);
13854   DONE;
13855 }")
13856
13857 ; We can't expand this before we know where the link register is stored.
13858 (define_insn "eh_set_lr_si"
13859   [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 9)
13860    (clobber (match_scratch:SI 1 "=&b"))]
13861   "TARGET_32BIT"
13862   "#")
13863
13864 (define_insn "eh_set_lr_di"
13865   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")] 9)
13866    (clobber (match_scratch:DI 1 "=&b"))]
13867   "TARGET_64BIT"
13868   "#")
13869
13870 (define_split
13871   [(unspec_volatile [(match_operand 0 "register_operand" "")] 9)
13872    (clobber (match_scratch 1 ""))]
13873   "reload_completed"
13874   [(const_int 0)]
13875   "
13876 {
13877   rs6000_stack_t *info = rs6000_stack_info ();
13878
13879   if (info->lr_save_p)
13880     {
13881       rtx frame_rtx = stack_pointer_rtx;
13882       int sp_offset = 0;
13883       rtx tmp;
13884
13885       if (frame_pointer_needed
13886           || current_function_calls_alloca
13887           || info->total_size > 32767)
13888         {
13889           emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
13890           frame_rtx = operands[1];
13891         }
13892       else if (info->push_p)
13893         sp_offset = info->total_size;
13894
13895       tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
13896       tmp = gen_rtx_MEM (Pmode, tmp);
13897       emit_move_insn (tmp, operands[0]);
13898     }
13899   else
13900     emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
13901   DONE;
13902 }")
13903
13904 (define_insn "prefetch"
13905   [(prefetch (match_operand:V4SI 0 "address_operand" "p")
13906              (match_operand:SI 1 "const_int_operand" "n")
13907              (match_operand:SI 2 "const_int_operand" "n"))]
13908   "TARGET_POWERPC"
13909   "*
13910 {
13911   if (GET_CODE (operands[0]) == REG)
13912     return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
13913   return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
13914 }"
13915   [(set_attr "type" "load")])
13916 \f
13917 ;; AltiVec patterns
13918
13919 ;; Generic LVX load instruction.
13920 (define_insn "altivec_lvx_4si"
13921   [(set (match_operand:V4SI 0 "altivec_register_operand" "=v")
13922         (match_operand:V4SI 1 "memory_operand" "m"))]
13923   "TARGET_ALTIVEC"
13924   "lvx %0,%y1"
13925   [(set_attr "type" "vecload")])
13926
13927 (define_insn "altivec_lvx_8hi"
13928   [(set (match_operand:V8HI 0 "altivec_register_operand" "=v")
13929         (match_operand:V8HI 1 "memory_operand" "m"))]
13930   "TARGET_ALTIVEC"
13931   "lvx %0,%y1"
13932   [(set_attr "type" "vecload")])
13933
13934 (define_insn "altivec_lvx_16qi"
13935   [(set (match_operand:V16QI 0 "altivec_register_operand" "=v")
13936         (match_operand:V16QI 1 "memory_operand" "m"))]
13937   "TARGET_ALTIVEC"
13938   "lvx %0,%y1"
13939   [(set_attr "type" "vecload")])
13940
13941 (define_insn "altivec_lvx_4sf"
13942   [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
13943         (match_operand:V4SF 1 "memory_operand" "m"))]
13944   "TARGET_ALTIVEC"
13945   "lvx %0,%y1"
13946   [(set_attr "type" "vecload")])
13947
13948 ;; Generic STVX store instruction.
13949 (define_insn "altivec_stvx_4si"
13950   [(set (match_operand:V4SI 0 "memory_operand" "=m")
13951         (match_operand:V4SI 1 "altivec_register_operand" "v"))]
13952   "TARGET_ALTIVEC"
13953   "stvx %1,%y0"
13954   [(set_attr "type" "vecstore")])
13955
13956 (define_insn "altivec_stvx_8hi"
13957   [(set (match_operand:V8HI 0 "memory_operand" "=m")
13958         (match_operand:V8HI 1 "altivec_register_operand" "v"))]
13959   "TARGET_ALTIVEC"
13960   "stvx %1,%y0"
13961   [(set_attr "type" "vecstore")])
13962
13963 (define_insn "altivec_stvx_16qi"
13964   [(set (match_operand:V16QI 0 "memory_operand" "=m")
13965         (match_operand:V16QI 1 "altivec_register_operand" "v"))]
13966   "TARGET_ALTIVEC"
13967   "stvx %1,%y0"
13968   [(set_attr "type" "vecstore")])
13969
13970 (define_insn "altivec_stvx_4sf"
13971   [(set (match_operand:V4SF 0 "memory_operand" "=m")
13972         (match_operand:V4SF 1 "altivec_register_operand" "v"))]
13973   "TARGET_ALTIVEC"
13974   "stvx %1,%y0"
13975   [(set_attr "type" "vecstore")])
13976
13977 ;; Vector move instructions.
13978 (define_expand "movv4si"
13979   [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
13980         (match_operand:V4SI 1 "any_operand" ""))]
13981   "TARGET_ALTIVEC"
13982   "{ rs6000_emit_move (operands[0], operands[1], V4SImode); DONE; }")
13983
13984 (define_insn "*movv4si_internal"
13985   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=m,v,v,m,r,r")
13986         (match_operand:V4SI 1 "input_operand" "v,m,v,r,m,r"))]
13987   "TARGET_ALTIVEC"
13988   "@
13989    stvx %1,%y0
13990    lvx %0,%y1
13991    vor %0,%1,%1
13992    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
13993    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
13994    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
13995   [(set_attr "type" "altivec")
13996    (set_attr "length" "*,*,*,16,16,16")])
13997
13998 (define_expand "movv8hi"
13999   [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
14000         (match_operand:V8HI 1 "any_operand" ""))]
14001   "TARGET_ALTIVEC"
14002   "{ rs6000_emit_move (operands[0], operands[1], V8HImode); DONE; }")
14003
14004 (define_insn "*movv8hi_internal1"
14005   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=m,v,v,m,r,r")
14006         (match_operand:V8HI 1 "input_operand" "v,m,v,r,m,r"))]
14007   "TARGET_ALTIVEC"
14008   "@
14009    stvx %1,%y0
14010    lvx %0,%y1
14011    vor %0,%1,%1
14012    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14013    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14014    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14015   [(set_attr "type" "altivec")
14016    (set_attr "length" "*,*,*,16,16,16")])
14017
14018 (define_expand "movv16qi"
14019   [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
14020         (match_operand:V16QI 1 "any_operand" ""))]
14021   "TARGET_ALTIVEC"
14022   "{ rs6000_emit_move (operands[0], operands[1], V16QImode); DONE; }")
14023
14024 (define_insn "*movv16qi_internal1"
14025   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=m,v,v,m,r,r")
14026         (match_operand:V16QI 1 "input_operand" "v,m,v,r,m,r"))]
14027   "TARGET_ALTIVEC"
14028   "@
14029    stvx %1,%y0
14030    lvx %0,%y1
14031    vor %0,%1,%1
14032   stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14033   lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14034   mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14035   [(set_attr "type" "altivec")
14036    (set_attr "length" "*,*,*,16,16,16")])
14037
14038 (define_expand "movv4sf"
14039   [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
14040         (match_operand:V4SF 1 "any_operand" ""))]
14041   "TARGET_ALTIVEC"
14042   "{ rs6000_emit_move (operands[0], operands[1], V4SFmode); DONE; }")
14043
14044 (define_insn "*movv4sf_internal1"
14045   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=m,v,v,m,r,r")
14046         (match_operand:V4SF 1 "input_operand" "v,m,v,r,m,r"))]
14047   "TARGET_ALTIVEC"
14048   "@
14049    stvx %1,%y0
14050    lvx %0,%y1
14051    vor %0,%1,%1
14052    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14053    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14054    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14055   [(set_attr "type" "altivec")
14056    (set_attr "length" "*,*,*,16,16,16")])
14057
14058 (define_insn "get_vrsave_internal"
14059   [(set (match_operand:SI 0 "register_operand" "=r")
14060         (unspec:SI [(reg:SI 109)] 214))]
14061   "TARGET_ALTIVEC"
14062   "*
14063 {
14064   if (TARGET_MACHO)
14065      return \"mfspr %0,256\";
14066   else
14067      return \"mfvrsave %0\";
14068 }"
14069   [(set_attr "type" "altivec")])
14070
14071 (define_insn "*set_vrsave_internal"
14072   [(match_parallel 0 "vrsave_operation"
14073      [(set (reg:SI 109)
14074            (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
14075                                 (reg:SI 109)] 30))])]
14076   "TARGET_ALTIVEC"
14077   "*
14078 {
14079   if (TARGET_MACHO)
14080     return \"mtspr 256,%1\";
14081   else
14082     return \"mtvrsave %1\";
14083 }"
14084   [(set_attr "type" "altivec")])
14085
14086 ;; Vector clears
14087 (define_insn "*movv4si_const0"
14088   [(set (match_operand:V4SI 0 "altivec_register_operand" "=v")
14089         (match_operand:V4SI 1 "zero_constant" ""))]
14090   "TARGET_ALTIVEC"
14091   "vxor %0,%0,%0"
14092   [(set_attr "type" "vecsimple")])
14093
14094 (define_insn "*movv4sf_const0"
14095   [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
14096         (match_operand:V4SF 1 "zero_constant" ""))]
14097                                          
14098   "TARGET_ALTIVEC"
14099   "vxor %0,%0,%0"
14100   [(set_attr "type" "vecsimple")])
14101
14102 (define_insn "*movv8hi_const0"
14103   [(set (match_operand:V8HI 0 "altivec_register_operand" "=v")
14104         (match_operand:V8HI 1 "zero_constant" ""))]
14105   "TARGET_ALTIVEC"
14106   "vxor %0,%0,%0"
14107   [(set_attr "type" "vecsimple")])
14108
14109 (define_insn "*movv16qi_const0"
14110   [(set (match_operand:V16QI 0 "altivec_register_operand" "=v")
14111         (match_operand:V16QI 1 "zero_constant" ""))]
14112   "TARGET_ALTIVEC"
14113   "vxor %0,%0,%0"
14114   [(set_attr "type" "vecsimple")])
14115
14116 ;; Simple binary operations.
14117
14118 (define_insn "addv16qi3"
14119   [(set (match_operand:V16QI 0 "register_operand" "=v")
14120         (plus:V16QI (match_operand:V16QI 1 "register_operand" "v")
14121                     (match_operand:V16QI 2 "register_operand" "v")))]
14122   "TARGET_ALTIVEC"
14123   "vaddubm %0,%1,%2"
14124   [(set_attr "type" "vecsimple")])
14125
14126 (define_insn "addv8hi3"
14127   [(set (match_operand:V8HI 0 "register_operand" "=v")
14128         (plus:V8HI (match_operand:V8HI 1 "register_operand" "v")
14129                    (match_operand:V8HI 2 "register_operand" "v")))]
14130   "TARGET_ALTIVEC"
14131   "vadduhm %0,%1,%2"
14132   [(set_attr "type" "vecsimple")])
14133
14134 (define_insn "addv4si3"
14135   [(set (match_operand:V4SI 0 "register_operand" "=v")
14136         (plus:V4SI (match_operand:V4SI 1 "register_operand" "v")
14137                    (match_operand:V4SI 2 "register_operand" "v")))]
14138   "TARGET_ALTIVEC"
14139   "vadduwm %0,%1,%2"
14140   [(set_attr "type" "vecsimple")])
14141
14142 (define_insn "addv4sf3"
14143   [(set (match_operand:V4SF 0 "register_operand" "=v")
14144         (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
14145                    (match_operand:V4SF 2 "register_operand" "v")))]
14146   "TARGET_ALTIVEC"
14147   "vaddfp %0,%1,%2"
14148   [(set_attr "type" "vecfloat")])
14149
14150 (define_insn "altivec_vaddcuw"
14151   [(set (match_operand:V4SI 0 "register_operand" "=v")
14152         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14153                       (match_operand:V4SI 2 "register_operand" "v")] 35))]
14154   "TARGET_ALTIVEC"
14155   "vaddcuw %0,%1,%2"
14156   [(set_attr "type" "vecsimple")])
14157
14158 (define_insn "altivec_vaddubs"
14159   [(set (match_operand:V16QI 0 "register_operand" "=v")
14160         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14161                        (match_operand:V16QI 2 "register_operand" "v")] 36))]
14162   "TARGET_ALTIVEC"
14163   "vaddubs %0,%1,%2"
14164   [(set_attr "type" "vecsimple")])
14165
14166 (define_insn "altivec_vaddsbs"
14167   [(set (match_operand:V16QI 0 "register_operand" "=v")
14168         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14169                        (match_operand:V16QI 2 "register_operand" "v")] 37))]
14170   "TARGET_ALTIVEC"
14171   "vaddsbs %0,%1,%2"
14172   [(set_attr "type" "vecsimple")])
14173
14174 (define_insn "altivec_vadduhs"
14175   [(set (match_operand:V8HI 0 "register_operand" "=v")
14176         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14177                       (match_operand:V8HI 2 "register_operand" "v")] 38))]
14178   "TARGET_ALTIVEC"
14179   "vadduhs %0,%1,%2"
14180   [(set_attr "type" "vecsimple")])
14181
14182 (define_insn "altivec_vaddshs"
14183   [(set (match_operand:V8HI 0 "register_operand" "=v")
14184         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14185                       (match_operand:V8HI 2 "register_operand" "v")] 39))]
14186   "TARGET_ALTIVEC"
14187   "vaddshs %0,%1,%2"
14188   [(set_attr "type" "vecsimple")])
14189
14190 (define_insn "altivec_vadduws"
14191   [(set (match_operand:V4SI 0 "register_operand" "=v")
14192         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14193                       (match_operand:V4SI 2 "register_operand" "v")] 40))]
14194   "TARGET_ALTIVEC"
14195   "vadduws %0,%1,%2"
14196   [(set_attr "type" "vecsimple")])
14197
14198 (define_insn "altivec_vaddsws"
14199   [(set (match_operand:V4SI 0 "register_operand" "=v")
14200         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14201                       (match_operand:V4SI 2 "register_operand" "v")] 41))]
14202   "TARGET_ALTIVEC"
14203   "vaddsws %0,%1,%2"
14204   [(set_attr "type" "vecsimple")])
14205
14206 (define_insn "andv4si3"
14207   [(set (match_operand:V4SI 0 "register_operand" "=v")
14208         (and:V4SI (match_operand:V4SI 1 "register_operand" "v")
14209                   (match_operand:V4SI 2 "register_operand" "v")))]
14210   "TARGET_ALTIVEC"
14211   "vand %0,%1,%2"
14212   [(set_attr "type" "vecsimple")])
14213
14214 (define_insn "altivec_vandc"
14215   [(set (match_operand:V4SI 0 "register_operand" "=v")
14216         (and:V4SI (match_operand:V4SI 1 "register_operand" "v")
14217                   (not:V4SI (match_operand:V4SI 2 "register_operand" "v"))))]
14218   "TARGET_ALTIVEC"
14219   "vandc %0,%1,%2"
14220   [(set_attr "type" "vecsimple")])
14221
14222 (define_insn "altivec_vavgub"
14223   [(set (match_operand:V16QI 0 "register_operand" "=v")
14224         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14225                        (match_operand:V16QI 2 "register_operand" "v")] 44))]
14226   "TARGET_ALTIVEC"
14227   "vavgub %0,%1,%2"
14228   [(set_attr "type" "vecsimple")])
14229
14230 (define_insn "altivec_vavgsb"
14231   [(set (match_operand:V16QI 0 "register_operand" "=v")
14232         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14233                        (match_operand:V16QI 2 "register_operand" "v")] 45))]
14234   "TARGET_ALTIVEC"
14235   "vavgsb %0,%1,%2"
14236   [(set_attr "type" "vecsimple")])
14237
14238 (define_insn "altivec_vavguh"
14239   [(set (match_operand:V8HI 0 "register_operand" "=v")
14240         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14241                       (match_operand:V8HI 2 "register_operand" "v")] 46))]
14242   "TARGET_ALTIVEC"
14243   "vavguh %0,%1,%2"
14244   [(set_attr "type" "vecsimple")])
14245
14246 (define_insn "altivec_vavgsh"
14247   [(set (match_operand:V8HI 0 "register_operand" "=v")
14248         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14249                       (match_operand:V8HI 2 "register_operand" "v")] 47))]
14250   "TARGET_ALTIVEC"
14251   "vavgsh %0,%1,%2"
14252   [(set_attr "type" "vecsimple")])
14253
14254 (define_insn "altivec_vavguw"
14255   [(set (match_operand:V4SI 0 "register_operand" "=v")
14256         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14257                       (match_operand:V4SI 2 "register_operand" "v")] 48))]
14258   "TARGET_ALTIVEC"
14259   "vavguw %0,%1,%2"
14260   [(set_attr "type" "vecsimple")])
14261
14262 (define_insn "altivec_vavgsw"
14263   [(set (match_operand:V4SI 0 "register_operand" "=v")
14264         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14265                       (match_operand:V4SI 2 "register_operand" "v")] 49))]
14266   "TARGET_ALTIVEC"
14267   "vavgsw %0,%1,%2"
14268   [(set_attr "type" "vecsimple")])
14269
14270 (define_insn "altivec_vcmpbfp"
14271   [(set (match_operand:V4SI 0 "register_operand" "=v")
14272         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14273                       (match_operand:V4SF 2 "register_operand" "v")] 50))]
14274   "TARGET_ALTIVEC"
14275   "vcmpbfp %0,%1,%2"
14276   [(set_attr "type" "veccmp")])
14277
14278 (define_insn "altivec_vcmpequb"
14279   [(set (match_operand:V16QI 0 "register_operand" "=v")
14280         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14281                        (match_operand:V16QI 2 "register_operand" "v")] 51))]
14282   "TARGET_ALTIVEC"
14283   "vcmpequb %0,%1,%2"
14284   [(set_attr "type" "vecsimple")])
14285
14286 (define_insn "altivec_vcmpequh"
14287   [(set (match_operand:V8HI 0 "register_operand" "=v")
14288         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14289                       (match_operand:V8HI 2 "register_operand" "v")] 52))]
14290   "TARGET_ALTIVEC"
14291   "vcmpequh %0,%1,%2"
14292   [(set_attr "type" "vecsimple")])
14293
14294 (define_insn "altivec_vcmpequw"
14295   [(set (match_operand:V4SI 0 "register_operand" "=v")
14296         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14297                       (match_operand:V4SI 2 "register_operand" "v")] 53))]
14298   "TARGET_ALTIVEC"
14299   "vcmpequw %0,%1,%2"
14300   [(set_attr "type" "vecsimple")])
14301
14302 (define_insn "altivec_vcmpeqfp"
14303   [(set (match_operand:V4SI 0 "register_operand" "=v")
14304         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14305                       (match_operand:V4SF 2 "register_operand" "v")] 54))]
14306   "TARGET_ALTIVEC"
14307   "vcmpeqfp %0,%1,%2"
14308   [(set_attr "type" "veccmp")])
14309
14310 (define_insn "altivec_vcmpgefp"
14311   [(set (match_operand:V4SI 0 "register_operand" "=v")
14312         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14313                       (match_operand:V4SF 2 "register_operand" "v")] 55))]
14314   "TARGET_ALTIVEC"
14315   "vcmpgefp %0,%1,%2"
14316   [(set_attr "type" "veccmp")])
14317
14318 (define_insn "altivec_vcmpgtub"
14319   [(set (match_operand:V16QI 0 "register_operand" "=v")
14320         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14321                        (match_operand:V16QI 2 "register_operand" "v")] 56))]
14322   "TARGET_ALTIVEC"
14323   "vcmpgtub %0,%1,%2"
14324   [(set_attr "type" "vecsimple")])
14325
14326 (define_insn "altivec_vcmpgtsb"
14327   [(set (match_operand:V16QI 0 "register_operand" "=v")
14328         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14329                        (match_operand:V16QI 2 "register_operand" "v")] 57))]
14330   "TARGET_ALTIVEC"
14331   "vcmpgtsb %0,%1,%2"
14332   [(set_attr "type" "vecsimple")])
14333
14334 (define_insn "altivec_vcmpgtuh"
14335   [(set (match_operand:V8HI 0 "register_operand" "=v")
14336         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14337                       (match_operand:V8HI 2 "register_operand" "v")] 58))]
14338   "TARGET_ALTIVEC"
14339   "vcmpgtuh %0,%1,%2"
14340   [(set_attr "type" "vecsimple")])
14341
14342 (define_insn "altivec_vcmpgtsh"
14343   [(set (match_operand:V8HI 0 "register_operand" "=v")
14344         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14345                       (match_operand:V8HI 2 "register_operand" "v")] 59))]
14346   "TARGET_ALTIVEC"
14347   "vcmpgtsh %0,%1,%2"
14348   [(set_attr "type" "vecsimple")])
14349
14350 (define_insn "altivec_vcmpgtuw"
14351   [(set (match_operand:V4SI 0 "register_operand" "=v")
14352         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14353                       (match_operand:V4SI 2 "register_operand" "v")] 60))]
14354   "TARGET_ALTIVEC"
14355   "vcmpgtuw %0,%1,%2"
14356   [(set_attr "type" "vecsimple")])
14357
14358 (define_insn "altivec_vcmpgtsw"
14359   [(set (match_operand:V4SI 0 "register_operand" "=v")
14360         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14361                       (match_operand:V4SI 2 "register_operand" "v")] 61))]
14362   "TARGET_ALTIVEC"
14363   "vcmpgtsw %0,%1,%2"
14364   [(set_attr "type" "vecsimple")])
14365
14366 (define_insn "altivec_vcmpgtfp"
14367   [(set (match_operand:V4SI 0 "register_operand" "=v")
14368         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14369                       (match_operand:V4SF 2 "register_operand" "v")] 62))]
14370   "TARGET_ALTIVEC"
14371   "vcmpgtfp %0,%1,%2"
14372   [(set_attr "type" "veccmp")])
14373
14374 ;; Fused multiply add
14375 (define_insn "altivec_vmaddfp"
14376   [(set (match_operand:V4SF 0 "register_operand" "=v")
14377         (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14378                               (match_operand:V4SF 2 "register_operand" "v"))
14379                    (match_operand:V4SF 3 "register_operand" "v")))]
14380   "TARGET_ALTIVEC"
14381   "vmaddfp %0,%1,%2,%3"
14382   [(set_attr "type" "vecfloat")])
14383
14384 ;; The unspec here is a vec splat of 0. We do multiply as a fused
14385 ;; multiply-add with an add of a 0 vector. 
14386
14387 (define_expand "mulv4sf3"
14388   [(set (match_dup 3) (unspec:V4SF [(const_int 0)] 142))
14389    (set (match_operand:V4SF 0 "register_operand" "=v")
14390         (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14391                               (match_operand:V4SF 2 "register_operand" "v"))
14392                    (match_dup 3)))]
14393   "TARGET_ALTIVEC && TARGET_FUSED_MADD"
14394   "
14395 { operands[3] = gen_reg_rtx (V4SFmode); }")
14396
14397 ;; Fused multiply subtract 
14398 (define_insn "altivec_vnmsubfp"
14399   [(set (match_operand:V4SF 0 "register_operand" "=v")
14400         (minus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14401                                (match_operand:V4SF 2 "register_operand" "v"))
14402                     (match_operand:V4SF 3 "register_operand" "v")))]
14403   "TARGET_ALTIVEC"
14404   "vnmsubfp %0,%1,%2,%3"
14405   [(set_attr "type" "vecfloat")])
14406
14407
14408 (define_insn "altivec_vmsumubm"
14409   [(set (match_operand:V4SI 0 "register_operand" "=v")
14410         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
14411                       (match_operand:V16QI 2 "register_operand" "v")
14412                       (match_operand:V4SI 3 "register_operand" "v")] 65))]
14413   "TARGET_ALTIVEC"
14414   "vmsumubm %0, %1, %2, %3"
14415   [(set_attr "type" "veccomplex")])
14416
14417 (define_insn "altivec_vmsummbm"
14418   [(set (match_operand:V4SI 0 "register_operand" "=v")
14419         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
14420                       (match_operand:V16QI 2 "register_operand" "v")
14421                       (match_operand:V4SI 3 "register_operand" "v")] 66))]
14422   "TARGET_ALTIVEC"
14423   "vmsumubm %0, %1, %2, %3"
14424   [(set_attr "type" "veccomplex")])
14425
14426 (define_insn "altivec_vmsumuhm"
14427   [(set (match_operand:V4SI 0 "register_operand" "=v")
14428         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14429                       (match_operand:V8HI 2 "register_operand" "v")
14430                       (match_operand:V4SI 3 "register_operand" "v")] 67))]
14431   "TARGET_ALTIVEC"
14432   "vmsumuhm %0, %1, %2, %3"
14433   [(set_attr "type" "veccomplex")])
14434
14435 (define_insn "altivec_vmsumshm"
14436   [(set (match_operand:V4SI 0 "register_operand" "=v")
14437         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14438                       (match_operand:V8HI 2 "register_operand" "v")
14439                       (match_operand:V4SI 3 "register_operand" "v")] 68))]
14440   "TARGET_ALTIVEC"
14441   "vmsumshm %0, %1, %2, %3"
14442   [(set_attr "type" "veccomplex")])
14443
14444 (define_insn "altivec_vmsumuhs"
14445   [(set (match_operand:V4SI 0 "register_operand" "=v")
14446         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14447                       (match_operand:V8HI 2 "register_operand" "v")
14448                       (match_operand:V4SI 3 "register_operand" "v")] 69))]
14449   "TARGET_ALTIVEC"
14450   "vmsumuhs %0, %1, %2, %3"
14451   [(set_attr "type" "veccomplex")])
14452
14453 (define_insn "altivec_vmsumshs"
14454   [(set (match_operand:V4SI 0 "register_operand" "=v")
14455         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14456                       (match_operand:V8HI 2 "register_operand" "v")
14457                       (match_operand:V4SI 3 "register_operand" "v")] 70))]
14458   "TARGET_ALTIVEC"
14459   "vmsumshs %0, %1, %2, %3"
14460   [(set_attr "type" "veccomplex")])
14461
14462 (define_insn "umaxv16qi3"
14463   [(set (match_operand:V16QI 0 "register_operand" "=v")
14464         (umax:V16QI (match_operand:V16QI 1 "register_operand" "v")
14465                     (match_operand:V16QI 2 "register_operand" "v")))]
14466   "TARGET_ALTIVEC"
14467   "vmaxub %0,%1,%2"
14468   [(set_attr "type" "vecsimple")])
14469
14470 (define_insn "smaxv16qi3"
14471   [(set (match_operand:V16QI 0 "register_operand" "=v")
14472         (smax:V16QI (match_operand:V16QI 1 "register_operand" "v")
14473                     (match_operand:V16QI 2 "register_operand" "v")))]
14474   "TARGET_ALTIVEC"
14475   "vmaxsb %0,%1,%2"
14476   [(set_attr "type" "vecsimple")])
14477
14478 (define_insn "umaxv8hi3"
14479   [(set (match_operand:V8HI 0 "register_operand" "=v")
14480         (umax:V8HI (match_operand:V8HI 1 "register_operand" "v")
14481                    (match_operand:V8HI 2 "register_operand" "v")))]
14482   "TARGET_ALTIVEC"
14483   "vmaxuh %0,%1,%2"
14484   [(set_attr "type" "vecsimple")])
14485
14486 (define_insn "smaxv8hi3"
14487   [(set (match_operand:V8HI 0 "register_operand" "=v")
14488         (smax:V8HI (match_operand:V8HI 1 "register_operand" "v")
14489                    (match_operand:V8HI 2 "register_operand" "v")))]
14490   "TARGET_ALTIVEC"
14491   "vmaxsh %0,%1,%2"
14492   [(set_attr "type" "vecsimple")])
14493
14494 (define_insn "umaxv4si3"
14495   [(set (match_operand:V4SI 0 "register_operand" "=v")
14496         (umax:V4SI (match_operand:V4SI 1 "register_operand" "v")
14497                    (match_operand:V4SI 2 "register_operand" "v")))]
14498   "TARGET_ALTIVEC"
14499   "vmaxuw %0,%1,%2"
14500   [(set_attr "type" "vecsimple")])
14501
14502 (define_insn "smaxv4si3"
14503   [(set (match_operand:V4SI 0 "register_operand" "=v")
14504         (smax:V4SI (match_operand:V4SI 1 "register_operand" "v")
14505                    (match_operand:V4SI 2 "register_operand" "v")))]
14506   "TARGET_ALTIVEC"
14507   "vmaxsw %0,%1,%2"
14508   [(set_attr "type" "vecsimple")])
14509
14510 (define_insn "smaxv4sf3"
14511   [(set (match_operand:V4SF 0 "register_operand" "=v")
14512         (smax:V4SF (match_operand:V4SF 1 "register_operand" "v")
14513                    (match_operand:V4SF 2 "register_operand" "v")))]
14514   "TARGET_ALTIVEC"
14515   "vmaxfp %0,%1,%2"
14516   [(set_attr "type" "veccmp")])
14517
14518 (define_insn "altivec_vmhaddshs"
14519   [(set (match_operand:V8HI 0 "register_operand" "=v")
14520         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14521                       (match_operand:V8HI 2 "register_operand" "v")
14522                       (match_operand:V8HI 3 "register_operand" "v")] 71))]
14523   "TARGET_ALTIVEC"
14524   "vmhaddshs %0, %1, %2, %3"
14525   [(set_attr "type" "veccomplex")])
14526 (define_insn "altivec_vmhraddshs"
14527   [(set (match_operand:V8HI 0 "register_operand" "=v")
14528         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14529                       (match_operand:V8HI 2 "register_operand" "v")
14530                       (match_operand:V8HI 3 "register_operand" "v")] 72))]
14531   "TARGET_ALTIVEC"
14532   "vmhraddshs %0, %1, %2, %3"
14533   [(set_attr "type" "veccomplex")])
14534 (define_insn "altivec_vmladduhm"
14535   [(set (match_operand:V8HI 0 "register_operand" "=v")
14536         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14537                       (match_operand:V8HI 2 "register_operand" "v")
14538                       (match_operand:V8HI 3 "register_operand" "v")] 73))]
14539   "TARGET_ALTIVEC"
14540   "vmladduhm %0, %1, %2, %3"
14541   [(set_attr "type" "veccomplex")])
14542
14543 (define_insn "altivec_vmrghb"
14544   [(set (match_operand:V16QI 0 "register_operand" "=v")
14545         (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
14546                                            (parallel [(const_int 8)
14547                                                       (const_int 9)
14548                                                       (const_int 10)
14549                                                       (const_int 11)
14550                                                       (const_int 12)
14551                                                       (const_int 13)
14552                                                       (const_int 14)
14553                                                       (const_int 15)
14554                                                       (const_int 0)
14555                                                       (const_int 1)
14556                                                       (const_int 2)
14557                                                       (const_int 3)
14558                                                       (const_int 4)
14559                                                       (const_int 5)
14560                                                       (const_int 6)
14561                                                       (const_int 7)]))
14562                       (match_operand:V16QI 2 "register_operand" "v")
14563                       (const_int 255)))]
14564   "TARGET_ALTIVEC"
14565   "vmrghb %0,%1,%2"
14566   [(set_attr "type" "vecperm")])
14567
14568 (define_insn "altivec_vmrghh"
14569   [(set (match_operand:V8HI 0 "register_operand" "=v")
14570         (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
14571                                            (parallel [(const_int 4)
14572                                                       (const_int 5)
14573                                                       (const_int 6)
14574                                                       (const_int 7)
14575                                                       (const_int 0)
14576                                                       (const_int 1)
14577                                                       (const_int 2)
14578                                                       (const_int 3)]))
14579                       (match_operand:V8HI 2 "register_operand" "v")
14580                       (const_int 15)))]
14581   "TARGET_ALTIVEC"
14582   "vmrghh %0,%1,%2"
14583   [(set_attr "type" "vecperm")])
14584
14585 (define_insn "altivec_vmrghw"
14586   [(set (match_operand:V4SI 0 "register_operand" "=v")
14587         (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
14588                                          (parallel [(const_int 2)
14589                                                     (const_int 3)
14590                                                     (const_int 0)
14591                                                     (const_int 1)]))
14592                       (match_operand:V4SI 2 "register_operand" "v")
14593                       (const_int 12)))]
14594   "TARGET_ALTIVEC"
14595   "vmrghw %0,%1,%2"
14596   [(set_attr "type" "vecperm")])
14597
14598 (define_insn "altivec_vmrglb"
14599   [(set (match_operand:V16QI 0 "register_operand" "=v")
14600         (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
14601                                            
14602                                            (parallel [(const_int 0)
14603                                                       (const_int 1)
14604                                                       (const_int 2)
14605                                                       (const_int 3)
14606                                                       (const_int 4)
14607                                                       (const_int 5)
14608                                                       (const_int 6)
14609                                                       (const_int 7)
14610                                                       (const_int 8)
14611                                                       (const_int 9)
14612                                                       (const_int 10)
14613                                                       (const_int 11)
14614                                                       (const_int 12)
14615                                                       (const_int 13)
14616                                                       (const_int 14)
14617                                                       (const_int 15)]))
14618                       (match_operand:V16QI 1 "register_operand" "v")
14619                       (const_int 255)))]
14620   "TARGET_ALTIVEC"
14621   "vmrglb %0,%1,%2"
14622   [(set_attr "type" "vecperm")])
14623
14624 (define_insn "altivec_vmrglh"
14625   [(set (match_operand:V8HI 0 "register_operand" "=v")
14626         (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
14627                                            (parallel [(const_int 0)
14628                                                       (const_int 1)
14629                                                       (const_int 2)
14630                                                       (const_int 3)
14631                                                       (const_int 4)
14632                                                       (const_int 5)
14633                                                       (const_int 6)
14634                                                       (const_int 7)]))
14635                       (match_operand:V8HI 1 "register_operand" "v")
14636                       (const_int 15)))]
14637   "TARGET_ALTIVEC"
14638   "vmrglh %0,%1,%2"
14639   [(set_attr "type" "vecperm")])
14640
14641 (define_insn "altivec_vmrglw"
14642   [(set (match_operand:V4SI 0 "register_operand" "=v")
14643         (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
14644                                          (parallel [(const_int 0)
14645                                                     (const_int 1)
14646                                                     (const_int 2)
14647                                                     (const_int 3)]))
14648                       (match_operand:V4SI 1 "register_operand" "v")
14649                       (const_int 12)))]
14650   "TARGET_ALTIVEC"
14651   "vmrglw %0,%1,%2"
14652   [(set_attr "type" "vecperm")])
14653
14654 (define_insn "uminv16qi3"
14655   [(set (match_operand:V16QI 0 "register_operand" "=v")
14656         (umin:V16QI (match_operand:V16QI 1 "register_operand" "v")
14657                     (match_operand:V16QI 2 "register_operand" "v")))]
14658   "TARGET_ALTIVEC"
14659   "vminub %0,%1,%2"
14660   [(set_attr "type" "vecsimple")])
14661
14662 (define_insn "sminv16qi3"
14663   [(set (match_operand:V16QI 0 "register_operand" "=v")
14664         (smin:V16QI (match_operand:V16QI 1 "register_operand" "v")
14665                     (match_operand:V16QI 2 "register_operand" "v")))]
14666   "TARGET_ALTIVEC"
14667   "vminsb %0,%1,%2"
14668   [(set_attr "type" "vecsimple")])
14669
14670 (define_insn "uminv8hi3"
14671   [(set (match_operand:V8HI 0 "register_operand" "=v")
14672         (umin:V8HI (match_operand:V8HI 1 "register_operand" "v")
14673                    (match_operand:V8HI 2 "register_operand" "v")))]
14674   "TARGET_ALTIVEC"
14675   "vminuh %0,%1,%2"
14676   [(set_attr "type" "vecsimple")])
14677
14678 (define_insn "sminv8hi3"
14679   [(set (match_operand:V8HI 0 "register_operand" "=v")
14680         (smin:V8HI (match_operand:V8HI 1 "register_operand" "v")
14681                    (match_operand:V8HI 2 "register_operand" "v")))]
14682   "TARGET_ALTIVEC"
14683   "vminsh %0,%1,%2"
14684   [(set_attr "type" "vecsimple")])
14685
14686 (define_insn "uminv4si3"
14687   [(set (match_operand:V4SI 0 "register_operand" "=v")
14688         (umin:V4SI (match_operand:V4SI 1 "register_operand" "v")
14689                    (match_operand:V4SI 2 "register_operand" "v")))]
14690   "TARGET_ALTIVEC"
14691   "vminuw %0,%1,%2"
14692   [(set_attr "type" "vecsimple")])
14693
14694 (define_insn "sminv4si3"
14695   [(set (match_operand:V4SI 0 "register_operand" "=v")
14696         (smin:V4SI (match_operand:V4SI 1 "register_operand" "v")
14697                    (match_operand:V4SI 2 "register_operand" "v")))]
14698   "TARGET_ALTIVEC"
14699   "vminsw %0,%1,%2"
14700   [(set_attr "type" "vecsimple")])
14701
14702 (define_insn "sminv4sf3"
14703   [(set (match_operand:V4SF 0 "register_operand" "=v")
14704         (smin:V4SF (match_operand:V4SF 1 "register_operand" "v")
14705                    (match_operand:V4SF 2 "register_operand" "v")))]
14706   "TARGET_ALTIVEC"
14707   "vminfp %0,%1,%2"
14708   [(set_attr "type" "veccmp")])
14709
14710 (define_insn "altivec_vmuleub"
14711   [(set (match_operand:V8HI 0 "register_operand" "=v")
14712         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14713                       (match_operand:V16QI 2 "register_operand" "v")] 83))]
14714   "TARGET_ALTIVEC"
14715   "vmuleub %0,%1,%2"
14716   [(set_attr "type" "veccomplex")])
14717
14718 (define_insn "altivec_vmulesb"
14719   [(set (match_operand:V8HI 0 "register_operand" "=v")
14720         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14721                       (match_operand:V16QI 2 "register_operand" "v")] 84))]
14722   "TARGET_ALTIVEC"
14723   "vmulesb %0,%1,%2"
14724   [(set_attr "type" "veccomplex")])
14725
14726 (define_insn "altivec_vmuleuh"
14727   [(set (match_operand:V4SI 0 "register_operand" "=v")
14728         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14729                       (match_operand:V8HI 2 "register_operand" "v")] 85))]
14730   "TARGET_ALTIVEC"
14731   "vmuleuh %0,%1,%2"
14732   [(set_attr "type" "veccomplex")])
14733
14734 (define_insn "altivec_vmulesh"
14735   [(set (match_operand:V4SI 0 "register_operand" "=v")
14736         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14737                       (match_operand:V8HI 2 "register_operand" "v")] 86))]
14738   "TARGET_ALTIVEC"
14739   "vmulesh %0,%1,%2"
14740   [(set_attr "type" "veccomplex")])
14741
14742 (define_insn "altivec_vmuloub"
14743   [(set (match_operand:V8HI 0 "register_operand" "=v")
14744         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14745                       (match_operand:V16QI 2 "register_operand" "v")] 87))]
14746   "TARGET_ALTIVEC"
14747   "vmuloub %0,%1,%2"
14748   [(set_attr "type" "veccomplex")])
14749
14750 (define_insn "altivec_vmulosb"
14751   [(set (match_operand:V8HI 0 "register_operand" "=v")
14752         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14753                       (match_operand:V16QI 2 "register_operand" "v")] 88))]
14754   "TARGET_ALTIVEC"
14755   "vmulosb %0,%1,%2"
14756   [(set_attr "type" "veccomplex")])
14757
14758 (define_insn "altivec_vmulouh"
14759   [(set (match_operand:V4SI 0 "register_operand" "=v")
14760         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14761                       (match_operand:V8HI 2 "register_operand" "v")] 89))]
14762   "TARGET_ALTIVEC"
14763   "vmulouh %0,%1,%2"
14764   [(set_attr "type" "veccomplex")])
14765
14766 (define_insn "altivec_vmulosh"
14767   [(set (match_operand:V4SI 0 "register_operand" "=v")
14768         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14769                       (match_operand:V8HI 2 "register_operand" "v")] 90))]
14770   "TARGET_ALTIVEC"
14771   "vmulosh %0,%1,%2"
14772   [(set_attr "type" "veccomplex")])
14773
14774 (define_insn "altivec_vnor"
14775   [(set (match_operand:V4SI 0 "register_operand" "=v")
14776         (not:V4SI (ior:V4SI (match_operand:V4SI 1 "register_operand" "v")
14777                             (match_operand:V4SI 2 "register_operand" "v"))))]
14778   "TARGET_ALTIVEC"
14779   "vnor %0,%1,%2"
14780   [(set_attr "type" "vecsimple")])
14781
14782 (define_insn "iorv4si3"
14783   [(set (match_operand:V4SI 0 "register_operand" "=v")
14784         (ior:V4SI (match_operand:V4SI 1 "register_operand" "v")
14785                   (match_operand:V4SI 2 "register_operand" "v")))]
14786   "TARGET_ALTIVEC"
14787   "vor %0,%1,%2"
14788   [(set_attr "type" "vecsimple")])
14789
14790 (define_insn "altivec_vpkuhum"
14791   [(set (match_operand:V16QI 0 "register_operand" "=v")
14792         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14793                        (match_operand:V8HI 2 "register_operand" "v")] 93))]
14794   "TARGET_ALTIVEC"
14795   "vpkuhum %0,%1,%2"
14796   [(set_attr "type" "vecperm")])
14797
14798 (define_insn "altivec_vpkuwum"
14799   [(set (match_operand:V8HI 0 "register_operand" "=v")
14800         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14801                       (match_operand:V4SI 2 "register_operand" "v")] 94))]
14802   "TARGET_ALTIVEC"
14803   "vpkuwum %0,%1,%2"
14804   [(set_attr "type" "vecperm")])
14805
14806 (define_insn "altivec_vpkpx"
14807   [(set (match_operand:V8HI 0 "register_operand" "=v")
14808         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14809                       (match_operand:V4SI 2 "register_operand" "v")] 95))]
14810   "TARGET_ALTIVEC"
14811   "vpkpx %0,%1,%2"
14812   [(set_attr "type" "vecperm")])
14813
14814 (define_insn "altivec_vpkuhss"
14815   [(set (match_operand:V16QI 0 "register_operand" "=v")
14816         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14817                        (match_operand:V8HI 2 "register_operand" "v")] 96))]
14818   "TARGET_ALTIVEC"
14819   "vpkuhss %0,%1,%2"
14820   [(set_attr "type" "vecperm")])
14821
14822 (define_insn "altivec_vpkshss"
14823   [(set (match_operand:V16QI 0 "register_operand" "=v")
14824         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14825                        (match_operand:V8HI 2 "register_operand" "v")] 97))]
14826   "TARGET_ALTIVEC"
14827   "vpkshss %0,%1,%2"
14828   [(set_attr "type" "vecperm")])
14829
14830 (define_insn "altivec_vpkuwss"
14831   [(set (match_operand:V8HI 0 "register_operand" "=v")
14832         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14833                       (match_operand:V4SI 2 "register_operand" "v")] 98))]
14834   "TARGET_ALTIVEC"
14835   "vpkuwss %0,%1,%2"
14836   [(set_attr "type" "vecperm")])
14837
14838 (define_insn "altivec_vpkswss"
14839   [(set (match_operand:V8HI 0 "register_operand" "=v")
14840         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14841                       (match_operand:V4SI 2 "register_operand" "v")] 99))]
14842   "TARGET_ALTIVEC"
14843   "vpkswss %0,%1,%2"
14844   [(set_attr "type" "vecperm")])
14845
14846 (define_insn "altivec_vpkuhus"
14847   [(set (match_operand:V16QI 0 "register_operand" "=v")
14848         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14849                        (match_operand:V8HI 2 "register_operand" "v")] 100))]
14850   "TARGET_ALTIVEC"
14851   "vpkuhus %0,%1,%2"
14852   [(set_attr "type" "vecperm")])
14853
14854 (define_insn "altivec_vpkshus"
14855   [(set (match_operand:V16QI 0 "register_operand" "=v")
14856         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14857                        (match_operand:V8HI 2 "register_operand" "v")] 101))]
14858   "TARGET_ALTIVEC"
14859   "vpkshus %0,%1,%2"
14860   [(set_attr "type" "vecperm")])
14861
14862 (define_insn "altivec_vpkuwus"
14863   [(set (match_operand:V8HI 0 "register_operand" "=v")
14864         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14865                       (match_operand:V4SI 2 "register_operand" "v")] 102))]
14866   "TARGET_ALTIVEC"
14867   "vpkuwus %0,%1,%2"
14868   [(set_attr "type" "vecperm")])
14869
14870 (define_insn "altivec_vpkswus"
14871   [(set (match_operand:V8HI 0 "register_operand" "=v")
14872         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14873                       (match_operand:V4SI 2 "register_operand" "v")] 103))]
14874   "TARGET_ALTIVEC"
14875   "vpkswus %0,%1,%2"
14876   [(set_attr "type" "vecperm")])
14877
14878 (define_insn "altivec_vrlb"
14879   [(set (match_operand:V16QI 0 "register_operand" "=v")
14880         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14881                        (match_operand:V16QI 2 "register_operand" "v")] 104))]
14882   "TARGET_ALTIVEC"
14883   "vrlb %0,%1,%2"
14884   [(set_attr "type" "vecsimple")])
14885
14886 (define_insn "altivec_vrlh"
14887   [(set (match_operand:V8HI 0 "register_operand" "=v")
14888         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14889                       (match_operand:V8HI 2 "register_operand" "v")] 105))]
14890   "TARGET_ALTIVEC"
14891   "vrlh %0,%1,%2"
14892   [(set_attr "type" "vecsimple")])
14893
14894 (define_insn "altivec_vrlw"
14895   [(set (match_operand:V4SI 0 "register_operand" "=v")
14896         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14897                       (match_operand:V4SI 2 "register_operand" "v")] 106))]
14898   "TARGET_ALTIVEC"
14899   "vrlw %0,%1,%2"
14900   [(set_attr "type" "vecsimple")])
14901
14902 (define_insn "altivec_vslb"
14903   [(set (match_operand:V16QI 0 "register_operand" "=v")
14904         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14905                        (match_operand:V16QI 2 "register_operand" "v")] 107))]
14906   "TARGET_ALTIVEC"
14907   "vslb %0,%1,%2"
14908   [(set_attr "type" "vecsimple")])
14909
14910 (define_insn "altivec_vslh"
14911   [(set (match_operand:V8HI 0 "register_operand" "=v")
14912         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14913                       (match_operand:V8HI 2 "register_operand" "v")] 108))]
14914   "TARGET_ALTIVEC"
14915   "vslh %0,%1,%2"
14916   [(set_attr "type" "vecsimple")])
14917
14918 (define_insn "altivec_vslw"
14919   [(set (match_operand:V4SI 0 "register_operand" "=v")
14920         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14921                       (match_operand:V4SI 2 "register_operand" "v")] 109))]
14922   "TARGET_ALTIVEC"
14923   "vslw %0,%1,%2"
14924   [(set_attr "type" "vecsimple")])
14925
14926 (define_insn "altivec_vsl"
14927   [(set (match_operand:V4SI 0 "register_operand" "=v")
14928         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14929                       (match_operand:V4SI 2 "register_operand" "v")] 110))]
14930   "TARGET_ALTIVEC"
14931   "vsl %0,%1,%2"
14932   [(set_attr "type" "vecperm")])
14933
14934 (define_insn "altivec_vslo"
14935   [(set (match_operand:V4SI 0 "register_operand" "=v")
14936         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14937                       (match_operand:V4SI 2 "register_operand" "v")] 111))]
14938   "TARGET_ALTIVEC"
14939   "vslo %0,%1,%2"
14940   [(set_attr "type" "vecperm")])
14941
14942 (define_insn "altivec_vsrb"
14943   [(set (match_operand:V16QI 0 "register_operand" "=v")
14944         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14945                        (match_operand:V16QI 2 "register_operand" "v")] 112))]
14946   "TARGET_ALTIVEC"
14947   "vsrb %0,%1,%2"
14948   [(set_attr "type" "vecsimple")])
14949
14950 (define_insn "altivec_vsrh"
14951   [(set (match_operand:V8HI 0 "register_operand" "=v")
14952         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14953                       (match_operand:V8HI 2 "register_operand" "v")] 113))]
14954   "TARGET_ALTIVEC"
14955   "vsrh %0,%1,%2"
14956   [(set_attr "type" "vecsimple")])
14957
14958 (define_insn "altivec_vsrw"
14959   [(set (match_operand:V4SI 0 "register_operand" "=v")
14960         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14961                       (match_operand:V4SI 2 "register_operand" "v")] 114))]
14962   "TARGET_ALTIVEC"
14963   "vsrw %0,%1,%2"
14964   [(set_attr "type" "vecsimple")])
14965
14966 (define_insn "altivec_vsrab"
14967   [(set (match_operand:V16QI 0 "register_operand" "=v")
14968         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14969                        (match_operand:V16QI 2 "register_operand" "v")] 115))]
14970   "TARGET_ALTIVEC"
14971   "vsrab %0,%1,%2"
14972   [(set_attr "type" "vecsimple")])
14973
14974 (define_insn "altivec_vsrah"
14975   [(set (match_operand:V8HI 0 "register_operand" "=v")
14976         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14977                       (match_operand:V8HI 2 "register_operand" "v")] 116))]
14978   "TARGET_ALTIVEC"
14979   "vsrah %0,%1,%2"
14980   [(set_attr "type" "vecsimple")])
14981
14982 (define_insn "altivec_vsraw"
14983   [(set (match_operand:V4SI 0 "register_operand" "=v")
14984         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14985                       (match_operand:V4SI 2 "register_operand" "v")] 117))]
14986   "TARGET_ALTIVEC"
14987   "vsraw %0,%1,%2"
14988   [(set_attr "type" "vecsimple")])
14989
14990 (define_insn "altivec_vsr"
14991   [(set (match_operand:V4SI 0 "register_operand" "=v")
14992         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14993                       (match_operand:V4SI 2 "register_operand" "v")] 118))]
14994   "TARGET_ALTIVEC"
14995   "vsr %0,%1,%2"
14996   [(set_attr "type" "vecperm")])
14997
14998 (define_insn "altivec_vsro"
14999   [(set (match_operand:V4SI 0 "register_operand" "=v")
15000         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15001                       (match_operand:V4SI 2 "register_operand" "v")] 119))]
15002   "TARGET_ALTIVEC"
15003   "vsro %0,%1,%2"
15004   [(set_attr "type" "vecperm")])
15005
15006 (define_insn "subv16qi3"
15007   [(set (match_operand:V16QI 0 "register_operand" "=v")
15008         (minus:V16QI (match_operand:V16QI 1 "register_operand" "v")
15009                      (match_operand:V16QI 2 "register_operand" "v")))]
15010   "TARGET_ALTIVEC"
15011   "vsububm %0,%1,%2"
15012   [(set_attr "type" "vecsimple")])
15013
15014 (define_insn "subv8hi3"
15015   [(set (match_operand:V8HI 0 "register_operand" "=v")
15016         (minus:V8HI (match_operand:V8HI 1 "register_operand" "v")
15017                     (match_operand:V8HI 2 "register_operand" "v")))]
15018   "TARGET_ALTIVEC"
15019   "vsubuhm %0,%1,%2"
15020   [(set_attr "type" "vecsimple")])
15021
15022 (define_insn "subv4si3"
15023   [(set (match_operand:V4SI 0 "register_operand" "=v")
15024         (minus:V4SI (match_operand:V4SI 1 "register_operand" "v")
15025                     (match_operand:V4SI 2 "register_operand" "v")))]
15026   "TARGET_ALTIVEC"
15027   "vsubuwm %0,%1,%2"
15028   [(set_attr "type" "vecsimple")])
15029
15030 (define_insn "subv4sf3"
15031   [(set (match_operand:V4SF 0 "register_operand" "=v")
15032         (minus:V4SF (match_operand:V4SF 1 "register_operand" "v")
15033                     (match_operand:V4SF 2 "register_operand" "v")))]
15034   "TARGET_ALTIVEC"
15035   "vsubfp %0,%1,%2"
15036   [(set_attr "type" "vecfloat")])
15037
15038 (define_insn "altivec_vsubcuw"
15039   [(set (match_operand:V4SI 0 "register_operand" "=v")
15040         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15041                       (match_operand:V4SI 2 "register_operand" "v")] 124))]
15042   "TARGET_ALTIVEC"
15043   "vsubcuw %0,%1,%2"
15044   [(set_attr "type" "vecsimple")])
15045
15046 (define_insn "altivec_vsububs"
15047   [(set (match_operand:V16QI 0 "register_operand" "=v")
15048         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15049                        (match_operand:V16QI 2 "register_operand" "v")] 125))]
15050   "TARGET_ALTIVEC"
15051   "vsububs %0,%1,%2"
15052   [(set_attr "type" "vecsimple")])
15053
15054 (define_insn "altivec_vsubsbs"
15055   [(set (match_operand:V16QI 0 "register_operand" "=v")
15056         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15057                        (match_operand:V16QI 2 "register_operand" "v")] 126))]
15058   "TARGET_ALTIVEC"
15059   "vsubsbs %0,%1,%2"
15060   [(set_attr "type" "vecsimple")])
15061
15062 (define_insn "altivec_vsubuhs"
15063   [(set (match_operand:V8HI 0 "register_operand" "=v")
15064         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15065                       (match_operand:V8HI 2 "register_operand" "v")] 127))]
15066   "TARGET_ALTIVEC"
15067   "vsubuhs %0,%1,%2"
15068   [(set_attr "type" "vecsimple")])
15069
15070 (define_insn "altivec_vsubshs"
15071   [(set (match_operand:V8HI 0 "register_operand" "=v")
15072         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15073                       (match_operand:V8HI 2 "register_operand" "v")] 128))]
15074   "TARGET_ALTIVEC"
15075   "vsubshs %0,%1,%2"
15076   [(set_attr "type" "vecsimple")])
15077
15078 (define_insn "altivec_vsubuws"
15079   [(set (match_operand:V4SI 0 "register_operand" "=v")
15080         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15081                       (match_operand:V4SI 2 "register_operand" "v")] 129))]
15082   "TARGET_ALTIVEC"
15083   "vsubuws %0,%1,%2"
15084   [(set_attr "type" "vecsimple")])
15085
15086 (define_insn "altivec_vsubsws"
15087   [(set (match_operand:V4SI 0 "register_operand" "=v")
15088         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15089                       (match_operand:V4SI 2 "register_operand" "v")] 130))]
15090   "TARGET_ALTIVEC"
15091   "vsubsws %0,%1,%2"
15092   [(set_attr "type" "vecsimple")])
15093
15094 (define_insn "altivec_vsum4ubs"
15095   [(set (match_operand:V4SI 0 "register_operand" "=v")
15096         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
15097                       (match_operand:V4SI 2 "register_operand" "v")] 131))]
15098   "TARGET_ALTIVEC"
15099   "vsum4ubs %0,%1,%2"
15100   [(set_attr "type" "veccomplex")])
15101
15102 (define_insn "altivec_vsum4sbs"
15103   [(set (match_operand:V4SI 0 "register_operand" "=v")
15104         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
15105                       (match_operand:V4SI 2 "register_operand" "v")] 132))]
15106   "TARGET_ALTIVEC"
15107   "vsum4sbs %0,%1,%2"
15108   [(set_attr "type" "veccomplex")])
15109
15110 (define_insn "altivec_vsum4shs"
15111   [(set (match_operand:V4SI 0 "register_operand" "=v")
15112         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
15113                       (match_operand:V4SI 2 "register_operand" "v")] 133))]
15114   "TARGET_ALTIVEC"
15115   "vsum4shs %0,%1,%2"
15116   [(set_attr "type" "veccomplex")])
15117
15118 (define_insn "altivec_vsum2sws"
15119   [(set (match_operand:V4SI 0 "register_operand" "=v")
15120         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15121                       (match_operand:V4SI 2 "register_operand" "v")] 134))]
15122   "TARGET_ALTIVEC"
15123   "vsum2sws %0,%1,%2"
15124   [(set_attr "type" "veccomplex")])
15125
15126 (define_insn "altivec_vsumsws"
15127   [(set (match_operand:V4SI 0 "register_operand" "=v")
15128         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15129                       (match_operand:V4SI 2 "register_operand" "v")] 135))]
15130   "TARGET_ALTIVEC"
15131   "vsumsws %0,%1,%2"
15132   [(set_attr "type" "veccomplex")])
15133
15134 (define_insn "xorv4si3"
15135   [(set (match_operand:V4SI 0 "register_operand" "=v")
15136         (xor:V4SI (match_operand:V4SI 1 "register_operand" "v")
15137                   (match_operand:V4SI 2 "register_operand" "v")))]
15138   "TARGET_ALTIVEC"
15139   "vxor %0,%1,%2"
15140   [(set_attr "type" "vecsimple")])
15141
15142 (define_insn "altivec_vspltb"
15143   [(set (match_operand:V16QI 0 "register_operand" "=v")
15144         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15145                        (match_operand:QI 2 "immediate_operand" "i")] 136))]
15146   "TARGET_ALTIVEC"
15147   "vspltb %0,%1,%2"
15148   [(set_attr "type" "vecperm")])
15149
15150 (define_insn "altivec_vsplth"
15151   [(set (match_operand:V8HI 0 "register_operand" "=v")
15152         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15153                       (match_operand:QI 2 "immediate_operand" "i")] 137))]
15154   "TARGET_ALTIVEC"
15155   "vsplth %0,%1,%2"
15156   [(set_attr "type" "vecperm")])
15157
15158 (define_insn "altivec_vspltw"
15159   [(set (match_operand:V4SI 0 "register_operand" "=v")
15160         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15161                       (match_operand:QI 2 "immediate_operand" "i")] 138))]
15162   "TARGET_ALTIVEC"
15163   "vspltw %0,%1,%2"
15164   [(set_attr "type" "vecperm")])
15165
15166 (define_insn "altivec_vspltisb"
15167   [(set (match_operand:V16QI 0 "register_operand" "=v")
15168         (unspec:V16QI [(match_operand:QI 1 "immediate_operand" "i")] 139))]
15169   "TARGET_ALTIVEC"
15170   "vspltisb %0, %1"
15171   [(set_attr "type" "vecsimple")])
15172
15173
15174 (define_insn "altivec_vspltish"
15175   [(set (match_operand:V8HI 0 "register_operand" "=v")
15176         (unspec:V8HI [(match_operand:QI 1 "immediate_operand" "i")] 140))]
15177   "TARGET_ALTIVEC"
15178   "vspltish %0, %1"
15179   [(set_attr "type" "vecsimple")])
15180
15181 (define_insn "altivec_vspltisw"
15182   [(set (match_operand:V4SI 0 "register_operand" "=v")
15183         (unspec:V4SI [(match_operand:QI 1 "immediate_operand" "i")] 141))]
15184   "TARGET_ALTIVEC"
15185   "vspltisw %0, %1"
15186   [(set_attr "type" "vecsimple")])
15187
15188 (define_insn ""
15189   [(set (match_operand:V4SF 0 "register_operand" "=v")
15190         (unspec:V4SF [(match_operand:QI 1 "immediate_operand" "i")] 142))]
15191   "TARGET_ALTIVEC"
15192   "vspltisw %0, %1"
15193   [(set_attr "type" "vecsimple")])
15194
15195 (define_insn "ftruncv4sf2"
15196   [(set (match_operand:V4SF 0 "register_operand" "=v")
15197         (fix:V4SF (match_operand:V4SF 1 "register_operand" "v")))]
15198   "TARGET_ALTIVEC"
15199   "vrfiz %0, %1"
15200   [(set_attr "type" "vecfloat")])
15201
15202 (define_insn "altivec_vperm_4si"
15203   [(set (match_operand:V4SI 0 "register_operand" "=v")
15204         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15205                       (match_operand:V4SI 2 "register_operand" "v")
15206                       (match_operand:V16QI 3 "register_operand" "v")] 144))]
15207   "TARGET_ALTIVEC"
15208   "vperm %0,%1,%2,%3"
15209   [(set_attr "type" "vecperm")])
15210
15211 (define_insn "altivec_vperm_4sf"
15212   [(set (match_operand:V4SF 0 "register_operand" "=v")
15213         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15214                       (match_operand:V4SF 2 "register_operand" "v")
15215                       (match_operand:V16QI 3 "register_operand" "v")] 145))]
15216   "TARGET_ALTIVEC"
15217   "vperm %0,%1,%2,%3"
15218   [(set_attr "type" "vecperm")])
15219
15220 (define_insn "altivec_vperm_8hi"
15221   [(set (match_operand:V8HI 0 "register_operand" "=v")
15222         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15223                       (match_operand:V8HI 2 "register_operand" "v")
15224                       (match_operand:V16QI 3 "register_operand" "v")] 146))]
15225   "TARGET_ALTIVEC"
15226   "vperm %0,%1,%2,%3"
15227   [(set_attr "type" "vecperm")])
15228
15229 (define_insn "altivec_vperm_16qi"
15230   [(set (match_operand:V16QI 0 "register_operand" "=v")
15231         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15232                        (match_operand:V16QI 2 "register_operand" "v")
15233                        (match_operand:V16QI 3 "register_operand" "v")] 147))]
15234   "TARGET_ALTIVEC"
15235   "vperm %0,%1,%2,%3"
15236   [(set_attr "type" "vecperm")])
15237
15238 (define_insn "altivec_vrfip"
15239   [(set (match_operand:V4SF 0 "register_operand" "=v")
15240         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 148))]
15241   "TARGET_ALTIVEC"
15242   "vrfip %0, %1"
15243   [(set_attr "type" "vecfloat")])
15244
15245 (define_insn "altivec_vrfin"
15246   [(set (match_operand:V4SF 0 "register_operand" "=v")
15247         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 149))]
15248   "TARGET_ALTIVEC"
15249   "vrfin %0, %1"
15250   [(set_attr "type" "vecfloat")])
15251
15252 (define_insn "altivec_vrfim"
15253   [(set (match_operand:V4SF 0 "register_operand" "=v")
15254         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 150))]
15255   "TARGET_ALTIVEC"
15256   "vrfim %0, %1"
15257   [(set_attr "type" "vecfloat")])
15258
15259 (define_insn "altivec_vcfux"
15260   [(set (match_operand:V4SF 0 "register_operand" "=v")
15261         (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
15262                       (match_operand:QI 2 "immediate_operand" "i")] 151))]
15263   "TARGET_ALTIVEC"
15264   "vcfux %0, %1, %2"
15265   [(set_attr "type" "vecfloat")])
15266
15267 (define_insn "altivec_vcfsx"
15268   [(set (match_operand:V4SF 0 "register_operand" "=v")
15269         (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
15270                       (match_operand:QI 2 "immediate_operand" "i")] 152))]
15271   "TARGET_ALTIVEC"
15272   "vcfsx %0, %1, %2"
15273   [(set_attr "type" "vecfloat")])
15274
15275 (define_insn "altivec_vctuxs"
15276   [(set (match_operand:V4SI 0 "register_operand" "=v")
15277         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
15278                       (match_operand:QI 2 "immediate_operand" "i")] 153))]
15279   "TARGET_ALTIVEC"
15280   "vctuxs %0, %1, %2"
15281   [(set_attr "type" "vecfloat")])
15282
15283 (define_insn "altivec_vctsxs"
15284   [(set (match_operand:V4SI 0 "register_operand" "=v")
15285         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
15286                       (match_operand:QI 2 "immediate_operand" "i")] 154))]
15287   "TARGET_ALTIVEC"
15288   "vctsxs %0, %1, %2"
15289   [(set_attr "type" "vecfloat")])
15290
15291 (define_insn "altivec_vlogefp"
15292   [(set (match_operand:V4SF 0 "register_operand" "=v")
15293         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 155))]
15294   "TARGET_ALTIVEC"
15295   "vlogefp %0, %1"
15296   [(set_attr "type" "vecfloat")])
15297
15298 (define_insn "altivec_vexptefp"
15299   [(set (match_operand:V4SF 0 "register_operand" "=v")
15300         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 156))]
15301   "TARGET_ALTIVEC"
15302   "vexptefp %0, %1"
15303   [(set_attr "type" "vecfloat")])
15304
15305 (define_insn "altivec_vrsqrtefp"
15306   [(set (match_operand:V4SF 0 "register_operand" "=v")
15307         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 157))]
15308   "TARGET_ALTIVEC"
15309   "vrsqrtefp %0, %1"
15310   [(set_attr "type" "vecfloat")])
15311
15312 (define_insn "altivec_vrefp"
15313   [(set (match_operand:V4SF 0 "register_operand" "=v")
15314         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 158))]
15315   "TARGET_ALTIVEC"
15316   "vrefp %0, %1"
15317   [(set_attr "type" "vecfloat")])
15318
15319 (define_insn "altivec_vsel_4si"
15320   [(set (match_operand:V4SI 0 "register_operand" "=v")
15321         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15322                       (match_operand:V4SI 2 "register_operand" "v")
15323                       (match_operand:V4SI 3 "register_operand" "v")] 159))]
15324   "TARGET_ALTIVEC"
15325   "vsel %0,%1,%2,%3"
15326   [(set_attr "type" "vecperm")])
15327
15328 (define_insn "altivec_vsel_4sf"
15329   [(set (match_operand:V4SF 0 "register_operand" "=v")
15330         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15331                       (match_operand:V4SF 2 "register_operand" "v")
15332                       (match_operand:V4SI 3 "register_operand" "v")] 160))]
15333   "TARGET_ALTIVEC"
15334   "vsel %0,%1,%2,%3"
15335   [(set_attr "type" "vecperm")])
15336
15337 (define_insn "altivec_vsel_8hi"
15338   [(set (match_operand:V8HI 0 "register_operand" "=v")
15339         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15340                       (match_operand:V8HI 2 "register_operand" "v")
15341                       (match_operand:V8HI 3 "register_operand" "v")] 161))]
15342   "TARGET_ALTIVEC"
15343   "vsel %0,%1,%2,%3"
15344   [(set_attr "type" "vecperm")])
15345
15346 (define_insn "altivec_vsel_16qi"
15347   [(set (match_operand:V16QI 0 "register_operand" "=v")
15348         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15349                        (match_operand:V16QI 2 "register_operand" "v")
15350                        (match_operand:V16QI 3 "register_operand" "v")] 162))]
15351   "TARGET_ALTIVEC"
15352   "vsel %0,%1,%2,%3"
15353   [(set_attr "type" "vecperm")])
15354
15355 (define_insn "altivec_vsldoi_4si"
15356   [(set (match_operand:V4SI 0 "register_operand" "=v")
15357         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15358                       (match_operand:V4SI 2 "register_operand" "v")
15359                       (match_operand:QI 3 "immediate_operand" "i")] 163))]
15360   "TARGET_ALTIVEC"
15361   "vsldoi %0, %1, %2, %3"
15362   [(set_attr "type" "vecperm")])
15363
15364 (define_insn "altivec_vsldoi_4sf"
15365   [(set (match_operand:V4SF 0 "register_operand" "=v")
15366         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15367                       (match_operand:V4SF 2 "register_operand" "v")
15368                       (match_operand:QI 3 "immediate_operand" "i")] 164))]
15369   "TARGET_ALTIVEC"
15370   "vsldoi %0, %1, %2, %3"
15371   [(set_attr "type" "vecperm")])
15372
15373 (define_insn "altivec_vsldoi_8hi"
15374   [(set (match_operand:V8HI 0 "register_operand" "=v")
15375         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15376                       (match_operand:V8HI 2 "register_operand" "v")
15377                       (match_operand:QI 3 "immediate_operand" "i")] 165))]
15378   "TARGET_ALTIVEC"
15379   "vsldoi %0, %1, %2, %3"
15380   [(set_attr "type" "vecperm")])
15381
15382 (define_insn "altivec_vsldoi_16qi"
15383   [(set (match_operand:V16QI 0 "register_operand" "=v")
15384         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15385                        (match_operand:V16QI 2 "register_operand" "v")
15386                        (match_operand:QI 3 "immediate_operand" "i")] 166))]
15387   "TARGET_ALTIVEC"
15388   "vsldoi %0, %1, %2, %3"
15389   [(set_attr "type" "vecperm")])
15390
15391 (define_insn "altivec_vupkhsb"
15392   [(set (match_operand:V8HI 0 "register_operand" "=v")
15393         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")] 167))]
15394   "TARGET_ALTIVEC"
15395   "vupkhsb %0, %1"
15396   [(set_attr "type" "vecperm")])
15397
15398 (define_insn "altivec_vupkhpx"
15399   [(set (match_operand:V4SI 0 "register_operand" "=v")
15400         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 168))]
15401   "TARGET_ALTIVEC"
15402   "vupkhpx %0, %1"
15403   [(set_attr "type" "vecperm")])
15404
15405 (define_insn "altivec_vupkhsh"
15406   [(set (match_operand:V4SI 0 "register_operand" "=v")
15407         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 169))]
15408   "TARGET_ALTIVEC"
15409   "vupkhsh %0, %1"
15410   [(set_attr "type" "vecperm")])
15411
15412 (define_insn "altivec_vupklsb"
15413   [(set (match_operand:V8HI 0 "register_operand" "=v")
15414         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")] 170))]
15415   "TARGET_ALTIVEC"
15416   "vupklsb %0, %1"
15417   [(set_attr "type" "vecperm")])
15418
15419 (define_insn "altivec_vupklpx"
15420   [(set (match_operand:V4SI 0 "register_operand" "=v")
15421         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 171))]
15422   "TARGET_ALTIVEC"
15423   "vupklpx %0, %1"
15424   [(set_attr "type" "vecperm")])
15425
15426 (define_insn "altivec_vupklsh"
15427   [(set (match_operand:V4SI 0 "register_operand" "=v")
15428         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 172))]
15429   "TARGET_ALTIVEC"
15430   "vupklsh %0, %1"
15431   [(set_attr "type" "vecperm")])
15432
15433 ;; AltiVec predicates.
15434
15435 (define_expand "cr6_test_for_zero"
15436   [(set (match_operand:SI 0 "register_operand" "=r")
15437         (eq:SI (reg:CC 74)
15438                (const_int 0)))]
15439   "TARGET_ALTIVEC"
15440   "")   
15441
15442 (define_expand "cr6_test_for_zero_reverse"
15443   [(set (match_operand:SI 0 "register_operand" "=r")
15444         (eq:SI (reg:CC 74)
15445                (const_int 0)))
15446    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
15447   "TARGET_ALTIVEC"
15448   "")
15449
15450 (define_expand "cr6_test_for_lt"
15451   [(set (match_operand:SI 0 "register_operand" "=r")
15452         (lt:SI (reg:CC 74)
15453                (const_int 0)))]
15454   "TARGET_ALTIVEC"
15455   "")
15456
15457 (define_expand "cr6_test_for_lt_reverse"
15458   [(set (match_operand:SI 0 "register_operand" "=r")
15459         (lt:SI (reg:CC 74)
15460                (const_int 0)))
15461    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
15462   "TARGET_ALTIVEC"
15463   "")
15464
15465 ;; We can get away with generating the opcode on the fly (%3 below)
15466 ;; because all the predicates have the same scheduling parameters.
15467
15468 (define_insn "altivec_predicate_v4si"
15469   [(set (reg:CC 74)
15470         (unspec:CC [(match_operand:V4SI 1 "register_operand" "v")
15471                     (match_operand:V4SI 2 "register_operand" "v")
15472                     (match_operand 3 "any_operand" "")] 173))
15473    (clobber (match_scratch:V4SI 0 "=v"))]
15474   "TARGET_ALTIVEC"
15475   "%3 %0,%1,%2"
15476 [(set_attr "type" "veccmp")])
15477
15478 (define_insn "altivec_predicate_v4sf"
15479   [(set (reg:CC 74)
15480         (unspec:CC [(match_operand:V4SF 1 "register_operand" "v")
15481                     (match_operand:V4SF 2 "register_operand" "v")
15482                     (match_operand 3 "any_operand" "")] 174))
15483    (clobber (match_scratch:V4SF 0 "=v"))]
15484   "TARGET_ALTIVEC"
15485   "%3 %0,%1,%2"
15486 [(set_attr "type" "veccmp")])
15487
15488 (define_insn "altivec_predicate_v8hi"
15489   [(set (reg:CC 74)
15490         (unspec:CC [(match_operand:V8HI 1 "register_operand" "v")
15491                     (match_operand:V8HI 2 "register_operand" "v")
15492                     (match_operand 3 "any_operand" "")] 175))
15493    (clobber (match_scratch:V8HI 0 "=v"))]
15494   "TARGET_ALTIVEC"
15495   "%3 %0,%1,%2"
15496 [(set_attr "type" "veccmp")])
15497
15498 (define_insn "altivec_predicate_v16qi"
15499   [(set (reg:CC 74)
15500         (unspec:CC [(match_operand:V16QI 1 "register_operand" "v")
15501                     (match_operand:V16QI 2 "register_operand" "v")
15502                     (match_operand 3 "any_operand" "")] 175))
15503    (clobber (match_scratch:V16QI 0 "=v"))]
15504   "TARGET_ALTIVEC"
15505   "%3 %0,%1,%2"
15506 [(set_attr "type" "veccmp")])
15507
15508 (define_insn "altivec_mtvscr"
15509   [(unspec [(match_operand:V4SI 0 "register_operand" "v")] 186)]
15510   "TARGET_ALTIVEC"
15511   "mtvscr %0"
15512   [(set_attr "type" "vecsimple")])
15513
15514 (define_insn "altivec_mfvscr"
15515   [(set (match_operand:V8HI 0 "register_operand" "=v")
15516         (unspec:V8HI [(const_int 0)] 187))]
15517   "TARGET_ALTIVEC"
15518   "mfvscr %0"
15519   [(set_attr "type" "vecsimple")])
15520
15521 (define_insn "altivec_dssall"
15522   [(unspec [(const_int 0)] 188)]
15523   "TARGET_ALTIVEC"
15524   "dssall"
15525   [(set_attr "type" "vecsimple")])
15526
15527 (define_insn "altivec_dss"
15528   [(unspec [(match_operand:QI 0 "immediate_operand" "i")] 189)]
15529   "TARGET_ALTIVEC"
15530   "dss %0"
15531   [(set_attr "type" "vecsimple")])
15532
15533 (define_insn "altivec_dst"
15534   [(unspec [(match_operand:SI 0 "register_operand" "b")
15535             (match_operand:SI 1 "register_operand" "r")
15536             (match_operand:QI 2 "immediate_operand" "i")] 190)]
15537   "TARGET_ALTIVEC"
15538   "dst %0,%1,%2"
15539   [(set_attr "type" "vecsimple")])
15540
15541 (define_insn "altivec_dstt"
15542   [(unspec [(match_operand:SI 0 "register_operand" "b")
15543             (match_operand:SI 1 "register_operand" "r")
15544             (match_operand:QI 2 "immediate_operand" "i")] 191)]
15545   "TARGET_ALTIVEC"
15546   "dstt %0,%1,%2"
15547   [(set_attr "type" "vecsimple")])
15548
15549 (define_insn "altivec_dstst"
15550   [(unspec [(match_operand:SI 0 "register_operand" "b")
15551             (match_operand:SI 1 "register_operand" "r")
15552             (match_operand:QI 2 "immediate_operand" "i")] 192)]
15553   "TARGET_ALTIVEC"
15554   "dstst %0,%1,%2"
15555   [(set_attr "type" "vecsimple")])
15556
15557 (define_insn "altivec_dststt"
15558   [(unspec [(match_operand:SI 0 "register_operand" "b")
15559             (match_operand:SI 1 "register_operand" "r")
15560             (match_operand:QI 2 "immediate_operand" "i")] 193)]
15561   "TARGET_ALTIVEC"
15562   "dststt %0,%1,%2"
15563   [(set_attr "type" "vecsimple")])
15564
15565 (define_insn "altivec_lvsl"
15566   [(set (match_operand:V16QI 0 "register_operand" "=v")
15567         (unspec:V16QI [(match_operand:SI 1 "register_operand" "b")
15568                        (match_operand:SI 2 "register_operand" "r")] 194))]
15569   "TARGET_ALTIVEC"
15570   "lvsl %0,%1,%2"
15571   [(set_attr "type" "vecload")])
15572
15573 (define_insn "altivec_lvsr"
15574   [(set (match_operand:V16QI 0 "register_operand" "=v")
15575         (unspec:V16QI [(match_operand:SI 1 "register_operand" "b")
15576                        (match_operand:SI 2 "register_operand" "r")] 195))]
15577   "TARGET_ALTIVEC"
15578   "lvsr %0,%1,%2"
15579   [(set_attr "type" "vecload")])
15580
15581 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
15582 ;; identical rtl but different instructions-- and gcc gets confused.
15583
15584 (define_insn "altivec_lvebx"
15585   [(parallel
15586     [(set (match_operand:V16QI 0 "register_operand" "=v")
15587           (mem:V16QI (plus:SI (match_operand:SI 1 "register_operand" "b")
15588                               (match_operand:SI 2 "register_operand" "r"))))
15589      (unspec [(const_int 0)] 196)])]
15590   "TARGET_ALTIVEC"
15591   "lvebx %0,%1,%2"
15592   [(set_attr "type" "vecload")])
15593
15594 (define_insn "altivec_lvehx"
15595   [(parallel
15596     [(set (match_operand:V8HI 0 "register_operand" "=v")
15597           (mem:V8HI
15598            (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15599                             (match_operand:SI 2 "register_operand" "r"))
15600                    (const_int -2))))
15601      (unspec [(const_int 0)] 197)])]
15602   "TARGET_ALTIVEC"
15603   "lvehx %0,%1,%2"
15604   [(set_attr "type" "vecload")])
15605
15606 (define_insn "altivec_lvewx"
15607   [(parallel
15608     [(set (match_operand:V4SI 0 "register_operand" "=v")
15609           (mem:V4SI
15610            (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15611                             (match_operand:SI 2 "register_operand" "r"))
15612                    (const_int -4))))
15613      (unspec [(const_int 0)] 198)])]
15614   "TARGET_ALTIVEC"
15615   "lvewx %0,%1,%2"
15616   [(set_attr "type" "vecload")])
15617
15618 (define_insn "altivec_lvxl"
15619   [(parallel
15620     [(set (match_operand:V4SI 0 "register_operand" "=v")
15621           (mem:V4SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15622                              (match_operand:SI 2 "register_operand" "r"))))
15623      (unspec [(const_int 0)] 213)])]
15624   "TARGET_ALTIVEC"
15625   "lvxl %0,%1,%2"
15626   [(set_attr "type" "vecload")])
15627
15628 (define_insn "altivec_lvx"
15629   [(set (match_operand:V4SI 0 "register_operand" "=v")
15630         (mem:V4SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15631                            (match_operand:SI 2 "register_operand" "r"))))]
15632   "TARGET_ALTIVEC"
15633   "lvx %0,%1,%2"
15634   [(set_attr "type" "vecload")])
15635
15636 (define_insn "altivec_stvx"
15637   [(parallel
15638     [(set (mem:V4SI
15639            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15640                             (match_operand:SI 1 "register_operand" "r"))
15641                    (const_int -16)))
15642           (match_operand:V4SI 2 "register_operand" "v"))
15643      (unspec [(const_int 0)] 201)])]
15644   "TARGET_ALTIVEC"
15645   "stvx %2,%0,%1"
15646   [(set_attr "type" "vecstore")])
15647
15648 (define_insn "altivec_stvxl"
15649   [(parallel
15650     [(set (mem:V4SI
15651            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15652                             (match_operand:SI 1 "register_operand" "r"))
15653                    (const_int -16)))
15654           (match_operand:V4SI 2 "register_operand" "v"))
15655      (unspec [(const_int 0)] 202)])]
15656   "TARGET_ALTIVEC"
15657   "stvxl %2,%0,%1"
15658   [(set_attr "type" "vecstore")])
15659
15660 (define_insn "altivec_stvebx"
15661   [(parallel
15662     [(set (mem:V16QI
15663            (plus:SI (match_operand:SI 0 "register_operand" "b")
15664                     (match_operand:SI 1 "register_operand" "r")))
15665           (match_operand:V16QI 2 "register_operand" "v"))
15666      (unspec [(const_int 0)] 203)])]
15667   "TARGET_ALTIVEC"
15668   "stvebx %2,%0,%1"
15669   [(set_attr "type" "vecstore")])
15670
15671 (define_insn "altivec_stvehx"
15672   [(parallel
15673     [(set (mem:V8HI
15674            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15675                             (match_operand:SI 1 "register_operand" "r"))
15676                    (const_int -2)))
15677           (match_operand:V8HI 2 "register_operand" "v"))
15678      (unspec [(const_int 0)] 204)])]
15679   "TARGET_ALTIVEC"
15680   "stvehx %2,%0,%1"
15681   [(set_attr "type" "vecstore")])
15682
15683 (define_insn "altivec_stvewx"
15684   [(parallel
15685     [(set (mem:V4SI
15686            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15687                             (match_operand:SI 1 "register_operand" "r"))
15688                    (const_int -4)))
15689           (match_operand:V4SI 2 "register_operand" "v"))
15690      (unspec [(const_int 0)] 205)])]
15691   "TARGET_ALTIVEC"
15692   "stvewx %2,%0,%1"
15693   [(set_attr "type" "vecstore")])
15694
15695 (define_insn "absv16qi2"
15696   [(set (match_operand:V16QI 0 "register_operand" "=v")
15697         (abs:V16QI (match_operand:V16QI 1 "register_operand" "v")))
15698    (clobber (match_scratch:V16QI 2 "=v"))
15699    (clobber (match_scratch:V16QI 3 "=v"))]
15700   "TARGET_ALTIVEC"
15701   "vspltisb %2,0\;vsububm %3,%2,%1\;vmaxsb %0,%1,%3"
15702   [(set_attr "type" "altivec")
15703    (set_attr "length" "12")])
15704
15705 (define_insn "absv8hi2"
15706   [(set (match_operand:V8HI 0 "register_operand" "=v")
15707         (abs:V8HI (match_operand:V8HI 1 "register_operand" "v")))
15708    (clobber (match_scratch:V8HI 2 "=v"))
15709    (clobber (match_scratch:V8HI 3 "=v"))]
15710   "TARGET_ALTIVEC"
15711   "vspltisb %2,0\;vsubuhm %3,%2,%1\;vmaxsh %0,%1,%3"
15712   [(set_attr "type" "altivec")
15713    (set_attr "length" "12")])
15714
15715 (define_insn "absv4si2"
15716   [(set (match_operand:V4SI 0 "register_operand" "=v")
15717         (abs:V4SI (match_operand:V4SI 1 "register_operand" "v")))
15718    (clobber (match_scratch:V4SI 2 "=v"))
15719    (clobber (match_scratch:V4SI 3 "=v"))]
15720   "TARGET_ALTIVEC"
15721   "vspltisb %2,0\;vsubuwm %3,%2,%1\;vmaxsw %0,%1,%3"
15722   [(set_attr "type" "altivec")
15723    (set_attr "length" "12")])
15724
15725 (define_insn "absv4sf2"
15726   [(set (match_operand:V4SF 0 "register_operand" "=v")
15727         (abs:V4SF (match_operand:V4SF 1 "register_operand" "v")))
15728    (clobber (match_scratch:V4SF 2 "=v"))
15729    (clobber (match_scratch:V4SF 3 "=v"))]
15730   "TARGET_ALTIVEC"
15731   "vspltisw %2, -1\;vslw %3,%2,%2\;vandc %0,%1,%3"
15732   [(set_attr "type" "altivec")
15733    (set_attr "length" "12")])
15734
15735 (define_insn "altivec_abss_v16qi"
15736   [(set (match_operand:V16QI 0 "register_operand" "=v")
15737         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")] 210))
15738    (clobber (match_scratch:V16QI 2 "=v"))
15739    (clobber (match_scratch:V16QI 3 "=v"))]
15740   "TARGET_ALTIVEC"
15741   "vspltisb %2,0\;vsubsbs %3,%2,%1\;vmaxsb %0,%1,%3"
15742   [(set_attr "type" "altivec")
15743    (set_attr "length" "12")])
15744
15745 (define_insn "altivec_abss_v8hi"
15746   [(set (match_operand:V8HI 0 "register_operand" "=v")
15747         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")] 211))
15748    (clobber (match_scratch:V8HI 2 "=v"))
15749    (clobber (match_scratch:V8HI 3 "=v"))]
15750   "TARGET_ALTIVEC"
15751   "vspltisb %2,0\;vsubshs %3,%2,%1\;vmaxsh %0,%1,%3"
15752   [(set_attr "type" "altivec")
15753    (set_attr "length" "12")])
15754
15755 (define_insn "altivec_abss_v4si"
15756   [(set (match_operand:V4SI 0 "register_operand" "=v")
15757         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")] 212))
15758    (clobber (match_scratch:V4SI 2 "=v"))
15759    (clobber (match_scratch:V4SI 3 "=v"))]
15760   "TARGET_ALTIVEC"
15761   "vspltisb %2,0\;vsubsws %3,%2,%1\;vmaxsw %0,%1,%3"
15762   [(set_attr "type" "altivec")
15763    (set_attr "length" "12")])