rs6000.md: Remove ppc630 fpcompare from single fpu list.
[official-gcc.git] / gcc / config / rs6000 / rs6000.md
blobde766637b5d4a3a5a639e086363e8d7706936bed
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)
6 ;; This file is part of GNU CC.
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.
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.
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.
23 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
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
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"))
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)))
56 ;; Processor type -- this attribute must exactly match the processor_type
57 ;; enumeration in rs6000.h.
59 (define_attr "cpu" "rios1,rios2,rs64a,mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400,ppc7450,power4"
60   (const (symbol_ref "rs6000_cpu_attr")))
62 ; (define_function_unit NAME MULTIPLICITY SIMULTANEITY
63 ;                       TEST READY-DELAY ISSUE-DELAY [CONFLICT-LIST])
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)
72 (define_function_unit "lsu" 1 0
73   (and (eq_attr "type" "load,vecload")
74        (eq_attr "cpu" "ppc7450"))
75   3 1)
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)
82 (define_function_unit "lsu" 1 0
83   (and (eq_attr "type" "store,fpstore")
84        (eq_attr "cpu" "ppc750,ppc7400"))
85   2 1)
87 (define_function_unit "lsu" 1 0
88   (and (eq_attr "type" "store,vecstore")
89        (eq_attr "cpu" "ppc7450"))
90   3 1)
92 (define_function_unit "lsu" 1 0
93   (and (eq_attr "type" "fpstore")
94        (eq_attr "cpu" "ppc7450"))
95   3 3)
97 (define_function_unit "lsu" 1 0
98   (and (eq_attr "type" "fpload")
99        (eq_attr "cpu" "mpccore,ppc603,ppc750,ppc7400"))
100   2 1)
102 (define_function_unit "lsu" 1 0
103   (and (eq_attr "type" "fpload")
104        (eq_attr "cpu" "ppc7450"))
105   4 1)
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)
112 (define_function_unit "iu" 1 0
113   (and (eq_attr "type" "load")
114        (eq_attr "cpu" "rios1,ppc403,ppc405,ppc601"))
115   2 1)
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)
122 (define_function_unit "fpu" 1 0
123   (and (eq_attr "type" "fpstore")
124        (eq_attr "cpu" "rios1,ppc601"))
125   0 1)
127 (define_function_unit "iu" 1 0
128   (and (eq_attr "type" "fpload")
129        (eq_attr "cpu" "rios1"))
130   2 1)
132 (define_function_unit "iu" 1 0
133   (and (eq_attr "type" "fpload")
134        (eq_attr "cpu" "ppc601"))
135   3 1)
137 (define_function_unit "iu2" 2 0
138   (and (eq_attr "type" "load,fpload")
139        (eq_attr "cpu" "rios2"))
140   2 1)
142 (define_function_unit "iu2" 2 0
143   (and (eq_attr "type" "store,fpstore")
144        (eq_attr "cpu" "rios2"))
145   1 1)
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)
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)
158 (define_function_unit "iu" 1 0
159   (and (eq_attr "type" "imul,imul2,imul3")
160        (eq_attr "cpu" "ppc403"))
161   4 4)
163 (define_function_unit "iu" 1 0
164   (and (eq_attr "type" "imul")
165        (eq_attr "cpu" "ppc405"))
166   4 3)
168 (define_function_unit "iu" 1 0
169   (and (eq_attr "type" "imul2,imul3")
170        (eq_attr "cpu" "ppc405"))
171   3 2)
173 (define_function_unit "iu" 1 0
174   (and (eq_attr "type" "imul")
175        (eq_attr "cpu" "rios1"))
176   5 5)
178 (define_function_unit "iu" 1 0
179   (and (eq_attr "type" "imul2")
180        (eq_attr "cpu" "rios1"))
181   4 4)
183 (define_function_unit "iu" 1 0
184   (and (eq_attr "type" "imul3")
185        (eq_attr "cpu" "rios1"))
186   3 3)
188 (define_function_unit "iu" 1 0
189   (and (eq_attr "type" "imul,imul2,imul3")
190        (eq_attr "cpu" "ppc601,ppc603"))
191   5 5)
193 (define_function_unit "iu" 1 0
194   (and (eq_attr "type" "imul")
195        (eq_attr "cpu" "rs64a"))
196   20 20)
198 (define_function_unit "iu" 1 0
199   (and (eq_attr "type" "imul2")
200        (eq_attr "cpu" "rs64a"))
201   12 12)
203 (define_function_unit "iu" 1 0
204   (and (eq_attr "type" "imul3")
205        (eq_attr "cpu" "rs64a"))
206   8 8)
208 (define_function_unit "iu" 1 0
209   (and (eq_attr "type" "lmul")
210        (eq_attr "cpu" "rs64a"))
211   34 34)
213 (define_function_unit "iu" 1 0
214   (and (eq_attr "type" "idiv")
215        (eq_attr "cpu" "rios1"))
216   19 19)
218 (define_function_unit "iu" 1 0
219   (and (eq_attr "type" "idiv")
220        (eq_attr "cpu" "rs64a"))
221   66 66)
223 (define_function_unit "iu" 1 0
224   (and (eq_attr "type" "ldiv")
225        (eq_attr "cpu" "rs64a"))
226   66 66)
228 (define_function_unit "iu" 1 0
229   (and (eq_attr "type" "idiv")
230        (eq_attr "cpu" "ppc403"))
231   33 33)
233 (define_function_unit "iu" 1 0
234   (and (eq_attr "type" "idiv")
235        (eq_attr "cpu" "ppc405"))
236   35 35)
238 (define_function_unit "iu" 1 0
239   (and (eq_attr "type" "idiv")
240        (eq_attr "cpu" "ppc601"))
241   36 36)
243 (define_function_unit "iu" 1 0
244   (and (eq_attr "type" "idiv")
245        (eq_attr "cpu" "ppc603"))
246   37 36)
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)
258 (define_function_unit "iu2" 2 0
259   (and (eq_attr "type" "imul,imul2,imul3")
260        (eq_attr "cpu" "rios2"))
261   2 2)
263 (define_function_unit "iu2" 2 0
264   (and (eq_attr "type" "idiv")
265        (eq_attr "cpu" "rios2"))
266   13 13)
268 (define_function_unit "imuldiv" 1 0
269   (and (eq_attr "type" "imul,imul2,imul3")
270        (eq_attr "cpu" "rios2"))
271   2 2)
273 (define_function_unit "imuldiv" 1 0
274   (and (eq_attr "type" "idiv")
275        (eq_attr "cpu" "rios2"))
276   13 13)
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)
285 (define_function_unit "imuldiv" 1 0
286   (and (eq_attr "type" "idiv")
287        (eq_attr "cpu" "mpccore"))
288   6 6)
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)
298 (define_function_unit "imuldiv" 1 0
299   (and (eq_attr "type" "imul,imul2,imul3")
300        (eq_attr "cpu" "ppc604"))
301   4 2)
303 (define_function_unit "imuldiv" 1 0
304   (and (eq_attr "type" "imul,imul2,imul3")
305        (eq_attr "cpu" "ppc604e"))
306   2 1)
308 (define_function_unit "imuldiv" 1 0
309   (and (eq_attr "type" "imul")
310        (eq_attr "cpu" "ppc620,ppc630"))
311   5 3)
313 (define_function_unit "imuldiv" 1 0
314   (and (eq_attr "type" "imul2")
315        (eq_attr "cpu" "ppc620,ppc630"))
316   4 3)
318 (define_function_unit "imuldiv" 1 0
319   (and (eq_attr "type" "imul3")
320        (eq_attr "cpu" "ppc620,ppc630"))
321   3 3)
323 (define_function_unit "imuldiv" 1 0
324   (and (eq_attr "type" "lmul")
325        (eq_attr "cpu" "ppc620,ppc630"))
326   7 5)
328 (define_function_unit "imuldiv" 1 0
329   (and (eq_attr "type" "idiv")
330        (eq_attr "cpu" "ppc604,ppc604e"))
331   20 19)
333 (define_function_unit "imuldiv" 1 0
334   (and (eq_attr "type" "idiv")
335        (eq_attr "cpu" "ppc620"))
336   37 36)
338 (define_function_unit "imuldiv" 1 0
339   (and (eq_attr "type" "idiv")
340        (eq_attr "cpu" "ppc630"))
341   21 20)
343 (define_function_unit "imuldiv" 1 0
344   (and (eq_attr "type" "ldiv")
345        (eq_attr "cpu" "ppc620,ppc630"))
346   37 36)
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)
359 (define_function_unit "imuldiv" 1 0
360   (and (eq_attr "type" "imul")
361        (eq_attr "cpu" "ppc7450"))
362   4 2)
364 (define_function_unit "imuldiv" 1 0
365   (and (eq_attr "type" "imul2,imul3")
366        (eq_attr "cpu" "ppc7450"))
367   3 1)
369 (define_function_unit "imuldiv" 1 0
370   (and (eq_attr "type" "idiv")
371        (eq_attr "cpu" "ppc7450"))
372   23 23)
374 (define_function_unit "imuldiv" 1 0
375   (and (eq_attr "type" "cr_logical")
376        (eq_attr "cpu" "ppc7450"))
377   1 1)
379 (define_function_unit "vec_alu2" 2 0
380   (and (eq_attr "type" "vecsimple")
381        (eq_attr "cpu" "ppc7450"))
382   1 2 [(eq_attr "type" "vecsimple")])
384 (define_function_unit "vec_alu2" 2 0
385   (and (eq_attr "type" "vecsimple")
386        (eq_attr "cpu" "ppc7450"))
387   1 1 [(eq_attr "type" "!vecsimple")])
389 (define_function_unit "vec_alu2" 2 0
390   (and (eq_attr "type" "veccomplex")
391        (eq_attr "cpu" "ppc7450"))
392   4 2 [(eq_attr "type" "veccomplex")])
394 (define_function_unit "vec_alu2" 2 0
395   (and (eq_attr "type" "veccomplex")
396        (eq_attr "cpu" "ppc7450"))
397   4 1 [(eq_attr "type" "!veccomplex")])
399 (define_function_unit "vec_alu2" 2 0
400   (and (eq_attr "type" "veccmp")
401        (eq_attr "cpu" "ppc7450"))
402   2 2 [(eq_attr "type" "veccmp")])
404 (define_function_unit "vec_alu2" 2 0
405   (and (eq_attr "type" "veccmp")
406        (eq_attr "cpu" "ppc7450"))
407   2 1 [(eq_attr "type" "!veccmp")])
409 (define_function_unit "vec_alu2" 2 0
410   (and (eq_attr "type" "vecfloat")
411        (eq_attr "cpu" "ppc7450"))
412   4 2 [(eq_attr "type" "vecfloat")])
414 (define_function_unit "vec_alu2" 2 0
415   (and (eq_attr "type" "vecfloat")
416        (eq_attr "cpu" "ppc7450"))
417   4 1 [(eq_attr "type" "!vecfloat")])
419 (define_function_unit "vec_alu2" 2 0
420   (and (eq_attr "type" "vecperm")
421        (eq_attr "cpu" "ppc7450"))
422   2 2 [(eq_attr "type" "vecperm")])
424 (define_function_unit "vec_alu2" 2 0
425   (and (eq_attr "type" "vecperm")
426        (eq_attr "cpu" "ppc7450"))
427   2 1 [(eq_attr "type" "!vecperm")])
429 ; PPC750 has two integer units: a primary one which can perform all
430 ; operations and a secondary one which is fed in lock step with the first
431 ; and can perform "simple" integer operations.  
432 ; To catch this we define a 'dummy' imuldiv-unit that is also needed
433 ; for the complex insns. 
434 (define_function_unit "iu2" 2 0
435   (and (eq_attr "type" "integer")
436        (eq_attr "cpu" "ppc750,ppc7400"))
437   1 1)
439 (define_function_unit "iu2" 2 0
440   (and (eq_attr "type" "imul")
441        (eq_attr "cpu" "ppc750,ppc7400"))
442   4 4)
444 (define_function_unit "iu2" 2 0
445   (and (eq_attr "type" "imul2")
446        (eq_attr "cpu" "ppc750,ppc7400"))
447   3 2)
449 (define_function_unit "iu2" 2 0
450   (and (eq_attr "type" "imul3")
451        (eq_attr "cpu" "ppc750,ppc7400"))
452   2 1)
454 (define_function_unit "iu2" 2 0
455   (and (eq_attr "type" "idiv")
456        (eq_attr "cpu" "ppc750,ppc7400"))
457   19 19)
459 (define_function_unit "imuldiv" 1 0
460   (and (eq_attr "type" "imul")
461        (eq_attr "cpu" "ppc750,ppc7400"))
462   4 4)
464 (define_function_unit "imuldiv" 1 0
465   (and (eq_attr "type" "imul2")
466        (eq_attr "cpu" "ppc750,ppc7400"))
467   3 2)
469 (define_function_unit "imuldiv" 1 0
470   (and (eq_attr "type" "imul3")
471        (eq_attr "cpu" "ppc750,ppc7400"))
472   2 1)
474 (define_function_unit "imuldiv" 1 0
475   (and (eq_attr "type" "idiv")
476        (eq_attr "cpu" "ppc750,ppc7400"))
477   19 19)
479 ; CR-logical operations are execute-serialized, that is they don't
480 ; start (and block the function unit) until all preceding operations
481 ; have finished.  They don't block dispatch of other insns, though.
482 ; I've imitated this by giving them longer latency.
483 (define_function_unit "sru" 1 0 
484   (and (eq_attr "type" "cr_logical")
485        (eq_attr "cpu" "ppc603,ppc750,ppc7400"))
486   3 2)
488 ; compare is done on integer unit, but feeds insns which
489 ; execute on the branch unit.
490 (define_function_unit "iu" 1 0   
491   (and (eq_attr "type" "compare")
492        (eq_attr "cpu" "rios1"))
493   4 1)
495 (define_function_unit "iu" 1 0   
496   (and (eq_attr "type" "delayed_compare")
497        (eq_attr "cpu" "rios1"))
498   5 1)
500 (define_function_unit "iu" 1 0
501   (and (eq_attr "type" "compare,delayed_compare")
502        (eq_attr "cpu" "rs64a,mpccore,ppc403,ppc405,ppc601,ppc603"))
503   3 1)
505 ; some extra cycles added by TARGET_SCHED_ADJUST_COST between compare
506 ; and a following branch, to reduce mispredicts
507 (define_function_unit "iu3" 3 0
508   (and (eq_attr "type" "compare,delayed_compare")
509        (eq_attr "cpu" "ppc7450"))
510   1 1)
512 (define_function_unit "iu2" 2 0   
513   (and (eq_attr "type" "compare,delayed_compare")
514        (eq_attr "cpu" "rios2"))
515   3 1)
517 (define_function_unit "iu2" 2 0
518   (and (eq_attr "type" "compare,delayed_compare")
519        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc630,ppc750,ppc7400"))
520   1 1)
522 ; fp compare uses fp unit
523 (define_function_unit "fpu" 1 0
524   (and (eq_attr "type" "fpcompare")
525        (eq_attr "cpu" "rios1"))
526   9 1)
528 ; rios1 and rios2 have different fpcompare delays
529 (define_function_unit "fpu2" 2 0
530   (and (eq_attr "type" "fpcompare")
531        (eq_attr "cpu" "rios2,ppc630"))
532   5 1)
534 ; on ppc601 and ppc603, fpcompare takes also 2 cycles from
535 ; the integer unit
536 ; here we do not define delays, just occupy the unit. The dependencies
537 ; will be assigned by the fpcompare definition in the fpu.
538 (define_function_unit "iu" 1 0
539   (and (eq_attr "type" "fpcompare")
540        (eq_attr "cpu" "ppc601,ppc603"))
541   0 2)
543 ; fp compare uses fp unit
544 (define_function_unit "fpu" 1 0
545   (and (eq_attr "type" "fpcompare")
546        (eq_attr "cpu" "rs64a,ppc601,ppc603,ppc604,ppc604e,ppc620"))
547   5 1)
549 (define_function_unit "fpu" 1 0
550   (and (eq_attr "type" "fpcompare")
551        (eq_attr "cpu"  "ppc750,ppc7400,ppc7450"))
552   3 1)
554 (define_function_unit "fpu" 1 0
555   (and (eq_attr "type" "fpcompare")
556        (eq_attr "cpu" "mpccore"))
557   1 1)
559 (define_function_unit "bpu" 1 0
560   (and (eq_attr "type" "mtjmpr")
561        (eq_attr "cpu" "rios1,rios2,rs64a"))
562   5 1)
564 (define_function_unit "bpu" 1 0
565   (and (eq_attr "type" "mtjmpr")
566        (eq_attr "cpu" "mpccore,ppc403,ppc405,ppc601,ppc603,ppc604,ppc604e,ppc620,ppc630"))
567   4 1)
569 (define_function_unit "sru" 1 0
570   (and (eq_attr "type" "mtjmpr")
571        (eq_attr "cpu" "ppc750,ppc7400"))
572   2 2)
574 (define_function_unit "imuldiv" 1 0
575   (and (eq_attr "type" "mtjmpr")
576        (eq_attr "cpu" "ppc7450"))
577   2 2)
579 (define_function_unit "bpu" 1 0
580   (and (eq_attr "type" "cr_logical")
581        (eq_attr "cpu" "rios1,rios2,ppc604"))
582   4 1)
583   
584 (define_function_unit "cru" 1 0
585   (and (eq_attr "type" "cr_logical")
586        (eq_attr "cpu" "ppc604e,ppc620,ppc630,rs64a"))
587   1 1)
589 ; all jumps/branches are executing on the bpu, in 1 cycle, for all machines.
590 (define_function_unit "bpu" 1 0
591   (eq_attr "type" "jmpreg")
592   1 1)
594 (define_function_unit "bpu" 1 0
595   (eq_attr "type" "branch")
596   1 1)
598 ; Floating Point Unit
599 (define_function_unit "fpu" 1 0
600   (and (eq_attr "type" "fp,dmul")
601        (eq_attr "cpu" "rios1"))
602   2 1)
604 (define_function_unit "fpu" 1 0
605   (and (eq_attr "type" "fp")
606        (eq_attr "cpu" "rs64a,mpccore"))
607   4 2)
609 (define_function_unit "fpu" 1 0
610   (and (eq_attr "type" "fp")
611        (eq_attr "cpu" "ppc601"))
612   4 1)
614 (define_function_unit "fpu" 1 0
615   (and (eq_attr "type" "fp")
616        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620,ppc750,ppc7400"))
617   3 1)
619 (define_function_unit "fpu" 1 0
620   (and (eq_attr "type" "fp,dmul")
621        (eq_attr "cpu" "ppc7450"))
622   5 1)
624 (define_function_unit "fpu" 1 0
625   (and (eq_attr "type" "dmul")
626        (eq_attr "cpu" "rs64a"))
627   7 2)
629 (define_function_unit "fpu" 1 0
630   (and (eq_attr "type" "dmul")
631        (eq_attr "cpu" "mpccore"))
632   5 5)
634 (define_function_unit "fpu" 1 0
635   (and (eq_attr "type" "dmul")
636        (eq_attr "cpu" "ppc601"))
637   5 2)
639 ; is this true?
640 (define_function_unit "fpu" 1 0
641   (and (eq_attr "type" "dmul")
642        (eq_attr "cpu" "ppc603,ppc750"))
643   4 2)
645 (define_function_unit "fpu" 1 0
646   (and (eq_attr "type" "dmul")
647        (eq_attr "cpu" "ppc604,ppc604e,ppc620,ppc7400"))
648   3 1)
650 (define_function_unit "fpu" 1 0
651   (and (eq_attr "type" "sdiv,ddiv")
652        (eq_attr "cpu" "rios1"))
653   19 19)
655 (define_function_unit "fpu" 1 0
656   (and (eq_attr "type" "sdiv")
657        (eq_attr "cpu" "rs64a"))
658   31 31)
660 (define_function_unit "fpu" 1 0
661   (and (eq_attr "type" "sdiv")
662        (eq_attr "cpu" "ppc601,ppc750,ppc7400"))
663   17 17)
665 (define_function_unit "fpu" 1 0
666   (and (eq_attr "type" "sdiv")
667        (eq_attr "cpu" "ppc7450"))
668   21 21)
670 (define_function_unit "fpu" 1 0
671   (and (eq_attr "type" "sdiv")
672        (eq_attr "cpu" "mpccore"))
673   10 10)
675 (define_function_unit "fpu" 1 0
676   (and (eq_attr "type" "sdiv")
677        (eq_attr "cpu" "ppc603,ppc604,ppc604e,ppc620"))
678   18 18)
680 (define_function_unit "fpu" 1 0
681   (and (eq_attr "type" "ddiv")
682        (eq_attr "cpu" "mpccore"))
683   17 17)
685 (define_function_unit "fpu" 1 0
686   (and (eq_attr "type" "ddiv")
687        (eq_attr "cpu" "rs64a,ppc601,ppc750,ppc604,ppc604e,ppc620,ppc7400"))
688   31 31)
690 (define_function_unit "fpu" 1 0
691   (and (eq_attr "type" "ddiv")
692        (eq_attr "cpu" "ppc7450"))
693   35 35)
695 (define_function_unit "fpu" 1 0
696   (and (eq_attr "type" "ddiv")
697        (eq_attr "cpu" "ppc603"))
698   33 33)
700 (define_function_unit "fpu" 1 0
701   (and (eq_attr "type" "ssqrt")
702        (eq_attr "cpu" "ppc620"))
703   31 31)
705 (define_function_unit "fpu" 1 0
706   (and (eq_attr "type" "dsqrt")
707        (eq_attr "cpu" "ppc620"))
708   31 31)
710 ; RIOS2 has two symmetric FPUs.
711 (define_function_unit "fpu2" 2 0
712   (and (eq_attr "type" "fp,dmul")
713        (eq_attr "cpu" "rios2"))
714   2 1)
716 (define_function_unit "fpu2" 2 0
717   (and (eq_attr "type" "fp,dmul")
718        (eq_attr "cpu" "ppc630"))
719   3 1)
721 (define_function_unit "fpu2" 2 0
722   (and (eq_attr "type" "sdiv,ddiv")
723        (eq_attr "cpu" "rios2"))
724   17 17)
726 (define_function_unit "fpu2" 2 0
727   (and (eq_attr "type" "sdiv")
728        (eq_attr "cpu" "ppc630"))
729   17 17)
731 (define_function_unit "fpu2" 2 0
732   (and (eq_attr "type" "ddiv")
733        (eq_attr "cpu" "ppc630"))
734   21 21)
736 (define_function_unit "fpu2" 2 0
737   (and (eq_attr "type" "ssqrt,dsqrt")
738        (eq_attr "cpu" "rios2"))
739   26 26)
741 (define_function_unit "fpu2" 2 0
742   (and (eq_attr "type" "ssqrt")
743        (eq_attr "cpu" "ppc630"))
744   18 18)
746 (define_function_unit "fpu2" 2 0
747   (and (eq_attr "type" "dsqrt")
748        (eq_attr "cpu" "ppc630"))
749   26 26)
751 ;; Power4
752 (define_function_unit "lsu2" 2 0
753   (and (eq_attr "type" "load")
754        (eq_attr "cpu" "power4"))
755   3 1)
757 (define_function_unit "lsu2" 2 0
758   (and (eq_attr "type" "fpload")
759        (eq_attr "cpu" "power4"))
760   5 1)
762 (define_function_unit "lsu2" 2 0
763   (and (eq_attr "type" "store,fpstore")
764        (eq_attr "cpu" "power4"))
765   1 1)
767 (define_function_unit "iu2" 2 0
768   (and (eq_attr "type" "integer")
769        (eq_attr "cpu" "power4"))
770   2 1)
772 (define_function_unit "iu2" 2 0
773   (and (eq_attr "type" "imul,lmul")
774        (eq_attr "cpu" "power4"))
775   7 6)
777 (define_function_unit "iu2" 2 0
778   (and (eq_attr "type" "imul2")
779        (eq_attr "cpu" "power4"))
780   5 4)
782 (define_function_unit "iu2" 2 0
783   (and (eq_attr "type" "imul3")
784        (eq_attr "cpu" "power4"))
785   4 3)
787 (define_function_unit "iu2" 2 0
788   (and (eq_attr "type" "idiv")
789        (eq_attr "cpu" "power4"))
790   36 35)
792 (define_function_unit "iu2" 2 0
793   (and (eq_attr "type" "ldiv")
794        (eq_attr "cpu" "power4"))
795   68 67)
797 (define_function_unit "imuldiv" 1 0
798   (and (eq_attr "type" "idiv")
799        (eq_attr "cpu" "power4"))
800   36 35)
802 (define_function_unit "imuldiv" 1 0
803   (and (eq_attr "type" "ldiv")
804        (eq_attr "cpu" "power4"))
805   68 67)
807 (define_function_unit "iu2" 2 0
808   (and (eq_attr "type" "compare")
809        (eq_attr "cpu" "power4"))
810   3 1)
812 (define_function_unit "iu2" 2 0
813   (and (eq_attr "type" "delayed_compare")
814        (eq_attr "cpu" "power4"))
815   4 1)
817 (define_function_unit "bpu" 1 0
818   (and (eq_attr "type" "mtjmpr")
819        (eq_attr "cpu" "power4"))
820   3 1)
822 (define_function_unit "bpu" 1 0
823   (and (eq_attr "type" "jmpreg,branch")
824        (eq_attr "cpu" "power4"))
825   2 1)
827 (define_function_unit "cru" 1 0
828   (and (eq_attr "type" "cr_logical")
829        (eq_attr "cpu" "power4"))
830   4 1)
832 (define_function_unit "fpu2" 2 0
833   (and (eq_attr "type" "fp,dmul")
834        (eq_attr "cpu" "power4"))
835   6 1)
837 ; adjust_cost increases the cost of dependent branches,
838 ; so shave a few cycles off for fpcompare.
839 (define_function_unit "fpu2" 2 0
840   (and (eq_attr "type" "fpcompare")
841        (eq_attr "cpu" "power4"))
842   5 1)
844 (define_function_unit "fpu2" 2 0
845   (and (eq_attr "type" "sdiv,ddiv")
846        (eq_attr "cpu" "power4"))
847   33 28)
849 (define_function_unit "fpu2" 2 0
850   (and (eq_attr "type" "ssqrt,dsqrt")
851        (eq_attr "cpu" "power4"))
852   40 35)
855 ;; Start with fixed-point load and store insns.  Here we put only the more
856 ;; complex forms.  Basic data transfer is done later.
858 (define_expand "zero_extendqidi2"
859   [(set (match_operand:DI 0 "gpc_reg_operand" "")
860         (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "")))]
861   "TARGET_POWERPC64"
862   "")
864 (define_insn ""
865   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
866         (zero_extend:DI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
867   "TARGET_POWERPC64"
868   "@
869    lbz%U1%X1 %0,%1
870    rldicl %0,%1,0,56"
871   [(set_attr "type" "load,*")])
873 (define_insn ""
874   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
875         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
876                     (const_int 0)))
877    (clobber (match_scratch:DI 2 "=r,r"))]
878   "TARGET_POWERPC64"
879   "@
880    rldicl. %2,%1,0,56
881    #"
882   [(set_attr "type" "compare")
883    (set_attr "length" "4,8")])
885 (define_split
886   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
887         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
888                     (const_int 0)))
889    (clobber (match_scratch:DI 2 ""))]
890   "TARGET_POWERPC64 && reload_completed"
891   [(set (match_dup 2)
892         (zero_extend:DI (match_dup 1)))
893    (set (match_dup 0)
894         (compare:CC (match_dup 2)
895                     (const_int 0)))]
896   "")
898 (define_insn ""
899   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
900         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
901                     (const_int 0)))
902    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
903         (zero_extend:DI (match_dup 1)))]
904   "TARGET_POWERPC64"
905   "@
906    rldicl. %0,%1,0,56
907    #"
908   [(set_attr "type" "compare")
909    (set_attr "length" "4,8")])
911 (define_split
912   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
913         (compare:CC (zero_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
914                     (const_int 0)))
915    (set (match_operand:DI 0 "gpc_reg_operand" "")
916         (zero_extend:DI (match_dup 1)))]
917   "TARGET_POWERPC64 && reload_completed"
918   [(set (match_dup 0)
919         (zero_extend:DI (match_dup 1)))
920    (set (match_dup 2)
921         (compare:CC (match_dup 0)
922                     (const_int 0)))]
923   "")
925 (define_insn "extendqidi2"
926   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
927         (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r")))]
928   "TARGET_POWERPC64"
929   "extsb %0,%1")
931 (define_insn ""
932   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
933         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
934                     (const_int 0)))
935    (clobber (match_scratch:DI 2 "=r,r"))]
936   "TARGET_POWERPC64"
937   "@
938    extsb. %2,%1
939    #"
940   [(set_attr "type" "compare")
941    (set_attr "length" "4,8")])
943 (define_split
944   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
945         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
946                     (const_int 0)))
947    (clobber (match_scratch:DI 2 ""))]
948   "TARGET_POWERPC64 && reload_completed"
949   [(set (match_dup 2)
950         (sign_extend:DI (match_dup 1)))
951    (set (match_dup 0)
952         (compare:CC (match_dup 2)
953                     (const_int 0)))]
954   "")
956 (define_insn ""
957   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
958         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
959                     (const_int 0)))
960    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
961         (sign_extend:DI (match_dup 1)))]
962   "TARGET_POWERPC64"
963   "@
964    extsb. %0,%1
965    #"
966   [(set_attr "type" "compare")
967    (set_attr "length" "4,8")])
969 (define_split
970   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
971         (compare:CC (sign_extend:DI (match_operand:QI 1 "gpc_reg_operand" ""))
972                     (const_int 0)))
973    (set (match_operand:DI 0 "gpc_reg_operand" "")
974         (sign_extend:DI (match_dup 1)))]
975   "TARGET_POWERPC64 && reload_completed"
976   [(set (match_dup 0)
977         (sign_extend:DI (match_dup 1)))
978    (set (match_dup 2)
979         (compare:CC (match_dup 0)
980                     (const_int 0)))]
981   "")
983 (define_expand "zero_extendhidi2"
984   [(set (match_operand:DI 0 "gpc_reg_operand" "")
985         (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
986   "TARGET_POWERPC64"
987   "")
989 (define_insn ""
990   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
991         (zero_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
992   "TARGET_POWERPC64"
993   "@
994    lhz%U1%X1 %0,%1
995    rldicl %0,%1,0,48"
996   [(set_attr "type" "load,*")])
998 (define_insn ""
999   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1000         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1001                     (const_int 0)))
1002    (clobber (match_scratch:DI 2 "=r,r"))]
1003   "TARGET_POWERPC64"
1004   "@
1005    rldicl. %2,%1,0,48
1006    #"
1007   [(set_attr "type" "compare")
1008    (set_attr "length" "4,8")])
1010 (define_split
1011   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1012         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1013                     (const_int 0)))
1014    (clobber (match_scratch:DI 2 ""))]
1015   "TARGET_POWERPC64 && reload_completed"
1016   [(set (match_dup 2)
1017         (zero_extend:DI (match_dup 1)))
1018    (set (match_dup 0)
1019         (compare:CC (match_dup 2)
1020                     (const_int 0)))]
1021   "")
1023 (define_insn ""
1024   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1025         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1026                     (const_int 0)))
1027    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1028         (zero_extend:DI (match_dup 1)))]
1029   "TARGET_POWERPC64"
1030   "@
1031    rldicl. %0,%1,0,48
1032    #"
1033   [(set_attr "type" "compare")
1034    (set_attr "length" "4,8")])
1036 (define_split
1037   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1038         (compare:CC (zero_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1039                     (const_int 0)))
1040    (set (match_operand:DI 0 "gpc_reg_operand" "")
1041         (zero_extend:DI (match_dup 1)))]
1042   "TARGET_POWERPC64 && reload_completed"
1043   [(set (match_dup 0)
1044         (zero_extend:DI (match_dup 1)))
1045    (set (match_dup 2)
1046         (compare:CC (match_dup 0)
1047                     (const_int 0)))]
1048   "")
1050 (define_expand "extendhidi2"
1051   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1052         (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "")))]
1053   "TARGET_POWERPC64"
1054   "")
1056 (define_insn ""
1057   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1058         (sign_extend:DI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1059   "TARGET_POWERPC64"
1060   "@
1061    lha%U1%X1 %0,%1
1062    extsh %0,%1"
1063   [(set_attr "type" "load,*")])
1065 (define_insn ""
1066   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1067         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1068                     (const_int 0)))
1069    (clobber (match_scratch:DI 2 "=r,r"))]
1070   "TARGET_POWERPC64"
1071   "@
1072    extsh. %2,%1
1073    #"
1074   [(set_attr "type" "compare")
1075    (set_attr "length" "4,8")])
1077 (define_split
1078   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1079         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1080                     (const_int 0)))
1081    (clobber (match_scratch:DI 2 ""))]
1082   "TARGET_POWERPC64 && reload_completed"
1083   [(set (match_dup 2)
1084         (sign_extend:DI (match_dup 1)))
1085    (set (match_dup 0)
1086         (compare:CC (match_dup 2)
1087                     (const_int 0)))]
1088   "")
1090 (define_insn ""
1091   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1092         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1093                     (const_int 0)))
1094    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1095         (sign_extend:DI (match_dup 1)))]
1096   "TARGET_POWERPC64"
1097   "@
1098    extsh. %0,%1
1099    #"
1100   [(set_attr "type" "compare")
1101    (set_attr "length" "4,8")])
1103 (define_split
1104   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1105         (compare:CC (sign_extend:DI (match_operand:HI 1 "gpc_reg_operand" ""))
1106                     (const_int 0)))
1107    (set (match_operand:DI 0 "gpc_reg_operand" "")
1108         (sign_extend:DI (match_dup 1)))]
1109   "TARGET_POWERPC64 && reload_completed"
1110   [(set (match_dup 0)
1111         (sign_extend:DI (match_dup 1)))
1112    (set (match_dup 2)
1113         (compare:CC (match_dup 0)
1114                     (const_int 0)))]
1115   "")
1117 (define_expand "zero_extendsidi2"
1118   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1119         (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1120   "TARGET_POWERPC64"
1121   "")
1123 (define_insn ""
1124   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1125         (zero_extend:DI (match_operand:SI 1 "reg_or_mem_operand" "m,r")))]
1126   "TARGET_POWERPC64"
1127   "@
1128    lwz%U1%X1 %0,%1
1129    rldicl %0,%1,0,32"
1130   [(set_attr "type" "load,*")])
1132 (define_insn ""
1133   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1134         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1135                     (const_int 0)))
1136    (clobber (match_scratch:DI 2 "=r,r"))]
1137   "TARGET_POWERPC64"
1138   "@
1139    rldicl. %2,%1,0,32
1140    #"
1141   [(set_attr "type" "compare")
1142    (set_attr "length" "4,8")])
1144 (define_split
1145   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1146         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1147                     (const_int 0)))
1148    (clobber (match_scratch:DI 2 ""))]
1149   "TARGET_POWERPC64 && reload_completed"
1150   [(set (match_dup 2)
1151         (zero_extend:DI (match_dup 1)))
1152    (set (match_dup 0)
1153         (compare:CC (match_dup 2)
1154                     (const_int 0)))]
1155   "")
1157 (define_insn ""
1158   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1159         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1160                     (const_int 0)))
1161    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1162         (zero_extend:DI (match_dup 1)))]
1163   "TARGET_POWERPC64"
1164   "@
1165    rldicl. %0,%1,0,32
1166    #"
1167   [(set_attr "type" "compare")
1168    (set_attr "length" "4,8")])
1170 (define_split
1171   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1172         (compare:CC (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1173                     (const_int 0)))
1174    (set (match_operand:DI 0 "gpc_reg_operand" "")
1175         (zero_extend:DI (match_dup 1)))]
1176   "TARGET_POWERPC64 && reload_completed"
1177   [(set (match_dup 0)
1178         (zero_extend:DI (match_dup 1)))
1179    (set (match_dup 2)
1180         (compare:CC (match_dup 0)
1181                     (const_int 0)))]
1182   "")
1184 (define_expand "extendsidi2"
1185   [(set (match_operand:DI 0 "gpc_reg_operand" "")
1186         (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "")))]
1187   "TARGET_POWERPC64"
1188   "")
1190 (define_insn ""
1191   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1192         (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
1193   "TARGET_POWERPC64"
1194   "@
1195    lwa%U1%X1 %0,%1
1196    extsw %0,%1"
1197   [(set_attr "type" "load,*")])
1199 (define_insn ""
1200   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1201         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1202                     (const_int 0)))
1203    (clobber (match_scratch:DI 2 "=r,r"))]
1204   "TARGET_POWERPC64"
1205   "@
1206    extsw. %2,%1
1207    #"
1208   [(set_attr "type" "compare")
1209    (set_attr "length" "4,8")])
1211 (define_split
1212   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1213         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1214                     (const_int 0)))
1215    (clobber (match_scratch:DI 2 ""))]
1216   "TARGET_POWERPC64 && reload_completed"
1217   [(set (match_dup 2)
1218         (sign_extend:DI (match_dup 1)))
1219    (set (match_dup 0)
1220         (compare:CC (match_dup 2)
1221                     (const_int 0)))]
1222   "")
1224 (define_insn ""
1225   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1226         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1227                     (const_int 0)))
1228    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
1229         (sign_extend:DI (match_dup 1)))]
1230   "TARGET_POWERPC64"
1231   "@
1232    extsw. %0,%1
1233    #"
1234   [(set_attr "type" "compare")
1235    (set_attr "length" "4,8")])
1237 (define_split
1238   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1239         (compare:CC (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
1240                     (const_int 0)))
1241    (set (match_operand:DI 0 "gpc_reg_operand" "")
1242         (sign_extend:DI (match_dup 1)))]
1243   "TARGET_POWERPC64 && reload_completed"
1244   [(set (match_dup 0)
1245         (sign_extend:DI (match_dup 1)))
1246    (set (match_dup 2)
1247         (compare:CC (match_dup 0)
1248                     (const_int 0)))]
1249   "")
1251 (define_expand "zero_extendqisi2"
1252   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1253         (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "")))]
1254   ""
1255   "")
1257 (define_insn ""
1258   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1259         (zero_extend:SI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1260   ""
1261   "@
1262    lbz%U1%X1 %0,%1
1263    {rlinm|rlwinm} %0,%1,0,0xff"
1264   [(set_attr "type" "load,*")])
1266 (define_insn ""
1267   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1268         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1269                     (const_int 0)))
1270    (clobber (match_scratch:SI 2 "=r,r"))]
1271   ""
1272   "@
1273    {andil.|andi.} %2,%1,0xff
1274    #"
1275   [(set_attr "type" "compare")
1276    (set_attr "length" "4,8")])
1278 (define_split
1279   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1280         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1281                     (const_int 0)))
1282    (clobber (match_scratch:SI 2 ""))]
1283   "reload_completed"
1284   [(set (match_dup 2)
1285         (zero_extend:SI (match_dup 1)))
1286    (set (match_dup 0)
1287         (compare:CC (match_dup 2)
1288                     (const_int 0)))]
1289   "")
1291 (define_insn ""
1292   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1293         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1294                     (const_int 0)))
1295    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1296         (zero_extend:SI (match_dup 1)))]
1297   ""
1298   "@
1299    {andil.|andi.} %0,%1,0xff
1300    #"
1301   [(set_attr "type" "compare")
1302    (set_attr "length" "4,8")])
1304 (define_split
1305   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1306         (compare:CC (zero_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1307                     (const_int 0)))
1308    (set (match_operand:SI 0 "gpc_reg_operand" "")
1309         (zero_extend:SI (match_dup 1)))]
1310   "reload_completed"
1311   [(set (match_dup 0)
1312         (zero_extend:SI (match_dup 1)))
1313    (set (match_dup 2)
1314         (compare:CC (match_dup 0)
1315                     (const_int 0)))]
1316   "")
1318 (define_expand "extendqisi2"
1319   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
1320    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1321   ""
1322   "
1324   if (TARGET_POWERPC)
1325     emit_insn (gen_extendqisi2_ppc (operands[0], operands[1]));
1326   else if (TARGET_POWER)
1327     emit_insn (gen_extendqisi2_power (operands[0], operands[1]));
1328   else
1329     emit_insn (gen_extendqisi2_no_power (operands[0], operands[1]));
1330   DONE;
1333 (define_insn "extendqisi2_ppc"
1334   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1335         (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1336   "TARGET_POWERPC"
1337   "extsb %0,%1")
1339 (define_insn ""
1340   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1341         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1342                     (const_int 0)))
1343    (clobber (match_scratch:SI 2 "=r,r"))]
1344   "TARGET_POWERPC"
1345   "@
1346    extsb. %2,%1
1347    #"
1348   [(set_attr "type" "compare")
1349    (set_attr "length" "4,8")])
1351 (define_split
1352   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1353         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1354                     (const_int 0)))
1355    (clobber (match_scratch:SI 2 ""))]
1356   "TARGET_POWERPC && reload_completed"
1357   [(set (match_dup 2)
1358         (sign_extend:SI (match_dup 1)))
1359    (set (match_dup 0)
1360         (compare:CC (match_dup 2)
1361                     (const_int 0)))]
1362   "")
1364 (define_insn ""
1365   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1366         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1367                     (const_int 0)))
1368    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1369         (sign_extend:SI (match_dup 1)))]
1370   "TARGET_POWERPC"
1371   "@
1372    extsb. %0,%1
1373    #"
1374   [(set_attr "type" "compare")
1375    (set_attr "length" "4,8")])
1377 (define_split
1378   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1379         (compare:CC (sign_extend:SI (match_operand:QI 1 "gpc_reg_operand" ""))
1380                     (const_int 0)))
1381    (set (match_operand:SI 0 "gpc_reg_operand" "")
1382         (sign_extend:SI (match_dup 1)))]
1383   "TARGET_POWERPC && reload_completed"
1384   [(set (match_dup 0)
1385         (sign_extend:SI (match_dup 1)))
1386    (set (match_dup 2)
1387         (compare:CC (match_dup 0)
1388                     (const_int 0)))]
1389   "")
1391 (define_expand "extendqisi2_power"
1392   [(parallel [(set (match_dup 2)
1393                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1394                               (const_int 24)))
1395               (clobber (scratch:SI))])
1396    (parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
1397                    (ashiftrt:SI (match_dup 2)
1398                                 (const_int 24)))
1399               (clobber (scratch:SI))])]
1400   "TARGET_POWER"
1401   "
1402 { operands[1] = gen_lowpart (SImode, operands[1]);
1403   operands[2] = gen_reg_rtx (SImode); }")
1405 (define_expand "extendqisi2_no_power"
1406   [(set (match_dup 2)
1407         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1408                    (const_int 24)))
1409    (set (match_operand:SI 0 "gpc_reg_operand" "")
1410         (ashiftrt:SI (match_dup 2)
1411                      (const_int 24)))]
1412   "! TARGET_POWER && ! TARGET_POWERPC"
1413   "
1414 { operands[1] = gen_lowpart (SImode, operands[1]);
1415   operands[2] = gen_reg_rtx (SImode); }")
1417 (define_expand "zero_extendqihi2"
1418   [(set (match_operand:HI 0 "gpc_reg_operand" "")
1419         (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "")))]
1420   ""
1421   "")
1423 (define_insn ""
1424   [(set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1425         (zero_extend:HI (match_operand:QI 1 "reg_or_mem_operand" "m,r")))]
1426   ""
1427   "@
1428    lbz%U1%X1 %0,%1
1429    {rlinm|rlwinm} %0,%1,0,0xff"
1430   [(set_attr "type" "load,*")])
1432 (define_insn ""
1433   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1434         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1435                     (const_int 0)))
1436    (clobber (match_scratch:HI 2 "=r,r"))]
1437   ""
1438   "@
1439    {andil.|andi.} %2,%1,0xff
1440    #"
1441   [(set_attr "type" "compare")
1442    (set_attr "length" "4,8")])
1444 (define_split
1445   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1446         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1447                     (const_int 0)))
1448    (clobber (match_scratch:HI 2 ""))]
1449   "reload_completed"
1450   [(set (match_dup 2)
1451         (zero_extend:HI (match_dup 1)))
1452    (set (match_dup 0)
1453         (compare:CC (match_dup 2)
1454                     (const_int 0)))]
1455   "")
1457 (define_insn ""
1458   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1459         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1460                     (const_int 0)))
1461    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1462         (zero_extend:HI (match_dup 1)))]
1463   ""
1464   "@
1465    {andil.|andi.} %0,%1,0xff
1466    #"
1467   [(set_attr "type" "compare")
1468    (set_attr "length" "4,8")])
1470 (define_split
1471   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1472         (compare:CC (zero_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1473                     (const_int 0)))
1474    (set (match_operand:HI 0 "gpc_reg_operand" "")
1475         (zero_extend:HI (match_dup 1)))]
1476   "reload_completed"
1477   [(set (match_dup 0)
1478         (zero_extend:HI (match_dup 1)))
1479    (set (match_dup 2)
1480         (compare:CC (match_dup 0)
1481                     (const_int 0)))]
1482   "")
1484 (define_expand "extendqihi2"
1485   [(use (match_operand:HI 0 "gpc_reg_operand" ""))
1486    (use (match_operand:QI 1 "gpc_reg_operand" ""))]
1487   ""
1488   "
1490   if (TARGET_POWERPC)
1491     emit_insn (gen_extendqihi2_ppc (operands[0], operands[1]));
1492   else if (TARGET_POWER)
1493     emit_insn (gen_extendqihi2_power (operands[0], operands[1]));
1494   else
1495     emit_insn (gen_extendqihi2_no_power (operands[0], operands[1]));
1496   DONE;
1499 (define_insn "extendqihi2_ppc"
1500   [(set (match_operand:HI 0 "gpc_reg_operand" "=r")
1501         (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r")))]
1502   "TARGET_POWERPC"
1503   "extsb %0,%1")
1505 (define_insn ""
1506   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1507         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1508                     (const_int 0)))
1509    (clobber (match_scratch:HI 2 "=r,r"))]
1510   "TARGET_POWERPC"
1511   "@
1512    extsb. %2,%1
1513    #"
1514   [(set_attr "type" "compare")
1515    (set_attr "length" "4,8")])
1517 (define_split
1518   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1519         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1520                     (const_int 0)))
1521    (clobber (match_scratch:HI 2 ""))]
1522   "TARGET_POWERPC && reload_completed"
1523   [(set (match_dup 2)
1524         (sign_extend:HI (match_dup 1)))
1525    (set (match_dup 0)
1526         (compare:CC (match_dup 2)
1527                     (const_int 0)))]
1528   "")
1530 (define_insn ""
1531   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1532         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" "r,r"))
1533                     (const_int 0)))
1534    (set (match_operand:HI 0 "gpc_reg_operand" "=r,r")
1535         (sign_extend:HI (match_dup 1)))]
1536   "TARGET_POWERPC"
1537   "@
1538    extsb. %0,%1
1539    #"
1540   [(set_attr "type" "compare")
1541    (set_attr "length" "4,8")])
1543 (define_split
1544   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1545         (compare:CC (sign_extend:HI (match_operand:QI 1 "gpc_reg_operand" ""))
1546                     (const_int 0)))
1547    (set (match_operand:HI 0 "gpc_reg_operand" "")
1548         (sign_extend:HI (match_dup 1)))]
1549   "TARGET_POWERPC && reload_completed"
1550   [(set (match_dup 0)
1551         (sign_extend:HI (match_dup 1)))
1552    (set (match_dup 2)
1553         (compare:CC (match_dup 0)
1554                     (const_int 0)))]
1555   "")
1557 (define_expand "extendqihi2_power"
1558   [(parallel [(set (match_dup 2)
1559                    (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1560                               (const_int 24)))
1561               (clobber (scratch:SI))])
1562    (parallel [(set (match_operand:HI 0 "gpc_reg_operand" "")
1563                    (ashiftrt:SI (match_dup 2)
1564                                 (const_int 24)))
1565               (clobber (scratch:SI))])]
1566   "TARGET_POWER"
1567   "
1568 { operands[0] = gen_lowpart (SImode, operands[0]);
1569   operands[1] = gen_lowpart (SImode, operands[1]);
1570   operands[2] = gen_reg_rtx (SImode); }")
1572 (define_expand "extendqihi2_no_power"
1573   [(set (match_dup 2)
1574         (ashift:SI (match_operand:QI 1 "gpc_reg_operand" "")
1575                    (const_int 24)))
1576    (set (match_operand:HI 0 "gpc_reg_operand" "")
1577         (ashiftrt:SI (match_dup 2)
1578                      (const_int 24)))]
1579   "! TARGET_POWER && ! TARGET_POWERPC"
1580   "
1581 { operands[0] = gen_lowpart (SImode, operands[0]);
1582   operands[1] = gen_lowpart (SImode, operands[1]);
1583   operands[2] = gen_reg_rtx (SImode); }")
1585 (define_expand "zero_extendhisi2"
1586   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1587         (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1588   ""
1589   "")
1591 (define_insn ""
1592   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1593         (zero_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1594   ""
1595   "@
1596    lhz%U1%X1 %0,%1
1597    {rlinm|rlwinm} %0,%1,0,0xffff"
1598   [(set_attr "type" "load,*")])
1600 (define_insn ""
1601   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1602         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1603                     (const_int 0)))
1604    (clobber (match_scratch:SI 2 "=r,r"))]
1605   ""
1606   "@
1607    {andil.|andi.} %2,%1,0xffff
1608    #"
1609   [(set_attr "type" "compare")
1610    (set_attr "length" "4,8")])
1612 (define_split
1613   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1614         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1615                     (const_int 0)))
1616    (clobber (match_scratch:SI 2 ""))]
1617   "reload_completed"
1618   [(set (match_dup 2)
1619         (zero_extend:SI (match_dup 1)))
1620    (set (match_dup 0)
1621         (compare:CC (match_dup 2)
1622                     (const_int 0)))]
1623   "")
1625 (define_insn ""
1626   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1627         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1628                     (const_int 0)))
1629    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1630         (zero_extend:SI (match_dup 1)))]
1631   ""
1632   "@
1633    {andil.|andi.} %0,%1,0xffff
1634    #"
1635   [(set_attr "type" "compare")
1636    (set_attr "length" "4,8")])
1638 (define_split
1639   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1640         (compare:CC (zero_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1641                     (const_int 0)))
1642    (set (match_operand:SI 0 "gpc_reg_operand" "")
1643         (zero_extend:SI (match_dup 1)))]
1644   "reload_completed"
1645   [(set (match_dup 0)
1646         (zero_extend:SI (match_dup 1)))
1647    (set (match_dup 2)
1648         (compare:CC (match_dup 0)
1649                     (const_int 0)))]
1650   "")
1652 (define_expand "extendhisi2"
1653   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1654         (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "")))]
1655   ""
1656   "")
1658 (define_insn ""
1659   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1660         (sign_extend:SI (match_operand:HI 1 "reg_or_mem_operand" "m,r")))]
1661   ""
1662   "@
1663    lha%U1%X1 %0,%1
1664    {exts|extsh} %0,%1"
1665   [(set_attr "type" "load,*")])
1667 (define_insn ""
1668   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1669         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1670                     (const_int 0)))
1671    (clobber (match_scratch:SI 2 "=r,r"))]
1672   ""
1673   "@
1674    {exts.|extsh.} %2,%1
1675    #"
1676   [(set_attr "type" "compare")
1677    (set_attr "length" "4,8")])
1679 (define_split
1680   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1681         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1682                     (const_int 0)))
1683    (clobber (match_scratch:SI 2 ""))]
1684   "reload_completed"
1685   [(set (match_dup 2)
1686         (sign_extend:SI (match_dup 1)))
1687    (set (match_dup 0)
1688         (compare:CC (match_dup 2)
1689                     (const_int 0)))]
1690   "")
1692 (define_insn ""
1693   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1694         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" "r,r"))
1695                     (const_int 0)))
1696    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1697         (sign_extend:SI (match_dup 1)))]
1698   ""
1699   "@
1700    {exts.|extsh.} %0,%1
1701    #"
1702   [(set_attr "type" "compare")
1703    (set_attr "length" "4,8")])
1705 (define_split
1706   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1707         (compare:CC (sign_extend:SI (match_operand:HI 1 "gpc_reg_operand" ""))
1708                     (const_int 0)))
1709    (set (match_operand:SI 0 "gpc_reg_operand" "")
1710         (sign_extend:SI (match_dup 1)))]
1711   "reload_completed"
1712   [(set (match_dup 0)
1713         (sign_extend:SI (match_dup 1)))
1714    (set (match_dup 2)
1715         (compare:CC (match_dup 0)
1716                     (const_int 0)))]
1717   "")
1719 ;; Fixed-point arithmetic insns.
1721 ;; Discourage ai/addic because of carry but provide it in an alternative
1722 ;; allowing register zero as source.
1723 (define_expand "addsi3"
1724   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1725         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1726                  (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
1727   ""
1728   "
1730   if (GET_CODE (operands[2]) == CONST_INT
1731                 && ! add_operand (operands[2], SImode))
1732     {
1733       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
1734                  ? operands[0] : gen_reg_rtx (SImode));
1736       HOST_WIDE_INT val = INTVAL (operands[2]);
1737       HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1738       HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1740       /* The ordering here is important for the prolog expander.
1741          When space is allocated from the stack, adding 'low' first may
1742          produce a temporary deallocation (which would be bad).  */
1743       emit_insn (gen_addsi3 (tmp, operands[1], GEN_INT (rest)));
1744       emit_insn (gen_addsi3 (operands[0], tmp, GEN_INT (low)));
1745       DONE;
1746     }
1749 (define_insn "*addsi3_internal1"
1750   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,?r,r")
1751         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,b,r,b")
1752                  (match_operand:SI 2 "add_operand" "r,I,I,L")))]
1753   ""
1754   "@
1755    {cax|add} %0,%1,%2
1756    {cal %0,%2(%1)|addi %0,%1,%2}
1757    {ai|addic} %0,%1,%2
1758    {cau|addis} %0,%1,%v2"
1759   [(set_attr "length" "4,4,4,4")])
1761 (define_insn "addsi3_high"
1762   [(set (match_operand:SI 0 "gpc_reg_operand" "=b")
1763         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "b")
1764                  (high:SI (match_operand 2 "" ""))))]
1765   "TARGET_MACHO && !TARGET_64BIT"
1766   "{cau|addis} %0,%1,ha16(%2)"
1767   [(set_attr "length" "4")])
1769 (define_insn "*addsi3_internal2"
1770   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
1771         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1772                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1773                     (const_int 0)))
1774    (clobber (match_scratch:SI 3 "=r,r,r,r"))]
1775   "! TARGET_POWERPC64"
1776   "@
1777    {cax.|add.} %3,%1,%2
1778    {ai.|addic.} %3,%1,%2
1779    #
1780    #"
1781   [(set_attr "type" "compare")
1782    (set_attr "length" "4,4,8,8")])
1784 (define_split
1785   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1786         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1787                              (match_operand:SI 2 "reg_or_short_operand" ""))
1788                     (const_int 0)))
1789    (clobber (match_scratch:SI 3 ""))]
1790   "! TARGET_POWERPC64 && reload_completed"
1791   [(set (match_dup 3)
1792         (plus:SI (match_dup 1)
1793                  (match_dup 2)))
1794    (set (match_dup 0)
1795         (compare:CC (match_dup 3)
1796                     (const_int 0)))]
1797   "")
1799 (define_insn "*addsi3_internal3"
1800   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
1801         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
1802                              (match_operand:SI 2 "reg_or_short_operand" "r,I,r,I"))
1803                     (const_int 0)))
1804    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
1805         (plus:SI (match_dup 1)
1806                  (match_dup 2)))]
1807   "! TARGET_POWERPC64"
1808   "@
1809    {cax.|add.} %0,%1,%2
1810    {ai.|addic.} %0,%1,%2
1811    #
1812    #"
1813   [(set_attr "type" "compare")
1814    (set_attr "length" "4,4,8,8")])
1816 (define_split
1817   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1818         (compare:CC (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1819                              (match_operand:SI 2 "reg_or_short_operand" ""))
1820                     (const_int 0)))
1821    (set (match_operand:SI 0 "gpc_reg_operand" "")
1822         (plus:SI (match_dup 1) (match_dup 2)))]
1823   "! TARGET_POWERPC64 && reload_completed"
1824   [(set (match_dup 0)
1825         (plus:SI (match_dup 1)
1826                  (match_dup 2)))
1827    (set (match_dup 3)
1828         (compare:CC (match_dup 0)
1829                     (const_int 0)))]
1830   "")
1832 ;; Split an add that we can't do in one insn into two insns, each of which
1833 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
1834 ;; add should be last in case the result gets used in an address.
1836 (define_split
1837   [(set (match_operand:SI 0 "gpc_reg_operand" "")
1838         (plus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1839                  (match_operand:SI 2 "non_add_cint_operand" "")))]
1840   ""
1841   [(set (match_dup 0) (plus:SI (match_dup 1) (match_dup 3)))
1842    (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 4)))]
1845   HOST_WIDE_INT val = INTVAL (operands[2]);
1846   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
1847   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, SImode);
1849   operands[3] = GEN_INT (rest);
1850   operands[4] = GEN_INT (low);
1853 (define_insn "one_cmplsi2"
1854   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1855         (not:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
1856   ""
1857   "nor %0,%1,%1")
1859 (define_insn ""
1860   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1861         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1862                     (const_int 0)))
1863    (clobber (match_scratch:SI 2 "=r,r"))]
1864   "! TARGET_POWERPC64"
1865   "@
1866    nor. %2,%1,%1
1867    #"
1868   [(set_attr "type" "compare")
1869    (set_attr "length" "4,8")])
1871 (define_split
1872   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1873         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1874                     (const_int 0)))
1875    (clobber (match_scratch:SI 2 ""))]
1876   "! TARGET_POWERPC64 && reload_completed"
1877   [(set (match_dup 2)
1878         (not:SI (match_dup 1)))
1879    (set (match_dup 0)
1880         (compare:CC (match_dup 2)
1881                     (const_int 0)))]
1882   "")
1884 (define_insn ""
1885   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
1886         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
1887                     (const_int 0)))
1888    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1889         (not:SI (match_dup 1)))]
1890   "! TARGET_POWERPC64"
1891   "@
1892    nor. %0,%1,%1
1893    #"
1894   [(set_attr "type" "compare")
1895    (set_attr "length" "4,8")])
1897 (define_split
1898   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
1899         (compare:CC (not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
1900                     (const_int 0)))
1901    (set (match_operand:SI 0 "gpc_reg_operand" "")
1902         (not:SI (match_dup 1)))]
1903   "! TARGET_POWERPC64 && reload_completed"
1904   [(set (match_dup 0)
1905         (not:SI (match_dup 1)))
1906    (set (match_dup 2)
1907         (compare:CC (match_dup 0)
1908                     (const_int 0)))]
1909   "")
1911 (define_insn ""
1912   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
1913         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "rI")
1914                   (match_operand:SI 2 "gpc_reg_operand" "r")))]
1915   "! TARGET_POWERPC"
1916   "{sf%I1|subf%I1c} %0,%2,%1")
1918 (define_insn ""
1919   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1920         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "r,I")
1921                   (match_operand:SI 2 "gpc_reg_operand" "r,r")))]
1922   "TARGET_POWERPC"
1923   "@
1924    subf %0,%2,%1
1925    subfic %0,%2,%1")
1927 (define_insn ""
1928   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1929         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1930                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1931                     (const_int 0)))
1932    (clobber (match_scratch:SI 3 "=r,r"))]
1933   "! TARGET_POWERPC"
1934   "@
1935    {sf.|subfc.} %3,%2,%1
1936    #"
1937   [(set_attr "type" "compare")
1938    (set_attr "length" "4,8")])
1940 (define_insn ""
1941   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
1942         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1943                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1944                     (const_int 0)))
1945    (clobber (match_scratch:SI 3 "=r,r"))]
1946   "TARGET_POWERPC && ! TARGET_POWERPC64"
1947   "@
1948    subf. %3,%2,%1
1949    #"
1950   [(set_attr "type" "compare")
1951    (set_attr "length" "4,8")])
1953 (define_split
1954   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
1955         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
1956                               (match_operand:SI 2 "gpc_reg_operand" ""))
1957                     (const_int 0)))
1958    (clobber (match_scratch:SI 3 ""))]
1959   "! TARGET_POWERPC64 && reload_completed"
1960   [(set (match_dup 3)
1961         (minus:SI (match_dup 1)
1962                   (match_dup 2)))
1963    (set (match_dup 0)
1964         (compare:CC (match_dup 3)
1965                     (const_int 0)))]
1966   "")
1968 (define_insn ""
1969   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1970         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1971                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1972                     (const_int 0)))
1973    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1974         (minus:SI (match_dup 1) (match_dup 2)))]
1975   "! TARGET_POWERPC"
1976   "@
1977    {sf.|subfc.} %0,%2,%1
1978    #"
1979   [(set_attr "type" "compare")
1980    (set_attr "length" "4,8")])
1982 (define_insn ""
1983   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
1984         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
1985                               (match_operand:SI 2 "gpc_reg_operand" "r,r"))
1986                     (const_int 0)))
1987    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
1988         (minus:SI (match_dup 1)
1989                   (match_dup 2)))]
1990   "TARGET_POWERPC && ! TARGET_POWERPC64"
1991   "@
1992    subf. %0,%2,%1
1993    #"
1994   [(set_attr "type" "compare")
1995    (set_attr "length" "4,8")])
1997 (define_split
1998   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
1999         (compare:CC (minus:SI (match_operand:SI 1 "gpc_reg_operand" "")
2000                               (match_operand:SI 2 "gpc_reg_operand" ""))
2001                     (const_int 0)))
2002    (set (match_operand:SI 0 "gpc_reg_operand" "")
2003         (minus:SI (match_dup 1)
2004                   (match_dup 2)))]
2005   "! TARGET_POWERPC64 && reload_completed"
2006   [(set (match_dup 0)
2007         (minus:SI (match_dup 1)
2008                   (match_dup 2)))
2009    (set (match_dup 3)
2010         (compare:CC (match_dup 0)
2011                     (const_int 0)))]
2012   "")
2014 (define_expand "subsi3"
2015   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2016         (minus:SI (match_operand:SI 1 "reg_or_short_operand" "")
2017                   (match_operand:SI 2 "reg_or_arith_cint_operand" "")))]
2018   ""
2019   "
2021   if (GET_CODE (operands[2]) == CONST_INT)
2022     {
2023       emit_insn (gen_addsi3 (operands[0], operands[1],
2024                              negate_rtx (SImode, operands[2])));
2025       DONE;
2026     }
2029 ;; For SMIN, SMAX, UMIN, and UMAX, we use DEFINE_EXPAND's that involve a doz[i]
2030 ;; instruction and some auxiliary computations.  Then we just have a single
2031 ;; DEFINE_INSN for doz[i] and the define_splits to make them if made by
2032 ;; combine.
2034 (define_expand "sminsi3"
2035   [(set (match_dup 3)
2036         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2037                                 (match_operand:SI 2 "reg_or_short_operand" ""))
2038                          (const_int 0)
2039                          (minus:SI (match_dup 2) (match_dup 1))))
2040    (set (match_operand:SI 0 "gpc_reg_operand" "")
2041         (minus:SI (match_dup 2) (match_dup 3)))]
2042   "TARGET_POWER"
2043   "
2044 { operands[3] = gen_reg_rtx (SImode); }")
2046 (define_split
2047   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2048         (smin:SI (match_operand:SI 1 "gpc_reg_operand" "")
2049                  (match_operand:SI 2 "reg_or_short_operand" "")))
2050    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
2051   "TARGET_POWER"
2052   [(set (match_dup 3)
2053         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
2054                          (const_int 0)
2055                          (minus:SI (match_dup 2) (match_dup 1))))
2056    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 3)))]
2057   "")
2059 (define_expand "smaxsi3"
2060   [(set (match_dup 3)
2061         (if_then_else:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
2062                                 (match_operand:SI 2 "reg_or_short_operand" ""))
2063                          (const_int 0)
2064                          (minus:SI (match_dup 2) (match_dup 1))))
2065    (set (match_operand:SI 0 "gpc_reg_operand" "")
2066         (plus:SI (match_dup 3) (match_dup 1)))]
2067   "TARGET_POWER"
2068   "
2069 { operands[3] = gen_reg_rtx (SImode); }")
2071 (define_split
2072   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2073         (smax:SI (match_operand:SI 1 "gpc_reg_operand" "")
2074                  (match_operand:SI 2 "reg_or_short_operand" "")))
2075    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
2076   "TARGET_POWER"
2077   [(set (match_dup 3)
2078         (if_then_else:SI (gt:SI (match_dup 1) (match_dup 2))
2079                          (const_int 0)
2080                          (minus:SI (match_dup 2) (match_dup 1))))
2081    (set (match_dup 0) (plus:SI (match_dup 3) (match_dup 1)))]
2082   "")
2084 (define_expand "uminsi3"
2085   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2086                               (match_dup 5)))
2087    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
2088                               (match_dup 5)))
2089    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2090                                        (const_int 0)
2091                                        (minus:SI (match_dup 4) (match_dup 3))))
2092    (set (match_operand:SI 0 "gpc_reg_operand" "")
2093         (minus:SI (match_dup 2) (match_dup 3)))]
2094   "TARGET_POWER"
2095   "
2097   operands[3] = gen_reg_rtx (SImode);
2098   operands[4] = gen_reg_rtx (SImode);
2099   operands[5] = GEN_INT (-2147483647 - 1);
2102 (define_expand "umaxsi3"
2103   [(set (match_dup 3) (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2104                               (match_dup 5)))
2105    (set (match_dup 4) (xor:SI (match_operand:SI 2 "gpc_reg_operand" "")
2106                               (match_dup 5)))
2107    (set (match_dup 3) (if_then_else:SI (gt (match_dup 3) (match_dup 4))
2108                                        (const_int 0)
2109                                        (minus:SI (match_dup 4) (match_dup 3))))
2110    (set (match_operand:SI 0 "gpc_reg_operand" "")
2111         (plus:SI (match_dup 3) (match_dup 1)))]
2112   "TARGET_POWER"
2113   "
2115   operands[3] = gen_reg_rtx (SImode);
2116   operands[4] = gen_reg_rtx (SImode);
2117   operands[5] = GEN_INT (-2147483647 - 1);
2120 (define_insn ""
2121   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2122         (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r")
2123                              (match_operand:SI 2 "reg_or_short_operand" "rI"))
2124                          (const_int 0)
2125                          (minus:SI (match_dup 2) (match_dup 1))))]
2126   "TARGET_POWER"
2127   "doz%I2 %0,%1,%2")
2129 (define_insn ""
2130   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2131         (compare:CC
2132          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2133                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2134                           (const_int 0)
2135                           (minus:SI (match_dup 2) (match_dup 1)))
2136          (const_int 0)))
2137    (clobber (match_scratch:SI 3 "=r,r"))]
2138   "TARGET_POWER"
2139   "@
2140    doz%I2. %3,%1,%2
2141    #"
2142   [(set_attr "type" "delayed_compare")
2143    (set_attr "length" "4,8")])
2145 (define_split
2146   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2147         (compare:CC
2148          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2149                               (match_operand:SI 2 "reg_or_short_operand" ""))
2150                           (const_int 0)
2151                           (minus:SI (match_dup 2) (match_dup 1)))
2152          (const_int 0)))
2153    (clobber (match_scratch:SI 3 ""))]
2154   "TARGET_POWER && reload_completed"
2155   [(set (match_dup 3)
2156         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2157                           (const_int 0)
2158                           (minus:SI (match_dup 2) (match_dup 1))))
2159    (set (match_dup 0)
2160         (compare:CC (match_dup 3)
2161                     (const_int 0)))]
2162   "")
2164 (define_insn ""
2165   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2166         (compare:CC
2167          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "r,r")
2168                               (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
2169                           (const_int 0)
2170                           (minus:SI (match_dup 2) (match_dup 1)))
2171          (const_int 0)))
2172    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2173         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2174                          (const_int 0)
2175                          (minus:SI (match_dup 2) (match_dup 1))))]
2176   "TARGET_POWER"
2177   "@
2178    doz%I2. %0,%1,%2
2179    #"
2180   [(set_attr "type" "delayed_compare")
2181    (set_attr "length" "4,8")])
2183 (define_split
2184   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2185         (compare:CC
2186          (if_then_else:SI (gt (match_operand:SI 1 "gpc_reg_operand" "")
2187                               (match_operand:SI 2 "reg_or_short_operand" ""))
2188                           (const_int 0)
2189                           (minus:SI (match_dup 2) (match_dup 1)))
2190          (const_int 0)))
2191    (set (match_operand:SI 0 "gpc_reg_operand" "")
2192         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2193                          (const_int 0)
2194                          (minus:SI (match_dup 2) (match_dup 1))))]
2195   "TARGET_POWER && reload_completed"
2196   [(set (match_dup 0)
2197         (if_then_else:SI (gt (match_dup 1) (match_dup 2))
2198                          (const_int 0)
2199                          (minus:SI (match_dup 2) (match_dup 1))))
2200    (set (match_dup 3)
2201         (compare:CC (match_dup 0)
2202                     (const_int 0)))]
2203   "")
2205 ;; We don't need abs with condition code because such comparisons should
2206 ;; never be done.
2207 (define_expand "abssi2"
2208   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2209         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))]
2210   ""
2211   "
2213   if (! TARGET_POWER)
2214     {
2215       emit_insn (gen_abssi2_nopower (operands[0], operands[1]));
2216       DONE;
2217     }
2220 (define_insn "*abssi2_power"
2221   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2222         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2223   "TARGET_POWER"
2224   "abs %0,%1")
2226 (define_insn_and_split "abssi2_nopower"
2227   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2228         (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0")))
2229    (clobber (match_scratch:SI 2 "=&r,&r"))]
2230   "! TARGET_POWER"
2231   "#"
2232   "&& reload_completed"
2233   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2234    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2235    (set (match_dup 0) (minus:SI (match_dup 0) (match_dup 2)))]
2236   "")
2238 (define_insn "*nabs_power"
2239   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2240         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r"))))]
2241   "TARGET_POWER"
2242   "nabs %0,%1")
2244 (define_insn_and_split "*nabs_nopower"
2245   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,r")
2246         (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,0"))))
2247    (clobber (match_scratch:SI 2 "=&r,&r"))]
2248   "! TARGET_POWER"
2249   "#"
2250   "&& reload_completed"
2251   [(set (match_dup 2) (ashiftrt:SI (match_dup 1) (const_int 31)))
2252    (set (match_dup 0) (xor:SI (match_dup 2) (match_dup 1)))
2253    (set (match_dup 0) (minus:SI (match_dup 2) (match_dup 0)))]
2254   "")
2256 (define_insn "negsi2"
2257   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2258         (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2259   ""
2260   "neg %0,%1")
2262 (define_insn ""
2263   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2264         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2265                     (const_int 0)))
2266    (clobber (match_scratch:SI 2 "=r,r"))]
2267   "! TARGET_POWERPC64"
2268   "@
2269    neg. %2,%1
2270    #"
2271   [(set_attr "type" "compare")
2272    (set_attr "length" "4,8")])
2274 (define_split
2275   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2276         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2277                     (const_int 0)))
2278    (clobber (match_scratch:SI 2 ""))]
2279   "! TARGET_POWERPC64 && reload_completed"
2280   [(set (match_dup 2)
2281         (neg:SI (match_dup 1)))
2282    (set (match_dup 0)
2283         (compare:CC (match_dup 2)
2284                     (const_int 0)))]
2285   "")
2287 (define_insn ""
2288   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
2289         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
2290                     (const_int 0)))
2291    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2292         (neg:SI (match_dup 1)))]
2293   "! TARGET_POWERPC64"
2294   "@
2295    neg. %0,%1
2296    #"
2297   [(set_attr "type" "compare")
2298    (set_attr "length" "4,8")])
2300 (define_split
2301   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
2302         (compare:CC (neg:SI (match_operand:SI 1 "gpc_reg_operand" ""))
2303                     (const_int 0)))
2304    (set (match_operand:SI 0 "gpc_reg_operand" "")
2305         (neg:SI (match_dup 1)))]
2306   "! TARGET_POWERPC64 && reload_completed"
2307   [(set (match_dup 0)
2308         (neg:SI (match_dup 1)))
2309    (set (match_dup 2)
2310         (compare:CC (match_dup 0)
2311                     (const_int 0)))]
2312   "")
2314 (define_insn "ffssi2"
2315   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
2316         (ffs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))]
2317   ""
2318   "neg %0,%1\;and %0,%0,%1\;{cntlz|cntlzw} %0,%0\;{sfi|subfic} %0,%0,32"
2319   [(set_attr "length" "16")])
2321 (define_expand "mulsi3"
2322   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2323    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2324    (use (match_operand:SI 2 "reg_or_short_operand" ""))]
2325   ""
2326   "
2328   if (TARGET_POWER)
2329     emit_insn (gen_mulsi3_mq (operands[0], operands[1], operands[2]));
2330   else
2331     emit_insn (gen_mulsi3_no_mq (operands[0], operands[1], operands[2]));
2332   DONE;
2335 (define_insn "mulsi3_mq"
2336   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2337         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2338                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))
2339    (clobber (match_scratch:SI 3 "=q,q"))]
2340   "TARGET_POWER"
2341   "@
2342    {muls|mullw} %0,%1,%2
2343    {muli|mulli} %0,%1,%2"
2344    [(set (attr "type") 
2345       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2346                 (const_string "imul3")
2347              (match_operand:SI 2 "short_cint_operand" "") 
2348                 (const_string "imul2")]
2349         (const_string "imul")))])
2351 (define_insn "mulsi3_no_mq"
2352   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2353         (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2354                  (match_operand:SI 2 "reg_or_short_operand" "r,I")))]
2355   "! TARGET_POWER"
2356   "@
2357    {muls|mullw} %0,%1,%2
2358    {muli|mulli} %0,%1,%2"
2359    [(set (attr "type") 
2360       (cond [(match_operand:SI 2 "s8bit_cint_operand" "")
2361                 (const_string "imul3")
2362              (match_operand:SI 2 "short_cint_operand" "") 
2363                 (const_string "imul2")]
2364         (const_string "imul")))])
2366 (define_insn ""
2367   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2368         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2369                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2370                     (const_int 0)))
2371    (clobber (match_scratch:SI 3 "=r,r"))
2372    (clobber (match_scratch:SI 4 "=q,q"))]
2373   "TARGET_POWER"
2374   "@
2375    {muls.|mullw.} %3,%1,%2
2376    #"
2377   [(set_attr "type" "delayed_compare")
2378    (set_attr "length" "4,8")])
2380 (define_split
2381   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2382         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2383                              (match_operand:SI 2 "gpc_reg_operand" ""))
2384                     (const_int 0)))
2385    (clobber (match_scratch:SI 3 ""))
2386    (clobber (match_scratch:SI 4 ""))]
2387   "TARGET_POWER && reload_completed"
2388   [(parallel [(set (match_dup 3)
2389         (mult:SI (match_dup 1) (match_dup 2)))
2390    (clobber (match_dup 4))])
2391    (set (match_dup 0)
2392         (compare:CC (match_dup 3)
2393                     (const_int 0)))]
2394   "")
2396 (define_insn ""
2397   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2398         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2399                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2400                     (const_int 0)))
2401    (clobber (match_scratch:SI 3 "=r,r"))]
2402   "! TARGET_POWER"
2403   "@
2404    {muls.|mullw.} %3,%1,%2
2405    #"
2406   [(set_attr "type" "delayed_compare")
2407    (set_attr "length" "4,8")])
2409 (define_split
2410   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2411         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2412                              (match_operand:SI 2 "gpc_reg_operand" ""))
2413                     (const_int 0)))
2414    (clobber (match_scratch:SI 3 ""))]
2415   "! TARGET_POWER && reload_completed"
2416   [(set (match_dup 3)
2417         (mult:SI (match_dup 1) (match_dup 2)))
2418    (set (match_dup 0)
2419         (compare:CC (match_dup 3)
2420                     (const_int 0)))]
2421   "")
2423 (define_insn ""
2424   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2425         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2426                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2427                     (const_int 0)))
2428    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2429         (mult:SI (match_dup 1) (match_dup 2)))
2430    (clobber (match_scratch:SI 4 "=q,q"))]
2431   "TARGET_POWER"
2432   "@
2433    {muls.|mullw.} %0,%1,%2
2434    #"
2435   [(set_attr "type" "delayed_compare")
2436    (set_attr "length" "4,8")])
2438 (define_split
2439   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2440         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2441                              (match_operand:SI 2 "gpc_reg_operand" ""))
2442                     (const_int 0)))
2443    (set (match_operand:SI 0 "gpc_reg_operand" "")
2444         (mult:SI (match_dup 1) (match_dup 2)))
2445    (clobber (match_scratch:SI 4 ""))]
2446   "TARGET_POWER && reload_completed"
2447   [(parallel [(set (match_dup 0)
2448         (mult:SI (match_dup 1) (match_dup 2)))
2449    (clobber (match_dup 4))])
2450    (set (match_dup 3)
2451         (compare:CC (match_dup 0)
2452                     (const_int 0)))]
2453   "")
2455 (define_insn ""
2456   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2457         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r")
2458                              (match_operand:SI 2 "gpc_reg_operand" "r,r"))
2459                     (const_int 0)))
2460    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2461         (mult:SI (match_dup 1) (match_dup 2)))]
2462   "! TARGET_POWER"
2463   "@
2464    {muls.|mullw.} %0,%1,%2
2465    #"
2466   [(set_attr "type" "delayed_compare")
2467    (set_attr "length" "4,8")])
2469 (define_split
2470   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2471         (compare:CC (mult:SI (match_operand:SI 1 "gpc_reg_operand" "")
2472                              (match_operand:SI 2 "gpc_reg_operand" ""))
2473                     (const_int 0)))
2474    (set (match_operand:SI 0 "gpc_reg_operand" "")
2475         (mult:SI (match_dup 1) (match_dup 2)))]
2476   "! TARGET_POWER && reload_completed"
2477   [(set (match_dup 0)
2478         (mult:SI (match_dup 1) (match_dup 2)))
2479    (set (match_dup 3)
2480         (compare:CC (match_dup 0)
2481                     (const_int 0)))]
2482   "")
2484 ;; Operand 1 is divided by operand 2; quotient goes to operand
2485 ;; 0 and remainder to operand 3.
2486 ;; ??? At some point, see what, if anything, we can do about if (x % y == 0).
2488 (define_expand "divmodsi4"
2489   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2490                    (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2491                            (match_operand:SI 2 "gpc_reg_operand" "")))
2492               (set (match_operand:SI 3 "gpc_reg_operand" "")
2493                    (mod:SI (match_dup 1) (match_dup 2)))])]
2494   "TARGET_POWER || (! TARGET_POWER && ! TARGET_POWERPC)"
2495   "
2497   if (! TARGET_POWER && ! TARGET_POWERPC)
2498     {
2499       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2500       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2501       emit_insn (gen_divss_call ());
2502       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2503       emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2504       DONE;
2505     }
2508 (define_insn ""
2509   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2510         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2511                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2512    (set (match_operand:SI 3 "gpc_reg_operand" "=q")
2513         (mod:SI (match_dup 1) (match_dup 2)))]
2514   "TARGET_POWER"
2515   "divs %0,%1,%2"
2516   [(set_attr "type" "idiv")])
2518 (define_expand "udivsi3"
2519   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2520         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2521                  (match_operand:SI 2 "gpc_reg_operand" "")))]
2522   "TARGET_POWERPC || (! TARGET_POWER && ! TARGET_POWERPC)"
2523   "
2525   if (! TARGET_POWER && ! TARGET_POWERPC)
2526     {
2527       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2528       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2529       emit_insn (gen_quous_call ());
2530       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2531       DONE;
2532     }
2533   else if (TARGET_POWER)
2534     {
2535       emit_insn (gen_udivsi3_mq (operands[0], operands[1], operands[2]));
2536       DONE;
2537     }
2540 (define_insn "udivsi3_mq"
2541   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2542         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2543                  (match_operand:SI 2 "gpc_reg_operand" "r")))
2544    (clobber (match_scratch:SI 3 "=q"))]
2545   "TARGET_POWERPC && TARGET_POWER"
2546   "divwu %0,%1,%2"
2547   [(set_attr "type" "idiv")])
2549 (define_insn "*udivsi3_no_mq"
2550   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2551         (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2552                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
2553   "TARGET_POWERPC && ! TARGET_POWER"
2554   "divwu %0,%1,%2"
2555   [(set_attr "type" "idiv")])
2557 ;; For powers of two we can do srai/aze for divide and then adjust for
2558 ;; modulus.  If it isn't a power of two, FAIL on POWER so divmodsi4 will be
2559 ;; used; for PowerPC, force operands into register and do a normal divide;
2560 ;; for AIX common-mode, use quoss call on register operands.
2561 (define_expand "divsi3"
2562   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2563         (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2564                 (match_operand:SI 2 "reg_or_cint_operand" "")))]
2565   ""
2566   "
2568   if (GET_CODE (operands[2]) == CONST_INT
2569       && INTVAL (operands[2]) > 0
2570       && exact_log2 (INTVAL (operands[2])) >= 0)
2571     ;
2572   else if (TARGET_POWERPC)
2573     {
2574       operands[2] = force_reg (SImode, operands[2]);
2575       if (TARGET_POWER)
2576         {
2577           emit_insn (gen_divsi3_mq (operands[0], operands[1], operands[2]));
2578           DONE;
2579         }
2580     }
2581   else if (TARGET_POWER)
2582     FAIL;
2583   else
2584     {
2585       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2586       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2587       emit_insn (gen_quoss_call ());
2588       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2589       DONE;
2590     }
2593 (define_insn "divsi3_mq"
2594   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2595         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2596                 (match_operand:SI 2 "gpc_reg_operand" "r")))
2597    (clobber (match_scratch:SI 3 "=q"))]
2598   "TARGET_POWERPC && TARGET_POWER"
2599   "divw %0,%1,%2"
2600   [(set_attr "type" "idiv")])
2602 (define_insn "*divsi3_no_mq"
2603   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2604         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2605                 (match_operand:SI 2 "gpc_reg_operand" "r")))]
2606   "TARGET_POWERPC && ! TARGET_POWER"
2607   "divw %0,%1,%2"
2608   [(set_attr "type" "idiv")])
2610 (define_expand "modsi3"
2611   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
2612    (use (match_operand:SI 1 "gpc_reg_operand" ""))
2613    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
2614   ""
2615   "
2617   int i;
2618   rtx temp1;
2619   rtx temp2;
2621   if (GET_CODE (operands[2]) != CONST_INT
2622       || INTVAL (operands[2]) <= 0
2623       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
2624     FAIL;
2626   temp1 = gen_reg_rtx (SImode);
2627   temp2 = gen_reg_rtx (SImode);
2629   emit_insn (gen_divsi3 (temp1, operands[1], operands[2]));
2630   emit_insn (gen_ashlsi3 (temp2, temp1, GEN_INT (i)));
2631   emit_insn (gen_subsi3 (operands[0], operands[1], temp2));
2632   DONE;
2635 (define_insn ""
2636   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2637         (div:SI (match_operand:SI 1 "gpc_reg_operand" "r")
2638                 (match_operand:SI 2 "exact_log2_cint_operand" "N")))]
2639   ""
2640   "{srai|srawi} %0,%1,%p2\;{aze|addze} %0,%0"
2641   [(set_attr "length" "8")])
2643 (define_insn ""
2644   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
2645         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2646                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2647                     (const_int 0)))
2648    (clobber (match_scratch:SI 3 "=r,r"))]
2649   ""
2650   "@
2651    {srai|srawi} %3,%1,%p2\;{aze.|addze.} %3,%3
2652    #"
2653   [(set_attr "type" "compare")
2654    (set_attr "length" "8,12")])
2656 (define_split
2657   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2658         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2659                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2660                     (const_int 0)))
2661    (clobber (match_scratch:SI 3 ""))]
2662   "reload_completed"
2663   [(set (match_dup 3)
2664         (div:SI (match_dup 1) (match_dup 2)))
2665    (set (match_dup 0)
2666         (compare:CC (match_dup 3)
2667                     (const_int 0)))]
2668   "")
2670 (define_insn ""
2671   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
2672         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
2673                             (match_operand:SI 2 "exact_log2_cint_operand" "N,N"))
2674                     (const_int 0)))
2675    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
2676         (div:SI (match_dup 1) (match_dup 2)))]
2677   ""
2678   "@
2679    {srai|srawi} %0,%1,%p2\;{aze.|addze.} %0,%0
2680    #"
2681   [(set_attr "type" "compare")
2682    (set_attr "length" "8,12")])
2684 (define_split
2685   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2686         (compare:CC (div:SI (match_operand:SI 1 "gpc_reg_operand" "")
2687                             (match_operand:SI 2 "exact_log2_cint_operand" ""))
2688                     (const_int 0)))
2689    (set (match_operand:SI 0 "gpc_reg_operand" "")
2690         (div:SI (match_dup 1) (match_dup 2)))]
2691   "reload_completed"
2692   [(set (match_dup 0)
2693         (div:SI (match_dup 1) (match_dup 2)))
2694    (set (match_dup 3)
2695         (compare:CC (match_dup 0)
2696                     (const_int 0)))]
2697   "")
2699 (define_insn ""
2700   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
2701         (udiv:SI
2702          (plus:DI (ashift:DI
2703                    (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "r"))
2704                    (const_int 32))
2705                   (zero_extend:DI (match_operand:SI 4 "register_operand" "2")))
2706          (match_operand:SI 3 "gpc_reg_operand" "r")))
2707    (set (match_operand:SI 2 "register_operand" "=*q")
2708         (umod:SI
2709          (plus:DI (ashift:DI
2710                    (zero_extend:DI (match_dup 1)) (const_int 32))
2711                   (zero_extend:DI (match_dup 4)))
2712          (match_dup 3)))]
2713   "TARGET_POWER"
2714   "div %0,%1,%3"
2715   [(set_attr "type" "idiv")])
2717 ;; To do unsigned divide we handle the cases of the divisor looking like a
2718 ;; negative number.  If it is a constant that is less than 2**31, we don't
2719 ;; have to worry about the branches.  So make a few subroutines here.
2721 ;; First comes the normal case.
2722 (define_expand "udivmodsi4_normal"
2723   [(set (match_dup 4) (const_int 0))
2724    (parallel [(set (match_operand:SI 0 "" "")
2725                    (udiv:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2726                                                 (const_int 32))
2727                                      (zero_extend:DI (match_operand:SI 1 "" "")))
2728                             (match_operand:SI 2 "" "")))
2729               (set (match_operand:SI 3 "" "")
2730                    (umod:SI (plus:DI (ashift:DI (zero_extend:DI (match_dup 4))
2731                                                 (const_int 32))
2732                                      (zero_extend:DI (match_dup 1)))
2733                             (match_dup 2)))])]
2734   "TARGET_POWER"
2735   "
2736 { operands[4] = gen_reg_rtx (SImode); }")
2738 ;; This handles the branches.
2739 (define_expand "udivmodsi4_tests"
2740   [(set (match_operand:SI 0 "" "") (const_int 0))
2741    (set (match_operand:SI 3 "" "") (match_operand:SI 1 "" ""))
2742    (set (match_dup 5) (compare:CCUNS (match_dup 1) (match_operand:SI 2 "" "")))
2743    (set (pc) (if_then_else (ltu (match_dup 5) (const_int 0))
2744                            (label_ref (match_operand:SI 4 "" "")) (pc)))
2745    (set (match_dup 0) (const_int 1))
2746    (set (match_dup 3) (minus:SI (match_dup 1) (match_dup 2)))
2747    (set (match_dup 6) (compare:CC (match_dup 2) (const_int 0)))
2748    (set (pc) (if_then_else (lt (match_dup 6) (const_int 0))
2749                            (label_ref (match_dup 4)) (pc)))]
2750   "TARGET_POWER"
2751   "
2752 { operands[5] = gen_reg_rtx (CCUNSmode);
2753   operands[6] = gen_reg_rtx (CCmode);
2756 (define_expand "udivmodsi4"
2757   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
2758                    (udiv:SI (match_operand:SI 1 "gpc_reg_operand" "")
2759                             (match_operand:SI 2 "reg_or_cint_operand" "")))
2760               (set (match_operand:SI 3 "gpc_reg_operand" "")
2761                    (umod:SI (match_dup 1) (match_dup 2)))])]
2762   ""
2763   "
2765   rtx label = 0;
2767   if (! TARGET_POWER)
2768     {
2769       if (! TARGET_POWERPC)
2770         {
2771           emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
2772           emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
2773           emit_insn (gen_divus_call ());
2774           emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
2775           emit_move_insn (operands[3], gen_rtx_REG (SImode, 4));
2776           DONE;
2777         }
2778       else
2779         FAIL;
2780     }
2782   if (GET_CODE (operands[2]) != CONST_INT || INTVAL (operands[2]) < 0)
2783     {
2784       operands[2] = force_reg (SImode, operands[2]);
2785       label = gen_label_rtx ();
2786       emit (gen_udivmodsi4_tests (operands[0], operands[1], operands[2],
2787                                   operands[3], label));
2788     }
2789   else
2790     operands[2] = force_reg (SImode, operands[2]);
2792   emit (gen_udivmodsi4_normal (operands[0], operands[1], operands[2],
2793                                operands[3]));
2794   if (label)
2795     emit_label (label);
2797   DONE;
2800 ;; AIX architecture-independent common-mode multiply (DImode),
2801 ;; divide/modulus, and quotient subroutine calls.  Input operands in R3 and
2802 ;; R4; results in R3 and sometimes R4; link register always clobbered by bla
2803 ;; instruction; R0 sometimes clobbered; also, MQ sometimes clobbered but
2804 ;; assumed unused if generating common-mode, so ignore.
2805 (define_insn "mulh_call"
2806   [(set (reg:SI 3)
2807         (truncate:SI
2808          (lshiftrt:DI (mult:DI (sign_extend:DI (reg:SI 3))
2809                                (sign_extend:DI (reg:SI 4)))
2810                       (const_int 32))))
2811    (clobber (match_scratch:SI 0 "=l"))]
2812   "! TARGET_POWER && ! TARGET_POWERPC"
2813   "bla __mulh"
2814   [(set_attr "type" "imul")])
2816 (define_insn "mull_call"
2817   [(set (reg:DI 3)
2818         (mult:DI (sign_extend:DI (reg:SI 3))
2819                  (sign_extend:DI (reg:SI 4))))
2820    (clobber (match_scratch:SI 0 "=l"))
2821    (clobber (reg:SI 0))]
2822   "! TARGET_POWER && ! TARGET_POWERPC"
2823   "bla __mull"
2824   [(set_attr "type" "imul")])
2826 (define_insn "divss_call"
2827   [(set (reg:SI 3)
2828         (div:SI (reg:SI 3) (reg:SI 4)))
2829    (set (reg:SI 4)
2830         (mod:SI (reg:SI 3) (reg:SI 4)))
2831    (clobber (match_scratch:SI 0 "=l"))
2832    (clobber (reg:SI 0))]
2833   "! TARGET_POWER && ! TARGET_POWERPC"
2834   "bla __divss"
2835   [(set_attr "type" "idiv")])
2837 (define_insn "divus_call"
2838   [(set (reg:SI 3)
2839         (udiv:SI (reg:SI 3) (reg:SI 4)))
2840    (set (reg:SI 4)
2841         (umod:SI (reg:SI 3) (reg:SI 4)))
2842    (clobber (match_scratch:SI 0 "=l"))
2843    (clobber (reg:SI 0))
2844    (clobber (match_scratch:CC 1 "=x"))
2845    (clobber (reg:CC 69))]
2846   "! TARGET_POWER && ! TARGET_POWERPC"
2847   "bla __divus"
2848   [(set_attr "type" "idiv")])
2850 (define_insn "quoss_call"
2851   [(set (reg:SI 3)
2852         (div:SI (reg:SI 3) (reg:SI 4)))
2853    (clobber (match_scratch:SI 0 "=l"))]
2854   "! TARGET_POWER && ! TARGET_POWERPC"
2855   "bla __quoss"
2856   [(set_attr "type" "idiv")])
2858 (define_insn "quous_call"
2859   [(set (reg:SI 3)
2860         (udiv:SI (reg:SI 3) (reg:SI 4)))
2861    (clobber (match_scratch:SI 0 "=l"))
2862    (clobber (reg:SI 0))
2863    (clobber (match_scratch:CC 1 "=x"))
2864    (clobber (reg:CC 69))]
2865   "! TARGET_POWER && ! TARGET_POWERPC"
2866   "bla __quous"
2867   [(set_attr "type" "idiv")])
2869 ;; Logical instructions
2870 ;; The logical instructions are mostly combined by using match_operator,
2871 ;; but the plain AND insns are somewhat different because there is no
2872 ;; plain 'andi' (only 'andi.'), no plain 'andis', and there are all
2873 ;; those rotate-and-mask operations.  Thus, the AND insns come first.
2875 (define_insn "andsi3"
2876   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
2877         (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r")
2878                 (match_operand:SI 2 "and_operand" "?r,T,K,L")))
2879    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
2880   ""
2881   "@
2882    and %0,%1,%2
2883    {rlinm|rlwinm} %0,%1,0,%m2,%M2
2884    {andil.|andi.} %0,%1,%b2
2885    {andiu.|andis.} %0,%1,%u2")
2887 ;; Note to set cr's other than cr0 we do the and immediate and then
2888 ;; the test again -- this avoids a mcrf which on the higher end
2889 ;; machines causes an execution serialization
2891 (define_insn "*andsi3_internal2"
2892   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2893         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2894                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2895                     (const_int 0)))
2896    (clobber (match_scratch:SI 3 "=r,r,r,r,r,r,r,r"))
2897    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2898   "! TARGET_POWERPC64"
2899   "@
2900    and. %3,%1,%2
2901    {andil.|andi.} %3,%1,%b2
2902    {andiu.|andis.} %3,%1,%u2
2903    {rlinm.|rlwinm.} %3,%1,0,%m2,%M2
2904    #
2905    #
2906    #
2907    #"
2908   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2909    (set_attr "length" "4,4,4,4,8,8,8,8")])
2911 (define_split
2912   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
2913         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2914                             (match_operand:SI 2 "and_operand" ""))
2915                     (const_int 0)))
2916    (clobber (match_scratch:SI 3 ""))
2917    (clobber (match_scratch:CC 4 ""))]
2918   "! TARGET_POWERPC64 && reload_completed"
2919   [(parallel [(set (match_dup 3)
2920                    (and:SI (match_dup 1)
2921                            (match_dup 2)))
2922               (clobber (match_dup 4))])
2923    (set (match_dup 0)
2924         (compare:CC (match_dup 3)
2925                     (const_int 0)))]
2926   "")
2928 (define_insn "*andsi3_internal3"
2929   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,??y,??y,?y")
2930         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
2931                             (match_operand:SI 2 "and_operand" "r,K,L,T,r,K,L,T"))
2932                     (const_int 0)))
2933    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
2934         (and:SI (match_dup 1)
2935                 (match_dup 2)))
2936    (clobber (match_scratch:CC 4 "=X,X,X,X,X,x,x,X"))]
2937   "! TARGET_POWERPC64"
2938   "@
2939    and. %0,%1,%2
2940    {andil.|andi.} %0,%1,%b2
2941    {andiu.|andis.} %0,%1,%u2
2942    {rlinm.|rlwinm.} %0,%1,0,%m2,%M2
2943    #
2944    #
2945    #
2946    #"
2947   [(set_attr "type" "compare,compare,compare,delayed_compare,compare,compare,compare,compare")
2948    (set_attr "length" "4,4,4,4,8,8,8,8")])
2950 (define_split
2951   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
2952         (compare:CC (and:SI (match_operand:SI 1 "gpc_reg_operand" "")
2953                             (match_operand:SI 2 "and_operand" ""))
2954                     (const_int 0)))
2955    (set (match_operand:SI 0 "gpc_reg_operand" "")
2956         (and:SI (match_dup 1)
2957                 (match_dup 2)))
2958    (clobber (match_scratch:CC 4 ""))]
2959   "! TARGET_POWERPC64 && reload_completed"
2960   [(parallel [(set (match_dup 0)
2961                    (and:SI (match_dup 1)
2962                            (match_dup 2)))
2963               (clobber (match_dup 4))])
2964    (set (match_dup 3)
2965         (compare:CC (match_dup 0)
2966                     (const_int 0)))]
2967   "")
2969 (define_expand "iorsi3"
2970   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2971         (ior:SI (match_operand:SI 1 "gpc_reg_operand" "")
2972                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2973   ""
2974   "
2976   if (GET_CODE (operands[2]) == CONST_INT
2977       && ! logical_operand (operands[2], SImode))
2978     {
2979       HOST_WIDE_INT value = INTVAL (operands[2]);
2980       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
2981                  ? operands[0] : gen_reg_rtx (SImode));
2983       emit_insn (gen_iorsi3 (tmp, operands[1],
2984                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
2985       emit_insn (gen_iorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
2986       DONE;
2987     }
2990 (define_expand "xorsi3"
2991   [(set (match_operand:SI 0 "gpc_reg_operand" "")
2992         (xor:SI (match_operand:SI 1 "gpc_reg_operand" "")
2993                 (match_operand:SI 2 "reg_or_logical_cint_operand" "")))]
2994   ""
2995   "
2997   if (GET_CODE (operands[2]) == CONST_INT
2998       && ! logical_operand (operands[2], SImode))
2999     {
3000       HOST_WIDE_INT value = INTVAL (operands[2]);
3001       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
3002                  ? operands[0] : gen_reg_rtx (SImode));
3004       emit_insn (gen_xorsi3 (tmp, operands[1],
3005                              GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
3006       emit_insn (gen_xorsi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
3007       DONE;
3008     }
3011 (define_insn "*boolsi3_internal1"
3012   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
3013         (match_operator:SI 3 "boolean_or_operator"
3014          [(match_operand:SI 1 "gpc_reg_operand" "%r,r,r")
3015           (match_operand:SI 2 "logical_operand" "r,K,L")]))]
3016   ""
3017   "@
3018    %q3 %0,%1,%2
3019    {%q3il|%q3i} %0,%1,%b2
3020    {%q3iu|%q3is} %0,%1,%u2")
3022 (define_insn "*boolsi3_internal2"
3023   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3024         (compare:CC (match_operator:SI 4 "boolean_or_operator"
3025          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3026           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3027          (const_int 0)))
3028    (clobber (match_scratch:SI 3 "=r,r"))]
3029   "! TARGET_POWERPC64"
3030   "@
3031    %q4. %3,%1,%2
3032    #"
3033   [(set_attr "type" "compare")
3034    (set_attr "length" "4,8")])
3036 (define_split
3037   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3038         (compare:CC (match_operator:SI 4 "boolean_operator"
3039          [(match_operand:SI 1 "gpc_reg_operand" "")
3040           (match_operand:SI 2 "gpc_reg_operand" "")])
3041          (const_int 0)))
3042    (clobber (match_scratch:SI 3 ""))]
3043   "! TARGET_POWERPC64 && reload_completed"
3044   [(set (match_dup 3) (match_dup 4))
3045    (set (match_dup 0)
3046         (compare:CC (match_dup 3)
3047                     (const_int 0)))]
3048   "")
3050 (define_insn "*boolsi3_internal3"
3051   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3052         (compare:CC (match_operator:SI 4 "boolean_operator"
3053          [(match_operand:SI 1 "gpc_reg_operand" "%r,r")
3054           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3055          (const_int 0)))
3056    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3057         (match_dup 4))]
3058   "! TARGET_POWERPC64"
3059   "@
3060    %q4. %0,%1,%2
3061    #"
3062   [(set_attr "type" "compare")
3063    (set_attr "length" "4,8")])
3065 (define_split
3066   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3067         (compare:CC (match_operator:SI 4 "boolean_operator"
3068          [(match_operand:SI 1 "gpc_reg_operand" "")
3069           (match_operand:SI 2 "gpc_reg_operand" "")])
3070          (const_int 0)))
3071    (set (match_operand:SI 0 "gpc_reg_operand" "")
3072         (match_dup 4))]
3073   "! TARGET_POWERPC64 && reload_completed"
3074   [(set (match_dup 0) (match_dup 4))
3075    (set (match_dup 3)
3076         (compare:CC (match_dup 0)
3077                     (const_int 0)))]
3078   "")
3080 ;; Split an logical operation that we can't do in one insn into two insns, 
3081 ;; each of which does one 16-bit part.  This is used by combine.
3083 (define_split
3084   [(set (match_operand:SI 0 "gpc_reg_operand" "")
3085         (match_operator:SI 3 "boolean_or_operator"
3086          [(match_operand:SI 1 "gpc_reg_operand" "")
3087           (match_operand:SI 2 "non_logical_cint_operand" "")]))]
3088   ""
3089   [(set (match_dup 0) (match_dup 4))
3090    (set (match_dup 0) (match_dup 5))]
3093   rtx i;
3094   i = GEN_INT (INTVAL (operands[2]) & (~ (HOST_WIDE_INT) 0xffff));
3095   operands[4] = gen_rtx (GET_CODE (operands[3]), SImode,
3096                          operands[1], i);
3097   i = GEN_INT (INTVAL (operands[2]) & 0xffff);
3098   operands[5] = gen_rtx (GET_CODE (operands[3]), SImode,
3099                          operands[0], i);
3102 (define_insn "*boolcsi3_internal1"
3103   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3104         (match_operator:SI 3 "boolean_operator"
3105          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3106           (match_operand:SI 2 "gpc_reg_operand" "r")]))]
3107   ""
3108   "%q3 %0,%2,%1")
3110 (define_insn "*boolcsi3_internal2"
3111   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3112         (compare:CC (match_operator:SI 4 "boolean_operator"
3113          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3114           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3115          (const_int 0)))
3116    (clobber (match_scratch:SI 3 "=r,r"))]
3117   "! TARGET_POWERPC64"
3118   "@
3119    %q4. %3,%2,%1
3120    #"
3121   [(set_attr "type" "compare")
3122    (set_attr "length" "4,8")])
3124 (define_split
3125   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3126         (compare:CC (match_operator:SI 4 "boolean_operator"
3127          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3128           (match_operand:SI 2 "gpc_reg_operand" "")])
3129          (const_int 0)))
3130    (clobber (match_scratch:SI 3 ""))]
3131   "! TARGET_POWERPC64 && reload_completed"
3132   [(set (match_dup 3) (match_dup 4))
3133    (set (match_dup 0)
3134         (compare:CC (match_dup 3)
3135                     (const_int 0)))]
3136   "")
3138 (define_insn "*boolcsi3_internal3"
3139   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3140         (compare:CC (match_operator:SI 4 "boolean_operator"
3141          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3142           (match_operand:SI 2 "gpc_reg_operand" "r,r")])
3143          (const_int 0)))
3144    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3145         (match_dup 4))]
3146   "! TARGET_POWERPC64"
3147   "@
3148    %q4. %0,%2,%1
3149    #"
3150   [(set_attr "type" "compare")
3151    (set_attr "length" "4,8")])
3153 (define_split
3154   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3155         (compare:CC (match_operator:SI 4 "boolean_operator"
3156          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3157           (match_operand:SI 2 "gpc_reg_operand" "")])
3158          (const_int 0)))
3159    (set (match_operand:SI 0 "gpc_reg_operand" "")
3160         (match_dup 4))]
3161   "! TARGET_POWERPC64 && reload_completed"
3162   [(set (match_dup 0) (match_dup 4))
3163    (set (match_dup 3)
3164         (compare:CC (match_dup 0)
3165                     (const_int 0)))]
3166   "")
3168 (define_insn "*boolccsi3_internal1"
3169   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3170         (match_operator:SI 3 "boolean_operator"
3171          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r"))
3172           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))]))]
3173   ""
3174   "%q3 %0,%1,%2")
3176 (define_insn "*boolccsi3_internal2"
3177   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3178         (compare:CC (match_operator:SI 4 "boolean_operator"
3179          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "r,r"))
3180           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3181          (const_int 0)))
3182    (clobber (match_scratch:SI 3 "=r,r"))]
3183   "! TARGET_POWERPC64"
3184   "@
3185    %q4. %3,%1,%2
3186    #"
3187   [(set_attr "type" "compare")
3188    (set_attr "length" "4,8")])
3190 (define_split
3191   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3192         (compare:CC (match_operator:SI 4 "boolean_operator"
3193          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3194           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3195          (const_int 0)))
3196    (clobber (match_scratch:SI 3 ""))]
3197   "! TARGET_POWERPC64 && reload_completed"
3198   [(set (match_dup 3) (match_dup 4))
3199    (set (match_dup 0)
3200         (compare:CC (match_dup 3)
3201                     (const_int 0)))]
3202   "")
3204 (define_insn "*boolccsi3_internal3"
3205   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3206         (compare:CC (match_operator:SI 4 "boolean_operator"
3207          [(not:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r"))
3208           (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))])
3209          (const_int 0)))
3210    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3211         (match_dup 4))]
3212   "! TARGET_POWERPC64"
3213   "@
3214    %q4. %0,%1,%2
3215    #"
3216   [(set_attr "type" "compare")
3217    (set_attr "length" "4,8")])
3219 (define_split
3220   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3221         (compare:CC (match_operator:SI 4 "boolean_operator"
3222          [(not:SI (match_operand:SI 1 "gpc_reg_operand" ""))
3223           (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))])
3224          (const_int 0)))
3225    (set (match_operand:SI 0 "gpc_reg_operand" "")
3226         (match_dup 4))]
3227   "! TARGET_POWERPC64 && reload_completed"
3228   [(set (match_dup 0) (match_dup 4))
3229    (set (match_dup 3)
3230         (compare:CC (match_dup 0)
3231                     (const_int 0)))]
3232   "")
3234 ;; maskir insn.  We need four forms because things might be in arbitrary
3235 ;; orders.  Don't define forms that only set CR fields because these
3236 ;; would modify an input register.
3238 (define_insn "*maskir_internal1"
3239   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3240         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3241                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3242                 (and:SI (match_dup 2)
3243                         (match_operand:SI 3 "gpc_reg_operand" "r"))))]
3244   "TARGET_POWER"
3245   "maskir %0,%3,%2")
3247 (define_insn "*maskir_internal2"
3248   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3249         (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r"))
3250                         (match_operand:SI 1 "gpc_reg_operand" "0"))
3251                 (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3252                         (match_dup 2))))]
3253   "TARGET_POWER"
3254   "maskir %0,%3,%2")
3256 (define_insn "*maskir_internal3"
3257   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3258         (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r")
3259                         (match_operand:SI 3 "gpc_reg_operand" "r"))
3260                 (and:SI (not:SI (match_dup 2))
3261                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3262   "TARGET_POWER"
3263   "maskir %0,%3,%2")
3265 (define_insn "*maskir_internal4"
3266   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3267         (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3268                         (match_operand:SI 2 "gpc_reg_operand" "r"))
3269                 (and:SI (not:SI (match_dup 2))
3270                         (match_operand:SI 1 "gpc_reg_operand" "0"))))]
3271   "TARGET_POWER"
3272   "maskir %0,%3,%2")
3274 (define_insn "*maskir_internal5"
3275   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3276         (compare:CC
3277          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3278                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3279                  (and:SI (match_dup 2)
3280                          (match_operand:SI 3 "gpc_reg_operand" "r,r")))
3281          (const_int 0)))
3282    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3283         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3284                 (and:SI (match_dup 2) (match_dup 3))))]
3285   "TARGET_POWER"
3286   "@
3287    maskir. %0,%3,%2
3288    #"
3289   [(set_attr "type" "compare")
3290    (set_attr "length" "4,8")])
3292 (define_split
3293   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3294         (compare:CC
3295          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3296                          (match_operand:SI 1 "gpc_reg_operand" ""))
3297                  (and:SI (match_dup 2)
3298                          (match_operand:SI 3 "gpc_reg_operand" "")))
3299          (const_int 0)))
3300    (set (match_operand:SI 0 "gpc_reg_operand" "")
3301         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3302                 (and:SI (match_dup 2) (match_dup 3))))]
3303   "TARGET_POWER && reload_completed"
3304   [(set (match_dup 0)
3305         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3306                 (and:SI (match_dup 2) (match_dup 3))))
3307    (set (match_dup 4)
3308         (compare:CC (match_dup 0)
3309                     (const_int 0)))]
3310   "")
3312 (define_insn "*maskir_internal6"
3313   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3314         (compare:CC
3315          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3316                          (match_operand:SI 1 "gpc_reg_operand" "0,0"))
3317                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3318                          (match_dup 2)))
3319          (const_int 0)))
3320    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3321         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3322                 (and:SI (match_dup 3) (match_dup 2))))]
3323   "TARGET_POWER"
3324   "@
3325    maskir. %0,%3,%2
3326    #"
3327   [(set_attr "type" "compare")
3328    (set_attr "length" "4,8")])
3330 (define_split
3331   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3332         (compare:CC
3333          (ior:SI (and:SI (not:SI (match_operand:SI 2 "gpc_reg_operand" ""))
3334                          (match_operand:SI 1 "gpc_reg_operand" ""))
3335                  (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3336                          (match_dup 2)))
3337          (const_int 0)))
3338    (set (match_operand:SI 0 "gpc_reg_operand" "")
3339         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3340                 (and:SI (match_dup 3) (match_dup 2))))]
3341   "TARGET_POWER && reload_completed"
3342   [(set (match_dup 0)
3343         (ior:SI (and:SI (not:SI (match_dup 2)) (match_dup 1))
3344                 (and:SI (match_dup 3) (match_dup 2))))
3345    (set (match_dup 4)
3346         (compare:CC (match_dup 0)
3347                     (const_int 0)))]
3348   "")
3350 (define_insn "*maskir_internal7"
3351   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3352         (compare:CC
3353          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "r,r")
3354                          (match_operand:SI 3 "gpc_reg_operand" "r,r"))
3355                  (and:SI (not:SI (match_dup 2))
3356                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3357          (const_int 0)))
3358    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3359         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3360                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3361   "TARGET_POWER"
3362   "@
3363    maskir. %0,%3,%2
3364    #"
3365   [(set_attr "type" "compare")
3366    (set_attr "length" "4,8")])
3368 (define_split
3369   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3370         (compare:CC
3371          (ior:SI (and:SI (match_operand:SI 2 "gpc_reg_operand" "")
3372                          (match_operand:SI 3 "gpc_reg_operand" ""))
3373                  (and:SI (not:SI (match_dup 2))
3374                          (match_operand:SI 1 "gpc_reg_operand" "")))
3375          (const_int 0)))
3376    (set (match_operand:SI 0 "gpc_reg_operand" "")
3377         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3378                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3379   "TARGET_POWER && reload_completed"
3380   [(set (match_dup 0)
3381         (ior:SI (and:SI (match_dup 2) (match_dup 3))
3382                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3383    (set (match_dup 4)
3384         (compare:CC (match_dup 0)
3385                     (const_int 0)))]
3386   "")
3388 (define_insn "*maskir_internal8"
3389   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3390         (compare:CC
3391          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "r,r")
3392                          (match_operand:SI 2 "gpc_reg_operand" "r,r"))
3393                  (and:SI (not:SI (match_dup 2))
3394                          (match_operand:SI 1 "gpc_reg_operand" "0,0")))
3395          (const_int 0)))
3396    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3397         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3398                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3399   "TARGET_POWER"
3400   "@
3401    maskir. %0,%3,%2
3402    #"
3403   [(set_attr "type" "compare")
3404    (set_attr "length" "4,8")])
3406 (define_split
3407   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3408         (compare:CC
3409          (ior:SI (and:SI (match_operand:SI 3 "gpc_reg_operand" "")
3410                          (match_operand:SI 2 "gpc_reg_operand" ""))
3411                  (and:SI (not:SI (match_dup 2))
3412                          (match_operand:SI 1 "gpc_reg_operand" "")))
3413          (const_int 0)))
3414    (set (match_operand:SI 0 "gpc_reg_operand" "")
3415         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3416                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))]
3417   "TARGET_POWER && reload_completed"
3418   [(set (match_dup 0)
3419         (ior:SI (and:SI (match_dup 3) (match_dup 2))
3420                 (and:SI (not:SI (match_dup 2)) (match_dup 1))))
3421    (set (match_dup 4)
3422         (compare:CC (match_dup 0)
3423                     (const_int 0)))]
3424   "")
3426 ;; Rotate and shift insns, in all their variants.  These support shifts,
3427 ;; field inserts and extracts, and various combinations thereof.
3428 (define_expand "insv"
3429   [(set (zero_extract (match_operand 0 "gpc_reg_operand" "")
3430                        (match_operand:SI 1 "const_int_operand" "")
3431                        (match_operand:SI 2 "const_int_operand" ""))
3432         (match_operand 3 "gpc_reg_operand" ""))]
3433   ""
3434   "
3436   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3437      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3438      compiler if the address of the structure is taken later.  */
3439   if (GET_CODE (operands[0]) == SUBREG
3440       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3441     FAIL;
3443   if (TARGET_POWERPC64 && GET_MODE (operands[0]) == DImode)
3444     emit_insn (gen_insvdi (operands[0], operands[1], operands[2], operands[3]));
3445   else
3446     emit_insn (gen_insvsi (operands[0], operands[1], operands[2], operands[3]));
3447   DONE;
3450 (define_insn "insvsi"
3451   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3452                          (match_operand:SI 1 "const_int_operand" "i")
3453                          (match_operand:SI 2 "const_int_operand" "i"))
3454         (match_operand:SI 3 "gpc_reg_operand" "r"))]
3455   ""
3456   "*
3458   int start = INTVAL (operands[2]) & 31;
3459   int size = INTVAL (operands[1]) & 31;
3461   operands[4] = GEN_INT (32 - start - size);
3462   operands[1] = GEN_INT (start + size - 1);
3463   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3466 (define_insn "*insvsi_internal1"
3467   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3468                          (match_operand:SI 1 "const_int_operand" "i")
3469                          (match_operand:SI 2 "const_int_operand" "i"))
3470         (ashift:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3471                    (match_operand:SI 4 "const_int_operand" "i")))]
3472   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3473   "*
3475   int shift = INTVAL (operands[4]) & 31;
3476   int start = INTVAL (operands[2]) & 31;
3477   int size = INTVAL (operands[1]) & 31;
3479   operands[4] = GEN_INT (shift - start - size);
3480   operands[1] = GEN_INT (start + size - 1);
3481   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3484 (define_insn "*insvsi_internal2"
3485   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3486                          (match_operand:SI 1 "const_int_operand" "i")
3487                          (match_operand:SI 2 "const_int_operand" "i"))
3488         (ashiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3489                      (match_operand:SI 4 "const_int_operand" "i")))]
3490   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3491   "*
3493   int shift = INTVAL (operands[4]) & 31;
3494   int start = INTVAL (operands[2]) & 31;
3495   int size = INTVAL (operands[1]) & 31;
3497   operands[4] = GEN_INT (32 - shift - start - size);
3498   operands[1] = GEN_INT (start + size - 1);
3499   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3502 (define_insn "*insvsi_internal3"
3503   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3504                          (match_operand:SI 1 "const_int_operand" "i")
3505                          (match_operand:SI 2 "const_int_operand" "i"))
3506         (lshiftrt:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3507                      (match_operand:SI 4 "const_int_operand" "i")))]
3508   "(32 - (INTVAL (operands[4]) & 31)) >= INTVAL (operands[1])"
3509   "*
3511   int shift = INTVAL (operands[4]) & 31;
3512   int start = INTVAL (operands[2]) & 31;
3513   int size = INTVAL (operands[1]) & 31;
3515   operands[4] = GEN_INT (32 - shift - start - size);
3516   operands[1] = GEN_INT (start + size - 1);
3517   return \"{rlimi|rlwimi} %0,%3,%h4,%h2,%h1\";
3520 (define_insn "*insvsi_internal4"
3521   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
3522                          (match_operand:SI 1 "const_int_operand" "i")
3523                          (match_operand:SI 2 "const_int_operand" "i"))
3524         (zero_extract:SI (match_operand:SI 3 "gpc_reg_operand" "r")
3525                          (match_operand:SI 4 "const_int_operand" "i")
3526                          (match_operand:SI 5 "const_int_operand" "i")))]
3527   "INTVAL (operands[4]) >= INTVAL (operands[1])"
3528   "*
3530   int extract_start = INTVAL (operands[5]) & 31;
3531   int extract_size = INTVAL (operands[4]) & 31;
3532   int insert_start = INTVAL (operands[2]) & 31;
3533   int insert_size = INTVAL (operands[1]) & 31;
3535 /* Align extract field with insert field */
3536   operands[5] = GEN_INT (extract_start + extract_size - insert_start - insert_size);
3537   operands[1] = GEN_INT (insert_start + insert_size - 1);
3538   return \"{rlimi|rlwimi} %0,%3,%h5,%h2,%h1\";
3541 (define_insn "insvdi"
3542   [(set (zero_extract:DI (match_operand:DI 0 "gpc_reg_operand" "+r")
3543                          (match_operand:SI 1 "const_int_operand" "i")
3544                          (match_operand:SI 2 "const_int_operand" "i"))
3545         (match_operand:DI 3 "gpc_reg_operand" "r"))]
3546   "TARGET_POWERPC64"
3547   "*
3549   int start = INTVAL (operands[2]) & 63;
3550   int size = INTVAL (operands[1]) & 63;
3552   operands[1] = GEN_INT (64 - start - size);
3553   return \"rldimi %0,%3,%H1,%H2\";
3556 (define_expand "extzv"
3557   [(set (match_operand 0 "gpc_reg_operand" "")
3558         (zero_extract (match_operand 1 "gpc_reg_operand" "")
3559                        (match_operand:SI 2 "const_int_operand" "")
3560                        (match_operand:SI 3 "const_int_operand" "")))]
3561   ""
3562   "
3564   /* Do not handle 16/8 bit structures that fit in HI/QI modes directly, since
3565      the (SUBREG:SI (REG:HI xxx)) that is otherwise generated can confuse the
3566      compiler if the address of the structure is taken later.  */
3567   if (GET_CODE (operands[0]) == SUBREG
3568       && (GET_MODE_SIZE (GET_MODE (SUBREG_REG (operands[0]))) < UNITS_PER_WORD))
3569     FAIL;
3571   if (TARGET_POWERPC64 && GET_MODE (operands[1]) == DImode)
3572     emit_insn (gen_extzvdi (operands[0], operands[1], operands[2], operands[3]));
3573   else
3574     emit_insn (gen_extzvsi (operands[0], operands[1], operands[2], operands[3]));
3575   DONE;
3578 (define_insn "extzvsi"
3579   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3580         (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3581                          (match_operand:SI 2 "const_int_operand" "i")
3582                          (match_operand:SI 3 "const_int_operand" "i")))]
3583   ""
3584   "*
3586   int start = INTVAL (operands[3]) & 31;
3587   int size = INTVAL (operands[2]) & 31;
3589   if (start + size >= 32)
3590     operands[3] = const0_rtx;
3591   else
3592     operands[3] = GEN_INT (start + size);
3593   return \"{rlinm|rlwinm} %0,%1,%3,%s2,31\";
3596 (define_insn "*extzvsi_internal1"
3597   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3598         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3599                          (match_operand:SI 2 "const_int_operand" "i,i")
3600                          (match_operand:SI 3 "const_int_operand" "i,i"))
3601                     (const_int 0)))
3602    (clobber (match_scratch:SI 4 "=r,r"))]
3603   "! TARGET_POWERPC64"
3604   "*
3606   int start = INTVAL (operands[3]) & 31;
3607   int size = INTVAL (operands[2]) & 31;
3609   /* Force split for non-cc0 compare.  */
3610   if (which_alternative == 1)
3611      return \"#\";
3613   /* If the bitfield being tested fits in the upper or lower half of a
3614      word, it is possible to use andiu. or andil. to test it.  This is
3615      useful because the condition register set-use delay is smaller for
3616      andi[ul]. than for rlinm.  This doesn't work when the starting bit
3617      position is 0 because the LT and GT bits may be set wrong.  */
3619   if ((start > 0 && start + size <= 16) || start >= 16)
3620     {
3621       operands[3] = GEN_INT (((1 << (16 - (start & 15)))
3622                               - (1 << (16 - (start & 15) - size))));
3623       if (start < 16)
3624         return \"{andiu.|andis.} %4,%1,%3\";
3625       else
3626         return \"{andil.|andi.} %4,%1,%3\";
3627     }
3629   if (start + size >= 32)
3630     operands[3] = const0_rtx;
3631   else
3632     operands[3] = GEN_INT (start + size);
3633   return \"{rlinm.|rlwinm.} %4,%1,%3,%s2,31\";
3635   [(set_attr "type" "compare")
3636    (set_attr "length" "4,8")])
3638 (define_split
3639   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3640         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3641                          (match_operand:SI 2 "const_int_operand" "")
3642                          (match_operand:SI 3 "const_int_operand" ""))
3643                     (const_int 0)))
3644    (clobber (match_scratch:SI 4 ""))]
3645   "! TARGET_POWERPC64 && reload_completed"
3646   [(set (match_dup 4)
3647         (zero_extract:SI (match_dup 1) (match_dup 2)
3648                          (match_dup 3)))
3649    (set (match_dup 0)
3650         (compare:CC (match_dup 4)
3651                     (const_int 0)))]
3652   "")
3654 (define_insn "*extzvsi_internal2"
3655   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3656         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3657                          (match_operand:SI 2 "const_int_operand" "i,i")
3658                          (match_operand:SI 3 "const_int_operand" "i,i"))
3659                     (const_int 0)))
3660    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3661         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3662   "! TARGET_POWERPC64"
3663   "*
3665   int start = INTVAL (operands[3]) & 31;
3666   int size = INTVAL (operands[2]) & 31;
3668   /* Force split for non-cc0 compare.  */
3669   if (which_alternative == 1)
3670      return \"#\";
3672   if (start >= 16 && start + size == 32)
3673     {
3674       operands[3] = GEN_INT ((1 << (32 - start)) - 1);
3675       return \"{andil.|andi.} %0,%1,%3\";
3676     }
3678   if (start + size >= 32)
3679     operands[3] = const0_rtx;
3680   else
3681     operands[3] = GEN_INT (start + size);
3682   return \"{rlinm.|rlwinm.} %0,%1,%3,%s2,31\";
3684   [(set_attr "type" "delayed_compare")
3685    (set_attr "length" "4,8")])
3687 (define_split
3688   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3689         (compare:CC (zero_extract:SI (match_operand:SI 1 "gpc_reg_operand" "")
3690                          (match_operand:SI 2 "const_int_operand" "")
3691                          (match_operand:SI 3 "const_int_operand" ""))
3692                     (const_int 0)))
3693    (set (match_operand:SI 0 "gpc_reg_operand" "")
3694         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))]
3695   "! TARGET_POWERPC64 && reload_completed"
3696   [(set (match_dup 0)
3697         (zero_extract:SI (match_dup 1) (match_dup 2) (match_dup 3)))
3698    (set (match_dup 4)
3699         (compare:CC (match_dup 0)
3700                     (const_int 0)))]
3701   "")
3703 (define_insn "extzvdi"
3704   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
3705         (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3706                          (match_operand:SI 2 "const_int_operand" "i")
3707                          (match_operand:SI 3 "const_int_operand" "i")))]
3708   "TARGET_POWERPC64"
3709   "*
3711   int start = INTVAL (operands[3]) & 63;
3712   int size = INTVAL (operands[2]) & 63;
3714   if (start + size >= 64)
3715     operands[3] = const0_rtx;
3716   else
3717     operands[3] = GEN_INT (start + size);
3718   operands[2] = GEN_INT (64 - size);
3719   return \"rldicl %0,%1,%3,%2\";
3722 (define_insn "*extzvdi_internal1"
3723   [(set (match_operand:CC 0 "gpc_reg_operand" "=x")
3724         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3725                          (match_operand:SI 2 "const_int_operand" "i")
3726                          (match_operand:SI 3 "const_int_operand" "i"))
3727                     (const_int 0)))
3728    (clobber (match_scratch:DI 4 "=r"))]
3729   "TARGET_POWERPC64"
3730   "*
3732   int start = INTVAL (operands[3]) & 63;
3733   int size = INTVAL (operands[2]) & 63;
3735   if (start + size >= 64)
3736     operands[3] = const0_rtx;
3737   else
3738     operands[3] = GEN_INT (start + size);
3739   operands[2] = GEN_INT (64 - size);
3740   return \"rldicl. %4,%1,%3,%2\";
3743 (define_insn "*extzvdi_internal2"
3744   [(set (match_operand:CC 4 "gpc_reg_operand" "=x")
3745         (compare:CC (zero_extract:DI (match_operand:DI 1 "gpc_reg_operand" "r")
3746                          (match_operand:SI 2 "const_int_operand" "i")
3747                          (match_operand:SI 3 "const_int_operand" "i"))
3748                     (const_int 0)))
3749    (set (match_operand:DI 0 "gpc_reg_operand" "=r")
3750         (zero_extract:DI (match_dup 1) (match_dup 2) (match_dup 3)))]
3751   "TARGET_POWERPC64"
3752   "*
3754   int start = INTVAL (operands[3]) & 63;
3755   int size = INTVAL (operands[2]) & 63;
3757   if (start + size >= 64)
3758     operands[3] = const0_rtx;
3759   else
3760     operands[3] = GEN_INT (start + size);
3761   operands[2] = GEN_INT (64 - size);
3762   return \"rldicl. %0,%1,%3,%2\";
3765 (define_insn "rotlsi3"
3766   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3767         (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3768                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
3769   ""
3770   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffffffff")
3772 (define_insn "*rotlsi3_internal2"
3773   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3774         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3775                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3776                     (const_int 0)))
3777    (clobber (match_scratch:SI 3 "=r,r"))]
3778   "! TARGET_POWERPC64"
3779   "@
3780    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffffffff
3781    #"
3782   [(set_attr "type" "delayed_compare")
3783    (set_attr "length" "4,8")])
3785 (define_split
3786   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3787         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3788                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3789                     (const_int 0)))
3790    (clobber (match_scratch:SI 3 ""))]
3791   "! TARGET_POWERPC64 && reload_completed"
3792   [(set (match_dup 3)
3793         (rotate:SI (match_dup 1) (match_dup 2)))
3794    (set (match_dup 0)
3795         (compare:CC (match_dup 3)
3796                     (const_int 0)))]
3797   "")
3799 (define_insn "*rotlsi3_internal3"
3800   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3801         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3802                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3803                     (const_int 0)))
3804    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3805         (rotate:SI (match_dup 1) (match_dup 2)))]
3806   "! TARGET_POWERPC64"
3807   "@
3808    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffffffff
3809    #"
3810   [(set_attr "type" "delayed_compare")
3811    (set_attr "length" "4,8")])
3813 (define_split
3814   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3815         (compare:CC (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3816                                (match_operand:SI 2 "reg_or_cint_operand" ""))
3817                     (const_int 0)))
3818    (set (match_operand:SI 0 "gpc_reg_operand" "")
3819         (rotate:SI (match_dup 1) (match_dup 2)))]
3820   "! TARGET_POWERPC64 && reload_completed"
3821   [(set (match_dup 0)
3822         (rotate:SI (match_dup 1) (match_dup 2)))
3823    (set (match_dup 3)
3824         (compare:CC (match_dup 0)
3825                     (const_int 0)))]
3826   "")
3828 (define_insn "*rotlsi3_internal4"
3829   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3830         (and:SI (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3831                            (match_operand:SI 2 "reg_or_cint_operand" "ri"))
3832                 (match_operand:SI 3 "mask_operand" "T")))]
3833   ""
3834   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,%m3,%M3")
3836 (define_insn "*rotlsi3_internal5"
3837   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3838         (compare:CC (and:SI
3839                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3840                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3841                      (match_operand:SI 3 "mask_operand" "T,T"))
3842                     (const_int 0)))
3843    (clobber (match_scratch:SI 4 "=r,r"))]
3844   "! TARGET_POWERPC64"
3845   "@
3846    {rl%I2nm.|rlw%I2nm.} %4,%1,%h2,%m3,%M3
3847    #"
3848   [(set_attr "type" "delayed_compare")
3849    (set_attr "length" "4,8")])
3851 (define_split
3852   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3853         (compare:CC (and:SI
3854                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3855                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3856                      (match_operand:SI 3 "mask_operand" ""))
3857                     (const_int 0)))
3858    (clobber (match_scratch:SI 4 ""))]
3859   "! TARGET_POWERPC64 && reload_completed"
3860   [(set (match_dup 4)
3861         (and:SI (rotate:SI (match_dup 1)
3862                                 (match_dup 2))
3863                      (match_dup 3)))
3864    (set (match_dup 0)
3865         (compare:CC (match_dup 4)
3866                     (const_int 0)))]
3867   "")
3869 (define_insn "*rotlsi3_internal6"
3870   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
3871         (compare:CC (and:SI
3872                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3873                                 (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
3874                      (match_operand:SI 3 "mask_operand" "T,T"))
3875                     (const_int 0)))
3876    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3877         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3878   "! TARGET_POWERPC64"
3879   "@
3880    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,%m3,%M3
3881    #"
3882   [(set_attr "type" "delayed_compare")
3883    (set_attr "length" "4,8")])
3885 (define_split
3886   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
3887         (compare:CC (and:SI
3888                      (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3889                                 (match_operand:SI 2 "reg_or_cint_operand" ""))
3890                      (match_operand:SI 3 "mask_operand" ""))
3891                     (const_int 0)))
3892    (set (match_operand:SI 0 "gpc_reg_operand" "")
3893         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
3894   "! TARGET_POWERPC64 && reload_completed"
3895   [(set (match_dup 0)
3896         (and:SI (rotate:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
3897    (set (match_dup 4)
3898         (compare:CC (match_dup 0)
3899                     (const_int 0)))]
3900   "")
3902 (define_insn "*rotlsi3_internal7"
3903   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3904         (zero_extend:SI
3905          (subreg:QI
3906           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3907                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3908   ""
3909   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xff")
3911 (define_insn "*rotlsi3_internal8"
3912   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3913         (compare:CC (zero_extend:SI
3914                      (subreg:QI
3915                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3916                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3917                     (const_int 0)))
3918    (clobber (match_scratch:SI 3 "=r,r"))]
3919   ""
3920   "@
3921    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xff
3922    #"
3923   [(set_attr "type" "delayed_compare")
3924    (set_attr "length" "4,8")])
3926 (define_split
3927   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
3928         (compare:CC (zero_extend:SI
3929                      (subreg:QI
3930                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3931                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3932                     (const_int 0)))
3933    (clobber (match_scratch:SI 3 ""))]
3934   "reload_completed"
3935   [(set (match_dup 3)
3936         (zero_extend:SI (subreg:QI
3937                       (rotate:SI (match_dup 1)
3938                                  (match_dup 2)) 0)))
3939    (set (match_dup 0)
3940         (compare:CC (match_dup 3)
3941                     (const_int 0)))]
3942   "")
3944 (define_insn "*rotlsi3_internal9"
3945   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
3946         (compare:CC (zero_extend:SI
3947                      (subreg:QI
3948                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3949                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3950                     (const_int 0)))
3951    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
3952         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3953   ""
3954   "@
3955    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xff
3956    #"
3957   [(set_attr "type" "delayed_compare")
3958    (set_attr "length" "4,8")])
3960 (define_split
3961   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
3962         (compare:CC (zero_extend:SI
3963                      (subreg:QI
3964                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
3965                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
3966                     (const_int 0)))
3967    (set (match_operand:SI 0 "gpc_reg_operand" "")
3968         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
3969   "reload_completed"
3970   [(set (match_dup 0)
3971         (zero_extend:SI (subreg:QI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
3972    (set (match_dup 3)
3973         (compare:CC (match_dup 0)
3974                     (const_int 0)))]
3975   "")
3977 (define_insn "*rotlsi3_internal10"
3978   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
3979         (zero_extend:SI
3980          (subreg:HI
3981           (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r")
3982                      (match_operand:SI 2 "reg_or_cint_operand" "ri")) 0)))]
3983   ""
3984   "{rl%I2nm|rlw%I2nm} %0,%1,%h2,0xffff")
3986 (define_insn "*rotlsi3_internal11"
3987   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
3988         (compare:CC (zero_extend:SI
3989                      (subreg:HI
3990                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
3991                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
3992                     (const_int 0)))
3993    (clobber (match_scratch:SI 3 "=r,r"))]
3994   ""
3995   "@
3996    {rl%I2nm.|rlw%I2nm.} %3,%1,%h2,0xffff
3997    #"
3998   [(set_attr "type" "delayed_compare")
3999    (set_attr "length" "4,8")])
4001 (define_split
4002   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4003         (compare:CC (zero_extend:SI
4004                      (subreg:HI
4005                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4006                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4007                     (const_int 0)))
4008    (clobber (match_scratch:SI 3 ""))]
4009   "reload_completed"
4010   [(set (match_dup 3)
4011         (zero_extend:SI (subreg:HI
4012                       (rotate:SI (match_dup 1)
4013                                  (match_dup 2)) 0)))
4014    (set (match_dup 0)
4015         (compare:CC (match_dup 3)
4016                     (const_int 0)))]
4017   "")
4019 (define_insn "*rotlsi3_internal12"
4020   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4021         (compare:CC (zero_extend:SI
4022                      (subreg:HI
4023                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4024                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri")) 0))
4025                     (const_int 0)))
4026    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4027         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4028   ""
4029   "@
4030    {rl%I2nm.|rlw%I2nm.} %0,%1,%h2,0xffff
4031    #"
4032   [(set_attr "type" "delayed_compare")
4033    (set_attr "length" "4,8")])
4035 (define_split
4036   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4037         (compare:CC (zero_extend:SI
4038                      (subreg:HI
4039                       (rotate:SI (match_operand:SI 1 "gpc_reg_operand" "")
4040                                  (match_operand:SI 2 "reg_or_cint_operand" "")) 0))
4041                     (const_int 0)))
4042    (set (match_operand:SI 0 "gpc_reg_operand" "")
4043         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))]
4044   "reload_completed"
4045   [(set (match_dup 0)
4046         (zero_extend:SI (subreg:HI (rotate:SI (match_dup 1) (match_dup 2)) 0)))
4047    (set (match_dup 3)
4048         (compare:CC (match_dup 0)
4049                     (const_int 0)))]
4050   "")
4052 ;; Note that we use "sle." instead of "sl." so that we can set
4053 ;; SHIFT_COUNT_TRUNCATED.
4055 (define_expand "ashlsi3"
4056   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4057    (use (match_operand:SI 1 "gpc_reg_operand" ""))
4058    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4059   ""
4060   "
4062   if (TARGET_POWER)
4063     emit_insn (gen_ashlsi3_power (operands[0], operands[1], operands[2]));
4064   else
4065     emit_insn (gen_ashlsi3_no_power (operands[0], operands[1], operands[2]));
4066   DONE;
4069 (define_insn "ashlsi3_power"
4070   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4071         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4072                    (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4073    (clobber (match_scratch:SI 3 "=q,X"))]
4074   "TARGET_POWER"
4075   "@
4076    sle %0,%1,%2
4077    {sli|slwi} %0,%1,%h2")
4079 (define_insn "ashlsi3_no_power"
4080   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4081         (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4082                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4083   "! TARGET_POWER"
4084   "{sl|slw}%I2 %0,%1,%h2")
4086 (define_insn ""
4087   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4088         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4089                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4090                     (const_int 0)))
4091    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4092    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4093   "TARGET_POWER"
4094   "@
4095    sle. %3,%1,%2
4096    {sli.|slwi.} %3,%1,%h2
4097    #
4098    #"
4099   [(set_attr "type" "delayed_compare")
4100    (set_attr "length" "4,4,8,8")])
4102 (define_split
4103   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4104         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4105                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4106                     (const_int 0)))
4107    (clobber (match_scratch:SI 3 ""))
4108    (clobber (match_scratch:SI 4 ""))]
4109   "TARGET_POWER && reload_completed"
4110   [(parallel [(set (match_dup 3)
4111         (ashift:SI (match_dup 1) (match_dup 2)))
4112    (clobber (match_dup 4))])
4113    (set (match_dup 0)
4114         (compare:CC (match_dup 3)
4115                     (const_int 0)))]
4116   "")
4118 (define_insn ""
4119   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4120         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4121                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4122                     (const_int 0)))
4123    (clobber (match_scratch:SI 3 "=r,r"))]
4124   "! TARGET_POWER && ! TARGET_POWERPC64"
4125   "@
4126    {sl|slw}%I2. %3,%1,%h2
4127    #"
4128   [(set_attr "type" "delayed_compare")
4129    (set_attr "length" "4,8")])
4131 (define_split
4132   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4133         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4134                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4135                     (const_int 0)))
4136    (clobber (match_scratch:SI 3 ""))]
4137   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4138   [(set (match_dup 3)
4139         (ashift:SI (match_dup 1) (match_dup 2)))
4140    (set (match_dup 0)
4141         (compare:CC (match_dup 3)
4142                     (const_int 0)))]
4143   "")
4145 (define_insn ""
4146   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4147         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4148                                (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4149                     (const_int 0)))
4150    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4151         (ashift:SI (match_dup 1) (match_dup 2)))
4152    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4153   "TARGET_POWER"
4154   "@
4155    sle. %0,%1,%2
4156    {sli.|slwi.} %0,%1,%h2
4157    #
4158    #"
4159   [(set_attr "type" "delayed_compare")
4160    (set_attr "length" "4,4,8,8")])
4162 (define_split
4163   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4164         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4165                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4166                     (const_int 0)))
4167    (set (match_operand:SI 0 "gpc_reg_operand" "")
4168         (ashift:SI (match_dup 1) (match_dup 2)))
4169    (clobber (match_scratch:SI 4 ""))]
4170   "TARGET_POWER && reload_completed"
4171   [(parallel [(set (match_dup 0)
4172         (ashift:SI (match_dup 1) (match_dup 2)))
4173    (clobber (match_dup 4))])
4174    (set (match_dup 3)
4175         (compare:CC (match_dup 0)
4176                     (const_int 0)))]
4177   "")
4179 (define_insn ""
4180   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4181         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4182                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4183                     (const_int 0)))
4184    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4185         (ashift:SI (match_dup 1) (match_dup 2)))]
4186   "! TARGET_POWER && ! TARGET_POWERPC64"
4187   "@
4188    {sl|slw}%I2. %0,%1,%h2
4189    #"
4190   [(set_attr "type" "delayed_compare")
4191    (set_attr "length" "4,8")])
4193 (define_split
4194   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4195         (compare:CC (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4196                                (match_operand:SI 2 "reg_or_cint_operand" ""))
4197                     (const_int 0)))
4198    (set (match_operand:SI 0 "gpc_reg_operand" "")
4199         (ashift:SI (match_dup 1) (match_dup 2)))]
4200   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4201   [(set (match_dup 0)
4202         (ashift:SI (match_dup 1) (match_dup 2)))
4203    (set (match_dup 3)
4204         (compare:CC (match_dup 0)
4205                     (const_int 0)))]
4206   "")
4208 (define_insn ""
4209   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4210         (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4211                            (match_operand:SI 2 "const_int_operand" "i"))
4212                 (match_operand:SI 3 "mask_operand" "T")))]
4213   "includes_lshift_p (operands[2], operands[3])"
4214   "{rlinm|rlwinm} %0,%1,%h2,%m3,%M3")
4216 (define_insn ""
4217   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4218         (compare:CC
4219          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4220                             (match_operand:SI 2 "const_int_operand" "i,i"))
4221                  (match_operand:SI 3 "mask_operand" "T,T"))
4222          (const_int 0)))
4223    (clobber (match_scratch:SI 4 "=r,r"))]
4224   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3])"
4225   "@
4226    {rlinm.|rlwinm.} %4,%1,%h2,%m3,%M3
4227    #"
4228   [(set_attr "type" "delayed_compare")
4229    (set_attr "length" "4,8")])
4231 (define_split
4232   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4233         (compare:CC
4234          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4235                             (match_operand:SI 2 "const_int_operand" ""))
4236                  (match_operand:SI 3 "mask_operand" ""))
4237          (const_int 0)))
4238    (clobber (match_scratch:SI 4 ""))]
4239   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3]) && reload_completed"
4240   [(set (match_dup 4)
4241         (and:SI (ashift:SI (match_dup 1) (match_dup 2))
4242                  (match_dup 3)))
4243    (set (match_dup 0)
4244         (compare:CC (match_dup 4)
4245                     (const_int 0)))]
4246   "")
4248 (define_insn ""
4249   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4250         (compare:CC
4251          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4252                             (match_operand:SI 2 "const_int_operand" "i,i"))
4253                  (match_operand:SI 3 "mask_operand" "T,T"))
4254          (const_int 0)))
4255    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4256         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4257   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3])"
4258   "@
4259    {rlinm.|rlwinm.} %0,%1,%h2,%m3,%M3
4260    #"
4261   [(set_attr "type" "delayed_compare")
4262    (set_attr "length" "4,8")])
4264 (define_split
4265   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4266         (compare:CC
4267          (and:SI (ashift:SI (match_operand:SI 1 "gpc_reg_operand" "")
4268                             (match_operand:SI 2 "const_int_operand" ""))
4269                  (match_operand:SI 3 "mask_operand" ""))
4270          (const_int 0)))
4271    (set (match_operand:SI 0 "gpc_reg_operand" "")
4272         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4273   "! TARGET_POWERPC64 && includes_lshift_p (operands[2], operands[3]) && reload_completed"
4274   [(set (match_dup 0)
4275         (and:SI (ashift:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4276    (set (match_dup 4)
4277         (compare:CC (match_dup 0)
4278                     (const_int 0)))]
4279   "")
4281 ;; The AIX assembler mis-handles "sri x,x,0", so write that case as
4282 ;; "sli x,x,0".
4283 (define_expand "lshrsi3"
4284   [(use (match_operand:SI 0 "gpc_reg_operand" ""))
4285    (use (match_operand:SI 1 "gpc_reg_operand" ""))
4286    (use (match_operand:SI 2 "reg_or_cint_operand" ""))]
4287   ""
4288   "
4290   if (TARGET_POWER)
4291     emit_insn (gen_lshrsi3_power (operands[0], operands[1], operands[2]));
4292   else
4293     emit_insn (gen_lshrsi3_no_power (operands[0], operands[1], operands[2]));
4294   DONE;
4297 (define_insn "lshrsi3_power"
4298   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r")
4299         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r")
4300                      (match_operand:SI 2 "reg_or_cint_operand" "r,O,i")))
4301    (clobber (match_scratch:SI 3 "=q,X,X"))]
4302   "TARGET_POWER"
4303   "@
4304   sre %0,%1,%2
4305   mr %0,%1
4306   {s%A2i|s%A2wi} %0,%1,%h2")
4308 (define_insn "lshrsi3_no_power"
4309   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4310         (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4311                      (match_operand:SI 2 "reg_or_cint_operand" "O,ri")))]
4312   "! TARGET_POWER"
4313   "@
4314   mr %0,%1
4315   {sr|srw}%I2 %0,%1,%h2")
4317 (define_insn ""
4318   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4319         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4320                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4321                     (const_int 0)))
4322    (clobber (match_scratch:SI 3 "=r,X,r,r,X,r"))
4323    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4324   "TARGET_POWER"
4325   "@
4326   sre. %3,%1,%2
4327   mr. %1,%1
4328   {s%A2i.|s%A2wi.} %3,%1,%h2
4329   #
4330   #
4331   #"
4332   [(set_attr "type" "delayed_compare")
4333    (set_attr "length" "4,4,4,8,8,8")])
4335 (define_split
4336   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4337         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4338                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4339                     (const_int 0)))
4340    (clobber (match_scratch:SI 3 ""))
4341    (clobber (match_scratch:SI 4 ""))]
4342   "TARGET_POWER && reload_completed"
4343   [(parallel [(set (match_dup 3)
4344         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4345    (clobber (match_dup 4))])
4346    (set (match_dup 0)
4347         (compare:CC (match_dup 3)
4348                     (const_int 0)))]
4349   "")
4351 (define_insn ""
4352   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4353         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4354                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4355                     (const_int 0)))
4356    (clobber (match_scratch:SI 3 "=X,r,X,r"))]
4357   "! TARGET_POWER && ! TARGET_POWERPC64"
4358   "@
4359    mr. %1,%1
4360    {sr|srw}%I2. %3,%1,%h2
4361    #
4362    #"
4363   [(set_attr "type" "delayed_compare")
4364    (set_attr "length" "4,4,8,8")])
4366 (define_split
4367   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4368         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4369                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4370                     (const_int 0)))
4371    (clobber (match_scratch:SI 3 ""))]
4372   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4373   [(set (match_dup 3)
4374         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4375    (set (match_dup 0)
4376         (compare:CC (match_dup 3)
4377                     (const_int 0)))]
4378   "")
4380 (define_insn ""
4381   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,?y,?y,?y")
4382         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r,r,r")
4383                                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,i,r,O,i"))
4384                     (const_int 0)))
4385    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r")
4386         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4387    (clobber (match_scratch:SI 4 "=q,X,X,q,X,X"))]
4388   "TARGET_POWER"
4389   "@
4390   sre. %0,%1,%2
4391   mr. %0,%1
4392   {s%A2i.|s%A2wi.} %0,%1,%h2
4393   #
4394   #
4395   #"
4396   [(set_attr "type" "delayed_compare")
4397    (set_attr "length" "4,4,4,8,8,8")])
4399 (define_split
4400   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4401         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4402                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4403                     (const_int 0)))
4404    (set (match_operand:SI 0 "gpc_reg_operand" "")
4405         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4406    (clobber (match_scratch:SI 4 ""))]
4407   "TARGET_POWER && reload_completed"
4408   [(parallel [(set (match_dup 0)
4409         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4410    (clobber (match_dup 4))])
4411    (set (match_dup 3)
4412         (compare:CC (match_dup 0)
4413                     (const_int 0)))]
4414   "")
4416 (define_insn ""
4417   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4418         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4419                                  (match_operand:SI 2 "reg_or_cint_operand" "O,ri,O,ri"))
4420                     (const_int 0)))
4421    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4422         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4423   "! TARGET_POWER && ! TARGET_POWERPC64"
4424   "@
4425    mr. %0,%1
4426    {sr|srw}%I2. %0,%1,%h2
4427    #
4428    #"
4429   [(set_attr "type" "delayed_compare")
4430    (set_attr "length" "4,4,8,8")])
4432 (define_split
4433   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4434         (compare:CC (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4435                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4436                     (const_int 0)))
4437    (set (match_operand:SI 0 "gpc_reg_operand" "")
4438         (lshiftrt:SI (match_dup 1) (match_dup 2)))]
4439   "! TARGET_POWER && ! TARGET_POWERPC64 && reload_completed"
4440   [(set (match_dup 0)
4441         (lshiftrt:SI (match_dup 1) (match_dup 2)))
4442    (set (match_dup 3)
4443         (compare:CC (match_dup 0)
4444                     (const_int 0)))]
4445   "")
4447 (define_insn ""
4448   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4449         (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4450                              (match_operand:SI 2 "const_int_operand" "i"))
4451                 (match_operand:SI 3 "mask_operand" "T")))]
4452   "includes_rshift_p (operands[2], operands[3])"
4453   "{rlinm|rlwinm} %0,%1,%s2,%m3,%M3")
4455 (define_insn ""
4456   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4457         (compare:CC
4458          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4459                               (match_operand:SI 2 "const_int_operand" "i,i"))
4460                  (match_operand:SI 3 "mask_operand" "T,T"))
4461          (const_int 0)))
4462    (clobber (match_scratch:SI 4 "=r,r"))]
4463   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3])"
4464   "@
4465    {rlinm.|rlwinm.} %4,%1,%s2,%m3,%M3
4466    #"
4467   [(set_attr "type" "delayed_compare")
4468    (set_attr "length" "4,8")])
4470 (define_split
4471   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4472         (compare:CC
4473          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4474                               (match_operand:SI 2 "const_int_operand" ""))
4475                  (match_operand:SI 3 "mask_operand" ""))
4476          (const_int 0)))
4477    (clobber (match_scratch:SI 4 ""))]
4478   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3]) && reload_completed"
4479   [(set (match_dup 4)
4480         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2))
4481                  (match_dup 3)))
4482    (set (match_dup 0)
4483         (compare:CC (match_dup 4)
4484                     (const_int 0)))]
4485   "")
4487 (define_insn ""
4488   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
4489         (compare:CC
4490          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4491                               (match_operand:SI 2 "const_int_operand" "i,i"))
4492                  (match_operand:SI 3 "mask_operand" "T,T"))
4493          (const_int 0)))
4494    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4495         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4496   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3])"
4497   "@
4498    {rlinm.|rlwinm.} %0,%1,%s2,%m3,%M3
4499    #"
4500   [(set_attr "type" "delayed_compare")
4501    (set_attr "length" "4,8")])
4503 (define_split
4504   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
4505         (compare:CC
4506          (and:SI (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4507                               (match_operand:SI 2 "const_int_operand" ""))
4508                  (match_operand:SI 3 "mask_operand" ""))
4509          (const_int 0)))
4510    (set (match_operand:SI 0 "gpc_reg_operand" "")
4511         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
4512   "! TARGET_POWERPC64 && includes_rshift_p (operands[2], operands[3]) && reload_completed"
4513   [(set (match_dup 0)
4514         (and:SI (lshiftrt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
4515    (set (match_dup 4)
4516         (compare:CC (match_dup 0)
4517                     (const_int 0)))]
4518   "")
4520 (define_insn ""
4521   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4522         (zero_extend:SI
4523          (subreg:QI
4524           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4525                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4526   "includes_rshift_p (operands[2], GEN_INT (255))"
4527   "{rlinm|rlwinm} %0,%1,%s2,0xff")
4529 (define_insn ""
4530   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4531         (compare:CC
4532          (zero_extend:SI
4533           (subreg:QI
4534            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4535                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4536          (const_int 0)))
4537    (clobber (match_scratch:SI 3 "=r,r"))]
4538   "includes_rshift_p (operands[2], GEN_INT (255))"
4539   "@
4540    {rlinm.|rlwinm.} %3,%1,%s2,0xff
4541    #"
4542   [(set_attr "type" "delayed_compare")
4543    (set_attr "length" "4,8")])
4545 (define_split
4546   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4547         (compare:CC
4548          (zero_extend:SI
4549           (subreg:QI
4550            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4551                         (match_operand:SI 2 "const_int_operand" "")) 0))
4552          (const_int 0)))
4553    (clobber (match_scratch:SI 3 ""))]
4554   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4555   [(set (match_dup 3)
4556         (zero_extend:SI (subreg:QI
4557            (lshiftrt:SI (match_dup 1)
4558                         (match_dup 2)) 0)))
4559    (set (match_dup 0)
4560         (compare:CC (match_dup 3)
4561                     (const_int 0)))]
4562   "")
4564 (define_insn ""
4565   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4566         (compare:CC
4567          (zero_extend:SI
4568           (subreg:QI
4569            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4570                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4571          (const_int 0)))
4572    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4573         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4574   "includes_rshift_p (operands[2], GEN_INT (255))"
4575   "@
4576    {rlinm.|rlwinm.} %0,%1,%s2,0xff
4577    #"
4578   [(set_attr "type" "delayed_compare")
4579    (set_attr "length" "4,8")])
4581 (define_split
4582   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4583         (compare:CC
4584          (zero_extend:SI
4585           (subreg:QI
4586            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4587                         (match_operand:SI 2 "const_int_operand" "")) 0))
4588          (const_int 0)))
4589    (set (match_operand:SI 0 "gpc_reg_operand" "")
4590         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4591   "includes_rshift_p (operands[2], GEN_INT (255)) && reload_completed"
4592   [(set (match_dup 0)
4593         (zero_extend:SI (subreg:QI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4594    (set (match_dup 3)
4595         (compare:CC (match_dup 0)
4596                     (const_int 0)))]
4597   "")
4599 (define_insn ""
4600   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4601         (zero_extend:SI
4602          (subreg:HI
4603           (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4604                        (match_operand:SI 2 "const_int_operand" "i")) 0)))]
4605   "includes_rshift_p (operands[2], GEN_INT (65535))"
4606   "{rlinm|rlwinm} %0,%1,%s2,0xffff")
4608 (define_insn ""
4609   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4610         (compare:CC
4611          (zero_extend:SI
4612           (subreg:HI
4613            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4614                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4615          (const_int 0)))
4616    (clobber (match_scratch:SI 3 "=r,r"))]
4617   "includes_rshift_p (operands[2], GEN_INT (65535))"
4618   "@
4619    {rlinm.|rlwinm.} %3,%1,%s2,0xffff
4620    #"
4621   [(set_attr "type" "delayed_compare")
4622    (set_attr "length" "4,8")])
4624 (define_split
4625   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4626         (compare:CC
4627          (zero_extend:SI
4628           (subreg:HI
4629            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4630                         (match_operand:SI 2 "const_int_operand" "")) 0))
4631          (const_int 0)))
4632    (clobber (match_scratch:SI 3 ""))]
4633   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4634   [(set (match_dup 3)
4635         (zero_extend:SI (subreg:HI
4636            (lshiftrt:SI (match_dup 1)
4637                         (match_dup 2)) 0)))
4638    (set (match_dup 0)
4639         (compare:CC (match_dup 3)
4640                     (const_int 0)))]
4641   "")
4643 (define_insn ""
4644   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4645         (compare:CC
4646          (zero_extend:SI
4647           (subreg:HI
4648            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4649                         (match_operand:SI 2 "const_int_operand" "i,i")) 0))
4650          (const_int 0)))
4651    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4652         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4653   "includes_rshift_p (operands[2], GEN_INT (65535))"
4654   "@
4655    {rlinm.|rlwinm.} %0,%1,%s2,0xffff
4656    #"
4657   [(set_attr "type" "delayed_compare")
4658    (set_attr "length" "4,8")])
4660 (define_split
4661   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4662         (compare:CC
4663          (zero_extend:SI
4664           (subreg:HI
4665            (lshiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4666                         (match_operand:SI 2 "const_int_operand" "")) 0))
4667          (const_int 0)))
4668    (set (match_operand:SI 0 "gpc_reg_operand" "")
4669         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))]
4670   "includes_rshift_p (operands[2], GEN_INT (65535)) && reload_completed"
4671   [(set (match_dup 0)
4672         (zero_extend:SI (subreg:HI (lshiftrt:SI (match_dup 1) (match_dup 2)) 0)))
4673    (set (match_dup 3)
4674         (compare:CC (match_dup 0)
4675                     (const_int 0)))]
4676   "")
4678 (define_insn ""
4679   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4680                          (const_int 1)
4681                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4682         (ashiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4683                      (const_int 31)))]
4684   "TARGET_POWER"
4685   "rrib %0,%1,%2")
4687 (define_insn ""
4688   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4689                          (const_int 1)
4690                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4691         (lshiftrt:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4692                      (const_int 31)))]
4693   "TARGET_POWER"
4694   "rrib %0,%1,%2")
4696 (define_insn ""
4697   [(set (zero_extract:SI (match_operand:SI 0 "gpc_reg_operand" "+r")
4698                          (const_int 1)
4699                          (match_operand:SI 1 "gpc_reg_operand" "r"))
4700         (zero_extract:SI (match_operand:SI 2 "gpc_reg_operand" "r")
4701                          (const_int 1)
4702                          (const_int 0)))]
4703   "TARGET_POWER"
4704   "rrib %0,%1,%2")
4706 (define_expand "ashrsi3"
4707   [(set (match_operand:SI 0 "gpc_reg_operand" "")
4708         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4709                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
4710   ""
4711   "
4713   if (TARGET_POWER)
4714     emit_insn (gen_ashrsi3_power (operands[0], operands[1], operands[2]));
4715   else
4716     emit_insn (gen_ashrsi3_no_power (operands[0], operands[1], operands[2]));
4717   DONE;
4720 (define_insn "ashrsi3_power"
4721   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4722         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4723                      (match_operand:SI 2 "reg_or_cint_operand" "r,i")))
4724    (clobber (match_scratch:SI 3 "=q,X"))]
4725   "TARGET_POWER"
4726   "@
4727    srea %0,%1,%2
4728    {srai|srawi} %0,%1,%h2")
4730 (define_insn "ashrsi3_no_power"
4731   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
4732         (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
4733                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
4734   "! TARGET_POWER"
4735   "{sra|sraw}%I2 %0,%1,%h2")
4737 (define_insn ""
4738   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
4739         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4740                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4741                     (const_int 0)))
4742    (clobber (match_scratch:SI 3 "=r,r,r,r"))
4743    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4744   "TARGET_POWER"
4745   "@
4746    srea. %3,%1,%2
4747    {srai.|srawi.} %3,%1,%h2
4748    #
4749    #"
4750   [(set_attr "type" "delayed_compare")
4751    (set_attr "length" "4,4,8,8")])
4753 (define_split
4754   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4755         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4756                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4757                     (const_int 0)))
4758    (clobber (match_scratch:SI 3 ""))
4759    (clobber (match_scratch:SI 4 ""))]
4760   "TARGET_POWER && reload_completed"
4761   [(parallel [(set (match_dup 3)
4762         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4763    (clobber (match_dup 4))])
4764    (set (match_dup 0)
4765         (compare:CC (match_dup 3)
4766                     (const_int 0)))]
4767   "")
4769 (define_insn ""
4770   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
4771         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4772                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4773                     (const_int 0)))
4774    (clobber (match_scratch:SI 3 "=r,r"))]
4775   "! TARGET_POWER"
4776   "@
4777    {sra|sraw}%I2. %3,%1,%h2
4778    #"
4779   [(set_attr "type" "delayed_compare")
4780    (set_attr "length" "4,8")])
4782 (define_split
4783   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
4784         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4785                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4786                     (const_int 0)))
4787    (clobber (match_scratch:SI 3 ""))]
4788   "! TARGET_POWER && reload_completed"
4789   [(set (match_dup 3)
4790         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4791    (set (match_dup 0)
4792         (compare:CC (match_dup 3)
4793                     (const_int 0)))]
4794   "")
4796 (define_insn ""
4797   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
4798         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
4799                                  (match_operand:SI 2 "reg_or_cint_operand" "r,i,r,i"))
4800                     (const_int 0)))
4801    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
4802         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4803    (clobber (match_scratch:SI 4 "=q,X,q,X"))]
4804   "TARGET_POWER"
4805   "@
4806    srea. %0,%1,%2
4807    {srai.|srawi.} %0,%1,%h2
4808    #
4809    #"
4810   [(set_attr "type" "delayed_compare")
4811    (set_attr "length" "4,4,8,8")])
4813 (define_split
4814   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4815         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4816                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4817                     (const_int 0)))
4818    (set (match_operand:SI 0 "gpc_reg_operand" "")
4819         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4820    (clobber (match_scratch:SI 4 ""))]
4821   "TARGET_POWER && reload_completed"
4822   [(parallel [(set (match_dup 0)
4823         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4824    (clobber (match_dup 4))])
4825    (set (match_dup 3)
4826         (compare:CC (match_dup 0)
4827                     (const_int 0)))]
4828   "")
4830 (define_insn ""
4831   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
4832         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
4833                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
4834                     (const_int 0)))
4835    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
4836         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4837   "! TARGET_POWER"
4838   "@
4839    {sra|sraw}%I2. %0,%1,%h2
4840    #"
4841   [(set_attr "type" "delayed_compare")
4842    (set_attr "length" "4,8")])
4844 (define_split
4845   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
4846         (compare:CC (ashiftrt:SI (match_operand:SI 1 "gpc_reg_operand" "")
4847                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
4848                     (const_int 0)))
4849    (set (match_operand:SI 0 "gpc_reg_operand" "")
4850         (ashiftrt:SI (match_dup 1) (match_dup 2)))]
4851   "! TARGET_POWER && reload_completed"
4852   [(set (match_dup 0)
4853         (ashiftrt:SI (match_dup 1) (match_dup 2)))
4854    (set (match_dup 3)
4855         (compare:CC (match_dup 0)
4856                     (const_int 0)))]
4857   "")
4859 ;; Floating-point insns, excluding normal data motion.
4861 ;; PowerPC has a full set of single-precision floating point instructions.
4863 ;; For the POWER architecture, we pretend that we have both SFmode and
4864 ;; DFmode insns, while, in fact, all fp insns are actually done in double.
4865 ;; The only conversions we will do will be when storing to memory.  In that
4866 ;; case, we will use the "frsp" instruction before storing.
4868 ;; Note that when we store into a single-precision memory location, we need to
4869 ;; use the frsp insn first.  If the register being stored isn't dead, we
4870 ;; need a scratch register for the frsp.  But this is difficult when the store
4871 ;; is done by reload.  It is not incorrect to do the frsp on the register in
4872 ;; this case, we just lose precision that we would have otherwise gotten but
4873 ;; is not guaranteed.  Perhaps this should be tightened up at some point.
4875 (define_insn "extendsfdf2"
4876   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
4877         (float_extend:DF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4878   "TARGET_HARD_FLOAT"
4879   "*
4881   if (REGNO (operands[0]) == REGNO (operands[1]))
4882     return \"\";
4883   else
4884     return \"fmr %0,%1\";
4886   [(set_attr "type" "fp")])
4888 (define_insn "truncdfsf2"
4889   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4890         (float_truncate:SF (match_operand:DF 1 "gpc_reg_operand" "f")))]
4891   "TARGET_HARD_FLOAT"
4892   "frsp %0,%1"
4893   [(set_attr "type" "fp")])
4895 (define_insn "aux_truncdfsf2"
4896   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4897         (unspec:SF [(match_operand:SF 1 "gpc_reg_operand" "f")] 0))]
4898   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4899   "frsp %0,%1"
4900   [(set_attr "type" "fp")])
4902 (define_insn "negsf2"
4903   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4904         (neg:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4905   "TARGET_HARD_FLOAT"
4906   "fneg %0,%1"
4907   [(set_attr "type" "fp")])
4909 (define_insn "abssf2"
4910   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4911         (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
4912   "TARGET_HARD_FLOAT"
4913   "fabs %0,%1"
4914   [(set_attr "type" "fp")])
4916 (define_insn ""
4917   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4918         (neg:SF (abs:SF (match_operand:SF 1 "gpc_reg_operand" "f"))))]
4919   "TARGET_HARD_FLOAT"
4920   "fnabs %0,%1"
4921   [(set_attr "type" "fp")])
4923 (define_expand "addsf3"
4924   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4925         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4926                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4927   "TARGET_HARD_FLOAT"
4928   "")
4930 (define_insn ""
4931   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4932         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4933                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4934   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4935   "fadds %0,%1,%2"
4936   [(set_attr "type" "fp")])
4938 (define_insn ""
4939   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4940         (plus:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4941                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4942   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4943   "{fa|fadd} %0,%1,%2"
4944   [(set_attr "type" "fp")])
4946 (define_expand "subsf3"
4947   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4948         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "")
4949                   (match_operand:SF 2 "gpc_reg_operand" "")))]
4950   "TARGET_HARD_FLOAT"
4951   "")
4953 (define_insn ""
4954   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4955         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4956                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4957   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4958   "fsubs %0,%1,%2"
4959   [(set_attr "type" "fp")])
4961 (define_insn ""
4962   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4963         (minus:SF (match_operand:SF 1 "gpc_reg_operand" "f")
4964                   (match_operand:SF 2 "gpc_reg_operand" "f")))]
4965   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4966   "{fs|fsub} %0,%1,%2"
4967   [(set_attr "type" "fp")])
4969 (define_expand "mulsf3"
4970   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4971         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "")
4972                  (match_operand:SF 2 "gpc_reg_operand" "")))]
4973   "TARGET_HARD_FLOAT"
4974   "")
4976 (define_insn ""
4977   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4978         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4979                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4980   "TARGET_POWERPC && TARGET_HARD_FLOAT"
4981   "fmuls %0,%1,%2"
4982   [(set_attr "type" "fp")])
4984 (define_insn ""
4985   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
4986         (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
4987                  (match_operand:SF 2 "gpc_reg_operand" "f")))]
4988   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
4989   "{fm|fmul} %0,%1,%2"
4990   [(set_attr "type" "dmul")])
4992 (define_expand "divsf3"
4993   [(set (match_operand:SF 0 "gpc_reg_operand" "")
4994         (div:SF (match_operand:SF 1 "gpc_reg_operand" "")
4995                 (match_operand:SF 2 "gpc_reg_operand" "")))]
4996   "TARGET_HARD_FLOAT"
4997   "")
4999 (define_insn ""
5000   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5001         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5002                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5003   "TARGET_POWERPC && TARGET_HARD_FLOAT"
5004   "fdivs %0,%1,%2"
5005   [(set_attr "type" "sdiv")])
5007 (define_insn ""
5008   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5009         (div:SF (match_operand:SF 1 "gpc_reg_operand" "f")
5010                 (match_operand:SF 2 "gpc_reg_operand" "f")))]
5011   "! TARGET_POWERPC && TARGET_HARD_FLOAT"
5012   "{fd|fdiv} %0,%1,%2"
5013   [(set_attr "type" "ddiv")])
5015 (define_insn ""
5016   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5017         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5018                           (match_operand:SF 2 "gpc_reg_operand" "f"))
5019                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
5020   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5021   "fmadds %0,%1,%2,%3"
5022   [(set_attr "type" "fp")])
5024 (define_insn ""
5025   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5026         (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5027                           (match_operand:SF 2 "gpc_reg_operand" "f"))
5028                  (match_operand:SF 3 "gpc_reg_operand" "f")))]
5029   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5030   "{fma|fmadd} %0,%1,%2,%3"
5031   [(set_attr "type" "dmul")])
5033 (define_insn ""
5034   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5035         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5036                            (match_operand:SF 2 "gpc_reg_operand" "f"))
5037                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
5038   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5039   "fmsubs %0,%1,%2,%3"
5040   [(set_attr "type" "fp")])
5042 (define_insn ""
5043   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5044         (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5045                            (match_operand:SF 2 "gpc_reg_operand" "f"))
5046                   (match_operand:SF 3 "gpc_reg_operand" "f")))]
5047   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5048   "{fms|fmsub} %0,%1,%2,%3"
5049   [(set_attr "type" "dmul")])
5051 (define_insn ""
5052   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5053         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5054                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
5055                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5056   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5057   "fnmadds %0,%1,%2,%3"
5058   [(set_attr "type" "fp")])
5060 (define_insn ""
5061   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5062         (neg:SF (plus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5063                                   (match_operand:SF 2 "gpc_reg_operand" "f"))
5064                          (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5065   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5066   "{fnma|fnmadd} %0,%1,%2,%3"
5067   [(set_attr "type" "dmul")])
5069 (define_insn ""
5070   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5071         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5072                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
5073                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5074   "TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5075   "fnmsubs %0,%1,%2,%3"
5076   [(set_attr "type" "fp")])
5078 (define_insn ""
5079   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5080         (neg:SF (minus:SF (mult:SF (match_operand:SF 1 "gpc_reg_operand" "%f")
5081                                    (match_operand:SF 2 "gpc_reg_operand" "f"))
5082                           (match_operand:SF 3 "gpc_reg_operand" "f"))))]
5083   "! TARGET_POWERPC && TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5084   "{fnms|fnmsub} %0,%1,%2,%3"
5085   [(set_attr "type" "dmul")])
5087 (define_expand "sqrtsf2"
5088   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5089         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "")))]
5090   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
5091   "")
5093 (define_insn ""
5094   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5095         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5096   "TARGET_PPC_GPOPT && TARGET_HARD_FLOAT"
5097   "fsqrts %0,%1"
5098   [(set_attr "type" "ssqrt")])
5100 (define_insn ""
5101   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5102         (sqrt:SF (match_operand:SF 1 "gpc_reg_operand" "f")))]
5103   "TARGET_POWER2 && TARGET_HARD_FLOAT"
5104   "fsqrt %0,%1"
5105   [(set_attr "type" "dsqrt")])
5107 ;; For MIN, MAX, and conditional move, we use DEFINE_EXPAND's that involve a
5108 ;; fsel instruction and some auxiliary computations.  Then we just have a
5109 ;; single DEFINE_INSN for fsel and the define_splits to make them if made by
5110 ;; combine.
5111 (define_expand "maxsf3"
5112   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5113         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5114                              (match_operand:SF 2 "gpc_reg_operand" ""))
5115                          (match_dup 1)
5116                          (match_dup 2)))]
5117   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5118   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5120 (define_expand "minsf3"
5121   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5122         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "")
5123                              (match_operand:SF 2 "gpc_reg_operand" ""))
5124                          (match_dup 2)
5125                          (match_dup 1)))]
5126   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5127   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5129 (define_split
5130   [(set (match_operand:SF 0 "gpc_reg_operand" "")
5131         (match_operator:SF 3 "min_max_operator"
5132          [(match_operand:SF 1 "gpc_reg_operand" "")
5133           (match_operand:SF 2 "gpc_reg_operand" "")]))]
5134   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5135   [(const_int 0)]
5136   "
5137 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5138                       operands[1], operands[2]);
5139   DONE;
5142 (define_expand "movsfcc"
5143    [(set (match_operand:SF 0 "gpc_reg_operand" "")
5144          (if_then_else:SF (match_operand 1 "comparison_operator" "")
5145                           (match_operand:SF 2 "gpc_reg_operand" "")
5146                           (match_operand:SF 3 "gpc_reg_operand" "")))]
5147   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5148   "
5150   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5151     DONE;
5152   else
5153     FAIL;
5156 (define_insn "*fselsfsf4"
5157   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5158         (if_then_else:SF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5159                              (match_operand:SF 4 "zero_fp_constant" "F"))
5160                          (match_operand:SF 2 "gpc_reg_operand" "f")
5161                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5162   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5163   "fsel %0,%1,%2,%3"
5164   [(set_attr "type" "fp")])
5166 (define_insn "*fseldfsf4"
5167   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5168         (if_then_else:SF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5169                              (match_operand:DF 4 "zero_fp_constant" "F"))
5170                          (match_operand:SF 2 "gpc_reg_operand" "f")
5171                          (match_operand:SF 3 "gpc_reg_operand" "f")))]
5172   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5173   "fsel %0,%1,%2,%3"
5174   [(set_attr "type" "fp")])
5176 (define_insn "negdf2"
5177   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5178         (neg:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5179   "TARGET_HARD_FLOAT"
5180   "fneg %0,%1"
5181   [(set_attr "type" "fp")])
5183 (define_insn "absdf2"
5184   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5185         (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5186   "TARGET_HARD_FLOAT"
5187   "fabs %0,%1"
5188   [(set_attr "type" "fp")])
5190 (define_insn ""
5191   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5192         (neg:DF (abs:DF (match_operand:DF 1 "gpc_reg_operand" "f"))))]
5193   "TARGET_HARD_FLOAT"
5194   "fnabs %0,%1"
5195   [(set_attr "type" "fp")])
5197 (define_insn "adddf3"
5198   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5199         (plus:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5200                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5201   "TARGET_HARD_FLOAT"
5202   "{fa|fadd} %0,%1,%2"
5203   [(set_attr "type" "fp")])
5205 (define_insn "subdf3"
5206   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5207         (minus:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5208                   (match_operand:DF 2 "gpc_reg_operand" "f")))]
5209   "TARGET_HARD_FLOAT"
5210   "{fs|fsub} %0,%1,%2"
5211   [(set_attr "type" "fp")])
5213 (define_insn "muldf3"
5214   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5215         (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5216                  (match_operand:DF 2 "gpc_reg_operand" "f")))]
5217   "TARGET_HARD_FLOAT"
5218   "{fm|fmul} %0,%1,%2"
5219   [(set_attr "type" "dmul")])
5221 (define_insn "divdf3"
5222   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5223         (div:DF (match_operand:DF 1 "gpc_reg_operand" "f")
5224                 (match_operand:DF 2 "gpc_reg_operand" "f")))]
5225   "TARGET_HARD_FLOAT"
5226   "{fd|fdiv} %0,%1,%2"
5227   [(set_attr "type" "ddiv")])
5229 (define_insn ""
5230   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5231         (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5232                           (match_operand:DF 2 "gpc_reg_operand" "f"))
5233                  (match_operand:DF 3 "gpc_reg_operand" "f")))]
5234   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5235   "{fma|fmadd} %0,%1,%2,%3"
5236   [(set_attr "type" "dmul")])
5238 (define_insn ""
5239   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5240         (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5241                            (match_operand:DF 2 "gpc_reg_operand" "f"))
5242                   (match_operand:DF 3 "gpc_reg_operand" "f")))]
5243   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5244   "{fms|fmsub} %0,%1,%2,%3"
5245   [(set_attr "type" "dmul")])
5247 (define_insn ""
5248   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5249         (neg:DF (plus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5250                                   (match_operand:DF 2 "gpc_reg_operand" "f"))
5251                          (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5252   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5253   "{fnma|fnmadd} %0,%1,%2,%3"
5254   [(set_attr "type" "dmul")])
5256 (define_insn ""
5257   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5258         (neg:DF (minus:DF (mult:DF (match_operand:DF 1 "gpc_reg_operand" "%f")
5259                                    (match_operand:DF 2 "gpc_reg_operand" "f"))
5260                           (match_operand:DF 3 "gpc_reg_operand" "f"))))]
5261   "TARGET_HARD_FLOAT && TARGET_FUSED_MADD"
5262   "{fnms|fnmsub} %0,%1,%2,%3"
5263   [(set_attr "type" "dmul")])
5265 (define_insn "sqrtdf2"
5266   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5267         (sqrt:DF (match_operand:DF 1 "gpc_reg_operand" "f")))]
5268   "(TARGET_PPC_GPOPT || TARGET_POWER2) && TARGET_HARD_FLOAT"
5269   "fsqrt %0,%1"
5270   [(set_attr "type" "dsqrt")])
5272 ;; The conditional move instructions allow us to perform max and min
5273 ;; operations even when 
5275 (define_expand "maxdf3"
5276   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5277         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5278                              (match_operand:DF 2 "gpc_reg_operand" ""))
5279                          (match_dup 1)
5280                          (match_dup 2)))]
5281   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5282   "{ rs6000_emit_minmax (operands[0], SMAX, operands[1], operands[2]); DONE;}")
5284 (define_expand "mindf3"
5285   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5286         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "")
5287                              (match_operand:DF 2 "gpc_reg_operand" ""))
5288                          (match_dup 2)
5289                          (match_dup 1)))]
5290   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5291   "{ rs6000_emit_minmax (operands[0], SMIN, operands[1], operands[2]); DONE;}")
5293 (define_split
5294   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5295         (match_operator:DF 3 "min_max_operator"
5296          [(match_operand:DF 1 "gpc_reg_operand" "")
5297           (match_operand:DF 2 "gpc_reg_operand" "")]))]
5298   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5299   [(const_int 0)]
5300   "
5301 { rs6000_emit_minmax (operands[0], GET_CODE (operands[3]), 
5302                       operands[1], operands[2]);
5303   DONE;
5306 (define_expand "movdfcc"
5307    [(set (match_operand:DF 0 "gpc_reg_operand" "")
5308          (if_then_else:DF (match_operand 1 "comparison_operator" "")
5309                           (match_operand:DF 2 "gpc_reg_operand" "")
5310                           (match_operand:DF 3 "gpc_reg_operand" "")))]
5311   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5312   "
5314   if (rs6000_emit_cmove (operands[0], operands[1], operands[2], operands[3]))
5315     DONE;
5316   else
5317     FAIL;
5320 (define_insn "*fseldfdf4"
5321   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5322         (if_then_else:DF (ge (match_operand:DF 1 "gpc_reg_operand" "f")
5323                              (match_operand:DF 4 "zero_fp_constant" "F"))
5324                          (match_operand:DF 2 "gpc_reg_operand" "f")
5325                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5326   "TARGET_PPC_GFXOPT && TARGET_HARD_FLOAT"
5327   "fsel %0,%1,%2,%3"
5328   [(set_attr "type" "fp")])
5330 (define_insn "*fselsfdf4"
5331   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5332         (if_then_else:DF (ge (match_operand:SF 1 "gpc_reg_operand" "f")
5333                              (match_operand:SF 4 "zero_fp_constant" "F"))
5334                          (match_operand:DF 2 "gpc_reg_operand" "f")
5335                          (match_operand:DF 3 "gpc_reg_operand" "f")))]
5336   "TARGET_PPC_GFXOPT"
5337   "fsel %0,%1,%2,%3"
5338   [(set_attr "type" "fp")])
5340 ;; Conversions to and from floating-point.
5342 ; For each of these conversions, there is a define_expand, a define_insn
5343 ; with a '#' template, and a define_split (with C code).  The idea is
5344 ; to allow constant folding with the template of the define_insn,
5345 ; then to have the insns split later (between sched1 and final).
5347 (define_expand "floatsidf2"
5348   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5349                    (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5350               (use (match_dup 2))
5351               (use (match_dup 3))
5352               (clobber (match_dup 4))
5353               (clobber (match_dup 5))
5354               (clobber (match_dup 6))])]
5355   "TARGET_HARD_FLOAT"
5356   "
5358   if (TARGET_POWERPC64)
5359     {
5360       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5361       rtx t1 = gen_reg_rtx (DImode);
5362       rtx t2 = gen_reg_rtx (DImode);
5363       emit_insn (gen_floatsidf_ppc64 (operands[0], operands[1], mem, t1, t2));
5364       DONE;
5365     }
5367   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5368   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503601774854144\", DFmode));
5369   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5370   operands[5] = gen_reg_rtx (DFmode);
5371   operands[6] = gen_reg_rtx (SImode);
5374 (define_insn "*floatsidf2_internal"
5375   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5376         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5377    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5378    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5379    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5380    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))
5381    (clobber (match_operand:SI 6 "gpc_reg_operand" "=r"))]
5382   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5383   "#"
5384   [(set_attr "length" "24")])
5386 (define_split
5387   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5388         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5389    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5390    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5391    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5392    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5393    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5394   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5395   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5396         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5397    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5398    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5399    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5400    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))
5401    (clobber (match_operand:SI 6 "gpc_reg_operand" ""))]
5402   "
5404   rtx lowword, highword;
5405   if (GET_CODE (operands[4]) != MEM)
5406     abort();
5407   highword = XEXP (operands[4], 0);
5408   lowword = plus_constant (highword, 4);
5409   if (! WORDS_BIG_ENDIAN)
5410     {
5411       rtx tmp;
5412       tmp = highword; highword = lowword; lowword = tmp;
5413     }
5415   emit_insn (gen_xorsi3 (operands[6], operands[1], 
5416                          GEN_INT (~ (HOST_WIDE_INT) 0x7fffffff)));
5417   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[6]);
5418   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5419   emit_move_insn (operands[5], operands[4]);
5420   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5421   DONE;
5424 (define_expand "floatunssidf2"
5425   [(parallel [(set (match_operand:DF 0 "gpc_reg_operand" "")
5426                    (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5427               (use (match_dup 2))
5428               (use (match_dup 3))
5429               (clobber (match_dup 4))
5430               (clobber (match_dup 5))])]
5431   "TARGET_HARD_FLOAT"
5432   "
5434   if (TARGET_POWERPC64)
5435     {
5436       rtx mem = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5437       rtx t1 = gen_reg_rtx (DImode);
5438       rtx t2 = gen_reg_rtx (DImode);
5439       emit_insn (gen_floatunssidf_ppc64 (operands[0], operands[1], mem,
5440                                          t1, t2));
5441       DONE;
5442     }
5444   operands[2] = force_reg (SImode, GEN_INT (0x43300000));
5445   operands[3] = force_reg (DFmode, CONST_DOUBLE_ATOF (\"4503599627370496\", DFmode));
5446   operands[4] = assign_stack_temp (DFmode, GET_MODE_SIZE (DFmode), 0);
5447   operands[5] = gen_reg_rtx (DFmode);
5450 (define_insn "*floatunssidf2_internal"
5451   [(set (match_operand:DF 0 "gpc_reg_operand" "=&f")
5452         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5453    (use (match_operand:SI 2 "gpc_reg_operand" "r"))
5454    (use (match_operand:DF 3 "gpc_reg_operand" "f"))
5455    (clobber (match_operand:DF 4 "memory_operand" "=o"))
5456    (clobber (match_operand:DF 5 "gpc_reg_operand" "=f"))]
5457   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5458   "#"
5459   [(set_attr "length" "20")])
5461 (define_split
5462   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5463         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5464    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5465    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5466    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5467    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5468   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5469   [(set (match_operand:DF 0 "gpc_reg_operand" "")
5470         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
5471    (use (match_operand:SI 2 "gpc_reg_operand" ""))
5472    (use (match_operand:DF 3 "gpc_reg_operand" ""))
5473    (clobber (match_operand:DF 4 "offsettable_mem_operand" ""))
5474    (clobber (match_operand:DF 5 "gpc_reg_operand" ""))]
5475   "
5477   rtx lowword, highword;
5478   if (GET_CODE (operands[4]) != MEM)
5479     abort();
5480   highword = XEXP (operands[4], 0);
5481   lowword = plus_constant (highword, 4);
5482   if (! WORDS_BIG_ENDIAN)
5483     {
5484       rtx tmp;
5485       tmp = highword; highword = lowword; lowword = tmp;
5486     }
5488   emit_move_insn (gen_rtx_MEM (SImode, lowword), operands[1]);
5489   emit_move_insn (gen_rtx_MEM (SImode, highword), operands[2]);
5490   emit_move_insn (operands[5], operands[4]);
5491   emit_insn (gen_subdf3 (operands[0], operands[5], operands[3]));
5492   DONE;
5495 (define_expand "fix_truncdfsi2"
5496   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "")
5497                    (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5498               (clobber (match_dup 2))
5499               (clobber (match_dup 3))])]
5500   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5501   "
5503   operands[2] = gen_reg_rtx (DImode);
5504   operands[3] = assign_stack_temp (DImode, GET_MODE_SIZE (DImode), 0);
5507 (define_insn "*fix_truncdfsi2_internal"
5508   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5509         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "f")))
5510    (clobber (match_operand:DI 2 "gpc_reg_operand" "=f"))
5511    (clobber (match_operand:DI 3 "memory_operand" "=o"))]
5512   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5513   "#"
5514   [(set_attr "length" "16")])
5516 (define_split
5517   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5518         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5519    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5520    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5521   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5522   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5523         (fix:SI (match_operand:DF 1 "gpc_reg_operand" "")))
5524    (clobber (match_operand:DI 2 "gpc_reg_operand" ""))
5525    (clobber (match_operand:DI 3 "offsettable_mem_operand" ""))]
5526   "
5528   rtx lowword;
5529   if (GET_CODE (operands[3]) != MEM)
5530     abort();
5531   lowword = XEXP (operands[3], 0);
5532   if (WORDS_BIG_ENDIAN)
5533     lowword = plus_constant (lowword, 4);
5535   emit_insn (gen_fctiwz (operands[2], operands[1]));
5536   emit_move_insn (operands[3], operands[2]);
5537   emit_move_insn (operands[0], gen_rtx_MEM (SImode, lowword));
5538   DONE;
5541 ; Here, we use (set (reg) (unspec:DI [(fix:SI ...)] 10))
5542 ; rather than (set (subreg:SI (reg)) (fix:SI ...))
5543 ; because the first makes it clear that operand 0 is not live
5544 ; before the instruction.
5545 (define_insn "fctiwz"
5546   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5547         (unspec:DI [(fix:SI (match_operand:DF 1 "gpc_reg_operand" "f"))] 10))]
5548   "(TARGET_POWER2 || TARGET_POWERPC) && TARGET_HARD_FLOAT"
5549   "{fcirz|fctiwz} %0,%1"
5550   [(set_attr "type" "fp")])
5552 (define_insn "floatdidf2"
5553   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5554         (float:DF (match_operand:DI 1 "gpc_reg_operand" "*f")))]
5555   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5556   "fcfid %0,%1"
5557   [(set_attr "type" "fp")])
5559 (define_insn_and_split "floatsidf_ppc64"
5560   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5561         (float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5562    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5563    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5564    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5565   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5566   "#"
5567   ""
5568   [(set (match_dup 3) (sign_extend:DI (match_dup 1)))
5569    (set (match_dup 2) (match_dup 3))
5570    (set (match_dup 4) (match_dup 2))
5571    (set (match_dup 0) (float:DF (match_dup 4)))]
5572   "")
5574 (define_insn_and_split "floatunssidf_ppc64"
5575   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
5576         (unsigned_float:DF (match_operand:SI 1 "gpc_reg_operand" "r")))
5577    (clobber (match_operand:DI 2 "memory_operand" "=o"))
5578    (clobber (match_operand:DI 3 "gpc_reg_operand" "=r"))
5579    (clobber (match_operand:DI 4 "gpc_reg_operand" "=f"))]
5580   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5581   "#"
5582   ""
5583   [(set (match_dup 3) (zero_extend:DI (match_dup 1)))
5584    (set (match_dup 2) (match_dup 3))
5585    (set (match_dup 4) (match_dup 2))
5586    (set (match_dup 0) (float:DF (match_dup 4)))]
5587   "")
5589 (define_insn "fix_truncdfdi2"
5590   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
5591         (fix:DI (match_operand:DF 1 "gpc_reg_operand" "f")))]
5592   "TARGET_POWERPC64 && TARGET_HARD_FLOAT"
5593   "fctidz %0,%1"
5594   [(set_attr "type" "fp")])
5596 ;; This only is safe if rounding mode set appropriately.
5597 (define_insn_and_split "floatdisf2"
5598   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
5599         (float:SF (match_operand:DI 1 "gpc_reg_operand" "*f")))
5600    (clobber (match_scratch:DF 2 "=f"))]
5601   "TARGET_POWERPC64 && TARGET_HARD_FLOAT && flag_unsafe_math_optimizations"
5602   "#"
5603   "&& reload_completed"
5604   [(set (match_dup 2)
5605         (float:DF (match_dup 1)))
5606    (set (match_dup 0)
5607         (float_truncate:SF (match_dup 2)))]
5608   "")
5610 ;; Define the DImode operations that can be done in a small number
5611 ;; of instructions.  The & constraints are to prevent the register
5612 ;; allocator from allocating registers that overlap with the inputs
5613 ;; (for example, having an input in 7,8 and an output in 6,7).  We
5614 ;; also allow for the output being the same as one of the inputs.
5616 (define_insn "*adddi3_noppc64"
5617   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r")
5618         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,0,0")
5619                  (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I")))]
5620   "! TARGET_POWERPC64"
5621   "*
5623   if (WORDS_BIG_ENDIAN)
5624     return (GET_CODE (operands[2])) != CONST_INT
5625             ? \"{a|addc} %L0,%L1,%L2\;{ae|adde} %0,%1,%2\"
5626             : \"{ai|addic} %L0,%L1,%2\;{a%G2e|add%G2e} %0,%1\";
5627   else
5628     return (GET_CODE (operands[2])) != CONST_INT
5629             ? \"{a|addc} %0,%1,%2\;{ae|adde} %L0,%L1,%L2\"
5630             : \"{ai|addic} %0,%1,%2\;{a%G2e|add%G2e} %L0,%L1\";
5632   [(set_attr "length" "8")])
5634 (define_insn "*subdi3_noppc64"
5635   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r,r,r,r")
5636         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I,0,r,I")
5637                   (match_operand:DI 2 "gpc_reg_operand" "r,r,r,0,0")))]
5638   "! TARGET_POWERPC64"
5639   "*
5641   if (WORDS_BIG_ENDIAN)
5642     return (GET_CODE (operands[1]) != CONST_INT)
5643             ? \"{sf|subfc} %L0,%L2,%L1\;{sfe|subfe} %0,%2,%1\"
5644             : \"{sfi|subfic} %L0,%L2,%1\;{sf%G1e|subf%G1e} %0,%2\";
5645   else
5646     return (GET_CODE (operands[1]) != CONST_INT)
5647             ? \"{sf|subfc} %0,%2,%1\;{sfe|subfe} %L0,%L2,%L1\"
5648             : \"{sfi|subfic} %0,%2,%1\;{sf%G1e|subf%G1e} %L0,%L2\";
5650   [(set_attr "length" "8")])
5652 (define_insn "*negdi2_noppc64"
5653   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5654         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))]
5655   "! TARGET_POWERPC64"
5656   "*
5658   return (WORDS_BIG_ENDIAN)
5659     ? \"{sfi|subfic} %L0,%L1,0\;{sfze|subfze} %0,%1\"
5660     : \"{sfi|subfic} %0,%1,0\;{sfze|subfze} %L0,%L1\";
5662   [(set_attr "length" "8")])
5664 (define_expand "mulsidi3"
5665   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5666         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5667                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5668   "! TARGET_POWERPC64"
5669   "
5671   if (! TARGET_POWER && ! TARGET_POWERPC)
5672     {
5673       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5674       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5675       emit_insn (gen_mull_call ());
5676       if (WORDS_BIG_ENDIAN)
5677         emit_move_insn (operands[0], gen_rtx_REG (DImode, 3));
5678       else
5679         {
5680           emit_move_insn (operand_subword (operands[0], 0, 0, DImode),
5681                           gen_rtx_REG (SImode, 3));
5682           emit_move_insn (operand_subword (operands[0], 1, 0, DImode),
5683                           gen_rtx_REG (SImode, 4));
5684         }
5685       DONE;
5686     }
5687   else if (TARGET_POWER)
5688     {
5689       emit_insn (gen_mulsidi3_mq (operands[0], operands[1], operands[2]));
5690       DONE;
5691     }
5694 (define_insn "mulsidi3_mq"
5695   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
5696         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5697                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5698    (clobber (match_scratch:SI 3 "=q"))]
5699   "TARGET_POWER"
5700   "mul %0,%1,%2\;mfmq %L0"
5701   [(set_attr "type" "imul")
5702    (set_attr "length" "8")])
5704 (define_insn "*mulsidi3_no_mq"
5705   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5706         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5707                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5708   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5709   "*
5711   return (WORDS_BIG_ENDIAN)
5712     ? \"mulhw %0,%1,%2\;mullw %L0,%1,%2\"
5713     : \"mulhw %L0,%1,%2\;mullw %0,%1,%2\";
5715   [(set_attr "type" "imul")
5716    (set_attr "length" "8")])
5718 (define_split
5719   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5720         (mult:DI (sign_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5721                  (sign_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5722   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5723   [(set (match_dup 3)
5724         (truncate:SI
5725          (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1))
5726                                (sign_extend:DI (match_dup 2)))
5727                       (const_int 32))))
5728    (set (match_dup 4)
5729         (mult:SI (match_dup 1)
5730                  (match_dup 2)))]
5731   "
5733   int endian = (WORDS_BIG_ENDIAN == 0);
5734   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5735   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5738 (define_expand "umulsidi3"
5739   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5740         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5741                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5742   "TARGET_POWERPC && ! TARGET_POWERPC64"
5743   "
5745   if (TARGET_POWER)
5746     {
5747       emit_insn (gen_umulsidi3_mq (operands[0], operands[1], operands[2]));
5748       DONE;
5749     }
5752 (define_insn "umulsidi3_mq"
5753   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5754         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5755                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))
5756    (clobber (match_scratch:SI 3 "=q"))]
5757   "TARGET_POWERPC && TARGET_POWER"
5758   "*
5760   return (WORDS_BIG_ENDIAN)
5761     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5762     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5764   [(set_attr "type" "imul")
5765    (set_attr "length" "8")])
5767 (define_insn "*umulsidi3_no_mq"
5768   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
5769         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" "%r"))
5770                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" "r"))))]
5771   "TARGET_POWERPC && ! TARGET_POWER && ! TARGET_POWERPC64"
5772   "*
5774   return (WORDS_BIG_ENDIAN)
5775     ? \"mulhwu %0,%1,%2\;mullw %L0,%1,%2\"
5776     : \"mulhwu %L0,%1,%2\;mullw %0,%1,%2\";
5778   [(set_attr "type" "imul")
5779    (set_attr "length" "8")])
5781 (define_split
5782   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5783         (mult:DI (zero_extend:DI (match_operand:SI 1 "gpc_reg_operand" ""))
5784                  (zero_extend:DI (match_operand:SI 2 "gpc_reg_operand" ""))))]
5785   "TARGET_POWERPC && ! TARGET_POWERPC64 && reload_completed"
5786   [(set (match_dup 3)
5787         (truncate:SI
5788          (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1))
5789                                (zero_extend:DI (match_dup 2)))
5790                       (const_int 32))))
5791    (set (match_dup 4)
5792         (mult:SI (match_dup 1)
5793                  (match_dup 2)))]
5794   "
5796   int endian = (WORDS_BIG_ENDIAN == 0);
5797   operands[3] = operand_subword (operands[0], endian, 0, DImode);
5798   operands[4] = operand_subword (operands[0], 1 - endian, 0, DImode);
5801 (define_expand "smulsi3_highpart"
5802   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5803         (truncate:SI
5804          (lshiftrt:DI (mult:DI (sign_extend:DI
5805                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5806                                (sign_extend:DI
5807                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5808                       (const_int 32))))]
5809   ""
5810   "
5812   if (! TARGET_POWER && ! TARGET_POWERPC)
5813     {
5814       emit_move_insn (gen_rtx_REG (SImode, 3), operands[1]);
5815       emit_move_insn (gen_rtx_REG (SImode, 4), operands[2]);
5816       emit_insn (gen_mulh_call ());
5817       emit_move_insn (operands[0], gen_rtx_REG (SImode, 3));
5818       DONE;
5819     }
5820   else if (TARGET_POWER)
5821     {
5822       emit_insn (gen_smulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5823       DONE;
5824     }
5827 (define_insn "smulsi3_highpart_mq"
5828   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5829         (truncate:SI
5830          (lshiftrt:DI (mult:DI (sign_extend:DI
5831                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5832                                (sign_extend:DI
5833                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5834                       (const_int 32))))
5835    (clobber (match_scratch:SI 3 "=q"))]
5836   "TARGET_POWER"
5837   "mul %0,%1,%2"
5838   [(set_attr "type" "imul")])
5840 (define_insn "*smulsi3_highpart_no_mq"
5841   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5842         (truncate:SI
5843          (lshiftrt:DI (mult:DI (sign_extend:DI
5844                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5845                                (sign_extend:DI
5846                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5847                       (const_int 32))))]
5848   "TARGET_POWERPC && ! TARGET_POWER"
5849   "mulhw %0,%1,%2"
5850   [(set_attr "type" "imul")])
5852 (define_expand "umulsi3_highpart"
5853   [(set (match_operand:SI 0 "gpc_reg_operand" "")
5854         (truncate:SI
5855          (lshiftrt:DI (mult:DI (zero_extend:DI
5856                                 (match_operand:SI 1 "gpc_reg_operand" ""))
5857                                (zero_extend:DI
5858                                 (match_operand:SI 2 "gpc_reg_operand" "")))
5859                       (const_int 32))))]
5860   "TARGET_POWERPC"
5861   "
5863   if (TARGET_POWER)
5864     {
5865       emit_insn (gen_umulsi3_highpart_mq (operands[0], operands[1], operands[2]));
5866       DONE;
5867     }
5870 (define_insn "umulsi3_highpart_mq"
5871   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5872         (truncate:SI
5873          (lshiftrt:DI (mult:DI (zero_extend:DI
5874                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5875                                (zero_extend:DI
5876                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5877                       (const_int 32))))
5878    (clobber (match_scratch:SI 3 "=q"))]
5879   "TARGET_POWERPC && TARGET_POWER"
5880   "mulhwu %0,%1,%2"
5881   [(set_attr "type" "imul")])
5883 (define_insn "*umulsi3_highpart_no_mq"
5884   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
5885         (truncate:SI
5886          (lshiftrt:DI (mult:DI (zero_extend:DI
5887                                 (match_operand:SI 1 "gpc_reg_operand" "%r"))
5888                                (zero_extend:DI
5889                                 (match_operand:SI 2 "gpc_reg_operand" "r")))
5890                       (const_int 32))))]
5891   "TARGET_POWERPC && ! TARGET_POWER"
5892   "mulhwu %0,%1,%2"
5893   [(set_attr "type" "imul")])
5895 ;; If operands 0 and 2 are in the same register, we have a problem.  But
5896 ;; operands 0 and 1 (the usual case) can be in the same register.  That's
5897 ;; why we have the strange constraints below.
5898 (define_insn "ashldi3_power"
5899   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5900         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5901                    (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5902    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5903   "TARGET_POWER"
5904   "@
5905    {sli|slwi} %0,%L1,%h2\;{cal %L0,0(0)|li %L0,0}
5906    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5907    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2
5908    sl%I2q %L0,%L1,%h2\;sll%I2q %0,%1,%h2"
5909   [(set_attr "length" "8")])
5911 (define_insn "lshrdi3_power"
5912   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,&r")
5913         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,0,r")
5914                      (match_operand:SI 2 "reg_or_cint_operand" "M,i,r,r")))
5915    (clobber (match_scratch:SI 3 "=X,q,q,q"))]
5916   "TARGET_POWER"
5917   "@
5918    {s%A2i|s%A2wi} %L0,%1,%h2\;{cal %0,0(0)|li %0,0}
5919    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5920    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2
5921    sr%I2q %0,%1,%h2\;srl%I2q %L0,%L1,%h2"
5922   [(set_attr "length" "8")])
5924 ;; Shift by a variable amount is too complex to be worth open-coding.  We
5925 ;; just handle shifts by constants.
5926 (define_insn "ashrdi3_power"
5927   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
5928         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5929                      (match_operand:SI 2 "const_int_operand" "M,i")))
5930    (clobber (match_scratch:SI 3 "=X,q"))]
5931   "TARGET_POWER"
5932   "@
5933    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5934    sraiq %0,%1,%h2\;srliq %L0,%L1,%h2"
5935   [(set_attr "length" "8")])
5937 (define_insn "ashrdi3_no_power"
5938   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,&r")
5939         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
5940                      (match_operand:SI 2 "const_int_operand" "M,i")))]
5941   "TARGET_32BIT && !TARGET_POWER"
5942   "@
5943    {srai|srawi} %0,%1,31\;{srai|srawi} %L0,%1,%h2
5944    {sri|srwi} %L0,%L1,%h2\;insrwi %L0,%1,%h2,0\;{srai|srawi} %0,%1,%h2"
5945   [(set_attr "length" "8,12")])
5947 ;; PowerPC64 DImode operations.
5949 (define_expand "adddi3"
5950   [(set (match_operand:DI 0 "gpc_reg_operand" "")
5951         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
5952                  (match_operand:DI 2 "reg_or_add_cint64_operand" "")))]
5953   ""
5954   "
5956   if (! TARGET_POWERPC64)
5957     {
5958       if (non_short_cint_operand (operands[2], DImode))
5959         FAIL;
5960     }
5961   else
5962     if (GET_CODE (operands[2]) == CONST_INT
5963         && ! add_operand (operands[2], DImode))
5964       {
5965         rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
5966                    ? operands[0] : gen_reg_rtx (DImode));
5968         HOST_WIDE_INT val = INTVAL (operands[2]);
5969         HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
5970         HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
5972         if (!CONST_OK_FOR_LETTER_P (rest, 'L'))
5973           FAIL;
5975         /* The ordering here is important for the prolog expander.
5976            When space is allocated from the stack, adding 'low' first may
5977            produce a temporary deallocation (which would be bad).  */
5978         emit_insn (gen_adddi3 (tmp, operands[1], GEN_INT (rest)));
5979         emit_insn (gen_adddi3 (operands[0], tmp, GEN_INT (low)));
5980         DONE;
5981       }
5984 ;; Discourage ai/addic because of carry but provide it in an alternative
5985 ;; allowing register zero as source.
5987 (define_insn "*adddi3_internal1"
5988   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,?r,r")
5989         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,b,r,b")
5990                  (match_operand:DI 2 "add_operand" "r,I,I,L")))]
5991   "TARGET_POWERPC64"
5992   "@
5993    add %0,%1,%2
5994    addi %0,%1,%2
5995    addic %0,%1,%2
5996    addis %0,%1,%v2")
5998 (define_insn "*adddi3_internal2"
5999   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
6000         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
6001                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
6002                     (const_int 0)))
6003    (clobber (match_scratch:DI 3 "=r,r,r,r"))]
6004   "TARGET_POWERPC64"
6005   "@
6006    add. %3,%1,%2
6007    addic. %3,%1,%2
6008    #
6009    #"
6010   [(set_attr "type" "compare")
6011    (set_attr "length" "4,4,8,8")])
6013 (define_split
6014   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6015         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6016                              (match_operand:DI 2 "reg_or_short_operand" ""))
6017                     (const_int 0)))
6018    (clobber (match_scratch:DI 3 ""))]
6019   "TARGET_POWERPC64 && reload_completed"
6020   [(set (match_dup 3)
6021         (plus:DI (match_dup 1) (match_dup 2)))
6022    (set (match_dup 0)
6023         (compare:CC (match_dup 3)
6024                     (const_int 0)))]
6025   "")
6027 (define_insn "*adddi3_internal3"
6028   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
6029         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
6030                              (match_operand:DI 2 "reg_or_short_operand" "r,I,r,I"))
6031                     (const_int 0)))
6032    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
6033         (plus:DI (match_dup 1) (match_dup 2)))]
6034   "TARGET_POWERPC64"
6035   "@
6036    add. %0,%1,%2
6037    addic. %0,%1,%2
6038    #
6039    #"
6040   [(set_attr "type" "compare")
6041    (set_attr "length" "4,4,8,8")])
6043 (define_split
6044   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6045         (compare:CC (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6046                              (match_operand:DI 2 "reg_or_short_operand" ""))
6047                     (const_int 0)))
6048    (set (match_operand:DI 0 "gpc_reg_operand" "")
6049         (plus:DI (match_dup 1) (match_dup 2)))]
6050   "TARGET_POWERPC64 && reload_completed"
6051   [(set (match_dup 0)
6052         (plus:DI (match_dup 1) (match_dup 2)))
6053    (set (match_dup 3)
6054         (compare:CC (match_dup 0)
6055                     (const_int 0)))]
6056   "")
6058 ;; Split an add that we can't do in one insn into two insns, each of which
6059 ;; does one 16-bit part.  This is used by combine.  Note that the low-order
6060 ;; add should be last in case the result gets used in an address.
6062 (define_split
6063   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6064         (plus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6065                  (match_operand:DI 2 "non_add_cint_operand" "")))]
6066   "TARGET_POWERPC64"
6067   [(set (match_dup 0) (plus:DI (match_dup 1) (match_dup 3)))
6068    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
6071   HOST_WIDE_INT val = INTVAL (operands[2]);
6072   HOST_WIDE_INT low = ((val & 0xffff) ^ 0x8000) - 0x8000;
6073   HOST_WIDE_INT rest = trunc_int_for_mode (val - low, DImode);
6075   operands[4] = GEN_INT (low);
6076   if (CONST_OK_FOR_LETTER_P (rest, 'L'))
6077     operands[3] = GEN_INT (rest);
6078   else if (! no_new_pseudos)
6079     {
6080       operands[3] = gen_reg_rtx (DImode);
6081       emit_move_insn (operands[3], operands[2]);
6082       emit_insn (gen_adddi3 (operands[0], operands[1], operands[3]));
6083       DONE;
6084     }
6085   else
6086     FAIL;
6089 (define_insn "one_cmpldi2"
6090   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6091         (not:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6092   "TARGET_POWERPC64"
6093   "nor %0,%1,%1")
6095 (define_insn ""
6096   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6097         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6098                     (const_int 0)))
6099    (clobber (match_scratch:DI 2 "=r,r"))]
6100   "TARGET_POWERPC64"
6101   "@
6102    nor. %2,%1,%1
6103    #"
6104   [(set_attr "type" "compare")
6105    (set_attr "length" "4,8")])
6107 (define_split
6108   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6109         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6110                     (const_int 0)))
6111    (clobber (match_scratch:DI 2 ""))]
6112   "TARGET_POWERPC64 && reload_completed"
6113   [(set (match_dup 2)
6114         (not:DI (match_dup 1)))
6115    (set (match_dup 0)
6116         (compare:CC (match_dup 2)
6117                     (const_int 0)))]
6118   "")
6120 (define_insn ""
6121   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6122         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6123                     (const_int 0)))
6124    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6125         (not:DI (match_dup 1)))]
6126   "TARGET_POWERPC64"
6127   "@
6128    nor. %0,%1,%1
6129    #"
6130   [(set_attr "type" "compare")
6131    (set_attr "length" "4,8")])
6133 (define_split
6134   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6135         (compare:CC (not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6136                     (const_int 0)))
6137    (set (match_operand:DI 0 "gpc_reg_operand" "")
6138         (not:DI (match_dup 1)))]
6139   "TARGET_POWERPC64 && reload_completed"
6140   [(set (match_dup 0)
6141         (not:DI (match_dup 1)))
6142    (set (match_dup 2)
6143         (compare:CC (match_dup 0)
6144                     (const_int 0)))]
6145   "")
6147 (define_insn ""
6148   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6149         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "r,I")
6150                   (match_operand:DI 2 "gpc_reg_operand" "r,r")))]
6151   "TARGET_POWERPC64"
6152   "@
6153    subf %0,%2,%1
6154    subfic %0,%2,%1")
6156 (define_insn ""
6157   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6158         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6159                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6160                     (const_int 0)))
6161    (clobber (match_scratch:DI 3 "=r,r"))]
6162   "TARGET_POWERPC64"
6163   "@
6164    subf. %3,%2,%1
6165    #"
6166   [(set_attr "type" "compare")
6167    (set_attr "length" "4,8")])
6169 (define_split
6170   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6171         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6172                               (match_operand:DI 2 "gpc_reg_operand" ""))
6173                     (const_int 0)))
6174    (clobber (match_scratch:DI 3 ""))]
6175   "TARGET_POWERPC64 && reload_completed"
6176   [(set (match_dup 3)
6177         (minus:DI (match_dup 1) (match_dup 2)))
6178    (set (match_dup 0)
6179         (compare:CC (match_dup 3)
6180                     (const_int 0)))]
6181   "")
6183 (define_insn ""
6184   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6185         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6186                               (match_operand:DI 2 "gpc_reg_operand" "r,r"))
6187                     (const_int 0)))
6188    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6189         (minus:DI (match_dup 1) (match_dup 2)))]
6190   "TARGET_POWERPC64"
6191   "@
6192    subf. %0,%2,%1
6193    #"
6194   [(set_attr "type" "compare")
6195    (set_attr "length" "4,8")])
6197 (define_split
6198   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6199         (compare:CC (minus:DI (match_operand:DI 1 "gpc_reg_operand" "")
6200                               (match_operand:DI 2 "gpc_reg_operand" ""))
6201                     (const_int 0)))
6202    (set (match_operand:DI 0 "gpc_reg_operand" "")
6203         (minus:DI (match_dup 1) (match_dup 2)))]
6204   "TARGET_POWERPC64 && reload_completed"
6205   [(set (match_dup 0)
6206         (minus:DI (match_dup 1) (match_dup 2)))
6207    (set (match_dup 3)
6208         (compare:CC (match_dup 0)
6209                     (const_int 0)))]
6210   "")
6212 (define_expand "subdi3"
6213   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6214         (minus:DI (match_operand:DI 1 "reg_or_short_operand" "")
6215                   (match_operand:DI 2 "reg_or_sub_cint64_operand" "")))]
6216   ""
6217   "
6219   if (GET_CODE (operands[2]) == CONST_INT)
6220     {
6221       emit_insn (gen_adddi3 (operands[0], operands[1],
6222                              negate_rtx (DImode, operands[2])));
6223       DONE;
6224     }
6227 (define_insn_and_split "absdi2"
6228   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6229         (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0")))
6230    (clobber (match_scratch:DI 2 "=&r,&r"))]
6231   "TARGET_POWERPC64"
6232   "#"
6233   "&& reload_completed"
6234   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6235    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6236    (set (match_dup 0) (minus:DI (match_dup 0) (match_dup 2)))]
6237   "")
6239 (define_insn_and_split "*nabsdi2"
6240   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r,r")
6241         (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,0"))))
6242    (clobber (match_scratch:DI 2 "=&r,&r"))]
6243   "TARGET_POWERPC64"
6244   "#"
6245   "&& reload_completed"
6246   [(set (match_dup 2) (ashiftrt:DI (match_dup 1) (const_int 63)))
6247    (set (match_dup 0) (xor:DI (match_dup 2) (match_dup 1)))
6248    (set (match_dup 0) (minus:DI (match_dup 2) (match_dup 0)))]
6249   "")
6251 (define_expand "negdi2"
6252   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6253         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "")))]
6254   ""
6255   "")
6257 (define_insn ""
6258   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6259         (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6260   "TARGET_POWERPC64"
6261   "neg %0,%1")
6263 (define_insn ""
6264   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6265         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6266                     (const_int 0)))
6267    (clobber (match_scratch:DI 2 "=r,r"))]
6268   "TARGET_POWERPC64"
6269   "@
6270    neg. %2,%1
6271    #"
6272   [(set_attr "type" "compare")
6273    (set_attr "length" "4,8")])
6275 (define_split
6276   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6277         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6278                     (const_int 0)))
6279    (clobber (match_scratch:DI 2 ""))]
6280   "TARGET_POWERPC64 && reload_completed"
6281   [(set (match_dup 2)
6282         (neg:DI (match_dup 1)))
6283    (set (match_dup 0)
6284         (compare:CC (match_dup 2)
6285                     (const_int 0)))]
6286   "")
6288 (define_insn ""
6289   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
6290         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
6291                     (const_int 0)))
6292    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6293         (neg:DI (match_dup 1)))]
6294   "TARGET_POWERPC64"
6295   "@
6296    neg. %0,%1
6297    #"
6298   [(set_attr "type" "compare")
6299    (set_attr "length" "4,8")])
6301 (define_split
6302   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
6303         (compare:CC (neg:DI (match_operand:DI 1 "gpc_reg_operand" ""))
6304                     (const_int 0)))
6305    (set (match_operand:DI 0 "gpc_reg_operand" "")
6306         (neg:DI (match_dup 1)))]
6307   "TARGET_POWERPC64 && reload_completed"
6308   [(set (match_dup 0)
6309         (neg:DI (match_dup 1)))
6310    (set (match_dup 2)
6311         (compare:CC (match_dup 0)
6312                     (const_int 0)))]
6313   "")
6315 (define_insn "ffsdi2"
6316   [(set (match_operand:DI 0 "gpc_reg_operand" "=&r")
6317         (ffs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))]
6318   "TARGET_POWERPC64"
6319   "neg %0,%1\;and %0,%0,%1\;cntlzd %0,%0\;subfic %0,%0,64"
6320   [(set_attr "length" "16")])
6322 (define_insn "muldi3"
6323   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6324         (mult:DI (match_operand:DI 1 "gpc_reg_operand" "%r")
6325                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6326   "TARGET_POWERPC64"
6327   "mulld %0,%1,%2"
6328    [(set_attr "type" "lmul")])
6330 (define_insn "smuldi3_highpart"
6331   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6332         (truncate:DI
6333          (lshiftrt:TI (mult:TI (sign_extend:TI
6334                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6335                                (sign_extend:TI
6336                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6337                       (const_int 64))))]
6338   "TARGET_POWERPC64"
6339   "mulhd %0,%1,%2"
6340   [(set_attr "type" "lmul")])
6342 (define_insn "umuldi3_highpart"
6343   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6344         (truncate:DI
6345          (lshiftrt:TI (mult:TI (zero_extend:TI
6346                                 (match_operand:DI 1 "gpc_reg_operand" "%r"))
6347                                (zero_extend:TI
6348                                 (match_operand:DI 2 "gpc_reg_operand" "r")))
6349                       (const_int 64))))]
6350   "TARGET_POWERPC64"
6351   "mulhdu %0,%1,%2"
6352   [(set_attr "type" "lmul")])
6354 (define_expand "divdi3"
6355   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6356         (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6357                 (match_operand:DI 2 "reg_or_cint_operand" "")))]
6358   "TARGET_POWERPC64"
6359   "
6361   if (GET_CODE (operands[2]) == CONST_INT
6362       && INTVAL (operands[2]) > 0
6363       && exact_log2 (INTVAL (operands[2])) >= 0)
6364     ;
6365   else
6366     operands[2] = force_reg (DImode, operands[2]);
6369 (define_expand "moddi3"
6370   [(use (match_operand:DI 0 "gpc_reg_operand" ""))
6371    (use (match_operand:DI 1 "gpc_reg_operand" ""))
6372    (use (match_operand:DI 2 "reg_or_cint_operand" ""))]
6373   "TARGET_POWERPC64"
6374   "
6376   int i;
6377   rtx temp1;
6378   rtx temp2;
6380   if (GET_CODE (operands[2]) != CONST_INT
6381       || INTVAL (operands[2]) <= 0
6382       || (i = exact_log2 (INTVAL (operands[2]))) < 0)
6383     FAIL;
6385   temp1 = gen_reg_rtx (DImode);
6386   temp2 = gen_reg_rtx (DImode);
6388   emit_insn (gen_divdi3 (temp1, operands[1], operands[2]));
6389   emit_insn (gen_ashldi3 (temp2, temp1, GEN_INT (i)));
6390   emit_insn (gen_subdi3 (operands[0], operands[1], temp2));
6391   DONE;
6394 (define_insn ""
6395   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6396         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6397                 (match_operand:DI 2 "exact_log2_cint_operand" "N")))]
6398   "TARGET_POWERPC64"
6399   "sradi %0,%1,%p2\;addze %0,%0"
6400   [(set_attr "length" "8")])
6402 (define_insn ""
6403   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6404         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6405                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6406                     (const_int 0)))
6407    (clobber (match_scratch:DI 3 "=r,r"))]
6408   "TARGET_POWERPC64"
6409   "@
6410    sradi %3,%1,%p2\;addze. %3,%3
6411    #"
6412   [(set_attr "type" "compare")
6413    (set_attr "length" "8,12")])
6415 (define_split
6416   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6417         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6418                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6419                     (const_int 0)))
6420    (clobber (match_scratch:DI 3 ""))]
6421   "TARGET_POWERPC64 && reload_completed"
6422   [(set (match_dup 3)
6423         (div:DI (match_dup 1) (match_dup 2)))
6424    (set (match_dup 0)
6425         (compare:CC (match_dup 3)
6426                     (const_int 0)))]
6427   "")
6429 (define_insn ""
6430   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6431         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6432                             (match_operand:DI 2 "exact_log2_cint_operand" "N,N"))
6433                     (const_int 0)))
6434    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6435         (div:DI (match_dup 1) (match_dup 2)))]
6436   "TARGET_POWERPC64"
6437   "@
6438    sradi %0,%1,%p2\;addze. %0,%0
6439    #"
6440   [(set_attr "type" "compare")
6441    (set_attr "length" "8,12")])
6443 (define_split
6444   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6445         (compare:CC (div:DI (match_operand:DI 1 "gpc_reg_operand" "")
6446                             (match_operand:DI 2 "exact_log2_cint_operand" ""))
6447                     (const_int 0)))
6448    (set (match_operand:DI 0 "gpc_reg_operand" "")
6449         (div:DI (match_dup 1) (match_dup 2)))]
6450   "TARGET_POWERPC64 && reload_completed"
6451   [(set (match_dup 0)
6452         (div:DI (match_dup 1) (match_dup 2)))
6453    (set (match_dup 3)
6454         (compare:CC (match_dup 0)
6455                     (const_int 0)))]
6456   "")
6458 (define_insn ""
6459   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6460         (div:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6461                 (match_operand:DI 2 "gpc_reg_operand" "r")))]
6462   "TARGET_POWERPC64"
6463   "divd %0,%1,%2"
6464   [(set_attr "type" "ldiv")])
6466 (define_insn "udivdi3"
6467   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6468         (udiv:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6469                  (match_operand:DI 2 "gpc_reg_operand" "r")))]
6470   "TARGET_POWERPC64"
6471   "divdu %0,%1,%2"
6472   [(set_attr "type" "ldiv")])
6474 (define_insn "rotldi3"
6475   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6476         (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6477                    (match_operand:DI 2 "reg_or_cint_operand" "ri")))]
6478   "TARGET_POWERPC64"
6479   "rld%I2cl %0,%1,%H2,0")
6481 (define_insn "*rotldi3_internal2"
6482   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6483         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6484                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6485                     (const_int 0)))
6486    (clobber (match_scratch:DI 3 "=r,r"))]
6487   "TARGET_POWERPC64"
6488   "@
6489    rld%I2cl. %3,%1,%H2,0
6490    #"
6491   [(set_attr "type" "delayed_compare")
6492    (set_attr "length" "4,8")])
6494 (define_split
6495   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6496         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6497                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6498                     (const_int 0)))
6499    (clobber (match_scratch:DI 3 ""))]
6500   "TARGET_POWERPC64 && reload_completed"
6501   [(set (match_dup 3)
6502         (rotate:DI (match_dup 1) (match_dup 2)))
6503    (set (match_dup 0)
6504         (compare:CC (match_dup 3)
6505                     (const_int 0)))]
6506   "")
6508 (define_insn "*rotldi3_internal3"
6509   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6510         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6511                                (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6512                     (const_int 0)))
6513    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6514         (rotate:DI (match_dup 1) (match_dup 2)))]
6515   "TARGET_POWERPC64"
6516   "@
6517    rld%I2cl. %0,%1,%H2,0
6518    #"
6519   [(set_attr "type" "delayed_compare")
6520    (set_attr "length" "4,8")])
6522 (define_split
6523   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6524         (compare:CC (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6525                                (match_operand:DI 2 "reg_or_cint_operand" ""))
6526                     (const_int 0)))
6527    (set (match_operand:DI 0 "gpc_reg_operand" "")
6528         (rotate:DI (match_dup 1) (match_dup 2)))]
6529   "TARGET_POWERPC64 && reload_completed"
6530   [(set (match_dup 0)
6531         (rotate:DI (match_dup 1) (match_dup 2)))
6532    (set (match_dup 3)
6533         (compare:CC (match_dup 0)
6534                     (const_int 0)))]
6535   "")
6537 (define_insn "*rotldi3_internal4"
6538   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6539         (and:DI (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6540                            (match_operand:DI 2 "reg_or_cint_operand" "ri"))
6541                 (match_operand:DI 3 "mask64_operand" "S")))]
6542   "TARGET_POWERPC64"
6543   "rld%I2c%B3 %0,%1,%H2,%S3")
6545 (define_insn "*rotldi3_internal5"
6546   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6547         (compare:CC (and:DI
6548                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6549                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6550                      (match_operand:DI 3 "mask64_operand" "S,S"))
6551                     (const_int 0)))
6552    (clobber (match_scratch:DI 4 "=r,r"))]
6553   "TARGET_POWERPC64"
6554   "@
6555    rld%I2c%B3. %4,%1,%H2,%S3
6556    #"
6557   [(set_attr "type" "delayed_compare")
6558    (set_attr "length" "4,8")])
6560 (define_split
6561   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6562         (compare:CC (and:DI
6563                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6564                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6565                      (match_operand:DI 3 "mask64_operand" ""))
6566                     (const_int 0)))
6567    (clobber (match_scratch:DI 4 ""))]
6568   "TARGET_POWERPC64 && reload_completed"
6569   [(set (match_dup 4)
6570         (and:DI (rotate:DI (match_dup 1)
6571                                 (match_dup 2))
6572                      (match_dup 3)))
6573    (set (match_dup 0)
6574         (compare:CC (match_dup 4)
6575                     (const_int 0)))]
6576   "")
6578 (define_insn "*rotldi3_internal6"
6579   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6580         (compare:CC (and:DI
6581                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6582                                 (match_operand:DI 2 "reg_or_cint_operand" "ri,ri"))
6583                      (match_operand:DI 3 "mask64_operand" "S,S"))
6584                     (const_int 0)))
6585    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6586         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6587   "TARGET_POWERPC64"
6588   "@
6589    rld%I2c%B3. %0,%1,%H2,%S3
6590    #"
6591   [(set_attr "type" "delayed_compare")
6592    (set_attr "length" "4,8")])
6594 (define_split
6595   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6596         (compare:CC (and:DI
6597                      (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6598                                 (match_operand:DI 2 "reg_or_cint_operand" ""))
6599                      (match_operand:DI 3 "mask64_operand" ""))
6600                     (const_int 0)))
6601    (set (match_operand:DI 0 "gpc_reg_operand" "")
6602         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6603   "TARGET_POWERPC64 && reload_completed"
6604   [(set (match_dup 0)
6605         (and:DI (rotate:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
6606    (set (match_dup 4)
6607         (compare:CC (match_dup 0)
6608                     (const_int 0)))]
6609   "")
6611 (define_insn "*rotldi3_internal7"
6612   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6613         (zero_extend:DI
6614          (subreg:QI
6615           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6616                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6617   "TARGET_POWERPC64"
6618   "rld%I2cl %0,%1,%H2,56")
6620 (define_insn "*rotldi3_internal8"
6621   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6622         (compare:CC (zero_extend:DI
6623                      (subreg:QI
6624                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6625                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6626                     (const_int 0)))
6627    (clobber (match_scratch:DI 3 "=r,r"))]
6628   "TARGET_POWERPC64"
6629   "@
6630    rld%I2cl. %3,%1,%H2,56
6631    #"
6632   [(set_attr "type" "delayed_compare")
6633    (set_attr "length" "4,8")])
6635 (define_split
6636   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6637         (compare:CC (zero_extend:DI
6638                      (subreg:QI
6639                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6640                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6641                     (const_int 0)))
6642    (clobber (match_scratch:DI 3 ""))]
6643   "TARGET_POWERPC64 && reload_completed"
6644   [(set (match_dup 3)
6645         (zero_extend:DI (subreg:QI
6646                       (rotate:DI (match_dup 1)
6647                                  (match_dup 2)) 0)))
6648    (set (match_dup 0)
6649         (compare:CC (match_dup 3)
6650                     (const_int 0)))]
6651   "")
6653 (define_insn "*rotldi3_internal9"
6654   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6655         (compare:CC (zero_extend:DI
6656                      (subreg:QI
6657                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6658                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6659                     (const_int 0)))
6660    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6661         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6662   "TARGET_POWERPC64"
6663   "@
6664    rld%I2cl. %0,%1,%H2,56
6665    #"
6666   [(set_attr "type" "delayed_compare")
6667    (set_attr "length" "4,8")])
6669 (define_split
6670   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6671         (compare:CC (zero_extend:DI
6672                      (subreg:QI
6673                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6674                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6675                     (const_int 0)))
6676    (set (match_operand:DI 0 "gpc_reg_operand" "")
6677         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6678   "TARGET_POWERPC64 && reload_completed"
6679   [(set (match_dup 0)
6680         (zero_extend:DI (subreg:QI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6681    (set (match_dup 3)
6682         (compare:CC (match_dup 0)
6683                     (const_int 0)))]
6684   "")
6686 (define_insn "*rotldi3_internal10"
6687   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6688         (zero_extend:DI
6689          (subreg:HI
6690           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6691                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6692   "TARGET_POWERPC64"
6693   "rld%I2cl %0,%1,%H2,48")
6695 (define_insn "*rotldi3_internal11"
6696   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6697         (compare:CC (zero_extend:DI
6698                      (subreg:HI
6699                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6700                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6701                     (const_int 0)))
6702    (clobber (match_scratch:DI 3 "=r,r"))]
6703   "TARGET_POWERPC64"
6704   "@
6705    rld%I2cl. %3,%1,%H2,48
6706    #"
6707   [(set_attr "type" "delayed_compare")
6708    (set_attr "length" "4,8")])
6710 (define_split
6711   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6712         (compare:CC (zero_extend:DI
6713                      (subreg:HI
6714                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6715                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6716                     (const_int 0)))
6717    (clobber (match_scratch:DI 3 ""))]
6718   "TARGET_POWERPC64 && reload_completed"
6719   [(set (match_dup 3)
6720         (zero_extend:DI (subreg:HI
6721                       (rotate:DI (match_dup 1)
6722                                  (match_dup 2)) 0)))
6723    (set (match_dup 0)
6724         (compare:CC (match_dup 3)
6725                     (const_int 0)))]
6726   "")
6728 (define_insn "*rotldi3_internal12"
6729   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6730         (compare:CC (zero_extend:DI
6731                      (subreg:HI
6732                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6733                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6734                     (const_int 0)))
6735    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6736         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6737   "TARGET_POWERPC64"
6738   "@
6739    rld%I2cl. %0,%1,%H2,48
6740    #"
6741   [(set_attr "type" "delayed_compare")
6742    (set_attr "length" "4,8")])
6744 (define_split
6745   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6746         (compare:CC (zero_extend:DI
6747                      (subreg:HI
6748                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6749                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6750                     (const_int 0)))
6751    (set (match_operand:DI 0 "gpc_reg_operand" "")
6752         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6753   "TARGET_POWERPC64 && reload_completed"
6754   [(set (match_dup 0)
6755         (zero_extend:DI (subreg:HI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6756    (set (match_dup 3)
6757         (compare:CC (match_dup 0)
6758                     (const_int 0)))]
6759   "")
6761 (define_insn "*rotldi3_internal13"
6762   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6763         (zero_extend:DI
6764          (subreg:SI
6765           (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6766                      (match_operand:DI 2 "reg_or_cint_operand" "ri")) 0)))]
6767   "TARGET_POWERPC64"
6768   "rld%I2cl %0,%1,%H2,32")
6770 (define_insn "*rotldi3_internal14"
6771   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6772         (compare:CC (zero_extend:DI
6773                      (subreg:SI
6774                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6775                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6776                     (const_int 0)))
6777    (clobber (match_scratch:DI 3 "=r,r"))]
6778   "TARGET_POWERPC64"
6779   "@
6780    rld%I2cl. %3,%1,%H2,32
6781    #"
6782   [(set_attr "type" "delayed_compare")
6783    (set_attr "length" "4,8")])
6785 (define_split
6786   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6787         (compare:CC (zero_extend:DI
6788                      (subreg:SI
6789                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6790                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6791                     (const_int 0)))
6792    (clobber (match_scratch:DI 3 ""))]
6793   "TARGET_POWERPC64 && reload_completed"
6794   [(set (match_dup 3)
6795         (zero_extend:DI (subreg:SI
6796                       (rotate:DI (match_dup 1)
6797                                  (match_dup 2)) 0)))
6798    (set (match_dup 0)
6799         (compare:CC (match_dup 3)
6800                     (const_int 0)))]
6801   "")
6803 (define_insn "*rotldi3_internal15"
6804   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6805         (compare:CC (zero_extend:DI
6806                      (subreg:SI
6807                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6808                                  (match_operand:DI 2 "reg_or_cint_operand" "ri,ri")) 0))
6809                     (const_int 0)))
6810    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6811         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6812   "TARGET_POWERPC64"
6813   "@
6814    rld%I2cl. %0,%1,%H2,32
6815    #"
6816   [(set_attr "type" "delayed_compare")
6817    (set_attr "length" "4,8")])
6819 (define_split
6820   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6821         (compare:CC (zero_extend:DI
6822                      (subreg:SI
6823                       (rotate:DI (match_operand:DI 1 "gpc_reg_operand" "")
6824                                  (match_operand:DI 2 "reg_or_cint_operand" "")) 0))
6825                     (const_int 0)))
6826    (set (match_operand:DI 0 "gpc_reg_operand" "")
6827         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))]
6828   "TARGET_POWERPC64 && reload_completed"
6829   [(set (match_dup 0)
6830         (zero_extend:DI (subreg:SI (rotate:DI (match_dup 1) (match_dup 2)) 0)))
6831    (set (match_dup 3)
6832         (compare:CC (match_dup 0)
6833                     (const_int 0)))]
6834   "")
6836 (define_expand "ashldi3"
6837   [(set (match_operand:DI 0 "gpc_reg_operand" "")
6838         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6839                    (match_operand:SI 2 "reg_or_cint_operand" "")))]
6840   "TARGET_POWERPC64 || TARGET_POWER"
6841   "
6843   if (TARGET_POWERPC64)
6844     ;
6845   else if (TARGET_POWER)
6846     {
6847       emit_insn (gen_ashldi3_power (operands[0], operands[1], operands[2]));
6848       DONE;
6849     }
6850   else
6851     FAIL;
6854 (define_insn "*ashldi3_internal1"
6855   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6856         (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6857                    (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
6858   "TARGET_POWERPC64"
6859   "sld%I2 %0,%1,%H2"
6860   [(set_attr "length" "8")])
6861   
6862 (define_insn "*ashldi3_internal2"
6863   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6864         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6865                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6866                     (const_int 0)))
6867    (clobber (match_scratch:DI 3 "=r,r"))]
6868   "TARGET_POWERPC64"
6869   "@
6870    sld%I2. %3,%1,%H2
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 (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6878                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6879                     (const_int 0)))
6880    (clobber (match_scratch:DI 3 ""))]
6881   "TARGET_POWERPC64 && reload_completed"
6882   [(set (match_dup 3)
6883         (ashift:DI (match_dup 1) (match_dup 2)))
6884    (set (match_dup 0)
6885         (compare:CC (match_dup 3)
6886                     (const_int 0)))]
6887   "")
6889 (define_insn "*ashldi3_internal3"
6890   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
6891         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6892                                (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
6893                     (const_int 0)))
6894    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6895         (ashift:DI (match_dup 1) (match_dup 2)))]
6896   "TARGET_POWERPC64"
6897   "@
6898    sld%I2. %0,%1,%H2
6899    #"
6900   [(set_attr "type" "delayed_compare")
6901    (set_attr "length" "4,8")])
6903 (define_split
6904   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
6905         (compare:CC (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6906                                (match_operand:SI 2 "reg_or_cint_operand" ""))
6907                     (const_int 0)))
6908    (set (match_operand:DI 0 "gpc_reg_operand" "")
6909         (ashift:DI (match_dup 1) (match_dup 2)))]
6910   "TARGET_POWERPC64 && reload_completed"
6911   [(set (match_dup 0)
6912         (ashift:DI (match_dup 1) (match_dup 2)))
6913    (set (match_dup 3)
6914         (compare:CC (match_dup 0)
6915                     (const_int 0)))]
6916   "")
6918 (define_insn "*ashldi3_internal4"
6919   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6920         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6921                            (match_operand:SI 2 "const_int_operand" "i"))
6922                 (match_operand:DI 3 "const_int_operand" "n")))]
6923   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6924   "rldic %0,%1,%H2,%W3")
6926 (define_insn "ashldi3_internal5"
6927   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
6928         (compare:CC
6929          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6930                             (match_operand:SI 2 "const_int_operand" "i,i"))
6931                  (match_operand:DI 3 "const_int_operand" "n,n"))
6932          (const_int 0)))
6933    (clobber (match_scratch:DI 4 "=r,r"))]
6934   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6935   "@
6936    rldic. %4,%1,%H2,%W3
6937    #"
6938   [(set_attr "type" "delayed_compare")
6939    (set_attr "length" "4,8")])
6941 (define_split
6942   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
6943         (compare:CC
6944          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6945                             (match_operand:SI 2 "const_int_operand" ""))
6946                  (match_operand:DI 3 "const_int_operand" ""))
6947          (const_int 0)))
6948    (clobber (match_scratch:DI 4 ""))]
6949   "TARGET_POWERPC64 && reload_completed
6950    && includes_rldic_lshift_p (operands[2], operands[3])"
6951   [(set (match_dup 4)
6952         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6953                 (match_dup 3)))
6954    (set (match_dup 0)
6955         (compare:CC (match_dup 4)
6956                     (const_int 0)))]
6957   "")
6959 (define_insn "*ashldi3_internal6"
6960   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
6961         (compare:CC
6962          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
6963                             (match_operand:SI 2 "const_int_operand" "i,i"))
6964                     (match_operand:DI 3 "const_int_operand" "n,n"))
6965          (const_int 0)))
6966    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
6967         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6968   "TARGET_POWERPC64 && includes_rldic_lshift_p (operands[2], operands[3])"
6969   "@
6970    rldic. %0,%1,%H2,%W3
6971    #"
6972   [(set_attr "type" "delayed_compare")
6973    (set_attr "length" "4,8")])
6975 (define_split
6976   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
6977         (compare:CC
6978          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
6979                             (match_operand:SI 2 "const_int_operand" ""))
6980                  (match_operand:DI 3 "const_int_operand" ""))
6981          (const_int 0)))
6982    (set (match_operand:DI 0 "gpc_reg_operand" "")
6983         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
6984   "TARGET_POWERPC64 && reload_completed
6985    && includes_rldic_lshift_p (operands[2], operands[3])"
6986   [(set (match_dup 0)
6987         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
6988                 (match_dup 3)))
6989    (set (match_dup 4)
6990         (compare:CC (match_dup 0)
6991                     (const_int 0)))]
6992   "")
6994 (define_insn "*ashldi3_internal7"
6995   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
6996         (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r")
6997                            (match_operand:SI 2 "const_int_operand" "i"))
6998                 (match_operand:DI 3 "mask64_operand" "S")))]
6999   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7000   "rldicr %0,%1,%H2,%S3")
7002 (define_insn "ashldi3_internal8"
7003   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7004         (compare:CC
7005          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7006                             (match_operand:SI 2 "const_int_operand" "i,i"))
7007                  (match_operand:DI 3 "mask64_operand" "S,S"))
7008          (const_int 0)))
7009    (clobber (match_scratch:DI 4 "=r,r"))]
7010   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7011   "@
7012    rldicr. %4,%1,%H2,%S3
7013    #"
7014   [(set_attr "type" "delayed_compare")
7015    (set_attr "length" "4,8")])
7017 (define_split
7018   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7019         (compare:CC
7020          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7021                             (match_operand:SI 2 "const_int_operand" ""))
7022                  (match_operand:DI 3 "mask64_operand" ""))
7023          (const_int 0)))
7024    (clobber (match_scratch:DI 4 ""))]
7025   "TARGET_POWERPC64 && reload_completed
7026    && includes_rldicr_lshift_p (operands[2], operands[3])"
7027   [(set (match_dup 4)
7028         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7029                 (match_dup 3)))
7030    (set (match_dup 0)
7031         (compare:CC (match_dup 4)
7032                     (const_int 0)))]
7033   "")
7035 (define_insn "*ashldi3_internal9"
7036   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
7037         (compare:CC
7038          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7039                             (match_operand:SI 2 "const_int_operand" "i,i"))
7040                     (match_operand:DI 3 "mask64_operand" "S,S"))
7041          (const_int 0)))
7042    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7043         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7044   "TARGET_POWERPC64 && includes_rldicr_lshift_p (operands[2], operands[3])"
7045   "@
7046    rldicr. %0,%1,%H2,%S3
7047    #"
7048   [(set_attr "type" "delayed_compare")
7049    (set_attr "length" "4,8")])
7051 (define_split
7052   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
7053         (compare:CC
7054          (and:DI (ashift:DI (match_operand:DI 1 "gpc_reg_operand" "")
7055                             (match_operand:SI 2 "const_int_operand" ""))
7056                  (match_operand:DI 3 "mask64_operand" ""))
7057          (const_int 0)))
7058    (set (match_operand:DI 0 "gpc_reg_operand" "")
7059         (and:DI (ashift:DI (match_dup 1) (match_dup 2)) (match_dup 3)))]
7060   "TARGET_POWERPC64 && reload_completed
7061    && includes_rldicr_lshift_p (operands[2], operands[3])"
7062   [(set (match_dup 0)
7063         (and:DI (ashift:DI (match_dup 1) (match_dup 2))
7064                 (match_dup 3)))
7065    (set (match_dup 4)
7066         (compare:CC (match_dup 0)
7067                     (const_int 0)))]
7068   "")
7070 (define_expand "lshrdi3"
7071   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7072         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7073                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7074   "TARGET_POWERPC64 || TARGET_POWER"
7075   "
7077   if (TARGET_POWERPC64)
7078     ;
7079   else if (TARGET_POWER)
7080     {
7081       emit_insn (gen_lshrdi3_power (operands[0], operands[1], operands[2]));
7082       DONE;
7083     }
7084   else
7085     FAIL;
7088 (define_insn "*lshrdi3_internal1"
7089   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7090         (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7091                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7092   "TARGET_POWERPC64"
7093   "srd%I2 %0,%1,%H2")
7095 (define_insn "*lshrdi3_internal2"
7096   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7097         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7098                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7099                     (const_int 0)))
7100    (clobber (match_scratch:DI 3 "=r,r"))]
7101   "TARGET_POWERPC64"
7102   "@
7103    srd%I2. %3,%1,%H2
7104    #"
7105   [(set_attr "type" "delayed_compare")
7106    (set_attr "length" "4,8")])
7108 (define_split
7109   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7110         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7111                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7112                     (const_int 0)))
7113    (clobber (match_scratch:DI 3 ""))]
7114   "TARGET_POWERPC64 && reload_completed"
7115   [(set (match_dup 3)
7116         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7117    (set (match_dup 0)
7118         (compare:CC (match_dup 3)
7119                     (const_int 0)))]
7120   "")
7122 (define_insn "*lshrdi3_internal3"
7123   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7124         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7125                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7126                     (const_int 0)))
7127    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7128         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7129   "TARGET_POWERPC64"
7130   "@
7131    srd%I2. %0,%1,%H2
7132    #"
7133   [(set_attr "type" "delayed_compare")
7134    (set_attr "length" "4,8")])
7136 (define_split
7137   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7138         (compare:CC (lshiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7139                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7140                     (const_int 0)))
7141    (set (match_operand:DI 0 "gpc_reg_operand" "")
7142         (lshiftrt:DI (match_dup 1) (match_dup 2)))]
7143   "TARGET_POWERPC64 && reload_completed"
7144   [(set (match_dup 0)
7145         (lshiftrt:DI (match_dup 1) (match_dup 2)))
7146    (set (match_dup 3)
7147         (compare:CC (match_dup 0)
7148                     (const_int 0)))]
7149   "")
7151 (define_expand "ashrdi3"
7152   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7153         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7154                      (match_operand:SI 2 "reg_or_cint_operand" "")))]
7155   ""
7156   "
7158   if (TARGET_POWERPC64)
7159     ;
7160   else if (TARGET_POWER && GET_CODE (operands[2]) == CONST_INT)
7161     {
7162       emit_insn (gen_ashrdi3_power (operands[0], operands[1], operands[2]));
7163       DONE;
7164     }
7165   else if (TARGET_32BIT && GET_CODE (operands[2]) == CONST_INT)
7166     {
7167       emit_insn (gen_ashrdi3_no_power (operands[0], operands[1], operands[2]));
7168       DONE;
7169     }
7170   else
7171     FAIL;
7174 (define_insn "*ashrdi3_internal1"
7175   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7176         (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
7177                      (match_operand:SI 2 "reg_or_cint_operand" "ri")))]
7178   "TARGET_POWERPC64"
7179   "srad%I2 %0,%1,%H2")
7181 (define_insn "*ashrdi3_internal2"
7182   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7183         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7184                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7185                     (const_int 0)))
7186    (clobber (match_scratch:DI 3 "=r,r"))]
7187   "TARGET_POWERPC64"
7188   "@
7189    srad%I2. %3,%1,%H2
7190    #"
7191   [(set_attr "type" "delayed_compare")
7192    (set_attr "length" "4,8")])
7194 (define_split
7195   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7196         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7197                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7198                     (const_int 0)))
7199    (clobber (match_scratch:DI 3 ""))]
7200   "TARGET_POWERPC64 && reload_completed"
7201   [(set (match_dup 3)
7202         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7203    (set (match_dup 0)
7204         (compare:CC (match_dup 3)
7205                     (const_int 0)))]
7206   "")
7208 (define_insn "*ashrdi3_internal3"
7209   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7210         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
7211                                  (match_operand:SI 2 "reg_or_cint_operand" "ri,ri"))
7212                     (const_int 0)))
7213    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7214         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7215   "TARGET_POWERPC64"
7216   "@
7217    srad%I2. %0,%1,%H2
7218    #"
7219   [(set_attr "type" "delayed_compare")
7220    (set_attr "length" "4,8")])
7222 (define_split
7223   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7224         (compare:CC (ashiftrt:DI (match_operand:DI 1 "gpc_reg_operand" "")
7225                                  (match_operand:SI 2 "reg_or_cint_operand" ""))
7226                     (const_int 0)))
7227    (set (match_operand:DI 0 "gpc_reg_operand" "")
7228         (ashiftrt:DI (match_dup 1) (match_dup 2)))]
7229   "TARGET_POWERPC64 && reload_completed"
7230   [(set (match_dup 0)
7231         (ashiftrt:DI (match_dup 1) (match_dup 2)))
7232    (set (match_dup 3)
7233         (compare:CC (match_dup 0)
7234                     (const_int 0)))]
7235   "")
7237 (define_insn "anddi3"
7238   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
7239         (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r")
7240                 (match_operand:DI 2 "and64_operand" "?r,S,K,J")))
7241    (clobber (match_scratch:CC 3 "=X,X,x,x"))]
7242   "TARGET_POWERPC64"
7243   "@
7244    and %0,%1,%2
7245    rldic%B2 %0,%1,0,%S2
7246    andi. %0,%1,%b2
7247    andis. %0,%1,%u2")
7249 (define_insn "*anddi3_internal2"
7250   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,?y,?y,??y,??y")
7251         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,")
7252                             (match_operand:DI 2 "and64_operand" "r,S,K,J,r,S,K,J"))
7253                     (const_int 0)))
7254    (clobber (match_scratch:DI 3 "=r,r,r,r,r,r,r,r"))
7255    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,x,x"))]
7256   "TARGET_POWERPC64"
7257   "@
7258    and. %3,%1,%2
7259    rldic%B2. %3,%1,0,%S2
7260    andi. %3,%1,%b2
7261    andis. %3,%1,%u2
7262    #
7263    #
7264    #
7265    #"
7266   [(set_attr "type" "compare,delayed_compare,compare,compare,compare,delayed_compare,compare,compare")
7267    (set_attr "length" "4,4,4,4,8,8,8,8")])
7269 (define_split
7270   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7271         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7272                             (match_operand:DI 2 "and64_operand" ""))
7273                     (const_int 0)))
7274    (clobber (match_scratch:DI 3 ""))
7275    (clobber (match_scratch:CC 4 ""))]
7276   "TARGET_POWERPC64 && reload_completed"
7277   [(parallel [(set (match_dup 3)
7278                    (and:DI (match_dup 1)
7279                            (match_dup 2)))
7280               (clobber (match_dup 4))])
7281    (set (match_dup 0)
7282         (compare:CC (match_dup 3)
7283                     (const_int 0)))]
7284   "")
7286 (define_insn "*anddi3_internal3"
7287   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,x,x,?y,?y,??y,??y")
7288         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r")
7289                             (match_operand:DI 2 "and64_operand" "r,S,K,J,r,S,K,J"))
7290                     (const_int 0)))
7291    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r")
7292         (and:DI (match_dup 1) (match_dup 2)))
7293    (clobber (match_scratch:CC 4 "=X,X,X,X,X,X,x,x"))]
7294   "TARGET_POWERPC64"
7295   "@
7296    and. %0,%1,%2
7297    rldic%B2. %0,%1,0,%S2
7298    andi. %0,%1,%b2
7299    andis. %0,%1,%u2
7300    #
7301    #
7302    #
7303    #"
7304   [(set_attr "type" "compare,delayed_compare,compare,compare,compare,delayed_compare,compare,compare")
7305    (set_attr "length" "4,4,4,4,8,8,8,8")])
7307 (define_split
7308   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7309         (compare:CC (and:DI (match_operand:DI 1 "gpc_reg_operand" "")
7310                             (match_operand:DI 2 "and64_operand" ""))
7311                     (const_int 0)))
7312    (set (match_operand:DI 0 "gpc_reg_operand" "")
7313         (and:DI (match_dup 1) (match_dup 2)))
7314    (clobber (match_scratch:CC 4 ""))]
7315   "TARGET_POWERPC64 && reload_completed"
7316   [(parallel [(set (match_dup 0)
7317                     (and:DI (match_dup 1) (match_dup 2)))
7318                (clobber (match_dup 4))])
7319    (set (match_dup 3)
7320         (compare:CC (match_dup 0)
7321                     (const_int 0)))]
7322   "")
7324 (define_expand "iordi3"
7325   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7326         (ior:DI (match_operand:DI 1 "gpc_reg_operand" "")
7327                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7328   "TARGET_POWERPC64"
7329   "
7331   if (non_logical_cint_operand (operands[2], DImode))
7332     {
7333       HOST_WIDE_INT value;
7334       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7335                  ? operands[0] : gen_reg_rtx (DImode));
7337       if (GET_CODE (operands[2]) == CONST_INT)
7338         {
7339           value = INTVAL (operands[2]);
7340           emit_insn (gen_iordi3 (tmp, operands[1],
7341                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7342         }
7343       else
7344         {
7345           value = CONST_DOUBLE_LOW (operands[2]);
7346           emit_insn (gen_iordi3 (tmp, operands[1],
7347                                  immed_double_const (value
7348                                                      & (~ (HOST_WIDE_INT) 0xffff),
7349                                                      0, DImode)));
7350         }
7352       emit_insn (gen_iordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7353       DONE;
7354     }
7357 (define_expand "xordi3"
7358   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7359         (xor:DI (match_operand:DI 1 "gpc_reg_operand" "")
7360                 (match_operand:DI 2 "reg_or_logical_cint_operand" "")))]
7361   "TARGET_POWERPC64"
7362   "
7364   if (non_logical_cint_operand (operands[2], DImode))
7365     {
7366       HOST_WIDE_INT value;
7367       rtx tmp = ((no_new_pseudos || rtx_equal_p (operands[0], operands[1]))
7368                  ? operands[0] : gen_reg_rtx (DImode));
7370       if (GET_CODE (operands[2]) == CONST_INT)
7371         {
7372           value = INTVAL (operands[2]);
7373           emit_insn (gen_xordi3 (tmp, operands[1],
7374                                  GEN_INT (value & (~ (HOST_WIDE_INT) 0xffff))));
7375         }
7376       else
7377         {
7378           value = CONST_DOUBLE_LOW (operands[2]);
7379           emit_insn (gen_xordi3 (tmp, operands[1],
7380                                  immed_double_const (value
7381                                                      & (~ (HOST_WIDE_INT) 0xffff),
7382                                                      0, DImode)));
7383         }
7385       emit_insn (gen_xordi3 (operands[0], tmp, GEN_INT (value & 0xffff)));
7386       DONE;
7387     }
7390 (define_insn "*booldi3_internal1"
7391   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r")
7392         (match_operator:DI 3 "boolean_or_operator"
7393          [(match_operand:DI 1 "gpc_reg_operand" "%r,r,r")
7394           (match_operand:DI 2 "logical_operand" "r,K,JF")]))]
7395   "TARGET_POWERPC64"
7396   "@
7397    %q3 %0,%1,%2
7398    %q3i %0,%1,%b2
7399    %q3is %0,%1,%u2")
7401 (define_insn "*booldi3_internal2"
7402   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7403         (compare:CC (match_operator:DI 4 "boolean_or_operator"
7404          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7405           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7406          (const_int 0)))
7407    (clobber (match_scratch:DI 3 "=r,r"))]
7408   "TARGET_POWERPC64"
7409   "@
7410    %q4. %3,%1,%2
7411    #"
7412   [(set_attr "type" "compare")
7413    (set_attr "length" "4,8")])
7415 (define_split
7416   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7417         (compare:CC (match_operator:DI 4 "boolean_operator"
7418          [(match_operand:DI 1 "gpc_reg_operand" "")
7419           (match_operand:DI 2 "gpc_reg_operand" "")])
7420          (const_int 0)))
7421    (clobber (match_scratch:DI 3 ""))]
7422   "TARGET_POWERPC64 && reload_completed"
7423   [(set (match_dup 3) (match_dup 4))
7424    (set (match_dup 0)
7425         (compare:CC (match_dup 3)
7426                     (const_int 0)))]
7427   "")
7429 (define_insn "*booldi3_internal3"
7430   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7431         (compare:CC (match_operator:DI 4 "boolean_operator"
7432          [(match_operand:DI 1 "gpc_reg_operand" "%r,r")
7433           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7434          (const_int 0)))
7435    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7436         (match_dup 4))]
7437   "TARGET_POWERPC64"
7438   "@
7439    %q4. %0,%1,%2
7440    #"
7441   [(set_attr "type" "compare")
7442    (set_attr "length" "4,8")])
7444 (define_split
7445   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7446         (compare:CC (match_operator:DI 4 "boolean_operator"
7447          [(match_operand:DI 1 "gpc_reg_operand" "")
7448           (match_operand:DI 2 "gpc_reg_operand" "")])
7449          (const_int 0)))
7450    (set (match_operand:DI 0 "gpc_reg_operand" "")
7451         (match_dup 4))]
7452   "TARGET_POWERPC64 && reload_completed"
7453   [(set (match_dup 0) (match_dup 4))
7454    (set (match_dup 3)
7455         (compare:CC (match_dup 0)
7456                     (const_int 0)))]
7457   "")
7459 ;; Split an logical operation that we can't do in one insn into two insns, 
7460 ;; each of which does one 16-bit part.  This is used by combine.
7462 (define_split
7463   [(set (match_operand:DI 0 "gpc_reg_operand" "")
7464         (match_operator:DI 3 "boolean_or_operator"
7465          [(match_operand:DI 1 "gpc_reg_operand" "")
7466           (match_operand:DI 2 "non_logical_cint_operand" "")]))]
7467   "TARGET_POWERPC64"
7468   [(set (match_dup 0) (match_dup 4))
7469    (set (match_dup 0) (match_dup 5))]
7472   rtx i3,i4;
7473   
7474   if (GET_CODE (operands[2]) == CONST_DOUBLE)
7475     {
7476       HOST_WIDE_INT value = CONST_DOUBLE_LOW (operands[2]);
7477       i3 = immed_double_const (value & (~ (HOST_WIDE_INT) 0xffff),
7478                                         0, DImode);
7479       i4 = GEN_INT (value & 0xffff);
7480     }
7481   else
7482     {
7483       i3 = GEN_INT (INTVAL (operands[2])
7484                              & (~ (HOST_WIDE_INT) 0xffff));
7485       i4 = GEN_INT (INTVAL (operands[2]) & 0xffff);
7486     }
7487   operands[4] = gen_rtx (GET_CODE (operands[3]), DImode,
7488                          operands[1], i3);
7489   operands[5] = gen_rtx (GET_CODE (operands[3]), DImode,
7490                          operands[0], i4);
7493 (define_insn "*boolcdi3_internal1"
7494   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7495         (match_operator:DI 3 "boolean_operator"
7496          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7497           (match_operand:DI 2 "gpc_reg_operand" "r")]))]
7498   "TARGET_POWERPC64"
7499   "%q3 %0,%2,%1")
7501 (define_insn "*boolcdi3_internal2"
7502   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7503         (compare:CC (match_operator:DI 4 "boolean_operator"
7504          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7505           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7506          (const_int 0)))
7507    (clobber (match_scratch:DI 3 "=r,r"))]
7508   "TARGET_POWERPC64"
7509   "@
7510    %q4. %3,%2,%1
7511    #"
7512   [(set_attr "type" "compare")
7513    (set_attr "length" "4,8")])
7515 (define_split
7516   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7517         (compare:CC (match_operator:DI 4 "boolean_operator"
7518          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7519           (match_operand:DI 2 "gpc_reg_operand" "")])
7520          (const_int 0)))
7521    (clobber (match_scratch:DI 3 ""))]
7522   "TARGET_POWERPC64 && reload_completed"
7523   [(set (match_dup 3) (match_dup 4))
7524    (set (match_dup 0)
7525         (compare:CC (match_dup 3)
7526                     (const_int 0)))]
7527   "")
7529 (define_insn "*boolcdi3_internal3"
7530   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7531         (compare:CC (match_operator:DI 4 "boolean_operator"
7532          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7533           (match_operand:DI 2 "gpc_reg_operand" "r,r")])
7534          (const_int 0)))
7535    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7536         (match_dup 4))]
7537   "TARGET_POWERPC64"
7538   "@
7539    %q4. %0,%2,%1
7540    #"
7541   [(set_attr "type" "compare")
7542    (set_attr "length" "4,8")])
7544 (define_split
7545   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7546         (compare:CC (match_operator:DI 4 "boolean_operator"
7547          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7548           (match_operand:DI 2 "gpc_reg_operand" "")])
7549          (const_int 0)))
7550    (set (match_operand:DI 0 "gpc_reg_operand" "")
7551         (match_dup 4))]
7552   "TARGET_POWERPC64 && reload_completed"
7553   [(set (match_dup 0) (match_dup 4))
7554    (set (match_dup 3)
7555         (compare:CC (match_dup 0)
7556                     (const_int 0)))]
7557   "")
7559 (define_insn "*boolccdi3_internal1"
7560   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
7561         (match_operator:DI 3 "boolean_operator"
7562          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r"))
7563           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r"))]))]
7564   "TARGET_POWERPC64"
7565   "%q3 %0,%1,%2")
7567 (define_insn "*boolccdi3_internal2"
7568   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
7569         (compare:CC (match_operator:DI 4 "boolean_operator"
7570          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "r,r"))
7571           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7572          (const_int 0)))
7573    (clobber (match_scratch:DI 3 "=r,r"))]
7574   "TARGET_POWERPC64"
7575   "@
7576    %q4. %3,%1,%2
7577    #"
7578   [(set_attr "type" "compare")
7579    (set_attr "length" "4,8")])
7581 (define_split
7582   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
7583         (compare:CC (match_operator:DI 4 "boolean_operator"
7584          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7585           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7586          (const_int 0)))
7587    (clobber (match_scratch:DI 3 ""))]
7588   "TARGET_POWERPC64 && reload_completed"
7589   [(set (match_dup 3) (match_dup 4))
7590    (set (match_dup 0)
7591         (compare:CC (match_dup 3)
7592                     (const_int 0)))]
7593   "")
7595 (define_insn "*boolccdi3_internal3"
7596   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
7597         (compare:CC (match_operator:DI 4 "boolean_operator"
7598          [(not:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r"))
7599           (not:DI (match_operand:DI 2 "gpc_reg_operand" "r,r"))])
7600          (const_int 0)))
7601    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
7602         (match_dup 4))]
7603   "TARGET_POWERPC64"
7604   "@
7605    %q4. %0,%1,%2
7606    #"
7607   [(set_attr "type" "compare")
7608    (set_attr "length" "4,8")])
7610 (define_split
7611   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
7612         (compare:CC (match_operator:DI 4 "boolean_operator"
7613          [(not:DI (match_operand:DI 1 "gpc_reg_operand" ""))
7614           (not:DI (match_operand:DI 2 "gpc_reg_operand" ""))])
7615          (const_int 0)))
7616    (set (match_operand:DI 0 "gpc_reg_operand" "")
7617         (match_dup 4))]
7618   "TARGET_POWERPC64 && reload_completed"
7619   [(set (match_dup 0) (match_dup 4))
7620    (set (match_dup 3)
7621         (compare:CC (match_dup 0)
7622                     (const_int 0)))]
7623   "")
7625 ;; Now define ways of moving data around.
7627 ;; Elf specific ways of loading addresses for non-PIC code.
7628 ;; The output of this could be r0, but we make a very strong
7629 ;; preference for a base register because it will usually
7630 ;; be needed there.
7631 (define_insn "elf_high"
7632   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7633         (high:SI (match_operand 1 "" "")))]
7634   "TARGET_ELF && ! TARGET_64BIT"
7635   "{liu|lis} %0,%1@ha")
7637 (define_insn "elf_low"
7638   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7639         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7640                    (match_operand 2 "" "")))]
7641    "TARGET_ELF && ! TARGET_64BIT"
7642    "@
7643     {cal|la} %0,%2@l(%1)
7644     {ai|addic} %0,%1,%K2")
7646 ;; Mach-O PIC trickery.
7647 (define_insn "macho_high"
7648   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
7649         (high:SI (match_operand 1 "" "")))]
7650   "TARGET_MACHO && ! TARGET_64BIT"
7651   "{liu|lis} %0,ha16(%1)")
7653 (define_insn "macho_low"
7654   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
7655         (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,!*r")
7656                    (match_operand 2 "" "")))]
7657    "TARGET_MACHO && ! TARGET_64BIT"
7658    "@
7659     {cal %0,%a2@l(%1)|la %0,lo16(%2)(%1)}
7660     {cal %0,%a2@l(%1)|addic %0,%1,lo16(%2)}")
7662 ;; Set up a register with a value from the GOT table
7664 (define_expand "movsi_got"
7665   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7666         (unspec:SI [(match_operand:SI 1 "got_operand" "")
7667                     (match_dup 2)] 8))]
7668   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7669   "
7671   if (GET_CODE (operands[1]) == CONST)
7672     {
7673       rtx offset = const0_rtx;
7674       HOST_WIDE_INT value;
7676       operands[1] = eliminate_constant_term (XEXP (operands[1], 0), &offset);
7677       value = INTVAL (offset);
7678       if (value != 0)
7679         {
7680           rtx tmp = (no_new_pseudos ? operands[0] : gen_reg_rtx (Pmode));
7681           emit_insn (gen_movsi_got (tmp, operands[1]));
7682           emit_insn (gen_addsi3 (operands[0], tmp, offset));
7683           DONE;
7684         }
7685     }
7687   operands[2] = rs6000_got_register (operands[1]);
7690 (define_insn "*movsi_got_internal"
7691   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7692         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7693                     (match_operand:SI 2 "gpc_reg_operand" "b")] 8))]
7694   "DEFAULT_ABI == ABI_V4 && flag_pic == 1"
7695   "{l|lwz} %0,%a1@got(%2)"
7696   [(set_attr "type" "load")])
7698 ;; Used by sched, shorten_branches and final when the GOT pseudo reg
7699 ;; didn't get allocated to a hard register.
7700 (define_split 
7701   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7702         (unspec:SI [(match_operand:SI 1 "got_no_const_operand" "")
7703                     (match_operand:SI 2 "memory_operand" "")] 8))]
7704   "DEFAULT_ABI == ABI_V4
7705     && flag_pic == 1
7706     && (reload_in_progress || reload_completed)"
7707   [(set (match_dup 0) (match_dup 2))
7708    (set (match_dup 0) (unspec:SI [(match_dup 1)(match_dup 0)] 8))]
7709   "")
7711 ;; For SI, we special-case integers that can't be loaded in one insn.  We
7712 ;; do the load 16-bits at a time.  We could do this by loading from memory,
7713 ;; and this is even supposed to be faster, but it is simpler not to get
7714 ;; integers in the TOC.
7715 (define_expand "movsi"
7716   [(set (match_operand:SI 0 "general_operand" "")
7717         (match_operand:SI 1 "any_operand" ""))]
7718   ""
7719   "{ rs6000_emit_move (operands[0], operands[1], SImode); DONE; }")
7721 (define_insn "movsi_low"
7722   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
7723         (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7724                            (match_operand 2 "" ""))))]
7725   "TARGET_MACHO && ! TARGET_64BIT"
7726   "{l|lwz} %0,lo16(%2)(%1)"
7727   [(set_attr "type" "load")
7728    (set_attr "length" "4")])
7730 (define_insn "movsi_low_st"
7731   [(set (mem:SI (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7732                            (match_operand 2 "" "")))
7733         (match_operand:SI 0 "gpc_reg_operand" "r"))]
7734   "TARGET_MACHO && ! TARGET_64BIT"
7735   "{st|stw} %0,lo16(%2)(%1)"
7736   [(set_attr "type" "store")
7737    (set_attr "length" "4")])
7739 (define_insn "movdf_low"
7740   [(set (match_operand:DF 0 "gpc_reg_operand" "=f,!r")
7741         (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7742                            (match_operand 2 "" ""))))]
7743   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7744   "*
7746   switch (which_alternative)
7747     {
7748       case 0:
7749         return \"lfd %0,lo16(%2)(%1)\";
7750       case 1:
7751         {
7752           rtx operands2[4];
7753           operands2[0] = operands[0];
7754           operands2[1] = operands[1];
7755           operands2[2] = operands[2];
7756           operands2[3] = gen_rtx_REG (SImode, RS6000_PIC_OFFSET_TABLE_REGNUM);
7757           output_asm_insn (\"{l|lwz} %0,lo16(%2)(%1)\", operands);
7758           /* We cannot rely on ha16(low half)==ha16(high half), alas,
7759              although in practice it almost always is.  */
7760           output_asm_insn (\"{cau|addis} %L0,%3,ha16(%2+4)\", operands2);
7761           return (\"{l|lwz} %L0,lo16(%2+4)(%L0)\");
7762         }
7763       default:
7764         abort();
7765     }
7767   [(set_attr "type" "load")
7768    (set_attr "length" "4,12")])
7770 (define_insn "movdf_low_st"
7771   [(set (mem:DF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
7772                            (match_operand 2 "" "")))
7773         (match_operand:DF 0 "gpc_reg_operand" "f"))]
7774   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7775   "stfd %0,lo16(%2)(%1)"
7776   [(set_attr "type" "store")
7777    (set_attr "length" "4")])
7779 (define_insn "movsf_low"
7780   [(set (match_operand:SF 0 "gpc_reg_operand" "=f,!r")
7781         (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7782                            (match_operand 2 "" ""))))]
7783   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7784   "@
7785    lfs %0,lo16(%2)(%1)
7786    {l|lwz} %0,lo16(%2)(%1)"
7787   [(set_attr "type" "load")
7788    (set_attr "length" "4")])
7790 (define_insn "movsf_low_st"
7791   [(set (mem:SF (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b,b")
7792                            (match_operand 2 "" "")))
7793         (match_operand:SF 0 "gpc_reg_operand" "f,!r"))]
7794   "TARGET_MACHO && TARGET_HARD_FLOAT && ! TARGET_64BIT"
7795   "@
7796    stfs %0,lo16(%2)(%1)
7797    {st|stw} %0,lo16(%2)(%1)"
7798   [(set_attr "type" "store")
7799    (set_attr "length" "4")])
7801 (define_insn "*movsi_internal1"
7802   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,m,r,r,r,r,r,*q,*c*l,*h,*h")
7803         (match_operand:SI 1 "input_operand" "r,U,m,r,I,L,n,R,*h,r,r,r,0"))]
7804   "gpc_reg_operand (operands[0], SImode)
7805    || gpc_reg_operand (operands[1], SImode)"
7806   "@
7807    mr %0,%1
7808    {cal|la} %0,%a1
7809    {l%U1%X1|lwz%U1%X1} %0,%1
7810    {st%U0%X0|stw%U0%X0} %1,%0
7811    {lil|li} %0,%1
7812    {liu|lis} %0,%v1
7813    #
7814    {cal|la} %0,%a1
7815    mf%1 %0
7816    mt%0 %1
7817    mt%0 %1
7818    mt%0 %1
7819    cror 0,0,0"
7820   [(set_attr "type" "*,*,load,store,*,*,*,*,*,*,mtjmpr,*,*")
7821    (set_attr "length" "4,4,4,4,4,4,8,4,4,4,4,4,4")])
7823 ;; Split a load of a large constant into the appropriate two-insn
7824 ;; sequence.
7826 (define_split
7827   [(set (match_operand:SI 0 "gpc_reg_operand" "")
7828         (match_operand:SI 1 "const_int_operand" ""))]
7829   "(unsigned HOST_WIDE_INT) (INTVAL (operands[1]) + 0x8000) >= 0x10000
7830    && (INTVAL (operands[1]) & 0xffff) != 0"
7831   [(set (match_dup 0)
7832         (match_dup 2))
7833    (set (match_dup 0)
7834         (ior:SI (match_dup 0)
7835                 (match_dup 3)))]
7836   "
7838   operands[2] = GEN_INT (INTVAL (operands[1]) & (~ (HOST_WIDE_INT) 0xffff));
7839   operands[3] = GEN_INT (INTVAL (operands[1]) & 0xffff);
7842 (define_insn "*movsi_internal2"
7843   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
7844         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r,r")
7845                     (const_int 0)))
7846    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
7847   "! TARGET_POWERPC64"
7848   "@
7849    mr. %0,%1
7850    #"
7851   [(set_attr "type" "compare")
7852    (set_attr "length" "4,8")])
7854 (define_split
7855   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
7856         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
7857                     (const_int 0)))
7858    (set (match_operand:SI 0 "gpc_reg_operand" "") (match_dup 1))]
7859   "! TARGET_POWERPC64 && reload_completed"
7860   [(set (match_dup 0) (match_dup 1))
7861    (set (match_dup 2)
7862         (compare:CC (match_dup 0)
7863                     (const_int 0)))]
7864   "")
7866 (define_expand "movhi"
7867   [(set (match_operand:HI 0 "general_operand" "")
7868         (match_operand:HI 1 "any_operand" ""))]
7869   ""
7870   "{ rs6000_emit_move (operands[0], operands[1], HImode); DONE; }")
7872 (define_insn ""
7873   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7874         (match_operand:HI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7875   "gpc_reg_operand (operands[0], HImode)
7876    || gpc_reg_operand (operands[1], HImode)"
7877   "@
7878    mr %0,%1
7879    lhz%U1%X1 %0,%1
7880    sth%U0%X0 %1,%0
7881    {lil|li} %0,%w1
7882    mf%1 %0
7883    mt%0 %1
7884    mt%0 %1
7885    cror 0,0,0"
7886   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7888 (define_expand "movqi"
7889   [(set (match_operand:QI 0 "general_operand" "")
7890         (match_operand:QI 1 "any_operand" ""))]
7891   ""
7892   "{ rs6000_emit_move (operands[0], operands[1], QImode); DONE; }")
7894 (define_insn ""
7895   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,m,r,r,*q,*c*l,*h")
7896         (match_operand:QI 1 "input_operand" "r,m,r,i,*h,r,r,0"))]
7897   "gpc_reg_operand (operands[0], QImode)
7898    || gpc_reg_operand (operands[1], QImode)"
7899   "@
7900    mr %0,%1
7901    lbz%U1%X1 %0,%1
7902    stb%U0%X0 %1,%0
7903    {lil|li} %0,%1
7904    mf%1 %0
7905    mt%0 %1
7906    mt%0 %1
7907    cror 0,0,0"
7908   [(set_attr "type" "*,load,store,*,*,*,mtjmpr,*")])
7910 ;; Here is how to move condition codes around.  When we store CC data in
7911 ;; an integer register or memory, we store just the high-order 4 bits.
7912 ;; This lets us not shift in the most common case of CR0.
7913 (define_expand "movcc"
7914   [(set (match_operand:CC 0 "nonimmediate_operand" "")
7915         (match_operand:CC 1 "nonimmediate_operand" ""))]
7916   ""
7917   "")
7919 (define_insn "*movcc_internal1"
7920   [(set (match_operand:CC 0 "nonimmediate_operand" "=y,x,y,r,r,r,r,m")
7921         (match_operand:CC 1 "nonimmediate_operand" "y,r,r,x,y,r,m,r"))]
7922   "register_operand (operands[0], CCmode)
7923    || register_operand (operands[1], CCmode)"
7924   "@
7925    mcrf %0,%1
7926    mtcrf 128,%1
7927    {rlinm|rlwinm} %1,%1,%F0,0xffffffff\;mtcrf %R0,%1\;{rlinm|rlwinm} %1,%1,%f0,0xffffffff
7928    mfcr %0
7929    mfcr %0\;{rlinm|rlwinm} %0,%0,%f1,0xf0000000
7930    mr %0,%1
7931    {l%U1%X1|lwz%U1%X1} %0,%1
7932    {st%U0%U1|stw%U0%U1} %1,%0"
7933   [(set_attr "type" "cr_logical,cr_logical,cr_logical,cr_logical,cr_logical,*,load,store")
7934    (set_attr "length" "*,*,12,*,8,*,*,*")])
7936 ;; For floating-point, we normally deal with the floating-point registers
7937 ;; unless -msoft-float is used.  The sole exception is that parameter passing
7938 ;; can produce floating-point values in fixed-point registers.  Unless the
7939 ;; value is a simple constant or already in memory, we deal with this by
7940 ;; allocating memory and copying the value explicitly via that memory location.
7941 (define_expand "movsf"
7942   [(set (match_operand:SF 0 "nonimmediate_operand" "")
7943         (match_operand:SF 1 "any_operand" ""))]
7944   ""
7945   "{ rs6000_emit_move (operands[0], operands[1], SFmode); DONE; }")
7947 (define_split
7948   [(set (match_operand:SF 0 "gpc_reg_operand" "")
7949         (match_operand:SF 1 "const_double_operand" ""))]
7950   "reload_completed
7951    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
7952        || (GET_CODE (operands[0]) == SUBREG
7953            && GET_CODE (SUBREG_REG (operands[0])) == REG
7954            && REGNO (SUBREG_REG (operands[0])) <= 31))"
7955   [(set (match_dup 2) (match_dup 3))]
7956   "
7958   long l;
7959   REAL_VALUE_TYPE rv;
7961   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
7962   REAL_VALUE_TO_TARGET_SINGLE (rv, l);
7964   if (! TARGET_POWERPC64)
7965     operands[2] = operand_subword (operands[0], 0, 0, SFmode);
7966   else
7967     operands[2] = gen_lowpart (SImode, operands[0]);
7969   operands[3] = gen_int_mode (l, SImode);
7972 (define_insn "*movsf_hardfloat"
7973   [(set (match_operand:SF 0 "nonimmediate_operand" "=!r,!r,m,f,f,m,!r,!r")
7974         (match_operand:SF 1 "input_operand" "r,m,r,f,m,f,G,Fn"))]
7975   "(gpc_reg_operand (operands[0], SFmode)
7976    || gpc_reg_operand (operands[1], SFmode)) && TARGET_HARD_FLOAT"
7977   "@
7978    mr %0,%1
7979    {l%U1%X1|lwz%U1%X1} %0,%1
7980    {st%U0%X0|stw%U0%X0} %1,%0
7981    fmr %0,%1
7982    lfs%U1%X1 %0,%1
7983    stfs%U0%X0 %1,%0
7984    #
7985    #"
7986   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*")
7987    (set_attr "length" "4,4,4,4,4,4,4,8")])
7989 (define_insn "*movsf_softfloat"
7990   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,r")
7991         (match_operand:SF 1 "input_operand" "r,m,r,I,L,R,G,Fn"))]
7992   "(gpc_reg_operand (operands[0], SFmode)
7993    || gpc_reg_operand (operands[1], SFmode)) && TARGET_SOFT_FLOAT"
7994   "@
7995    mr %0,%1
7996    {l%U1%X1|lwz%U1%X1} %0,%1
7997    {st%U0%X0|stw%U0%X0} %1,%0
7998    {lil|li} %0,%1
7999    {liu|lis} %0,%v1
8000    {cal|la} %0,%a1
8001    #
8002    #"
8003   [(set_attr "type" "*,load,store,*,*,*,*,*")
8004    (set_attr "length" "4,4,4,4,4,4,4,8")])
8007 (define_expand "movdf"
8008   [(set (match_operand:DF 0 "nonimmediate_operand" "")
8009         (match_operand:DF 1 "any_operand" ""))]
8010   ""
8011   "{ rs6000_emit_move (operands[0], operands[1], DFmode); DONE; }")
8013 (define_split
8014   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8015         (match_operand:DF 1 "const_int_operand" ""))]
8016   "! TARGET_POWERPC64 && reload_completed
8017    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8018        || (GET_CODE (operands[0]) == SUBREG
8019            && GET_CODE (SUBREG_REG (operands[0])) == REG
8020            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8021   [(set (match_dup 2) (match_dup 4))
8022    (set (match_dup 3) (match_dup 1))]
8023   "
8025   int endian = (WORDS_BIG_ENDIAN == 0);
8026   HOST_WIDE_INT value = INTVAL (operands[1]);
8028   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8029   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8030 #if HOST_BITS_PER_WIDE_INT == 32
8031   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8032 #else
8033   operands[4] = GEN_INT (value >> 32);
8034   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8035 #endif
8038 (define_split
8039   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8040         (match_operand:DF 1 "const_double_operand" ""))]
8041   "! TARGET_POWERPC64 && reload_completed
8042    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8043        || (GET_CODE (operands[0]) == SUBREG
8044            && GET_CODE (SUBREG_REG (operands[0])) == REG
8045            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8046   [(set (match_dup 2) (match_dup 4))
8047    (set (match_dup 3) (match_dup 5))]
8048   "
8050   int endian = (WORDS_BIG_ENDIAN == 0);
8051   long l[2];
8052   REAL_VALUE_TYPE rv;
8054   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8055   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8057   operands[2] = operand_subword (operands[0], endian, 0, DFmode);
8058   operands[3] = operand_subword (operands[0], 1 - endian, 0, DFmode);
8059   operands[4] = gen_int_mode (l[endian], SImode);
8060   operands[5] = gen_int_mode (l[1 - endian], SImode);
8063 (define_split
8064   [(set (match_operand:DF 0 "gpc_reg_operand" "")
8065         (match_operand:DF 1 "easy_fp_constant" ""))]
8066   "TARGET_POWERPC64 && reload_completed
8067    && ((GET_CODE (operands[0]) == REG && REGNO (operands[0]) <= 31)
8068        || (GET_CODE (operands[0]) == SUBREG
8069            && GET_CODE (SUBREG_REG (operands[0])) == REG
8070            && REGNO (SUBREG_REG (operands[0])) <= 31))"
8071   [(set (match_dup 2) (match_dup 3))]
8072   "
8074   int endian = (WORDS_BIG_ENDIAN == 0);
8075   long l[2];
8076   REAL_VALUE_TYPE rv;
8077   HOST_WIDE_INT val;
8079   REAL_VALUE_FROM_CONST_DOUBLE (rv, operands[1]);
8080   REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
8082   operands[2] = gen_lowpart (DImode, operands[0]);
8083   /* HIGHPART is lower memory address when WORDS_BIG_ENDIAN.  */
8084 #if HOST_BITS_PER_WIDE_INT >= 64
8085   val = ((HOST_WIDE_INT)(unsigned long)l[endian] << 32 |
8086         ((HOST_WIDE_INT)(unsigned long)l[1 - endian]));
8088   operands[3] = immed_double_const (val, -(val < 0), DImode);
8089 #else
8090   operands[3] = immed_double_const (l[1 - endian], l[endian], DImode);
8091 #endif
8094 ;; Don't have reload use general registers to load a constant.  First,
8095 ;; it might not work if the output operand is the equivalent of
8096 ;; a non-offsettable memref, but also it is less efficient than loading
8097 ;; the constant into an FP register, since it will probably be used there.
8098 ;; The "??" is a kludge until we can figure out a more reasonable way
8099 ;; of handling these non-offsettable values.
8100 (define_insn "*movdf_hardfloat32"
8101   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
8102         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
8103   "! TARGET_POWERPC64 && TARGET_HARD_FLOAT
8104    && (gpc_reg_operand (operands[0], DFmode)
8105        || gpc_reg_operand (operands[1], DFmode))"
8106   "*
8108   switch (which_alternative)
8109     {
8110     default:
8111       abort ();
8112     case 0:
8113       /* We normally copy the low-numbered register first.  However, if
8114          the first register operand 0 is the same as the second register
8115          of operand 1, we must copy in the opposite order.  */
8116       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8117         return \"mr %L0,%L1\;mr %0,%1\";
8118       else
8119         return \"mr %0,%1\;mr %L0,%L1\";
8120     case 1:
8121       if (offsettable_memref_p (operands[1])
8122           || (GET_CODE (operands[1]) == MEM
8123               && (GET_CODE (XEXP (operands[1], 0)) == LO_SUM
8124                   || GET_CODE (XEXP (operands[1], 0)) == PRE_INC
8125                   || GET_CODE (XEXP (operands[1], 0)) == PRE_DEC)))
8126         {
8127           /* If the low-address word is used in the address, we must load
8128              it last.  Otherwise, load it first.  Note that we cannot have
8129              auto-increment in that case since the address register is
8130              known to be dead.  */
8131           if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8132                                  operands[1], 0))
8133             return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8134           else
8135             return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8136         }
8137       else
8138         {
8139           rtx addreg;
8141           addreg = find_addr_reg (XEXP (operands[1], 0));
8142           if (refers_to_regno_p (REGNO (operands[0]),
8143                                  REGNO (operands[0]) + 1,
8144                                  operands[1], 0))
8145             {
8146               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8147               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8148               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8149               return \"{lx|lwzx} %0,%1\";
8150             }
8151           else
8152             {
8153               output_asm_insn (\"{lx|lwzx} %0,%1\", operands);
8154               output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8155               output_asm_insn (\"{lx|lwzx} %L0,%1\", operands);
8156               output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8157               return \"\";
8158             }
8159         }
8160     case 2:
8161       if (offsettable_memref_p (operands[0])
8162           || (GET_CODE (operands[0]) == MEM
8163               && (GET_CODE (XEXP (operands[0], 0)) == LO_SUM
8164                   || GET_CODE (XEXP (operands[0], 0)) == PRE_INC
8165                   || GET_CODE (XEXP (operands[0], 0)) == PRE_DEC)))
8166         return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8167       else
8168         {
8169           rtx addreg;
8171           addreg = find_addr_reg (XEXP (operands[0], 0));
8172           output_asm_insn (\"{stx|stwx} %1,%0\", operands);
8173           output_asm_insn (\"{cal|la} %0,4(%0)\", &addreg);
8174           output_asm_insn (\"{stx|stwx} %L1,%0\", operands);
8175           output_asm_insn (\"{cal|la} %0,-4(%0)\", &addreg);
8176           return \"\";
8177         }
8178     case 3:
8179     case 4:
8180     case 5:
8181       return \"#\";
8182     case 6:
8183       return \"fmr %0,%1\";
8184     case 7:
8185       return \"lfd%U1%X1 %0,%1\";
8186     case 8:
8187       return \"stfd%U0%X0 %1,%0\";
8188     }
8190   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8191    (set_attr "length" "8,16,16,8,12,16,*,*,*")])
8193 (define_insn "*movdf_softfloat32"
8194   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8195         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8196   "! TARGET_POWERPC64 && TARGET_SOFT_FLOAT
8197    && (gpc_reg_operand (operands[0], DFmode)
8198        || gpc_reg_operand (operands[1], DFmode))"
8199   "*
8201   switch (which_alternative)
8202     {
8203     default:
8204       abort ();
8205     case 0:
8206       /* We normally copy the low-numbered register first.  However, if
8207          the first register operand 0 is the same as the second register of
8208          operand 1, we must copy in the opposite order.  */
8209       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8210         return \"mr %L0,%L1\;mr %0,%1\";
8211       else
8212         return \"mr %0,%1\;mr %L0,%L1\";
8213     case 1:
8214       /* If the low-address word is used in the address, we must load
8215          it last.  Otherwise, load it first.  Note that we cannot have
8216          auto-increment in that case since the address register is
8217          known to be dead.  */
8218       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8219                              operands[1], 0))
8220         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8221       else
8222         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8223     case 2:
8224       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8225     case 3:
8226     case 4:
8227     case 5:
8228       return \"#\";
8229     }
8231   [(set_attr "type" "*,load,store,*,*,*")
8232    (set_attr "length" "8,8,8,8,12,16")])
8234 (define_insn "*movdf_hardfloat64"
8235   [(set (match_operand:DF 0 "nonimmediate_operand" "=!r,??r,m,!r,!r,!r,f,f,m")
8236         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F,f,m,f"))]
8237   "TARGET_POWERPC64 && TARGET_HARD_FLOAT
8238    && (gpc_reg_operand (operands[0], DFmode)
8239        || gpc_reg_operand (operands[1], DFmode))"
8240   "@
8241    mr %0,%1
8242    ld%U1%X1 %0,%1
8243    std%U0%X0 %1,%0
8244    #
8245    #
8246    #
8247    fmr %0,%1
8248    lfd%U1%X1 %0,%1
8249    stfd%U0%X0 %1,%0"
8250   [(set_attr "type" "*,load,store,*,*,*,fp,fpload,fpstore")
8251    (set_attr "length" "4,4,4,8,12,16,4,4,4")])
8253 (define_insn "*movdf_softfloat64"
8254   [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m,r,r,r")
8255         (match_operand:DF 1 "input_operand" "r,m,r,G,H,F"))]
8256   "TARGET_POWERPC64 && TARGET_SOFT_FLOAT
8257    && (gpc_reg_operand (operands[0], DFmode)
8258        || gpc_reg_operand (operands[1], DFmode))"
8259   "@
8260    mr %0,%1
8261    ld%U1%X1 %0,%1
8262    std%U0%X0 %1,%0
8263    #
8264    #
8265    #"
8266   [(set_attr "type" "*,load,store,*,*,*")
8267    (set_attr "length" "*,*,*,8,12,16")])
8269 (define_expand "movtf"
8270   [(set (match_operand:TF 0 "general_operand" "")
8271         (match_operand:TF 1 "any_operand" ""))]
8272   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8273   "{ rs6000_emit_move (operands[0], operands[1], TFmode); DONE; }")
8275 (define_insn "*movtf_internal"
8276   [(set (match_operand:TF 0 "nonimmediate_operand" "=f,f,m,!r,!r,!r")
8277         (match_operand:TF 1 "input_operand" "f,m,f,G,H,F"))]
8278   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128
8279    && (gpc_reg_operand (operands[0], TFmode)
8280        || gpc_reg_operand (operands[1], TFmode))"
8281   "*
8283   switch (which_alternative)
8284     {
8285     default:
8286       abort ();
8287     case 0:
8288       /* We normally copy the low-numbered register first.  However, if
8289          the first register operand 0 is the same as the second register of
8290          operand 1, we must copy in the opposite order.  */
8291       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8292         return \"fmr %L0,%L1\;fmr %0,%1\";
8293       else
8294         return \"fmr %0,%1\;fmr %L0,%L1\";
8295     case 1:
8296       return \"lfd %0,%1\;lfd %L0,%L1\";
8297     case 2:
8298       return \"stfd %1,%0\;stfd %L1,%L0\";
8299     case 3:
8300     case 4:
8301     case 5:
8302       return \"#\";
8303     }
8305   [(set_attr "type" "fp,fpload,fpstore,*,*,*")
8306    (set_attr "length" "8,8,8,12,16,20")])
8308 (define_split
8309   [(set (match_operand:TF 0 "gpc_reg_operand" "")
8310         (match_operand:TF 1 "const_double_operand" ""))]
8311   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8312   [(set (match_dup 3) (match_dup 1))
8313    (set (match_dup 0)
8314         (float_extend:TF (match_dup 3)))]
8315   "
8317   operands[2] = operand_subword (operands[1], 0, 0, DFmode);
8318   operands[3] = gen_reg_rtx (DFmode);
8321 (define_insn_and_split "extenddftf2"
8322   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8323         (float_extend:TF (match_operand:DF 1 "gpc_reg_operand" "f")))]
8324   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8325   "#"
8326   ""
8327   [(set (match_dup 2) (match_dup 3))]
8328   "
8330   operands[2] = gen_rtx_REG (DFmode, REGNO (operands[0] + 1));
8331   operands[3] = CONST0_RTX (DFmode);
8334 (define_insn_and_split "extendsftf2"
8335   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8336         (float_extend:TF (match_operand:SF 1 "gpc_reg_operand" "f")))]
8337   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8338   "#"
8339   ""
8340   [(set (match_dup 2) (match_dup 3))]
8341   "
8343   operands[2] = gen_rtx_REG (SFmode, REGNO (operands[0] + 1));
8344   operands[3] = CONST0_RTX (SFmode);
8347 (define_insn "trunctfdf2"
8348   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
8349         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8350   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8351   "fadd %0,%1,%L1"
8352   [(set_attr "type" "fp")
8353    (set_attr "length" "8")])
8355 (define_insn_and_split "trunctfsf2"
8356   [(set (match_operand:SF 0 "gpc_reg_operand" "=f")
8357         (float_truncate:SF (match_operand:TF 1 "gpc_reg_operand" "f")))
8358    (clobber (match_scratch:DF 2 "=f"))]
8359   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8360   "#"
8361   "&& reload_completed"
8362   [(set (match_dup 2)
8363         (float_truncate:DF (match_dup 1)))
8364    (set (match_dup 0)
8365         (float_truncate:SF (match_dup 2)))]
8366   "")
8368 (define_insn_and_split "floatditf2"
8369   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8370         (float:TF (match_operand:DI 1 "gpc_reg_operand" "*f")))
8371    (clobber (match_scratch:DF 2 "=f"))]
8372   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8373    && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8374   "#"
8375   "&& reload_completed"
8376   [(set (match_dup 2)
8377         (float:DF (match_operand:DI 1 "gpc_reg_operand" "")))
8378    (set (match_operand:TF 0 "gpc_reg_operand" "")
8379         (float_extend:TF (match_dup 2)))]
8380   "")
8382 (define_insn_and_split "floatsitf2"
8383   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8384         (float:TF (match_operand:SI 1 "gpc_reg_operand" "r")))
8385    (clobber (match_scratch:DF 2 "=f"))]
8386   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8387   "#"
8388   "&& reload_completed"
8389   [(set (match_dup 2)
8390         (float:DF (match_operand:SI 1 "gpc_reg_operand" "")))
8391    (set (match_operand:TF 0 "gpc_reg_operand" "")
8392         (float_extend:TF (match_dup 2)))]
8393   "")
8395 (define_insn_and_split "fix_trunctfdi2"
8396   [(set (match_operand:DI 0 "gpc_reg_operand" "=*f")
8397         (fix:DI (match_operand:TF 1 "gpc_reg_operand" "f")))]
8398   "DEFAULT_ABI == ABI_AIX && TARGET_POWERPC64
8399    && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8400   "#"
8401   "&& reload_completed"
8402   [(set (match_dup 2)
8403         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8404    (set (match_operand:DI 0 "gpc_reg_operand" "")
8405         (fix:SI (match_dup 2)))]
8406   "")
8408 (define_insn_and_split "fix_trunctfsi2"
8409   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
8410         (fix:SI (match_operand:TF 1 "gpc_reg_operand" "f")))]
8411   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8412   "#"
8413   "&& reload_completed"
8414   [(set (match_dup 2)
8415         (float_truncate:DF (match_operand:TF 1 "gpc_reg_operand" "")))
8416    (set (match_operand:SI 0 "gpc_reg_operand" "")
8417         (fix:SI (match_dup 2)))]
8418   "")
8420 (define_insn "negtf2"
8421   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8422         (neg:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8423   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8424   "*
8426   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8427     return \"fneg %L0,%L1\;fneg %0,%1\";
8428   else
8429     return \"fneg %0,%1\;fneg %L0,%L1\";
8431   [(set_attr "type" "fp")
8432    (set_attr "length" "8")])
8434 (define_insn "abstf2"
8435   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8436         (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f")))]
8437   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8438   "*
8440   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8441     return \"fabs %L0,%L1\;fabs %0,%1\";
8442   else
8443     return \"fabs %0,%1\;fabs %L0,%L1\";
8445   [(set_attr "type" "fp")
8446    (set_attr "length" "8")])
8448 (define_insn ""
8449   [(set (match_operand:TF 0 "gpc_reg_operand" "=f")
8450         (neg:TF (abs:TF (match_operand:TF 1 "gpc_reg_operand" "f"))))]
8451   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
8452   "*
8454   if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8455     return \"fnabs %L0,%L1\;fnabs %0,%1\";
8456   else
8457     return \"fnabs %0,%1\;fnabs %L0,%L1\";
8459   [(set_attr "type" "fp")
8460    (set_attr "length" "8")])
8462 ;; Next come the multi-word integer load and store and the load and store
8463 ;; multiple insns.
8464 (define_expand "movdi"
8465   [(set (match_operand:DI 0 "general_operand" "")
8466         (match_operand:DI 1 "any_operand" ""))]
8467   ""
8468   "{ rs6000_emit_move (operands[0], operands[1], DImode); DONE; }")
8470 (define_insn "*movdi_internal32"
8471   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,f,f,m,r,r,r,r,r")
8472         (match_operand:DI 1 "input_operand" "r,m,r,f,m,f,IJK,n,G,H,F"))]
8473   "! TARGET_POWERPC64
8474    && (gpc_reg_operand (operands[0], DImode)
8475        || gpc_reg_operand (operands[1], DImode))"
8476   "*
8478   switch (which_alternative)
8479     {
8480     default:
8481       abort ();
8482     case 0:
8483       /* We normally copy the low-numbered register first.  However, if
8484          the first register operand 0 is the same as the second register of
8485          operand 1, we must copy in the opposite order.  */
8486       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8487         return \"mr %L0,%L1\;mr %0,%1\";
8488       else
8489         return \"mr %0,%1\;mr %L0,%L1\";
8490     case 1:
8491       /* If the low-address word is used in the address, we must load it
8492          last.  Otherwise, load it first.  Note that we cannot have
8493          auto-increment in that case since the address register is known to be
8494          dead.  */
8495       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8496                              operands[1], 0))
8497         return \"{l|lwz} %L0,%L1\;{l|lwz} %0,%1\";
8498       else
8499         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\";
8500     case 2:
8501       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\";
8502     case 3:
8503       return \"fmr %0,%1\";
8504     case 4:
8505       return \"lfd%U1%X1 %0,%1\";
8506     case 5:
8507       return \"stfd%U0%X0 %1,%0\";
8508     case 6:
8509     case 7:
8510     case 8:
8511     case 9:
8512     case 10:
8513       return \"#\";
8514     }
8516   [(set_attr "type" "*,load,store,fp,fpload,fpstore,*,*,*,*,*")
8517    (set_attr "length" "8,8,8,*,*,*,8,12,8,12,16")])
8519 (define_split
8520   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8521         (match_operand:DI 1 "const_int_operand" ""))]
8522   "! TARGET_POWERPC64 && reload_completed"
8523   [(set (match_dup 2) (match_dup 4))
8524    (set (match_dup 3) (match_dup 1))]
8525   "
8527   HOST_WIDE_INT value = INTVAL (operands[1]);
8528   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8529                                        DImode);
8530   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8531                                        DImode);
8532 #if HOST_BITS_PER_WIDE_INT == 32
8533   operands[4] = (value & 0x80000000) ? constm1_rtx : const0_rtx;
8534 #else
8535   operands[4] = GEN_INT (value >> 32);
8536   operands[1] = GEN_INT (((value & 0xffffffff) ^ 0x80000000) - 0x80000000);
8537 #endif
8540 (define_split
8541   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8542         (match_operand:DI 1 "const_double_operand" ""))]
8543   "HOST_BITS_PER_WIDE_INT == 32 && ! TARGET_POWERPC64 && reload_completed"
8544   [(set (match_dup 2) (match_dup 4))
8545    (set (match_dup 3) (match_dup 5))]
8546   "
8548   operands[2] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN == 0,
8549                                        DImode);
8550   operands[3] = operand_subword_force (operands[0], WORDS_BIG_ENDIAN != 0,
8551                                        DImode);
8552   operands[4] = GEN_INT (CONST_DOUBLE_HIGH (operands[1]));
8553   operands[5] = GEN_INT (CONST_DOUBLE_LOW  (operands[1]));
8556 (define_insn "*movdi_internal64"
8557   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m,r,r,r,r,f,f,m,r,*h,*h")
8558         (match_operand:DI 1 "input_operand" "r,m,r,I,L,nF,R,f,m,f,*h,r,0"))]
8559   "TARGET_POWERPC64
8560    && (gpc_reg_operand (operands[0], DImode)
8561        || gpc_reg_operand (operands[1], DImode))"
8562   "@
8563    mr %0,%1
8564    ld%U1%X1 %0,%1
8565    std%U0%X0 %1,%0
8566    li %0,%1
8567    lis %0,%v1
8568    #
8569    {cal|la} %0,%a1
8570    fmr %0,%1
8571    lfd%U1%X1 %0,%1
8572    stfd%U0%X0 %1,%0
8573    mf%1 %0
8574    mt%0 %1
8575    cror 0,0,0"
8576   [(set_attr "type" "*,load,store,*,*,*,*,fp,fpload,fpstore,*,mtjmpr,*")
8577    (set_attr "length" "4,4,4,4,4,20,4,4,4,4,4,4,4")])
8579 ;; immediate value valid for a single instruction hiding in a const_double
8580 (define_insn ""
8581   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
8582         (match_operand:DI 1 "const_double_operand" "F"))]
8583   "HOST_BITS_PER_WIDE_INT == 32 && TARGET_POWERPC64
8584    && GET_CODE (operands[1]) == CONST_DOUBLE
8585    && num_insns_constant (operands[1], DImode) == 1"
8586   "*
8588   return ((unsigned HOST_WIDE_INT)
8589           (CONST_DOUBLE_LOW (operands[1]) + 0x8000) < 0x10000)
8590          ? \"li %0,%1\" : \"lis %0,%v1\";
8593 ;; Generate all one-bits and clear left or right.
8594 ;; Use (and:DI (rotate:DI ...)) to avoid anddi3 unnecessary clobber.
8595 (define_split
8596   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8597         (match_operand:DI 1 "mask64_operand" ""))]
8598   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8599   [(set (match_dup 0) (const_int -1))
8600    (set (match_dup 0)
8601         (and:DI (rotate:DI (match_dup 0)
8602                            (const_int 0))
8603                 (match_dup 1)))]
8604   "")
8606 ;; Split a load of a large constant into the appropriate five-instruction
8607 ;; sequence.  Handle anything in a constant number of insns.
8608 ;; When non-easy constants can go in the TOC, this should use
8609 ;; easy_fp_constant predicate.
8610 (define_split
8611   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8612         (match_operand:DI 1 "const_int_operand" ""))]
8613   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8614   [(set (match_dup 0) (match_dup 2))
8615    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8616   "
8617 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8619   if (tem == operands[0])
8620     DONE;
8621   else
8622     FAIL;
8625 (define_split
8626   [(set (match_operand:DI 0 "gpc_reg_operand" "")
8627         (match_operand:DI 1 "const_double_operand" ""))]
8628   "TARGET_POWERPC64 && num_insns_constant (operands[1], DImode) > 1"
8629   [(set (match_dup 0) (match_dup 2))
8630    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 3)))]
8631   "
8632 { rtx tem = rs6000_emit_set_const (operands[0], DImode, operands[1], 5);
8634   if (tem == operands[0])
8635     DONE;
8636   else
8637     FAIL;
8640 ;; Split a load of a large constant into the appropriate five-instruction
8641 (define_insn "*movdi_internal2"
8642   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
8643         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r,r")
8644                     (const_int 0)))
8645    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r") (match_dup 1))]
8646   "TARGET_POWERPC64"
8647   "@
8648    mr. %0,%1
8649    #"
8650   [(set_attr "type" "compare")
8651    (set_attr "length" "4,8")])
8653 (define_split
8654   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
8655         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "")
8656                     (const_int 0)))
8657    (set (match_operand:DI 0 "gpc_reg_operand" "") (match_dup 1))]
8658   "TARGET_POWERPC64 && reload_completed"
8659   [(set (match_dup 0) (match_dup 1))
8660    (set (match_dup 2)
8661         (compare:CC (match_dup 0)
8662                     (const_int 0)))]
8663   "")
8665 ;; TImode is similar, except that we usually want to compute the address into
8666 ;; a register and use lsi/stsi (the exception is during reload).  MQ is also
8667 ;; clobbered in stsi for POWER, so we need a SCRATCH for it.
8668 (define_expand "movti"
8669   [(parallel [(set (match_operand:TI 0 "general_operand" "")
8670                    (match_operand:TI 1 "general_operand" ""))
8671               (clobber (scratch:SI))])]
8672   "TARGET_STRING || TARGET_POWERPC64"
8673   "{ rs6000_emit_move (operands[0], operands[1], TImode); DONE; }")
8675 ;; We say that MQ is clobbered in the last alternative because the first
8676 ;; alternative would never get used otherwise since it would need a reload
8677 ;; while the 2nd alternative would not.  We put memory cases first so they
8678 ;; are preferred.  Otherwise, we'd try to reload the output instead of
8679 ;; giving the SCRATCH mq.
8680 (define_insn "*movti_power"
8681   [(set (match_operand:TI 0 "reg_or_mem_operand" "=Q,m,????r,????r,????r")
8682         (match_operand:TI 1 "reg_or_mem_operand" "r,r,r,Q,m"))
8683    (clobber (match_scratch:SI 2 "=q,q#X,X,X,X"))]
8684   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
8685    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8686   "*
8688   switch (which_alternative)
8689     {
8690     default:
8691       abort ();
8693     case 0:
8694       return \"{stsi|stswi} %1,%P0,16\";
8696     case 1:
8697       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8699     case 2:
8700       /* Normally copy registers with lowest numbered register copied first.
8701          But copy in the other order if the first register of the output
8702          is the second, third, or fourth register in the input.  */
8703       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8704           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8705         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8706       else
8707         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8708     case 3:
8709       /* If the address is not used in the output, we can use lsi.  Otherwise,
8710          fall through to generating four loads.  */
8711       if (! reg_overlap_mentioned_p (operands[0], operands[1]))
8712         return \"{lsi|lswi} %0,%P1,16\";
8713       /* ... fall through ...  */
8714     case 4:
8715       /* If the address register is the same as the register for the lowest-
8716          addressed word, load it last.  Similarly for the next two words.
8717          Otherwise load lowest address to highest.  */
8718       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8719                              operands[1], 0))
8720         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8721       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8722                                   REGNO (operands[0]) + 2, operands[1], 0))
8723         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8724       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8725                                   REGNO (operands[0]) + 3, operands[1], 0))
8726         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8727       else
8728         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8729     }
8731   [(set_attr "type" "store,store,*,load,load")
8732    (set_attr "length" "*,16,16,*,16")])
8734 (define_insn "*movti_string"
8735   [(set (match_operand:TI 0 "reg_or_mem_operand" "=m,????r,????r")
8736         (match_operand:TI 1 "reg_or_mem_operand" "r,r,m"))
8737    (clobber (match_scratch:SI 2 "=X,X,X"))]
8738   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
8739    && (gpc_reg_operand (operands[0], TImode) || gpc_reg_operand (operands[1], TImode))"
8740   "*
8742   switch (which_alternative)
8743     {
8744     default:
8745       abort ();
8747     case 0:
8748       return \"{st%U0|stw%U0} %1,%0\;{st|stw} %L1,%L0\;{st|stw} %Y1,%Y0\;{st|stw} %Z1,%Z0\";
8750     case 1:
8751       /* Normally copy registers with lowest numbered register copied first.
8752          But copy in the other order if the first register of the output
8753          is the second, third, or fourth register in the input.  */
8754       if (REGNO (operands[0]) >= REGNO (operands[1]) + 1
8755           && REGNO (operands[0]) <= REGNO (operands[1]) + 3)
8756         return \"mr %Z0,%Z1\;mr %Y0,%Y1\;mr %L0,%L1\;mr %0,%1\";
8757       else
8758         return \"mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1\";
8759     case 2:
8760       /* If the address register is the same as the register for the lowest-
8761          addressed word, load it last.  Similarly for the next two words.
8762          Otherwise load lowest address to highest.  */
8763       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8764                              operands[1], 0))
8765         return \"{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %0,%1\";
8766       else if (refers_to_regno_p (REGNO (operands[0]) + 1,
8767                                   REGNO (operands[0]) + 2, operands[1], 0))
8768         return \"{l|lwz} %0,%1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\;{l|lwz} %L0,%L1\";
8769       else if (refers_to_regno_p (REGNO (operands[0]) + 2,
8770                                   REGNO (operands[0]) + 3, operands[1], 0))
8771         return \"{l|lwz} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Z0,%Z1\;{l|lwz} %Y0,%Y1\";
8772       else
8773         return \"{l%U1|lwz%U1} %0,%1\;{l|lwz} %L0,%L1\;{l|lwz} %Y0,%Y1\;{l|lwz} %Z0,%Z1\";
8774     }
8776   [(set_attr "type" "store,*,load")
8777    (set_attr "length" "16,16,16")])
8779 (define_insn "*movti_ppc64"
8780   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
8781         (match_operand:TI 1 "input_operand" "r,m,r"))]
8782   "TARGET_POWERPC64 && (gpc_reg_operand (operands[0], TImode)
8783    || gpc_reg_operand (operands[1], TImode))"
8784   "*
8786   switch (which_alternative)
8787     {
8788     default:
8789       abort ();
8790     case 0:
8791       /* We normally copy the low-numbered register first.  However, if
8792          the first register operand 0 is the same as the second register of
8793          operand 1, we must copy in the opposite order.  */
8794       if (REGNO (operands[0]) == REGNO (operands[1]) + 1)
8795         return \"mr %L0,%L1\;mr %0,%1\";
8796       else
8797         return \"mr %0,%1\;mr %L0,%L1\";
8798     case 1:
8799       /* If the low-address word is used in the address, we must load it
8800          last.  Otherwise, load it first.  Note that we cannot have
8801          auto-increment in that case since the address register is known to be
8802          dead.  */
8803       if (refers_to_regno_p (REGNO (operands[0]), REGNO (operands[0]) + 1,
8804                              operands[1], 0))
8805         return \"ld %L0,%L1\;ld %0,%1\";
8806       else
8807         return \"ld%U1 %0,%1\;ld %L0,%L1\";
8808     case 2:
8809       return \"std%U0 %1,%0\;std %L1,%L0\";
8810     }
8812   [(set_attr "type" "*,load,store")
8813    (set_attr "length" "8,8,8")])
8815 (define_expand "load_multiple"
8816   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8817                           (match_operand:SI 1 "" ""))
8818                      (use (match_operand:SI 2 "" ""))])]
8819   "TARGET_STRING && !TARGET_POWERPC64"
8820   "
8822   int regno;
8823   int count;
8824   rtx op1;
8825   int i;
8827   /* Support only loading a constant number of fixed-point registers from
8828      memory and only bother with this if more than two; the machine
8829      doesn't support more than eight.  */
8830   if (GET_CODE (operands[2]) != CONST_INT
8831       || INTVAL (operands[2]) <= 2
8832       || INTVAL (operands[2]) > 8
8833       || GET_CODE (operands[1]) != MEM
8834       || GET_CODE (operands[0]) != REG
8835       || REGNO (operands[0]) >= 32)
8836     FAIL;
8838   count = INTVAL (operands[2]);
8839   regno = REGNO (operands[0]);
8841   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count));
8842   op1 = replace_equiv_address (operands[1],
8843                                force_reg (SImode, XEXP (operands[1], 0)));
8845   for (i = 0; i < count; i++)
8846     XVECEXP (operands[3], 0, i)
8847       = gen_rtx_SET (VOIDmode, gen_rtx_REG (SImode, regno + i),
8848                      adjust_address (op1, SImode, i * 4));
8851 (define_insn ""
8852   [(match_parallel 0 "load_multiple_operation"
8853                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
8854                          (mem:SI (match_operand:SI 2 "gpc_reg_operand" "b")))])]
8855   "TARGET_STRING"
8856   "*
8858   /* We have to handle the case where the pseudo used to contain the address
8859      is assigned to one of the output registers.  */
8860   int i, j;
8861   int words = XVECLEN (operands[0], 0);
8862   rtx xop[10];
8864   if (XVECLEN (operands[0], 0) == 1)
8865     return \"{l|lwz} %1,0(%2)\";
8867   for (i = 0; i < words; i++)
8868     if (refers_to_regno_p (REGNO (operands[1]) + i,
8869                            REGNO (operands[1]) + i + 1, operands[2], 0))
8870       {
8871         if (i == words-1)
8872           {
8873             xop[0] = operands[1];
8874             xop[1] = operands[2];
8875             xop[2] = GEN_INT (4 * (words-1));
8876             output_asm_insn (\"{lsi|lswi} %0,%1,%2\;{l|lwz} %1,%2(%1)\", xop);
8877             return \"\";
8878           }
8879         else if (i == 0)
8880           {
8881             xop[0] = operands[1];
8882             xop[1] = gen_rtx_REG (SImode, REGNO (operands[1]) + 1);
8883             xop[2] = GEN_INT (4 * (words-1));
8884             output_asm_insn (\"{cal %0,4(%0)|addi %0,%0,4}\;{lsi|lswi} %1,%0,%2\;{l|lwz} %0,-4(%0)\", xop);
8885             return \"\";
8886           }
8887         else
8888           {
8889             for (j = 0; j < words; j++)
8890               if (j != i)
8891                 {
8892                   xop[0] = gen_rtx_REG (SImode, REGNO (operands[1]) + j);
8893                   xop[1] = operands[2];
8894                   xop[2] = GEN_INT (j * 4);
8895                   output_asm_insn (\"{l|lwz} %0,%2(%1)\", xop);
8896                 }
8897             xop[0] = operands[2];
8898             xop[1] = GEN_INT (i * 4);
8899             output_asm_insn (\"{l|lwz} %0,%1(%0)\", xop);
8900             return \"\";
8901           }
8902       }
8904   return \"{lsi|lswi} %1,%2,%N0\";
8906   [(set_attr "type" "load")
8907    (set_attr "length" "32")])
8910 (define_expand "store_multiple"
8911   [(match_par_dup 3 [(set (match_operand:SI 0 "" "")
8912                           (match_operand:SI 1 "" ""))
8913                      (clobber (scratch:SI))
8914                      (use (match_operand:SI 2 "" ""))])]
8915   "TARGET_STRING && !TARGET_POWERPC64"
8916   "
8918   int regno;
8919   int count;
8920   rtx to;
8921   rtx op0;
8922   int i;
8924   /* Support only storing a constant number of fixed-point registers to
8925      memory and only bother with this if more than two; the machine
8926      doesn't support more than eight.  */
8927   if (GET_CODE (operands[2]) != CONST_INT
8928       || INTVAL (operands[2]) <= 2
8929       || INTVAL (operands[2]) > 8
8930       || GET_CODE (operands[0]) != MEM
8931       || GET_CODE (operands[1]) != REG
8932       || REGNO (operands[1]) >= 32)
8933     FAIL;
8935   count = INTVAL (operands[2]);
8936   regno = REGNO (operands[1]);
8938   operands[3] = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (count + 1));
8939   to = force_reg (SImode, XEXP (operands[0], 0));
8940   op0 = replace_equiv_address (operands[0], to);
8942   XVECEXP (operands[3], 0, 0)
8943     = gen_rtx_SET (VOIDmode, adjust_address (op0, SImode, 0), operands[1]);
8944   XVECEXP (operands[3], 0, 1) = gen_rtx_CLOBBER (VOIDmode,
8945                                                  gen_rtx_SCRATCH (SImode));
8947   for (i = 1; i < count; i++)
8948     XVECEXP (operands[3], 0, i + 1)
8949       = gen_rtx_SET (VOIDmode,
8950                      adjust_address (op0, SImode, i * 4),
8951                      gen_rtx_REG (SImode, regno + i));
8954 (define_insn ""
8955   [(match_parallel 0 "store_multiple_operation"
8956                    [(set (match_operand:SI 1 "indirect_operand" "=Q")
8957                          (match_operand:SI 2 "gpc_reg_operand" "r"))
8958                     (clobber (match_scratch:SI 3 "=q"))])]
8959   "TARGET_STRING && TARGET_POWER"
8960   "{stsi|stswi} %2,%P1,%O0"
8961   [(set_attr "type" "store")])
8963 (define_insn ""
8964   [(match_parallel 0 "store_multiple_operation"
8965                    [(set (mem:SI (match_operand:SI 1 "gpc_reg_operand" "b"))
8966                          (match_operand:SI 2 "gpc_reg_operand" "r"))
8967                     (clobber (match_scratch:SI 3 "X"))])]
8968   "TARGET_STRING && ! TARGET_POWER"
8969   "{stsi|stswi} %2,%1,%O0"
8970   [(set_attr "type" "store")])
8973 ;; String/block move insn.
8974 ;; Argument 0 is the destination
8975 ;; Argument 1 is the source
8976 ;; Argument 2 is the length
8977 ;; Argument 3 is the alignment
8979 (define_expand "movstrsi"
8980   [(parallel [(set (match_operand:BLK 0 "" "")
8981                    (match_operand:BLK 1 "" ""))
8982               (use (match_operand:SI 2 "" ""))
8983               (use (match_operand:SI 3 "" ""))])]
8984   ""
8985   "
8987   if (expand_block_move (operands))
8988     DONE;
8989   else
8990     FAIL;
8993 ;; Move up to 32 bytes at a time.  The fixed registers are needed because the
8994 ;; register allocator doesn't have a clue about allocating 8 word registers.
8995 ;; rD/rS = r5 is preferred, efficient form.
8996 (define_expand "movstrsi_8reg"
8997   [(parallel [(set (match_operand 0 "" "")
8998                    (match_operand 1 "" ""))
8999               (use (match_operand 2 "" ""))
9000               (use (match_operand 3 "" ""))
9001               (clobber (reg:SI  5))
9002               (clobber (reg:SI  6))
9003               (clobber (reg:SI  7))
9004               (clobber (reg:SI  8))
9005               (clobber (reg:SI  9))
9006               (clobber (reg:SI 10))
9007               (clobber (reg:SI 11))
9008               (clobber (reg:SI 12))
9009               (clobber (match_scratch:SI 4 ""))])]
9010   "TARGET_STRING"
9011   "")
9013 (define_insn ""
9014   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9015         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9016    (use (match_operand:SI 2 "immediate_operand" "i"))
9017    (use (match_operand:SI 3 "immediate_operand" "i"))
9018    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9019    (clobber (reg:SI  6))
9020    (clobber (reg:SI  7))
9021    (clobber (reg:SI  8))
9022    (clobber (reg:SI  9))
9023    (clobber (reg:SI 10))
9024    (clobber (reg:SI 11))
9025    (clobber (reg:SI 12))
9026    (clobber (match_scratch:SI 5 "=q"))]
9027   "TARGET_STRING && TARGET_POWER
9028    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9029        || INTVAL (operands[2]) == 0)
9030    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9031    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9032    && REGNO (operands[4]) == 5"
9033   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9034   [(set_attr "type" "load")
9035    (set_attr "length" "8")])
9037 (define_insn ""
9038   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9039         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9040    (use (match_operand:SI 2 "immediate_operand" "i"))
9041    (use (match_operand:SI 3 "immediate_operand" "i"))
9042    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9043    (clobber (reg:SI  6))
9044    (clobber (reg:SI  7))
9045    (clobber (reg:SI  8))
9046    (clobber (reg:SI  9))
9047    (clobber (reg:SI 10))
9048    (clobber (reg:SI 11))
9049    (clobber (reg:SI 12))
9050    (clobber (match_scratch:SI 5 "X"))]
9051   "TARGET_STRING && ! TARGET_POWER
9052    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9053        || INTVAL (operands[2]) == 0)
9054    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9055    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9056    && REGNO (operands[4]) == 5"
9057   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9058   [(set_attr "type" "load")
9059    (set_attr "length" "8")])
9061 (define_insn ""
9062   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9063         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9064    (use (match_operand:SI 2 "immediate_operand" "i"))
9065    (use (match_operand:SI 3 "immediate_operand" "i"))
9066    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9067    (clobber (reg:SI  6))
9068    (clobber (reg:SI  7))
9069    (clobber (reg:SI  8))
9070    (clobber (reg:SI  9))
9071    (clobber (reg:SI 10))
9072    (clobber (reg:SI 11))
9073    (clobber (reg:SI 12))
9074    (clobber (match_scratch:SI 5 "X"))]
9075   "TARGET_STRING && TARGET_POWERPC64
9076    && ((INTVAL (operands[2]) > 24 && INTVAL (operands[2]) < 32)
9077        || INTVAL (operands[2]) == 0)
9078    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 12)
9079    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 12)
9080    && REGNO (operands[4]) == 5"
9081   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9082   [(set_attr "type" "load")
9083    (set_attr "length" "8")])
9085 ;; Move up to 24 bytes at a time.  The fixed registers are needed because the
9086 ;; register allocator doesn't have a clue about allocating 6 word registers.
9087 ;; rD/rS = r5 is preferred, efficient form.
9088 (define_expand "movstrsi_6reg"
9089   [(parallel [(set (match_operand 0 "" "")
9090                    (match_operand 1 "" ""))
9091               (use (match_operand 2 "" ""))
9092               (use (match_operand 3 "" ""))
9093               (clobber (reg:SI  5))
9094               (clobber (reg:SI  6))
9095               (clobber (reg:SI  7))
9096               (clobber (reg:SI  8))
9097               (clobber (reg:SI  9))
9098               (clobber (reg:SI 10))
9099               (clobber (match_scratch:SI 4 ""))])]
9100   "TARGET_STRING"
9101   "")
9103 (define_insn ""
9104   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9105         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9106    (use (match_operand:SI 2 "immediate_operand" "i"))
9107    (use (match_operand:SI 3 "immediate_operand" "i"))
9108    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9109    (clobber (reg:SI  6))
9110    (clobber (reg:SI  7))
9111    (clobber (reg:SI  8))
9112    (clobber (reg:SI  9))
9113    (clobber (reg:SI 10))
9114    (clobber (match_scratch:SI 5 "=q"))]
9115   "TARGET_STRING && TARGET_POWER
9116    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 24
9117    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9118    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9119    && REGNO (operands[4]) == 5"
9120   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9121   [(set_attr "type" "load")
9122    (set_attr "length" "8")])
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_operand:SI 4 "gpc_reg_operand" "=r"))
9130    (clobber (reg:SI  6))
9131    (clobber (reg:SI  7))
9132    (clobber (reg:SI  8))
9133    (clobber (reg:SI  9))
9134    (clobber (reg:SI 10))
9135    (clobber (match_scratch:SI 5 "X"))]
9136   "TARGET_STRING && ! TARGET_POWER
9137    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9138    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9139    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9140    && REGNO (operands[4]) == 5"
9141   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9142   [(set_attr "type" "load")
9143    (set_attr "length" "8")])
9145 (define_insn ""
9146   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9147         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9148    (use (match_operand:SI 2 "immediate_operand" "i"))
9149    (use (match_operand:SI 3 "immediate_operand" "i"))
9150    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9151    (clobber (reg:SI  6))
9152    (clobber (reg:SI  7))
9153    (clobber (reg:SI  8))
9154    (clobber (reg:SI  9))
9155    (clobber (reg:SI 10))
9156    (clobber (match_scratch:SI 5 "X"))]
9157   "TARGET_STRING && TARGET_POWERPC64
9158    && INTVAL (operands[2]) > 16 && INTVAL (operands[2]) <= 32
9159    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 10)
9160    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 10)
9161    && REGNO (operands[4]) == 5"
9162   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9163   [(set_attr "type" "load")
9164    (set_attr "length" "8")])
9166 ;; Move up to 16 bytes at a time, using 4 fixed registers to avoid spill
9167 ;; problems with TImode.
9168 ;; rD/rS = r5 is preferred, efficient form.
9169 (define_expand "movstrsi_4reg"
9170   [(parallel [(set (match_operand 0 "" "")
9171                    (match_operand 1 "" ""))
9172               (use (match_operand 2 "" ""))
9173               (use (match_operand 3 "" ""))
9174               (clobber (reg:SI 5))
9175               (clobber (reg:SI 6))
9176               (clobber (reg:SI 7))
9177               (clobber (reg:SI 8))
9178               (clobber (match_scratch:SI 4 ""))])]
9179   "TARGET_STRING"
9180   "")
9182 (define_insn ""
9183   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9184         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9185    (use (match_operand:SI 2 "immediate_operand" "i"))
9186    (use (match_operand:SI 3 "immediate_operand" "i"))
9187    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9188    (clobber (reg:SI 6))
9189    (clobber (reg:SI 7))
9190    (clobber (reg:SI 8))
9191    (clobber (match_scratch:SI 5 "=q"))]
9192   "TARGET_STRING && TARGET_POWER
9193    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9194    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9195    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9196    && REGNO (operands[4]) == 5"
9197   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9198   [(set_attr "type" "load")
9199    (set_attr "length" "8")])
9201 (define_insn ""
9202   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9203         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9204    (use (match_operand:SI 2 "immediate_operand" "i"))
9205    (use (match_operand:SI 3 "immediate_operand" "i"))
9206    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9207    (clobber (reg:SI 6))
9208    (clobber (reg:SI 7))
9209    (clobber (reg:SI 8))
9210    (clobber (match_scratch:SI 5 "X"))]
9211   "TARGET_STRING && ! TARGET_POWER
9212    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9213    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9214    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9215    && REGNO (operands[4]) == 5"
9216   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9217   [(set_attr "type" "load")
9218    (set_attr "length" "8")])
9220 (define_insn ""
9221   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9222         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9223    (use (match_operand:SI 2 "immediate_operand" "i"))
9224    (use (match_operand:SI 3 "immediate_operand" "i"))
9225    (clobber (match_operand:SI 4 "gpc_reg_operand" "=r"))
9226    (clobber (reg:SI 6))
9227    (clobber (reg:SI 7))
9228    (clobber (reg:SI 8))
9229    (clobber (match_scratch:SI 5 "X"))]
9230   "TARGET_STRING && TARGET_POWERPC64
9231    && INTVAL (operands[2]) > 8 && INTVAL (operands[2]) <= 16
9232    && (REGNO (operands[0]) < 5 || REGNO (operands[0]) > 8)
9233    && (REGNO (operands[1]) < 5 || REGNO (operands[1]) > 8)
9234    && REGNO (operands[4]) == 5"
9235   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9236   [(set_attr "type" "load")
9237    (set_attr "length" "8")])
9239 ;; Move up to 8 bytes at a time.
9240 (define_expand "movstrsi_2reg"
9241   [(parallel [(set (match_operand 0 "" "")
9242                    (match_operand 1 "" ""))
9243               (use (match_operand 2 "" ""))
9244               (use (match_operand 3 "" ""))
9245               (clobber (match_scratch:DI 4 ""))
9246               (clobber (match_scratch:SI 5 ""))])]
9247   "TARGET_STRING && ! TARGET_POWERPC64"
9248   "")
9250 (define_insn ""
9251   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9252         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9253    (use (match_operand:SI 2 "immediate_operand" "i"))
9254    (use (match_operand:SI 3 "immediate_operand" "i"))
9255    (clobber (match_scratch:DI 4 "=&r"))
9256    (clobber (match_scratch:SI 5 "=q"))]
9257   "TARGET_STRING && TARGET_POWER && ! TARGET_POWERPC64
9258    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9259   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9260   [(set_attr "type" "load")
9261    (set_attr "length" "8")])
9263 (define_insn ""
9264   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9265         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9266    (use (match_operand:SI 2 "immediate_operand" "i"))
9267    (use (match_operand:SI 3 "immediate_operand" "i"))
9268    (clobber (match_scratch:DI 4 "=&r"))
9269    (clobber (match_scratch:SI 5 "X"))]
9270   "TARGET_STRING && ! TARGET_POWER && ! TARGET_POWERPC64
9271    && INTVAL (operands[2]) > 4 && INTVAL (operands[2]) <= 8"
9272   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9273   [(set_attr "type" "load")
9274    (set_attr "length" "8")])
9276 ;; Move up to 4 bytes at a time.
9277 (define_expand "movstrsi_1reg"
9278   [(parallel [(set (match_operand 0 "" "")
9279                    (match_operand 1 "" ""))
9280               (use (match_operand 2 "" ""))
9281               (use (match_operand 3 "" ""))
9282               (clobber (match_scratch:SI 4 ""))
9283               (clobber (match_scratch:SI 5 ""))])]
9284   "TARGET_STRING"
9285   "")
9287 (define_insn ""
9288   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9289         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9290    (use (match_operand:SI 2 "immediate_operand" "i"))
9291    (use (match_operand:SI 3 "immediate_operand" "i"))
9292    (clobber (match_scratch:SI 4 "=&r"))
9293    (clobber (match_scratch:SI 5 "=q"))]
9294   "TARGET_STRING && TARGET_POWER
9295    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9296   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9297   [(set_attr "type" "load")
9298    (set_attr "length" "8")])
9300 (define_insn ""
9301   [(set (mem:BLK (match_operand:SI 0 "gpc_reg_operand" "b"))
9302         (mem:BLK (match_operand:SI 1 "gpc_reg_operand" "b")))
9303    (use (match_operand:SI 2 "immediate_operand" "i"))
9304    (use (match_operand:SI 3 "immediate_operand" "i"))
9305    (clobber (match_scratch:SI 4 "=&r"))
9306    (clobber (match_scratch:SI 5 "X"))]
9307   "TARGET_STRING && ! TARGET_POWER
9308    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9309   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9310   [(set_attr "type" "load")
9311    (set_attr "length" "8")])
9313 (define_insn ""
9314   [(set (mem:BLK (match_operand:DI 0 "gpc_reg_operand" "b"))
9315         (mem:BLK (match_operand:DI 1 "gpc_reg_operand" "b")))
9316    (use (match_operand:SI 2 "immediate_operand" "i"))
9317    (use (match_operand:SI 3 "immediate_operand" "i"))
9318    (clobber (match_scratch:SI 4 "=&r"))
9319    (clobber (match_scratch:SI 5 "X"))]
9320   "TARGET_STRING && TARGET_POWERPC64
9321    && INTVAL (operands[2]) > 0 && INTVAL (operands[2]) <= 4"
9322   "{lsi|lswi} %4,%1,%2\;{stsi|stswi} %4,%0,%2"
9323   [(set_attr "type" "load")
9324    (set_attr "length" "8")])
9327 ;; Define insns that do load or store with update.  Some of these we can
9328 ;; get by using pre-decrement or pre-increment, but the hardware can also
9329 ;; do cases where the increment is not the size of the object.
9331 ;; In all these cases, we use operands 0 and 1 for the register being
9332 ;; incremented because those are the operands that local-alloc will
9333 ;; tie and these are the pair most likely to be tieable (and the ones
9334 ;; that will benefit the most).
9336 (define_insn "*movdi_update1"
9337   [(set (match_operand:DI 3 "gpc_reg_operand" "=r,r")
9338         (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9339                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I"))))
9340    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9341         (plus:DI (match_dup 1) (match_dup 2)))]
9342   "TARGET_POWERPC64 && TARGET_UPDATE"
9343   "@
9344    ldux %3,%0,%2
9345    ldu %3,%2(%0)"
9346   [(set_attr "type" "load")])
9348 (define_insn "*movdi_update2"
9349   [(set (match_operand:DI 3 "gpc_reg_operand" "=r")
9350         (sign_extend:DI
9351          (mem:SI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0")
9352                           (match_operand:DI 2 "gpc_reg_operand" "r")))))
9353    (set (match_operand:DI 0 "gpc_reg_operand" "=b")
9354         (plus:DI (match_dup 1) (match_dup 2)))]
9355   "TARGET_POWERPC64"
9356   "lwaux %3,%0,%2"
9357   [(set_attr "type" "load")])
9359 (define_insn "movdi_update"
9360   [(set (mem:DI (plus:DI (match_operand:DI 1 "gpc_reg_operand" "0,0")
9361                          (match_operand:DI 2 "reg_or_aligned_short_operand" "r,I")))
9362         (match_operand:DI 3 "gpc_reg_operand" "r,r"))
9363    (set (match_operand:DI 0 "gpc_reg_operand" "=b,b")
9364         (plus:DI (match_dup 1) (match_dup 2)))]
9365   "TARGET_POWERPC64 && TARGET_UPDATE"
9366   "@
9367    stdux %3,%0,%2
9368    stdu %3,%2(%0)"
9369   [(set_attr "type" "store")])
9371 (define_insn "*movsi_update1"
9372   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9373         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9374                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9375    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9376         (plus:SI (match_dup 1) (match_dup 2)))]
9377   ""
9378   "@
9379    {lux|lwzux} %3,%0,%2
9380    {lu|lwzu} %3,%2(%0)"
9381   [(set_attr "type" "load")])
9383 (define_insn "movsi_update"
9384   [(set (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9385                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9386         (match_operand:SI 3 "gpc_reg_operand" "r,r"))
9387    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9388         (plus:SI (match_dup 1) (match_dup 2)))]
9389   "TARGET_UPDATE"
9390   "@
9391    {stux|stwux} %3,%0,%2
9392    {stu|stwu} %3,%2(%0)"
9393   [(set_attr "type" "store")])
9395 (define_insn "*movhi_update"
9396   [(set (match_operand:HI 3 "gpc_reg_operand" "=r,r")
9397         (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9398                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9399    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9400         (plus:SI (match_dup 1) (match_dup 2)))]
9401   "TARGET_UPDATE"
9402   "@
9403    lhzux %3,%0,%2
9404    lhzu %3,%2(%0)"
9405   [(set_attr "type" "load")])
9407 (define_insn "*movhi_update2"
9408   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9409         (zero_extend:SI
9410          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9411                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9412    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9413         (plus:SI (match_dup 1) (match_dup 2)))]
9414   "TARGET_UPDATE"
9415   "@
9416    lhzux %3,%0,%2
9417    lhzu %3,%2(%0)"
9418   [(set_attr "type" "load")])
9420 (define_insn "*movhi_update3"
9421   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9422         (sign_extend:SI
9423          (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9424                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9425    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9426         (plus:SI (match_dup 1) (match_dup 2)))]
9427   "TARGET_UPDATE"
9428   "@
9429    lhaux %3,%0,%2
9430    lhau %3,%2(%0)"
9431   [(set_attr "type" "load")])
9433 (define_insn "*movhi_update4"
9434   [(set (mem:HI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9435                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9436         (match_operand:HI 3 "gpc_reg_operand" "r,r"))
9437    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9438         (plus:SI (match_dup 1) (match_dup 2)))]
9439   "TARGET_UPDATE"
9440   "@
9441    sthux %3,%0,%2
9442    sthu %3,%2(%0)"
9443   [(set_attr "type" "store")])
9445 (define_insn "*movqi_update1"
9446   [(set (match_operand:QI 3 "gpc_reg_operand" "=r,r")
9447         (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9448                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9449    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9450         (plus:SI (match_dup 1) (match_dup 2)))]
9451   "TARGET_UPDATE"
9452   "@
9453    lbzux %3,%0,%2
9454    lbzu %3,%2(%0)"
9455   [(set_attr "type" "load")])
9457 (define_insn "*movqi_update2"
9458   [(set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
9459         (zero_extend:SI
9460          (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9461                           (match_operand:SI 2 "reg_or_short_operand" "r,I")))))
9462    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9463         (plus:SI (match_dup 1) (match_dup 2)))]
9464   "TARGET_UPDATE"
9465   "@
9466    lbzux %3,%0,%2
9467    lbzu %3,%2(%0)"
9468   [(set_attr "type" "load")])
9470 (define_insn "*movqi_update3"
9471   [(set (mem:QI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9472                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9473         (match_operand:QI 3 "gpc_reg_operand" "r,r"))
9474    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9475         (plus:SI (match_dup 1) (match_dup 2)))]
9476   "TARGET_UPDATE"
9477   "@
9478    stbux %3,%0,%2
9479    stbu %3,%2(%0)"
9480   [(set_attr "type" "store")])
9482 (define_insn "*movsf_update1"
9483   [(set (match_operand:SF 3 "gpc_reg_operand" "=f,f")
9484         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9485                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9486    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9487         (plus:SI (match_dup 1) (match_dup 2)))]
9488   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9489   "@
9490    lfsux %3,%0,%2
9491    lfsu %3,%2(%0)"
9492   [(set_attr "type" "fpload")])
9494 (define_insn "*movsf_update2"
9495   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9496                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9497         (match_operand:SF 3 "gpc_reg_operand" "f,f"))
9498    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9499         (plus:SI (match_dup 1) (match_dup 2)))]
9500   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9501   "@
9502    stfsux %3,%0,%2
9503    stfsu %3,%2(%0)"
9504   [(set_attr "type" "fpstore")])
9506 (define_insn "*movsf_update3"
9507   [(set (match_operand:SF 3 "gpc_reg_operand" "=r,r")
9508         (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9509                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9510    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9511         (plus:SI (match_dup 1) (match_dup 2)))]
9512   "TARGET_SOFT_FLOAT && TARGET_UPDATE"
9513   "@
9514    {lux|lwzux} %3,%0,%2
9515    {lu|lwzu} %3,%2(%0)"
9516   [(set_attr "type" "load")])
9518 (define_insn "*movsf_update4"
9519   [(set (mem:SF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9520                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9521         (match_operand:SF 3 "gpc_reg_operand" "r,r"))
9522    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9523         (plus:SI (match_dup 1) (match_dup 2)))]
9524   "TARGET_SOFT_FLOAT && TARGET_UPDATE"
9525   "@
9526    {stux|stwux} %3,%0,%2
9527    {stu|stwu} %3,%2(%0)"
9528   [(set_attr "type" "store")])
9530 (define_insn "*movdf_update1"
9531   [(set (match_operand:DF 3 "gpc_reg_operand" "=f,f")
9532         (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9533                          (match_operand:SI 2 "reg_or_short_operand" "r,I"))))
9534    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9535         (plus:SI (match_dup 1) (match_dup 2)))]
9536   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9537   "@
9538    lfdux %3,%0,%2
9539    lfdu %3,%2(%0)"
9540   [(set_attr "type" "fpload")])
9542 (define_insn "*movdf_update2"
9543   [(set (mem:DF (plus:SI (match_operand:SI 1 "gpc_reg_operand" "0,0")
9544                          (match_operand:SI 2 "reg_or_short_operand" "r,I")))
9545         (match_operand:DF 3 "gpc_reg_operand" "f,f"))
9546    (set (match_operand:SI 0 "gpc_reg_operand" "=b,b")
9547         (plus:SI (match_dup 1) (match_dup 2)))]
9548   "TARGET_HARD_FLOAT && TARGET_UPDATE"
9549   "@
9550    stfdux %3,%0,%2
9551    stfdu %3,%2(%0)"
9552   [(set_attr "type" "fpstore")])
9554 ;; Peephole to convert two consecutive FP loads or stores into lfq/stfq.
9556 (define_peephole
9557   [(set (match_operand:DF 0 "gpc_reg_operand" "=f")
9558         (match_operand:DF 1 "memory_operand" ""))
9559    (set (match_operand:DF 2 "gpc_reg_operand" "=f")
9560         (match_operand:DF 3 "memory_operand" ""))]
9561   "TARGET_POWER2
9562    && TARGET_HARD_FLOAT
9563    && registers_ok_for_quad_peep (operands[0], operands[2])
9564    && ! MEM_VOLATILE_P (operands[1]) && ! MEM_VOLATILE_P (operands[3])
9565    && addrs_ok_for_quad_peep (XEXP (operands[1], 0), XEXP (operands[3], 0))"
9566   "lfq%U1%X1 %0,%1")
9568 (define_peephole
9569   [(set (match_operand:DF 0 "memory_operand" "")
9570         (match_operand:DF 1 "gpc_reg_operand" "f"))
9571    (set (match_operand:DF 2 "memory_operand" "")
9572         (match_operand:DF 3 "gpc_reg_operand" "f"))]
9573   "TARGET_POWER2
9574    && TARGET_HARD_FLOAT
9575    && registers_ok_for_quad_peep (operands[1], operands[3])
9576    && ! MEM_VOLATILE_P (operands[0]) && ! MEM_VOLATILE_P (operands[2])
9577    && addrs_ok_for_quad_peep (XEXP (operands[0], 0), XEXP (operands[2], 0))"
9578   "stfq%U0%X0 %1,%0")
9580 ;; Next come insns related to the calling sequence.
9582 ;; First, an insn to allocate new stack space for dynamic use (e.g., alloca).
9583 ;; We move the back-chain and decrement the stack pointer.
9585 (define_expand "allocate_stack"
9586   [(set (match_operand 0 "gpc_reg_operand" "=r")
9587         (minus (reg 1) (match_operand 1 "reg_or_short_operand" "")))
9588    (set (reg 1)
9589         (minus (reg 1) (match_dup 1)))]
9590   ""
9591   "
9592 { rtx chain = gen_reg_rtx (Pmode);
9593   rtx stack_bot = gen_rtx_MEM (Pmode, stack_pointer_rtx);
9594   rtx neg_op0;
9596   emit_move_insn (chain, stack_bot);
9598   /* Check stack bounds if necessary.  */
9599   if (current_function_limit_stack)
9600     {
9601       rtx available;
9602       available = expand_binop (Pmode, sub_optab, 
9603                                 stack_pointer_rtx, stack_limit_rtx,
9604                                 NULL_RTX, 1, OPTAB_WIDEN);
9605       emit_insn (gen_cond_trap (LTU, available, operands[1], const0_rtx));
9606     }
9608   if (GET_CODE (operands[1]) != CONST_INT
9609       || INTVAL (operands[1]) < -32767
9610       || INTVAL (operands[1]) > 32768)
9611     {
9612       neg_op0 = gen_reg_rtx (Pmode);
9613       if (TARGET_32BIT)
9614         emit_insn (gen_negsi2 (neg_op0, operands[1]));
9615       else
9616         emit_insn (gen_negdi2 (neg_op0, operands[1]));
9617     }
9618   else
9619     neg_op0 = GEN_INT (- INTVAL (operands[1]));
9621   if (TARGET_UPDATE)
9622     emit_insn ((* ((TARGET_32BIT) ? gen_movsi_update : gen_movdi_update))
9623                 (stack_pointer_rtx, stack_pointer_rtx, neg_op0, chain));
9625   else
9626     {
9627       emit_insn ((* ((TARGET_32BIT) ? gen_addsi3 : gen_adddi3))
9628                  (stack_pointer_rtx, stack_pointer_rtx, neg_op0));
9629       emit_move_insn (gen_rtx_MEM (Pmode, stack_pointer_rtx), chain);
9630     }
9632   emit_move_insn (operands[0], virtual_stack_dynamic_rtx);
9633   DONE;
9636 ;; These patterns say how to save and restore the stack pointer.  We need not
9637 ;; save the stack pointer at function level since we are careful to
9638 ;; preserve the backchain.  At block level, we have to restore the backchain
9639 ;; when we restore the stack pointer.
9641 ;; For nonlocal gotos, we must save both the stack pointer and its
9642 ;; backchain and restore both.  Note that in the nonlocal case, the
9643 ;; save area is a memory location.
9645 (define_expand "save_stack_function"
9646   [(match_operand 0 "any_operand" "")
9647    (match_operand 1 "any_operand" "")]
9648   ""
9649   "DONE;")
9651 (define_expand "restore_stack_function"
9652   [(match_operand 0 "any_operand" "")
9653    (match_operand 1 "any_operand" "")]
9654   ""
9655   "DONE;")
9657 (define_expand "restore_stack_block"
9658   [(use (match_operand 0 "register_operand" ""))
9659    (set (match_dup 2) (match_dup 3))
9660    (set (match_dup 0) (match_operand 1 "register_operand" ""))
9661    (set (match_dup 3) (match_dup 2))]
9662   ""
9663   "
9665   operands[2] = gen_reg_rtx (Pmode);
9666   operands[3] = gen_rtx_MEM (Pmode, operands[0]);
9669 (define_expand "save_stack_nonlocal"
9670   [(match_operand 0 "memory_operand" "")
9671    (match_operand 1 "register_operand" "")]
9672   ""
9673   "
9675   rtx temp = gen_reg_rtx (Pmode);
9677   /* Copy the backchain to the first word, sp to the second.  */
9678   emit_move_insn (temp, gen_rtx_MEM (Pmode, operands[1]));
9679   emit_move_insn (operand_subword (operands[0], 0, 0,
9680                                    (TARGET_32BIT ? DImode : TImode)),
9681                   temp);
9682   emit_move_insn (operand_subword (operands[0], 1, 0, (TARGET_32BIT ? DImode : TImode)),
9683                   operands[1]);
9684   DONE;
9687 (define_expand "restore_stack_nonlocal"
9688   [(match_operand 0 "register_operand" "")
9689    (match_operand 1 "memory_operand" "")]
9690   ""
9691   "
9693   rtx temp = gen_reg_rtx (Pmode);
9695   /* Restore the backchain from the first word, sp from the second.  */
9696   emit_move_insn (temp,
9697                   operand_subword (operands[1], 0, 0, (TARGET_32BIT ? DImode : TImode)));
9698   emit_move_insn (operands[0],
9699                   operand_subword (operands[1], 1, 0,
9700                                    (TARGET_32BIT ? DImode : TImode)));
9701   emit_move_insn (gen_rtx_MEM (Pmode, operands[0]), temp);
9702   DONE;
9705 ;; TOC register handling.
9707 ;; Code to initialize the TOC register...
9709 (define_insn "load_toc_aix_si"
9710   [(parallel [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9711                    (unspec:SI [(const_int 0)] 7))
9712               (use (reg:SI 2))])]
9713   "DEFAULT_ABI == ABI_AIX && TARGET_32BIT"
9714   "*
9716   char buf[30];
9717   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9718   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9719   operands[2] = gen_rtx_REG (Pmode, 2);
9720   return \"{l|lwz} %0,%1(%2)\";
9722   [(set_attr "type" "load")])
9724 (define_insn "load_toc_aix_di"
9725   [(parallel [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
9726                    (unspec:DI [(const_int 0)] 7))
9727               (use (reg:DI 2))])]
9728   "DEFAULT_ABI == ABI_AIX && TARGET_64BIT"
9729   "*
9731   char buf[30];
9732 #ifdef TARGET_RELOCATABLE
9733   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\",
9734                                !TARGET_MINIMAL_TOC || TARGET_RELOCATABLE);
9735 #else
9736   ASM_GENERATE_INTERNAL_LABEL (buf, \"LCTOC\", 1);
9737 #endif
9738   if (TARGET_ELF)
9739     strcat (buf, \"@toc\");
9740   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));
9741   operands[2] = gen_rtx_REG (Pmode, 2);
9742   return \"ld %0,%1(%2)\";
9744   [(set_attr "type" "load")])
9746 (define_insn "load_toc_v4_pic_si"
9747   [(set (match_operand:SI 0 "register_operand" "=l")
9748         (unspec:SI [(const_int 0)] 7))]
9749   "DEFAULT_ABI == ABI_V4 && flag_pic == 1 && TARGET_32BIT"
9750   "bl _GLOBAL_OFFSET_TABLE_@local-4"
9751   [(set_attr "type" "branch")
9752    (set_attr "length" "4")])
9754 (define_insn "load_toc_v4_PIC_1"
9755   [(set (match_operand:SI 0 "register_operand" "=l")
9756         (match_operand:SI 1 "immediate_operand" "s"))
9757    (unspec [(match_dup 1)] 7)]
9758   "TARGET_ELF && flag_pic == 2"
9759   "bl %1\\n%1:"
9760   [(set_attr "type" "branch")
9761    (set_attr "length" "4")])
9763 (define_insn "load_toc_v4_PIC_1b"
9764   [(set (match_operand:SI 0 "register_operand" "=l")
9765         (match_operand:SI 1 "immediate_operand" "s"))
9766    (unspec [(match_dup 1) (match_operand 2 "immediate_operand" "s")] 6)]
9767   "TARGET_ELF && flag_pic == 2"
9768   "bl %1\\n\\t.long %2-%1+4\\n%1:"
9769   [(set_attr "type" "branch")
9770    (set_attr "length" "8")])
9772 (define_insn "load_toc_v4_PIC_2"
9773   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
9774         (mem:SI (plus:SI (match_operand:SI 1 "gpc_reg_operand" "r")
9775                    (minus:SI (match_operand:SI 2 "immediate_operand" "s")
9776                              (match_operand:SI 3 "immediate_operand" "s")))))]
9777   "TARGET_ELF && flag_pic == 2"
9778   "{l|lwz} %0,%2-%3(%1)"
9779   [(set_attr "type" "load")])
9781 (define_insn "load_macho_picbase"
9782   [(set (match_operand:SI 0 "register_operand" "=l")
9783         (unspec:SI [(const_int 0)] 15))]
9784   "(DEFAULT_ABI == ABI_DARWIN) && flag_pic"
9785   "*
9787 #if TARGET_MACHO
9788   char *picbase = machopic_function_base_name ();
9789   operands[1] = gen_rtx_SYMBOL_REF (Pmode, ggc_alloc_string (picbase, -1));
9790 #endif
9791   return \"bcl 20,31,%1\\n%1:\";
9793   [(set_attr "type" "branch")
9794    (set_attr "length" "4")])
9796 ;; If the TOC is shared over a translation unit, as happens with all
9797 ;; the kinds of PIC that we support, we need to restore the TOC
9798 ;; pointer only when jumping over units of translation.
9800 (define_expand "builtin_setjmp_receiver"
9801   [(use (label_ref (match_operand 0 "" "")))]
9802   "(DEFAULT_ABI == ABI_V4 && flag_pic == 1)
9803    || (TARGET_TOC && TARGET_MINIMAL_TOC)"
9804   "
9806   rs6000_emit_load_toc_table (FALSE);
9807   DONE;
9810 ;; A function pointer under AIX is a pointer to a data area whose first word
9811 ;; contains the actual address of the function, whose second word contains a
9812 ;; pointer to its TOC, and whose third word contains a value to place in the
9813 ;; static chain register (r11).  Note that if we load the static chain, our
9814 ;; "trampoline" need not have any executable code.
9816 (define_expand "call_indirect_aix32"
9817   [(set (match_dup 2)
9818         (mem:SI (match_operand:SI 0 "gpc_reg_operand" "")))
9819    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9820         (reg:SI 2))
9821    (set (reg:SI 2)
9822         (mem:SI (plus:SI (match_dup 0)
9823                          (const_int 4))))
9824    (set (reg:SI 11)
9825         (mem:SI (plus:SI (match_dup 0)
9826                          (const_int 8))))
9827    (parallel [(call (mem:SI (match_dup 2))
9828                     (match_operand 1 "" ""))
9829               (use (reg:SI 2))
9830               (use (reg:SI 11))
9831               (set (reg:SI 2)
9832                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9833               (clobber (scratch:SI))])]
9834   "TARGET_32BIT"
9835   "
9836 { operands[2] = gen_reg_rtx (SImode); }")
9838 (define_expand "call_indirect_aix64"
9839   [(set (match_dup 2)
9840         (mem:DI (match_operand:DI 0 "gpc_reg_operand" "")))
9841    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9842         (reg:DI 2))
9843    (set (reg:DI 2)
9844         (mem:DI (plus:DI (match_dup 0)
9845                          (const_int 8))))
9846    (set (reg:DI 11)
9847         (mem:DI (plus:DI (match_dup 0)
9848                          (const_int 16))))
9849    (parallel [(call (mem:SI (match_dup 2))
9850                     (match_operand 1 "" ""))
9851               (use (reg:DI 2))
9852               (use (reg:DI 11))
9853               (set (reg:DI 2)
9854                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9855               (clobber (scratch:SI))])]
9856   "TARGET_64BIT"
9857   "
9858 { operands[2] = gen_reg_rtx (DImode); }")
9860 (define_expand "call_value_indirect_aix32"
9861   [(set (match_dup 3)
9862         (mem:SI (match_operand:SI 1 "gpc_reg_operand" "")))
9863    (set (mem:SI (plus:SI (reg:SI 1) (const_int 20)))
9864         (reg:SI 2))
9865    (set (reg:SI 2)
9866         (mem:SI (plus:SI (match_dup 1)
9867                          (const_int 4))))
9868    (set (reg:SI 11)
9869         (mem:SI (plus:SI (match_dup 1)
9870                          (const_int 8))))
9871    (parallel [(set (match_operand 0 "" "")
9872                    (call (mem:SI (match_dup 3))
9873                          (match_operand 2 "" "")))
9874               (use (reg:SI 2))
9875               (use (reg:SI 11))
9876               (set (reg:SI 2)
9877                    (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
9878               (clobber (scratch:SI))])]
9879   "TARGET_32BIT"
9880   "
9881 { operands[3] = gen_reg_rtx (SImode); }")
9883 (define_expand "call_value_indirect_aix64"
9884   [(set (match_dup 3)
9885         (mem:DI (match_operand:DI 1 "gpc_reg_operand" "")))
9886    (set (mem:DI (plus:DI (reg:DI 1) (const_int 40)))
9887         (reg:DI 2))
9888    (set (reg:DI 2)
9889         (mem:DI (plus:DI (match_dup 1)
9890                          (const_int 8))))
9891    (set (reg:DI 11)
9892         (mem:DI (plus:DI (match_dup 1)
9893                          (const_int 16))))
9894    (parallel [(set (match_operand 0 "" "")
9895                    (call (mem:SI (match_dup 3))
9896                          (match_operand 2 "" "")))
9897               (use (reg:DI 2))
9898               (use (reg:DI 11))
9899               (set (reg:DI 2)
9900                    (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
9901               (clobber (scratch:SI))])]
9902   "TARGET_64BIT"
9903   "
9904 { operands[3] = gen_reg_rtx (DImode); }")
9906 ;; Now the definitions for the call and call_value insns
9907 (define_expand "call"
9908   [(parallel [(call (mem:SI (match_operand 0 "address_operand" ""))
9909                     (match_operand 1 "" ""))
9910               (use (match_operand 2 "" ""))
9911               (clobber (scratch:SI))])]
9912   ""
9913   "
9915 #if TARGET_MACHO
9916   if (flag_pic)
9917     operands[0] = machopic_indirect_call_target (operands[0]);
9918 #endif
9920   if (GET_CODE (operands[0]) != MEM || GET_CODE (operands[1]) != CONST_INT)
9921     abort ();
9923   operands[0] = XEXP (operands[0], 0);
9925   if (GET_CODE (operands[0]) != SYMBOL_REF
9926       || (INTVAL (operands[2]) & CALL_LONG) != 0)
9927     {
9928       if (INTVAL (operands[2]) & CALL_LONG)
9929         operands[0] = rs6000_longcall_ref (operands[0]);
9931       if (DEFAULT_ABI == ABI_V4
9932           || DEFAULT_ABI == ABI_AIX_NODESC
9933           || DEFAULT_ABI == ABI_DARWIN)
9934         operands[0] = force_reg (Pmode, operands[0]);
9936       else if (DEFAULT_ABI == ABI_AIX)
9937         {
9938           /* AIX function pointers are really pointers to a three word
9939              area.  */
9940           emit_call_insn (TARGET_32BIT
9941                           ? gen_call_indirect_aix32 (force_reg (SImode,
9942                                                                 operands[0]),
9943                                                      operands[1])
9944                           : gen_call_indirect_aix64 (force_reg (DImode,
9945                                                                 operands[0]),
9946                                                      operands[1]));
9947           DONE;
9948         }
9949       else
9950         abort ();
9951     }
9954 (define_expand "call_value"
9955   [(parallel [(set (match_operand 0 "" "")
9956                    (call (mem:SI (match_operand 1 "address_operand" ""))
9957                          (match_operand 2 "" "")))
9958               (use (match_operand 3 "" ""))
9959               (clobber (scratch:SI))])]
9960   ""
9961   "
9963 #if TARGET_MACHO
9964   if (flag_pic)
9965     operands[1] = machopic_indirect_call_target (operands[1]);
9966 #endif
9968   if (GET_CODE (operands[1]) != MEM || GET_CODE (operands[2]) != CONST_INT)
9969     abort ();
9971   operands[1] = XEXP (operands[1], 0);
9973   if (GET_CODE (operands[1]) != SYMBOL_REF
9974       || (INTVAL (operands[3]) & CALL_LONG) != 0)
9975     {
9976       if (INTVAL (operands[3]) & CALL_LONG)
9977         operands[1] = rs6000_longcall_ref (operands[1]);
9979       if (DEFAULT_ABI == ABI_V4
9980           || DEFAULT_ABI == ABI_AIX_NODESC
9981           || DEFAULT_ABI == ABI_DARWIN)
9982         operands[0] = force_reg (Pmode, operands[0]);
9984       else if (DEFAULT_ABI == ABI_AIX)
9985         {
9986           /* AIX function pointers are really pointers to a three word
9987              area.  */
9988           emit_call_insn (TARGET_32BIT
9989                           ? gen_call_value_indirect_aix32 (operands[0],
9990                                                            force_reg (SImode,
9991                                                                       operands[1]),
9992                                                            operands[2])
9993                           : gen_call_value_indirect_aix64 (operands[0],
9994                                                            force_reg (DImode,
9995                                                                       operands[1]),
9996                                                            operands[2]));
9997           DONE;
9998         }
9999       else
10000         abort ();
10001     }
10004 ;; Call to function in current module.  No TOC pointer reload needed.
10005 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
10006 ;; either the function was not prototyped, or it was prototyped as a
10007 ;; variable argument function.  It is > 0 if FP registers were passed
10008 ;; and < 0 if they were not.
10010 (define_insn "*call_local32"
10011   [(call (mem:SI (match_operand:SI 0 "current_file_function_operand" "s,s"))
10012          (match_operand 1 "" "g,g"))
10013    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10014    (clobber (match_scratch:SI 3 "=l,l"))]
10015   "(INTVAL (operands[2]) & CALL_LONG) == 0"
10016   "*
10018   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10019     output_asm_insn (\"crxor 6,6,6\", operands);
10021   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10022     output_asm_insn (\"creqv 6,6,6\", operands);
10024   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10026   [(set_attr "type" "branch")
10027    (set_attr "length" "4,8")])
10029 (define_insn "*call_local64"
10030   [(call (mem:SI (match_operand:DI 0 "current_file_function_operand" "s,s"))
10031          (match_operand 1 "" "g,g"))
10032    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10033    (clobber (match_scratch:SI 3 "=l,l"))]
10034   "TARGET_64BIT && (INTVAL (operands[2]) & CALL_LONG) == 0"
10035   "*
10037   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10038     output_asm_insn (\"crxor 6,6,6\", operands);
10040   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10041     output_asm_insn (\"creqv 6,6,6\", operands);
10043   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z0@local\" : \"bl %z0\";
10045   [(set_attr "type" "branch")
10046    (set_attr "length" "4,8")])
10048 (define_insn "*call_value_local32"
10049   [(set (match_operand 0 "" "")
10050         (call (mem:SI (match_operand:SI 1 "current_file_function_operand" "s,s"))
10051               (match_operand 2 "" "g,g")))
10052    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10053    (clobber (match_scratch:SI 4 "=l,l"))]
10054   "(INTVAL (operands[3]) & CALL_LONG) == 0"
10055   "*
10057   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10058     output_asm_insn (\"crxor 6,6,6\", operands);
10060   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10061     output_asm_insn (\"creqv 6,6,6\", operands);
10063   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10065   [(set_attr "type" "branch")
10066    (set_attr "length" "4,8")])
10069 (define_insn "*call_value_local64"
10070   [(set (match_operand 0 "" "")
10071         (call (mem:SI (match_operand:DI 1 "current_file_function_operand" "s,s"))
10072               (match_operand 2 "" "g,g")))
10073    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10074    (clobber (match_scratch:SI 4 "=l,l"))]
10075   "TARGET_64BIT && (INTVAL (operands[3]) & CALL_LONG) == 0"
10076   "*
10078   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10079     output_asm_insn (\"crxor 6,6,6\", operands);
10081   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10082     output_asm_insn (\"creqv 6,6,6\", operands);
10084   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? \"bl %z1@local\" : \"bl %z1\";
10086   [(set_attr "type" "branch")
10087    (set_attr "length" "4,8")])
10089 ;; Call to function which may be in another module.  Restore the TOC
10090 ;; pointer (r2) after the call unless this is System V.
10091 ;; Operand2 is non-zero if we are using the V.4 calling sequence and
10092 ;; either the function was not prototyped, or it was prototyped as a
10093 ;; variable argument function.  It is > 0 if FP registers were passed
10094 ;; and < 0 if they were not.
10096 (define_insn "*call_indirect_nonlocal_aix32"
10097   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl"))
10098          (match_operand 1 "" "g"))
10099    (use (reg:SI 2))
10100    (use (reg:SI 11))
10101    (set (reg:SI 2)
10102         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10103    (clobber (match_scratch:SI 2 "=l"))]
10104   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10105   "b%T0l\;{l|lwz} 2,20(1)"
10106   [(set_attr "type" "jmpreg")
10107    (set_attr "length" "8")])
10109 (define_insn "*call_nonlocal_aix32"
10110   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s"))
10111          (match_operand 1 "" "g"))
10112    (use (match_operand:SI 2 "immediate_operand" "O"))
10113    (clobber (match_scratch:SI 3 "=l"))]
10114   "TARGET_32BIT
10115    && DEFAULT_ABI == ABI_AIX
10116    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10117   "bl %z0\;%."
10118   [(set_attr "type" "branch")
10119    (set_attr "length" "8")])
10121 (define_insn "*call_indirect_nonlocal_aix64"
10122   [(call (mem:SI (match_operand:DI 0 "register_operand" "cl"))
10123          (match_operand 1 "" "g"))
10124    (use (reg:DI 2))
10125    (use (reg:DI 11))
10126    (set (reg:DI 2)
10127         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10128    (clobber (match_scratch:SI 2 "=l"))]
10129   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10130   "b%T0l\;ld 2,40(1)"
10131   [(set_attr "type" "jmpreg")
10132    (set_attr "length" "8")])
10134 (define_insn "*call_nonlocal_aix64"
10135   [(call (mem:SI (match_operand:DI 0 "symbol_ref_operand" "s"))
10136          (match_operand 1 "" "g"))
10137    (use (match_operand:SI 2 "immediate_operand" "O"))
10138    (clobber (match_scratch:SI 3 "=l"))]
10139   "TARGET_64BIT 
10140    && DEFAULT_ABI == ABI_AIX
10141    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10142   "bl %z0\;%."
10143   [(set_attr "type" "branch")
10144    (set_attr "length" "8")])
10146 (define_insn "*call_value_indirect_nonlocal_aix32"
10147   [(set (match_operand 0 "" "")
10148         (call (mem:SI (match_operand:SI 1 "register_operand" "cl"))
10149               (match_operand 2 "" "g")))
10150    (use (reg:SI 2))
10151    (use (reg:SI 11))
10152    (set (reg:SI 2)
10153         (mem:SI (plus:SI (reg:SI 1) (const_int 20))))
10154    (clobber (match_scratch:SI 3 "=l"))]
10155   "TARGET_32BIT && DEFAULT_ABI == ABI_AIX"
10156   "b%T1l\;{l|lwz} 2,20(1)"
10157   [(set_attr "type" "jmpreg")
10158    (set_attr "length" "8")])
10160 (define_insn "*call_value_nonlocal_aix32"
10161   [(set (match_operand 0 "" "")
10162         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s"))
10163               (match_operand 2 "" "g")))
10164    (use (match_operand:SI 3 "immediate_operand" "O"))
10165    (clobber (match_scratch:SI 4 "=l"))]
10166   "TARGET_32BIT
10167    && DEFAULT_ABI == ABI_AIX
10168    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10169   "bl %z1\;%."
10170   [(set_attr "type" "branch")
10171    (set_attr "length" "8")])
10173 (define_insn "*call_value_indirect_nonlocal_aix64"
10174   [(set (match_operand 0 "" "")
10175         (call (mem:SI (match_operand:DI 1 "register_operand" "cl"))
10176               (match_operand 2 "" "g")))
10177    (use (reg:DI 2))
10178    (use (reg:DI 11))
10179    (set (reg:DI 2)
10180         (mem:DI (plus:DI (reg:DI 1) (const_int 40))))
10181    (clobber (match_scratch:SI 3 "=l"))]
10182   "TARGET_64BIT && DEFAULT_ABI == ABI_AIX"
10183   "b%T1l\;ld 2,40(1)"
10184   [(set_attr "type" "jmpreg")
10185    (set_attr "length" "8")])
10187 (define_insn "*call_value_nonlocal_aix64"
10188   [(set (match_operand 0 "" "")
10189         (call (mem:SI (match_operand:DI 1 "symbol_ref_operand" "s"))
10190               (match_operand 2 "" "g")))
10191    (use (match_operand:SI 3 "immediate_operand" "O"))
10192    (clobber (match_scratch:SI 4 "=l"))]
10193   "TARGET_64BIT 
10194    && DEFAULT_ABI == ABI_AIX
10195    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10196   "bl %z1\;%."
10197   [(set_attr "type" "branch")
10198    (set_attr "length" "8")])
10200 ;; A function pointer under System V is just a normal pointer
10201 ;; operands[0] is the function pointer
10202 ;; operands[1] is the stack size to clean up
10203 ;; operands[2] is the value FUNCTION_ARG returns for the VOID argument
10204 ;; which indicates how to set cr1
10206 (define_insn "*call_indirect_nonlocal_sysv"
10207   [(call (mem:SI (match_operand:SI 0 "register_operand" "cl,cl"))
10208          (match_operand 1 "" "g,g"))
10209    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10210    (clobber (match_scratch:SI 3 "=l,l"))]
10211   "DEFAULT_ABI == ABI_AIX_NODESC
10212    || DEFAULT_ABI == ABI_V4
10213    || DEFAULT_ABI == ABI_DARWIN"
10215   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10216     output_asm_insn ("crxor 6,6,6", operands);
10218   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10219     output_asm_insn ("creqv 6,6,6", operands);
10221   return "b%T0l";
10223   [(set_attr "type" "jmpreg,jmpreg")
10224    (set_attr "length" "4,8")])
10226 (define_insn "*call_nonlocal_sysv"
10227   [(call (mem:SI (match_operand:SI 0 "symbol_ref_operand" "s,s"))
10228          (match_operand 1 "" "g,g"))
10229    (use (match_operand:SI 2 "immediate_operand" "O,n"))
10230    (clobber (match_scratch:SI 3 "=l,l"))]
10231   "(DEFAULT_ABI == ABI_AIX_NODESC
10232     || DEFAULT_ABI == ABI_V4
10233     || DEFAULT_ABI == ABI_DARWIN)
10234    && (INTVAL (operands[2]) & CALL_LONG) == 0"
10236   if (INTVAL (operands[2]) & CALL_V4_SET_FP_ARGS)
10237     output_asm_insn ("crxor 6,6,6", operands);
10239   else if (INTVAL (operands[2]) & CALL_V4_CLEAR_FP_ARGS)
10240     output_asm_insn ("creqv 6,6,6", operands);
10242   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z0@plt" : "bl %z0";
10244   [(set_attr "type" "branch,branch")
10245    (set_attr "length" "4,8")])
10247 (define_insn "*call_value_indirect_nonlocal_sysv"
10248   [(set (match_operand 0 "" "")
10249         (call (mem:SI (match_operand:SI 1 "register_operand" "cl,cl"))
10250               (match_operand 2 "" "g,g")))
10251    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10252    (clobber (match_scratch:SI 4 "=l,l"))]
10253   "DEFAULT_ABI == ABI_AIX_NODESC
10254    || DEFAULT_ABI == ABI_V4
10255    || DEFAULT_ABI == ABI_DARWIN"
10257   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10258     output_asm_insn ("crxor 6,6,6", operands);
10260   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10261     output_asm_insn ("creqv 6,6,6", operands);
10263   return "b%T1l";
10265   [(set_attr "type" "jmpreg,jmpreg")
10266    (set_attr "length" "4,8")])
10268 (define_insn "*call_value_nonlocal_sysv"
10269   [(set (match_operand 0 "" "")
10270         (call (mem:SI (match_operand:SI 1 "symbol_ref_operand" "s,s"))
10271               (match_operand 2 "" "g,g")))
10272    (use (match_operand:SI 3 "immediate_operand" "O,n"))
10273    (clobber (match_scratch:SI 4 "=l,l"))]
10274   "(DEFAULT_ABI == ABI_AIX_NODESC
10275     || DEFAULT_ABI == ABI_V4
10276     || DEFAULT_ABI == ABI_DARWIN)
10277    && (INTVAL (operands[3]) & CALL_LONG) == 0"
10279   if (INTVAL (operands[3]) & CALL_V4_SET_FP_ARGS)
10280     output_asm_insn ("crxor 6,6,6", operands);
10282   else if (INTVAL (operands[3]) & CALL_V4_CLEAR_FP_ARGS)
10283     output_asm_insn ("creqv 6,6,6", operands);
10285   return (DEFAULT_ABI == ABI_V4 && flag_pic) ? "bl %z1@plt" : "bl %z1";
10287   [(set_attr "type" "branch,branch")
10288    (set_attr "length" "4,8")])
10290 ;; Call subroutine returning any type.
10291 (define_expand "untyped_call"
10292   [(parallel [(call (match_operand 0 "" "")
10293                     (const_int 0))
10294               (match_operand 1 "" "")
10295               (match_operand 2 "" "")])]
10296   ""
10297   "
10299   int i;
10301   emit_call_insn (GEN_CALL (operands[0], const0_rtx, const0_rtx, const0_rtx));
10303   for (i = 0; i < XVECLEN (operands[2], 0); i++)
10304     {
10305       rtx set = XVECEXP (operands[2], 0, i);
10306       emit_move_insn (SET_DEST (set), SET_SRC (set));
10307     }
10309   /* The optimizer does not know that the call sets the function value
10310      registers we stored in the result block.  We avoid problems by
10311      claiming that all hard registers are used and clobbered at this
10312      point.  */
10313   emit_insn (gen_blockage ());
10315   DONE;
10318 ;; UNSPEC_VOLATILE is considered to use and clobber all hard registers and
10319 ;; all of memory.  This blocks insns from being moved across this point.
10321 (define_insn "blockage"
10322   [(unspec_volatile [(const_int 0)] 0)]
10323   ""
10324   "")
10326 ;; Compare insns are next.  Note that the RS/6000 has two types of compares,
10327 ;; signed & unsigned, and one type of branch.
10329 ;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc
10330 ;; insns, and branches.  We store the operands of compares until we see
10331 ;; how it is used.
10332 (define_expand "cmpsi"
10333   [(set (cc0)
10334         (compare (match_operand:SI 0 "gpc_reg_operand" "")
10335                  (match_operand:SI 1 "reg_or_short_operand" "")))]
10336   ""
10337   "
10339   /* Take care of the possibility that operands[1] might be negative but
10340      this might be a logical operation.  That insn doesn't exist.  */
10341   if (GET_CODE (operands[1]) == CONST_INT
10342       && INTVAL (operands[1]) < 0)
10343     operands[1] = force_reg (SImode, operands[1]);
10345   rs6000_compare_op0 = operands[0];
10346   rs6000_compare_op1 = operands[1];
10347   rs6000_compare_fp_p = 0;
10348   DONE;
10351 (define_expand "cmpdi"
10352   [(set (cc0)
10353         (compare (match_operand:DI 0 "gpc_reg_operand" "")
10354                  (match_operand:DI 1 "reg_or_short_operand" "")))]
10355   "TARGET_POWERPC64"
10356   "
10358   /* Take care of the possibility that operands[1] might be negative but
10359      this might be a logical operation.  That insn doesn't exist.  */
10360   if (GET_CODE (operands[1]) == CONST_INT
10361       && INTVAL (operands[1]) < 0)
10362     operands[1] = force_reg (DImode, operands[1]);
10364   rs6000_compare_op0 = operands[0];
10365   rs6000_compare_op1 = operands[1];
10366   rs6000_compare_fp_p = 0;
10367   DONE;
10370 (define_expand "cmpsf"
10371   [(set (cc0) (compare (match_operand:SF 0 "gpc_reg_operand" "")
10372                        (match_operand:SF 1 "gpc_reg_operand" "")))]
10373   "TARGET_HARD_FLOAT"
10374   "
10376   rs6000_compare_op0 = operands[0];
10377   rs6000_compare_op1 = operands[1];
10378   rs6000_compare_fp_p = 1;
10379   DONE;
10382 (define_expand "cmpdf"
10383   [(set (cc0) (compare (match_operand:DF 0 "gpc_reg_operand" "")
10384                        (match_operand:DF 1 "gpc_reg_operand" "")))]
10385   "TARGET_HARD_FLOAT"
10386   "
10388   rs6000_compare_op0 = operands[0];
10389   rs6000_compare_op1 = operands[1];
10390   rs6000_compare_fp_p = 1;
10391   DONE;
10394 (define_expand "cmptf"
10395   [(set (cc0) (compare (match_operand:TF 0 "gpc_reg_operand" "")
10396                        (match_operand:TF 1 "gpc_reg_operand" "")))]
10397   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
10398   "
10400   rs6000_compare_op0 = operands[0];
10401   rs6000_compare_op1 = operands[1];
10402   rs6000_compare_fp_p = 1;
10403   DONE;
10406 (define_expand "beq"
10407   [(use (match_operand 0 "" ""))]
10408   ""
10409   "{ rs6000_emit_cbranch (EQ, operands[0]); DONE; }")
10411 (define_expand "bne"
10412   [(use (match_operand 0 "" ""))]
10413   ""
10414   "{ rs6000_emit_cbranch (NE, operands[0]); DONE; }")
10416 (define_expand "bge"
10417   [(use (match_operand 0 "" ""))]
10418   ""
10419   "{ rs6000_emit_cbranch (GE, operands[0]); DONE; }")
10421 (define_expand "bgt"
10422   [(use (match_operand 0 "" ""))]
10423   ""
10424   "{ rs6000_emit_cbranch (GT, operands[0]); DONE; }")
10426 (define_expand "ble"
10427   [(use (match_operand 0 "" ""))]
10428   ""
10429   "{ rs6000_emit_cbranch (LE, operands[0]); DONE; }")
10431 (define_expand "blt"
10432   [(use (match_operand 0 "" ""))]
10433   ""
10434   "{ rs6000_emit_cbranch (LT, operands[0]); DONE; }")
10436 (define_expand "bgeu"
10437   [(use (match_operand 0 "" ""))]
10438   ""
10439   "{ rs6000_emit_cbranch (GEU, operands[0]); DONE; }")
10441 (define_expand "bgtu"
10442   [(use (match_operand 0 "" ""))]
10443   ""
10444   "{ rs6000_emit_cbranch (GTU, operands[0]); DONE; }")
10446 (define_expand "bleu"
10447   [(use (match_operand 0 "" ""))]
10448   ""
10449   "{ rs6000_emit_cbranch (LEU, operands[0]); DONE; }")
10451 (define_expand "bltu"
10452   [(use (match_operand 0 "" ""))]
10453   ""
10454   "{ rs6000_emit_cbranch (LTU, operands[0]); DONE; }")
10456 (define_expand "bunordered"
10457   [(use (match_operand 0 "" ""))]
10458   ""
10459   "{ rs6000_emit_cbranch (UNORDERED, operands[0]); DONE; }")
10461 (define_expand "bordered"
10462   [(use (match_operand 0 "" ""))]
10463   ""
10464   "{ rs6000_emit_cbranch (ORDERED, operands[0]); DONE; }")
10466 (define_expand "buneq"
10467   [(use (match_operand 0 "" ""))]
10468   ""
10469   "{ rs6000_emit_cbranch (UNEQ, operands[0]); DONE; }")
10471 (define_expand "bunge"
10472   [(use (match_operand 0 "" ""))]
10473   ""
10474   "{ rs6000_emit_cbranch (UNGE, operands[0]); DONE; }")
10476 (define_expand "bungt"
10477   [(use (match_operand 0 "" ""))]
10478   ""
10479   "{ rs6000_emit_cbranch (UNGT, operands[0]); DONE; }")
10481 (define_expand "bunle"
10482   [(use (match_operand 0 "" ""))]
10483   ""
10484   "{ rs6000_emit_cbranch (UNLE, operands[0]); DONE; }")
10486 (define_expand "bunlt"
10487   [(use (match_operand 0 "" ""))]
10488   ""
10489   "{ rs6000_emit_cbranch (UNLT, operands[0]); DONE; }")
10491 (define_expand "bltgt"
10492   [(use (match_operand 0 "" ""))]
10493   ""
10494   "{ rs6000_emit_cbranch (LTGT, operands[0]); DONE; }")
10496 ;; For SNE, we would prefer that the xor/abs sequence be used for integers.
10497 ;; For SEQ, likewise, except that comparisons with zero should be done
10498 ;; with an scc insns.  However, due to the order that combine see the
10499 ;; resulting insns, we must, in fact, allow SEQ for integers.  Fail in
10500 ;; the cases we don't want to handle.
10501 (define_expand "seq"
10502   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10503   ""
10504   "{ rs6000_emit_sCOND (EQ, operands[0]); DONE; }")
10506 (define_expand "sne"
10507   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10508   ""
10509   "
10511   if (! rs6000_compare_fp_p)
10512     FAIL;
10514   rs6000_emit_sCOND (NE, operands[0]); 
10515   DONE;
10518 ;; A > 0 is best done using the portable sequence, so fail in that case.
10519 (define_expand "sgt"
10520   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10521   ""
10522   "
10524   if (! rs6000_compare_fp_p
10525       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10526     FAIL;
10528   rs6000_emit_sCOND (GT, operands[0]); 
10529   DONE;
10532 ;; A < 0 is best done in the portable way for A an integer.
10533 (define_expand "slt"
10534   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10535   ""
10536   "
10538   if (! rs6000_compare_fp_p 
10539       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10540     FAIL;
10542   rs6000_emit_sCOND (LT, operands[0]); 
10543   DONE;
10546 ;; A >= 0 is best done the portable way for A an integer.
10547 (define_expand "sge"
10548   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10549   ""
10550   "
10552   if (! rs6000_compare_fp_p
10553       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10554     FAIL;
10556   rs6000_emit_sCOND (GE, operands[0]);
10557   DONE;
10560 ;; A <= 0 is best done the portable way for A an integer.
10561 (define_expand "sle"
10562   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10563   ""
10564   "
10566   if (! rs6000_compare_fp_p
10567       && (! TARGET_POWER || rs6000_compare_op1 == const0_rtx))
10568     FAIL;
10570   rs6000_emit_sCOND (LE, operands[0]); 
10571   DONE;
10574 (define_expand "sgtu"
10575   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10576   ""
10577   "{ rs6000_emit_sCOND (GTU, operands[0]); DONE; }")
10579 (define_expand "sltu"
10580   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10581   ""
10582   "{ rs6000_emit_sCOND (LTU, operands[0]); DONE; }")
10584 (define_expand "sgeu"
10585   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10586   ""
10587   "{ rs6000_emit_sCOND (GEU, operands[0]); DONE; }")
10589 (define_expand "sleu"
10590   [(clobber (match_operand:SI 0 "gpc_reg_operand" ""))]
10591   ""
10592   "{ rs6000_emit_sCOND (LEU, operands[0]); DONE; }")
10594 ;; Here are the actual compare insns.
10595 (define_insn "*cmpsi_internal1"
10596   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10597         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10598                     (match_operand:SI 2 "reg_or_short_operand" "rI")))]
10599   ""
10600   "{cmp%I2|cmpw%I2} %0,%1,%2"
10601   [(set_attr "type" "compare")])
10603 (define_insn "*cmpdi_internal1"
10604   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
10605         (compare:CC (match_operand:DI 1 "gpc_reg_operand" "r")
10606                     (match_operand:DI 2 "reg_or_short_operand" "rI")))]
10607   "TARGET_POWERPC64"
10608   "cmpd%I2 %0,%1,%2"
10609   [(set_attr "type" "compare")])
10611 ;; If we are comparing a register for equality with a large constant,
10612 ;; we can do this with an XOR followed by a compare.  But we need a scratch
10613 ;; register for the result of the XOR.
10615 (define_split
10616   [(set (match_operand:CC 0 "cc_reg_operand" "")
10617         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10618                     (match_operand:SI 2 "non_short_cint_operand" "")))
10619    (clobber (match_operand:SI 3 "gpc_reg_operand" ""))]
10620   "find_single_use (operands[0], insn, 0)
10621    && (GET_CODE (*find_single_use (operands[0], insn, 0)) == EQ
10622        || GET_CODE (*find_single_use (operands[0], insn, 0)) == NE)"
10623   [(set (match_dup 3) (xor:SI (match_dup 1) (match_dup 4)))
10624    (set (match_dup 0) (compare:CC (match_dup 3) (match_dup 5)))]
10625   "
10627   /* Get the constant we are comparing against, C,  and see what it looks like
10628      sign-extended to 16 bits.  Then see what constant could be XOR'ed
10629      with C to get the sign-extended value.  */
10631   HOST_WIDE_INT c = INTVAL (operands[2]);
10632   HOST_WIDE_INT sextc = ((c & 0xffff) ^ 0x8000) - 0x8000;
10633   HOST_WIDE_INT xorv = c ^ sextc;
10635   operands[4] = GEN_INT (xorv);
10636   operands[5] = GEN_INT (sextc);
10639 (define_insn "*cmpsi_internal2"
10640   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10641         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10642                        (match_operand:SI 2 "reg_or_u_short_operand" "rK")))]
10643   ""
10644   "{cmpl%I2|cmplw%I2} %0,%1,%b2"
10645   [(set_attr "type" "compare")])
10647 (define_insn "*cmpdi_internal2"
10648   [(set (match_operand:CCUNS 0 "cc_reg_operand" "=y")
10649         (compare:CCUNS (match_operand:DI 1 "gpc_reg_operand" "r")
10650                        (match_operand:DI 2 "reg_or_u_short_operand" "rK")))]
10651   ""
10652   "cmpld%I2 %0,%1,%b2"
10653   [(set_attr "type" "compare")])
10655 ;; The following two insns don't exist as single insns, but if we provide
10656 ;; them, we can swap an add and compare, which will enable us to overlap more
10657 ;; of the required delay between a compare and branch.  We generate code for
10658 ;; them by splitting.
10660 (define_insn ""
10661   [(set (match_operand:CC 3 "cc_reg_operand" "=y")
10662         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "r")
10663                     (match_operand:SI 2 "short_cint_operand" "i")))
10664    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10665         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10666   ""
10667   "#"
10668   [(set_attr "length" "8")])
10670 (define_insn ""
10671   [(set (match_operand:CCUNS 3 "cc_reg_operand" "=y")
10672         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "r")
10673                        (match_operand:SI 2 "u_short_cint_operand" "i")))
10674    (set (match_operand:SI 0 "gpc_reg_operand" "=r")
10675         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "i")))]
10676   ""
10677   "#"
10678   [(set_attr "length" "8")])
10680 (define_split
10681   [(set (match_operand:CC 3 "cc_reg_operand" "")
10682         (compare:CC (match_operand:SI 1 "gpc_reg_operand" "")
10683                     (match_operand:SI 2 "short_cint_operand" "")))
10684    (set (match_operand:SI 0 "gpc_reg_operand" "")
10685         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10686   ""
10687   [(set (match_dup 3) (compare:CC (match_dup 1) (match_dup 2)))
10688    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10690 (define_split
10691   [(set (match_operand:CCUNS 3 "cc_reg_operand" "")
10692         (compare:CCUNS (match_operand:SI 1 "gpc_reg_operand" "")
10693                        (match_operand:SI 2 "u_short_cint_operand" "")))
10694    (set (match_operand:SI 0 "gpc_reg_operand" "")
10695         (plus:SI (match_dup 1) (match_operand:SI 4 "short_cint_operand" "")))]
10696   ""
10697   [(set (match_dup 3) (compare:CCUNS (match_dup 1) (match_dup 2)))
10698    (set (match_dup 0) (plus:SI (match_dup 1) (match_dup 4)))])
10700 (define_insn "*cmpsf_internal1"
10701   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10702         (compare:CCFP (match_operand:SF 1 "gpc_reg_operand" "f")
10703                       (match_operand:SF 2 "gpc_reg_operand" "f")))]
10704   "TARGET_HARD_FLOAT"
10705   "fcmpu %0,%1,%2"
10706   [(set_attr "type" "fpcompare")])
10708 (define_insn "*cmpdf_internal1"
10709   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10710         (compare:CCFP (match_operand:DF 1 "gpc_reg_operand" "f")
10711                       (match_operand:DF 2 "gpc_reg_operand" "f")))]
10712   "TARGET_HARD_FLOAT"
10713   "fcmpu %0,%1,%2"
10714   [(set_attr "type" "fpcompare")])
10716 ;; Only need to compare second words if first words equal
10717 (define_insn "*cmptf_internal1"
10718   [(set (match_operand:CCFP 0 "cc_reg_operand" "=y")
10719         (compare:CCFP (match_operand:TF 1 "gpc_reg_operand" "f")
10720                       (match_operand:TF 2 "gpc_reg_operand" "f")))]
10721   "DEFAULT_ABI == ABI_AIX && TARGET_HARD_FLOAT && TARGET_LONG_DOUBLE_128"
10722   "fcmpu %0,%1,%2\;bne %0,$+4\;fcmpu %0,%L1,%L2"
10723   [(set_attr "type" "fpcompare")
10724    (set_attr "length" "12")])
10726 ;; Now we have the scc insns.  We can do some combinations because of the
10727 ;; way the machine works.
10729 ;; Note that this is probably faster if we can put an insn between the
10730 ;; mfcr and rlinm, but this is tricky.  Let's leave it for now.  In most
10731 ;; cases the insns below which don't use an intermediate CR field will
10732 ;; be used instead.
10733 (define_insn ""
10734   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10735         (match_operator:SI 1 "scc_comparison_operator"
10736                            [(match_operand 2 "cc_reg_operand" "y")
10737                             (const_int 0)]))]
10738   ""
10739   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
10740   [(set_attr "type" "cr_logical")
10741    (set_attr "length" "12")])
10743 (define_insn ""
10744   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10745         (match_operator:DI 1 "scc_comparison_operator"
10746                            [(match_operand 2 "cc_reg_operand" "y")
10747                             (const_int 0)]))]
10748   "TARGET_POWERPC64"
10749   "%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%J1,1"
10750   [(set_attr "type" "cr_logical")
10751    (set_attr "length" "12")])
10753 (define_insn ""
10754   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10755         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10756                                        [(match_operand 2 "cc_reg_operand" "y,y")
10757                                         (const_int 0)])
10758                     (const_int 0)))
10759    (set (match_operand:SI 3 "gpc_reg_operand" "=r,r")
10760         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10761   "! TARGET_POWERPC64"
10762   "@
10763    %D1mfcr %3\;{rlinm.|rlwinm.} %3,%3,%J1,1
10764    #"
10765   [(set_attr "type" "delayed_compare")
10766    (set_attr "length" "12,16")])
10768 (define_split
10769   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10770         (compare:CC (match_operator:SI 1 "scc_comparison_operator"
10771                                        [(match_operand 2 "cc_reg_operand" "")
10772                                         (const_int 0)])
10773                     (const_int 0)))
10774    (set (match_operand:SI 3 "gpc_reg_operand" "")
10775         (match_op_dup 1 [(match_dup 2) (const_int 0)]))]
10776   "! TARGET_POWERPC64 && reload_completed"
10777   [(set (match_dup 3)
10778         (match_op_dup 1 [(match_dup 2) (const_int 0)]))
10779    (set (match_dup 0)
10780         (compare:CC (match_dup 3)
10781                     (const_int 0)))]
10782   "")
10784 (define_insn ""
10785   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10786         (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10787                                       [(match_operand 2 "cc_reg_operand" "y")
10788                                        (const_int 0)])
10789                    (match_operand:SI 3 "const_int_operand" "n")))]
10790   ""
10791   "*
10793   int is_bit = ccr_bit (operands[1], 1);
10794   int put_bit = 31 - (INTVAL (operands[3]) & 31);
10795   int count;
10797   if (is_bit >= put_bit)
10798     count = is_bit - put_bit;
10799   else
10800     count = 32 - (put_bit - is_bit);
10802   operands[4] = GEN_INT (count);
10803   operands[5] = GEN_INT (put_bit);
10805   return \"%D1mfcr %0\;{rlinm|rlwinm} %0,%0,%4,%5,%5\";
10807   [(set_attr "type" "cr_logical")
10808    (set_attr "length" "12")])
10810 (define_insn ""
10811   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
10812         (compare:CC
10813          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10814                                        [(match_operand 2 "cc_reg_operand" "y,y")
10815                                         (const_int 0)])
10816                     (match_operand:SI 3 "const_int_operand" "n,n"))
10817          (const_int 0)))
10818    (set (match_operand:SI 4 "gpc_reg_operand" "=r,r")
10819         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10820                    (match_dup 3)))]
10821   "! TARGET_POWERPC64"
10822   "*
10824   int is_bit = ccr_bit (operands[1], 1);
10825   int put_bit = 31 - (INTVAL (operands[3]) & 31);
10826   int count;
10828   /* Force split for non-cc0 compare.  */
10829   if (which_alternative == 1)
10830      return \"#\";
10832   if (is_bit >= put_bit)
10833     count = is_bit - put_bit;
10834   else
10835     count = 32 - (put_bit - is_bit);
10837   operands[5] = GEN_INT (count);
10838   operands[6] = GEN_INT (put_bit);
10840   return \"%D1mfcr %4\;{rlinm.|rlwinm.} %4,%4,%5,%6,%6\";
10842   [(set_attr "type" "delayed_compare")
10843    (set_attr "length" "12,16")])
10845 (define_split
10846   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
10847         (compare:CC
10848          (ashift:SI (match_operator:SI 1 "scc_comparison_operator"
10849                                        [(match_operand 2 "cc_reg_operand" "")
10850                                         (const_int 0)])
10851                     (match_operand:SI 3 "const_int_operand" ""))
10852          (const_int 0)))
10853    (set (match_operand:SI 4 "gpc_reg_operand" "")
10854         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10855                    (match_dup 3)))]
10856   "! TARGET_POWERPC64 && reload_completed"
10857   [(set (match_dup 4)
10858         (ashift:SI (match_op_dup 1 [(match_dup 2) (const_int 0)])
10859                    (match_dup 3)))
10860    (set (match_dup 0)
10861         (compare:CC (match_dup 4)
10862                     (const_int 0)))]
10863   "")
10865 ;; There is a 3 cycle delay between consecutive mfcr instructions
10866 ;; so it is useful to combine 2 scc instructions to use only one mfcr.
10868 (define_peephole
10869   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
10870         (match_operator:SI 1 "scc_comparison_operator"
10871                            [(match_operand 2 "cc_reg_operand" "y")
10872                             (const_int 0)]))
10873    (set (match_operand:SI 3 "gpc_reg_operand" "=r")
10874         (match_operator:SI 4 "scc_comparison_operator"
10875                            [(match_operand 5 "cc_reg_operand" "y")
10876                             (const_int 0)]))]
10877   "REGNO (operands[2]) != REGNO (operands[5])"
10878   "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
10879   [(set_attr "type" "cr_logical")
10880    (set_attr "length" "20")])
10882 (define_peephole
10883   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
10884         (match_operator:DI 1 "scc_comparison_operator"
10885                            [(match_operand 2 "cc_reg_operand" "y")
10886                             (const_int 0)]))
10887    (set (match_operand:DI 3 "gpc_reg_operand" "=r")
10888         (match_operator:DI 4 "scc_comparison_operator"
10889                            [(match_operand 5 "cc_reg_operand" "y")
10890                             (const_int 0)]))]
10891   "TARGET_POWERPC64 && REGNO (operands[2]) != REGNO (operands[5])"
10892   "%D1%D4mfcr %3\;{rlinm|rlwinm} %0,%3,%J1,1\;{rlinm|rlwinm} %3,%3,%J4,1"
10893   [(set_attr "type" "cr_logical")
10894    (set_attr "length" "20")])
10896 ;; There are some scc insns that can be done directly, without a compare.
10897 ;; These are faster because they don't involve the communications between
10898 ;; the FXU and branch units.   In fact, we will be replacing all of the
10899 ;; integer scc insns here or in the portable methods in emit_store_flag.
10901 ;; Also support (neg (scc ..)) since that construct is used to replace
10902 ;; branches, (plus (scc ..) ..) since that construct is common and
10903 ;; takes no more insns than scc, and (and (neg (scc ..)) ..) in the
10904 ;; cases where it is no more expensive than (neg (scc ..)).
10906 ;; Have reload force a constant into a register for the simple insns that
10907 ;; otherwise won't accept constants.  We do this because it is faster than
10908 ;; the cmp/mfcr sequence we would otherwise generate.
10910 (define_insn ""
10911   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
10912         (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
10913                (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I")))
10914    (clobber (match_scratch:SI 3 "=r,&r,r,r,r"))]
10915   "! TARGET_POWERPC64"
10916   "@
10917    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10918    {sfi|subfic} %3,%1,0\;{ae|adde} %0,%3,%1
10919    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10920    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0
10921    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae|adde} %0,%3,%0"
10922   [(set_attr "length" "12,8,12,12,12")])
10924 (define_insn ""
10925   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r")
10926         (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r")
10927                (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I")))
10928    (clobber (match_scratch:DI 3 "=r,&r,r,r,r"))]
10929   "TARGET_POWERPC64"
10930   "@
10931    xor %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0
10932    subfic %3,%1,0\;adde %0,%3,%1
10933    xori %0,%1,%b2\;subfic %3,%0,0\;adde %0,%3,%0
10934    xoris %0,%1,%u2\;subfic %3,%0,0\;adde %0,%3,%0
10935    subfic %0,%1,%2\;subfic %3,%0,0\;adde %0,%3,%0"
10936   [(set_attr "length" "12,8,12,12,12")])
10938 (define_insn ""
10939   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10940         (compare:CC
10941          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10942                 (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
10943          (const_int 0)))
10944    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
10945         (eq:SI (match_dup 1) (match_dup 2)))
10946    (clobber (match_scratch:SI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
10947   "! TARGET_POWERPC64"
10948   "@
10949    xor %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10950    {sfi|subfic} %3,%1,0\;{ae.|adde.} %0,%3,%1
10951    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10952    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10953    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %3,%0,0\;{ae.|adde.} %0,%3,%0
10954    #
10955    #
10956    #
10957    #
10958    #"
10959   [(set_attr "type" "compare")
10960    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
10962 (define_split
10963   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
10964         (compare:CC
10965          (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
10966                 (match_operand:SI 2 "reg_or_cint_operand" ""))
10967          (const_int 0)))
10968    (set (match_operand:SI 0 "gpc_reg_operand" "")
10969         (eq:SI (match_dup 1) (match_dup 2)))
10970    (clobber (match_scratch:SI 3 ""))]
10971   "! TARGET_POWERPC64 && reload_completed"
10972   [(parallel [(set (match_dup 0)
10973         (eq:SI (match_dup 1) (match_dup 2)))
10974    (clobber (match_dup 3))])
10975    (set (match_dup 4)
10976         (compare:CC (match_dup 0)
10977                     (const_int 0)))]
10978   "")
10980 (define_insn ""
10981   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
10982         (compare:CC
10983          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
10984                 (match_operand:DI 2 "reg_or_cint_operand" "r,O,K,J,I,r,O,K,J,I"))
10985          (const_int 0)))
10986    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r,r,r,r,r,r,r")
10987         (eq:DI (match_dup 1) (match_dup 2)))
10988    (clobber (match_scratch:DI 3 "=r,&r,r,r,r,r,&r,r,r,r"))]
10989   "TARGET_POWERPC64"
10990   "@
10991    xor %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
10992    subfic %3,%1,0\;adde. %0,%3,%1
10993    xori %0,%1,%b2\;subfic %3,%0,0\;adde. %0,%3,%0
10994    xoris %0,%1,%u2\;subfic %3,%0,0\;adde. %0,%3,%0
10995    subfic %0,%1,%2\;subfic %3,%0,0\;adde. %0,%3,%0
10996    #
10997    #
10998    #
10999    #
11000    #"
11001   [(set_attr "type" "compare")
11002    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11004 (define_split
11005   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11006         (compare:CC
11007          (eq:DI (match_operand:DI 1 "gpc_reg_operand" "")
11008                 (match_operand:DI 2 "reg_or_cint_operand" ""))
11009          (const_int 0)))
11010    (set (match_operand:DI 0 "gpc_reg_operand" "")
11011         (eq:DI (match_dup 1) (match_dup 2)))
11012    (clobber (match_scratch:DI 3 ""))]
11013   "TARGET_POWERPC64 && reload_completed"
11014   [(parallel [(set (match_dup 0)
11015         (eq:DI (match_dup 1) (match_dup 2)))
11016    (clobber (match_dup 3))])
11017    (set (match_dup 4)
11018         (compare:CC (match_dup 0)
11019                     (const_int 0)))]
11020   "")
11022 ;; We have insns of the form shown by the first define_insn below.  If
11023 ;; there is something inside the comparison operation, we must split it.
11024 (define_split
11025   [(set (match_operand:SI 0 "gpc_reg_operand" "")
11026         (plus:SI (match_operator 1 "comparison_operator"
11027                                  [(match_operand:SI 2 "" "")
11028                                   (match_operand:SI 3
11029                                                     "reg_or_cint_operand" "")])
11030                  (match_operand:SI 4 "gpc_reg_operand" "")))
11031    (clobber (match_operand:SI 5 "register_operand" ""))]
11032   "! gpc_reg_operand (operands[2], SImode)"
11033   [(set (match_dup 5) (match_dup 2))
11034    (set (match_dup 2) (plus:SI (match_op_dup 1 [(match_dup 2) (match_dup 3)])
11035                                (match_dup 4)))])
11037 (define_insn ""
11038   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r")
11039         (plus:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11040                         (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))
11041                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r")))]
11042   "! TARGET_POWERPC64"
11043   "@
11044    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11045    {sfi|subfic} %0,%1,0\;{aze|addze} %0,%3
11046    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11047    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3
11048    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze|addze} %0,%3"
11049   [(set_attr "length" "12,8,12,12,12")])
11051 (define_insn ""
11052   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11053         (compare:CC
11054          (plus:SI
11055           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11056                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11057           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11058          (const_int 0)))
11059    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r"))]
11060   "! TARGET_POWERPC64"
11061   "@
11062    xor %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11063    {sfi|subfic} %4,%1,0\;{aze.|addze.} %4,%3
11064    {xoril|xori} %4,%1,%b2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11065    {xoriu|xoris} %4,%1,%u2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11066    {sfi|subfic} %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11067    #
11068    #
11069    #
11070    #
11071    #"
11072   [(set_attr "type" "compare")
11073    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11075 (define_split
11076   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11077         (compare:CC
11078          (plus:SI
11079           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11080                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11081           (match_operand:SI 3 "gpc_reg_operand" ""))
11082          (const_int 0)))
11083    (clobber (match_scratch:SI 4 ""))]
11084   "! TARGET_POWERPC64 && reload_completed"
11085   [(set (match_dup 4)
11086         (plus:SI (eq:SI (match_dup 1)
11087                  (match_dup 2))
11088           (match_dup 3)))
11089    (set (match_dup 0)
11090         (compare:CC (match_dup 4)
11091                     (const_int 0)))]
11092   "")
11094 (define_insn ""
11095   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,x,x,x,?y,?y,?y,?y,?y")
11096         (compare:CC
11097          (plus:SI
11098           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r,r,r,r,r,r")
11099                  (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I,r,O,K,L,I"))
11100           (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r,r,r,r,r,r,r"))
11101          (const_int 0)))
11102    (set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r,&r,&r,&r,&r,&r,&r,&r,&r")
11103         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11104   "! TARGET_POWERPC64"
11105   "@
11106    xor %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11107    {sfi|subfic} %0,%1,0\;{aze.|addze.} %0,%3
11108    {xoril|xori} %0,%1,%b2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11109    {xoriu|xoris} %0,%1,%u2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11110    {sfi|subfic} %0,%1,%2\;{sfi|subfic} %0,%0,0\;{aze.|addze.} %0,%3
11111    #
11112    #
11113    #
11114    #
11115    #"
11116   [(set_attr "type" "compare")
11117    (set_attr "length" "12,8,12,12,12,16,12,16,16,16")])
11119 (define_split
11120   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11121         (compare:CC
11122          (plus:SI
11123           (eq:SI (match_operand:SI 1 "gpc_reg_operand" "")
11124                  (match_operand:SI 2 "reg_or_cint_operand" ""))
11125           (match_operand:SI 3 "gpc_reg_operand" ""))
11126          (const_int 0)))
11127    (set (match_operand:SI 0 "gpc_reg_operand" "")
11128         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))]
11129   "! TARGET_POWERPC64 && reload_completed"
11130   [(set (match_dup 0)
11131         (plus:SI (eq:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11132    (set (match_dup 4)
11133         (compare:CC (match_dup 0)
11134                     (const_int 0)))]
11135   "")
11137 (define_insn ""
11138   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r,r")
11139         (neg:SI (eq:SI (match_operand:SI 1 "gpc_reg_operand" "%r,r,r,r,r")
11140                        (match_operand:SI 2 "reg_or_cint_operand" "r,O,K,L,I"))))]
11141   "! TARGET_POWERPC64"
11142   "@
11143    xor %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11144    {ai|addic} %0,%1,-1\;{sfe|subfe} %0,%0,%0
11145    {xoril|xori} %0,%1,%b2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11146    {xoriu|xoris} %0,%1,%u2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11147    {sfi|subfic} %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
11148    [(set_attr "length" "12,8,12,12,12")])
11150 ;; Simplify (ne X (const_int 0)) on the PowerPC.  No need to on the Power,
11151 ;; since it nabs/sr is just as fast.
11152 (define_insn "*ne0"
11153   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11154         (lshiftrt:SI (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11155                      (const_int 31)))
11156    (clobber (match_scratch:SI 2 "=&r"))]
11157   "! TARGET_POWER && ! TARGET_POWERPC64"
11158   "{ai|addic} %2,%1,-1\;{sfe|subfe} %0,%2,%1"
11159   [(set_attr "length" "8")])
11161 (define_insn ""
11162   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11163         (lshiftrt:DI (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11164                      (const_int 63)))
11165    (clobber (match_scratch:DI 2 "=&r"))]
11166   "TARGET_POWERPC64"
11167   "addic %2,%1,-1\;subfe %0,%2,%1"
11168   [(set_attr "length" "8")])
11170 ;; This is what (plus (ne X (const_int 0)) Y) looks like.
11171 (define_insn ""
11172   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11173         (plus:SI (lshiftrt:SI
11174                   (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r")))
11175                   (const_int 31))
11176                  (match_operand:SI 2 "gpc_reg_operand" "r")))
11177    (clobber (match_scratch:SI 3 "=&r"))]
11178   "! TARGET_POWERPC64"
11179   "{ai|addic} %3,%1,-1\;{aze|addze} %0,%2"
11180   [(set_attr "length" "8")])
11182 (define_insn ""
11183   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11184         (plus:DI (lshiftrt:DI
11185                   (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r")))
11186                   (const_int 63))
11187                  (match_operand:DI 2 "gpc_reg_operand" "r")))
11188    (clobber (match_scratch:DI 3 "=&r"))]
11189   "TARGET_POWERPC64"
11190   "addic %3,%1,-1\;addze %0,%2"
11191   [(set_attr "length" "8")])
11193 (define_insn ""
11194   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11195         (compare:CC
11196          (plus:SI (lshiftrt:SI
11197                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11198                    (const_int 31))
11199                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11200          (const_int 0)))
11201    (clobber (match_scratch:SI 3 "=&r,&r"))
11202    (clobber (match_scratch:SI 4 "=X,&r"))]
11203   "! TARGET_POWERPC64"
11204   "@
11205    {ai|addic} %3,%1,-1\;{aze.|addze.} %3,%2
11206    #"
11207   [(set_attr "type" "compare")
11208    (set_attr "length" "8,12")])
11210 (define_split
11211   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11212         (compare:CC
11213          (plus:SI (lshiftrt:SI
11214                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11215                    (const_int 31))
11216                   (match_operand:SI 2 "gpc_reg_operand" ""))
11217          (const_int 0)))
11218    (clobber (match_scratch:SI 3 ""))
11219    (clobber (match_scratch:SI 4 ""))]
11220   "! TARGET_POWERPC64 && reload_completed"
11221   [(parallel [(set (match_dup 3)
11222                   (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1)))
11223                                         (const_int 31))
11224                            (match_dup 2)))
11225               (clobber (match_dup 4))])
11226    (set (match_dup 0)
11227         (compare:CC (match_dup 3)
11228                     (const_int 0)))]
11229   "")
11231 (define_insn ""
11232   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11233         (compare:CC
11234          (plus:DI (lshiftrt:DI
11235                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11236                    (const_int 63))
11237                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11238          (const_int 0)))
11239    (clobber (match_scratch:DI 3 "=&r,&r"))]
11240   "TARGET_POWERPC64"
11241   "@
11242    addic %3,%1,-1\;addze. %3,%2
11243    #"
11244   [(set_attr "type" "compare")
11245    (set_attr "length" "8,12")])
11247 (define_split
11248   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11249         (compare:CC
11250          (plus:DI (lshiftrt:DI
11251                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11252                    (const_int 63))
11253                   (match_operand:DI 2 "gpc_reg_operand" ""))
11254          (const_int 0)))
11255    (clobber (match_scratch:DI 3 ""))]
11256   "TARGET_POWERPC64 && reload_completed"
11257   [(set (match_dup 3)
11258         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1)))
11259                    (const_int 63))
11260                   (match_dup 2)))
11261    (set (match_dup 0)
11262         (compare:CC (match_dup 3)
11263                     (const_int 0)))]
11264   "")
11266 (define_insn ""
11267   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11268         (compare:CC
11269          (plus:SI (lshiftrt:SI
11270                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")))
11271                    (const_int 31))
11272                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
11273          (const_int 0)))
11274    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11275         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11276                  (match_dup 2)))
11277    (clobber (match_scratch:SI 3 "=&r,&r"))]
11278   "! TARGET_POWERPC64"
11279   "@
11280    {ai|addic} %3,%1,-1\;{aze.|addze.} %0,%2
11281    #"
11282   [(set_attr "type" "compare")
11283    (set_attr "length" "8,12")])
11285 (define_split
11286   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11287         (compare:CC
11288          (plus:SI (lshiftrt:SI
11289                    (neg:SI (abs:SI (match_operand:SI 1 "gpc_reg_operand" "")))
11290                    (const_int 31))
11291                   (match_operand:SI 2 "gpc_reg_operand" ""))
11292          (const_int 0)))
11293    (set (match_operand:SI 0 "gpc_reg_operand" "")
11294         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11295                  (match_dup 2)))
11296    (clobber (match_scratch:SI 3 ""))]
11297   "! TARGET_POWERPC64 && reload_completed"
11298   [(parallel [(set (match_dup 0)
11299         (plus:SI (lshiftrt:SI (neg:SI (abs:SI (match_dup 1))) (const_int 31))
11300                  (match_dup 2)))
11301    (clobber (match_dup 3))])
11302    (set (match_dup 4)
11303         (compare:CC (match_dup 0)
11304                     (const_int 0)))]
11305   "")
11307 (define_insn ""
11308   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
11309         (compare:CC
11310          (plus:DI (lshiftrt:DI
11311                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")))
11312                    (const_int 63))
11313                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
11314          (const_int 0)))
11315    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11316         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11317                  (match_dup 2)))
11318    (clobber (match_scratch:DI 3 "=&r,&r"))]
11319   "TARGET_POWERPC64"
11320   "@
11321    addic %3,%1,-1\;addze. %0,%2
11322    #"
11323   [(set_attr "type" "compare")
11324    (set_attr "length" "8,12")])
11326 (define_split
11327   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11328         (compare:CC
11329          (plus:DI (lshiftrt:DI
11330                    (neg:DI (abs:DI (match_operand:DI 1 "gpc_reg_operand" "")))
11331                    (const_int 63))
11332                   (match_operand:DI 2 "gpc_reg_operand" ""))
11333          (const_int 0)))
11334    (set (match_operand:DI 0 "gpc_reg_operand" "")
11335         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11336                  (match_dup 2)))
11337    (clobber (match_scratch:DI 3 ""))]
11338   "TARGET_POWERPC64 && reload_completed"
11339   [(parallel [(set (match_dup 0)
11340         (plus:DI (lshiftrt:DI (neg:DI (abs:DI (match_dup 1))) (const_int 63))
11341                  (match_dup 2)))
11342    (clobber (match_dup 3))])
11343    (set (match_dup 4)
11344         (compare:CC (match_dup 0)
11345                     (const_int 0)))]
11346   "")
11348 (define_insn ""
11349   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11350         (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11351                (match_operand:SI 2 "reg_or_short_operand" "r,O")))
11352    (clobber (match_scratch:SI 3 "=r,X"))]
11353   "TARGET_POWER"
11354   "@
11355    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3
11356    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri|srwi} %0,%0,31"
11357   [(set_attr "length" "12")])
11359 (define_insn ""
11360   [(set (match_operand:CC 4 "cc_reg_operand" "=x,x,?y,?y")
11361         (compare:CC
11362          (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11363                 (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11364          (const_int 0)))
11365    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11366         (le:SI (match_dup 1) (match_dup 2)))
11367    (clobber (match_scratch:SI 3 "=r,X,r,X"))]
11368   "TARGET_POWER"
11369   "@
11370    doz %3,%2,%1\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
11371    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{sri.|srwi.} %0,%0,31
11372    #
11373    #"
11374   [(set_attr "type" "compare,delayed_compare,compare,delayed_compare")
11375    (set_attr "length" "12,12,16,16")])
11377 (define_split
11378   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
11379         (compare:CC
11380          (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11381                 (match_operand:SI 2 "reg_or_short_operand" ""))
11382          (const_int 0)))
11383    (set (match_operand:SI 0 "gpc_reg_operand" "")
11384         (le:SI (match_dup 1) (match_dup 2)))
11385    (clobber (match_scratch:SI 3 ""))]
11386   "TARGET_POWER && reload_completed"
11387   [(parallel [(set (match_dup 0)
11388         (le:SI (match_dup 1) (match_dup 2)))
11389    (clobber (match_dup 3))])
11390    (set (match_dup 4)
11391         (compare:CC (match_dup 0)
11392                     (const_int 0)))]
11393   "")
11395 (define_insn ""
11396   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11397         (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11398                         (match_operand:SI 2 "reg_or_short_operand" "r,O"))
11399                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))
11400    (clobber (match_scratch:SI 4 "=&r,&r"))]
11401   "TARGET_POWER"
11402   "@
11403    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3
11404    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze|addze} %0,%3"
11405   [(set_attr "length" "12")])
11407 (define_insn ""
11408   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11409         (compare:CC
11410          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11411                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11412                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11413          (const_int 0)))
11414    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11415   "TARGET_POWER"
11416   "@
11417    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
11418    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %4,%3
11419    #
11420    #"
11421   [(set_attr "type" "compare")
11422    (set_attr "length" "12,12,16,16")])
11424 (define_split
11425   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11426         (compare:CC
11427          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11428                          (match_operand:SI 2 "reg_or_short_operand" ""))
11429                   (match_operand:SI 3 "gpc_reg_operand" ""))
11430          (const_int 0)))
11431    (clobber (match_scratch:SI 4 ""))]
11432   "TARGET_POWER && reload_completed"
11433   [(set (match_dup 4)
11434         (plus:SI (le:SI (match_dup 1) (match_dup 2))
11435                   (match_dup 3)))
11436    (set (match_dup 0)
11437         (compare:CC (match_dup 4)
11438                     (const_int 0)))]
11439   "")
11441 (define_insn ""
11442   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
11443         (compare:CC
11444          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11445                          (match_operand:SI 2 "reg_or_short_operand" "r,O,r,O"))
11446                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11447          (const_int 0)))
11448    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11449         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11450    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11451   "TARGET_POWER"
11452   "@
11453    doz %4,%2,%1\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
11454    {srai|srawi} %4,%1,31\;{sf|subfc} %4,%1,%4\;{aze.|addze.} %0,%3
11455    #
11456    #"
11457   [(set_attr "type" "compare")
11458    (set_attr "length" "12,12,16,16")])
11460 (define_split
11461   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11462         (compare:CC
11463          (plus:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "")
11464                          (match_operand:SI 2 "reg_or_short_operand" ""))
11465                   (match_operand:SI 3 "gpc_reg_operand" ""))
11466          (const_int 0)))
11467    (set (match_operand:SI 0 "gpc_reg_operand" "")
11468         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11469    (clobber (match_scratch:SI 4 ""))]
11470   "TARGET_POWER && reload_completed"
11471   [(parallel [(set (match_dup 0)
11472         (plus:SI (le:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11473    (clobber (match_dup 4))])
11474    (set (match_dup 5)
11475         (compare:CC (match_dup 0)
11476                     (const_int 0)))]
11477   "")
11479 (define_insn ""
11480   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11481         (neg:SI (le:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11482                        (match_operand:SI 2 "reg_or_short_operand" "r,O"))))]
11483   "TARGET_POWER"
11484   "@
11485    doz %0,%2,%1\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0
11486    {ai|addic} %0,%1,-1\;{aze|addze} %0,%0\;{srai|srawi} %0,%0,31"
11487   [(set_attr "length" "12")])
11489 (define_insn ""
11490   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11491         (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11492                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11493   "! TARGET_POWERPC64"
11494   "{sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
11495   [(set_attr "length" "12")])
11497 (define_insn ""
11498   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
11499         (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
11500                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
11501   "TARGET_POWERPC64"
11502   "subf%I2c %0,%1,%2\;li %0,0\;adde %0,%0,%0"
11503   [(set_attr "length" "12")])
11505 (define_insn ""
11506   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11507         (compare:CC
11508          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11509                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11510          (const_int 0)))
11511    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11512         (leu:DI (match_dup 1) (match_dup 2)))]
11513   "TARGET_POWERPC64"
11514   "@
11515    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11516    #"
11517   [(set_attr "type" "compare")
11518    (set_attr "length" "12,16")])
11520 (define_split
11521   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11522         (compare:CC
11523          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "")
11524                  (match_operand:DI 2 "reg_or_short_operand" ""))
11525          (const_int 0)))
11526    (set (match_operand:DI 0 "gpc_reg_operand" "")
11527         (leu:DI (match_dup 1) (match_dup 2)))]
11528   "TARGET_POWERPC64 && reload_completed"
11529   [(set (match_dup 0)
11530         (leu:DI (match_dup 1) (match_dup 2)))
11531    (set (match_dup 3)
11532         (compare:CC (match_dup 0)
11533                     (const_int 0)))]
11534   "")
11536 (define_insn ""
11537   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11538         (compare:CC
11539          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11540                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11541          (const_int 0)))
11542    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11543         (leu:SI (match_dup 1) (match_dup 2)))]
11544   "! TARGET_POWERPC64"
11545   "@
11546    {sf%I2|subf%I2c} %0,%1,%2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
11547    #"
11548   [(set_attr "type" "compare")
11549    (set_attr "length" "12,16")])
11551 (define_split
11552   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11553         (compare:CC
11554          (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11555                  (match_operand:SI 2 "reg_or_short_operand" ""))
11556          (const_int 0)))
11557    (set (match_operand:SI 0 "gpc_reg_operand" "")
11558         (leu:SI (match_dup 1) (match_dup 2)))]
11559   "! TARGET_POWERPC64 && reload_completed"
11560   [(set (match_dup 0)
11561         (leu:SI (match_dup 1) (match_dup 2)))
11562    (set (match_dup 3)
11563         (compare:CC (match_dup 0)
11564                     (const_int 0)))]
11565   "")
11567 (define_insn ""
11568   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11569         (compare:CC
11570          (leu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
11571                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
11572          (const_int 0)))
11573    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
11574         (leu:DI (match_dup 1) (match_dup 2)))]
11575   "TARGET_POWERPC64"
11576   "@
11577    subf%I2c %0,%1,%2\;li %0,0\;adde. %0,%0,%0
11578    #"
11579   [(set_attr "type" "compare")
11580    (set_attr "length" "12,16")])
11582 (define_insn ""
11583   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
11584         (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11585                          (match_operand:SI 2 "reg_or_short_operand" "rI"))
11586                  (match_operand:SI 3 "gpc_reg_operand" "r")))]
11587   "! TARGET_POWERPC64"
11588   "{sf%I2|subf%I2c} %0,%1,%2\;{aze|addze} %0,%3"
11589   [(set_attr "length" "8")])
11591 (define_insn ""
11592   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11593         (compare:CC
11594          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11595                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11596                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11597          (const_int 0)))
11598    (clobber (match_scratch:SI 4 "=&r,&r"))]
11599   "! TARGET_POWERPC64"
11600   "@
11601    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %4,%3
11602    #"
11603   [(set_attr "type" "compare")
11604    (set_attr "length" "8,12")])
11606 (define_split
11607   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11608         (compare:CC
11609          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11610                           (match_operand:SI 2 "reg_or_short_operand" ""))
11611                   (match_operand:SI 3 "gpc_reg_operand" ""))
11612          (const_int 0)))
11613    (clobber (match_scratch:SI 4 ""))]
11614   "! TARGET_POWERPC64 && reload_completed"
11615   [(set (match_dup 4)
11616         (plus:SI (leu:SI (match_dup 1) (match_dup 2))
11617                   (match_dup 3)))
11618    (set (match_dup 0)
11619         (compare:CC (match_dup 4)
11620                     (const_int 0)))]
11621   "")
11623 (define_insn ""
11624   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11625         (compare:CC
11626          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11627                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11628                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11629          (const_int 0)))
11630    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11631         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11632    (clobber (match_scratch:SI 4 "=&r,&r"))]
11633   "! TARGET_POWERPC64"
11634   "@
11635    {sf%I2|subf%I2c} %4,%1,%2\;{aze.|addze.} %0,%3
11636    #"
11637   [(set_attr "type" "compare")
11638    (set_attr "length" "8,12")])
11640 (define_split
11641   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11642         (compare:CC
11643          (plus:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11644                           (match_operand:SI 2 "reg_or_short_operand" ""))
11645                   (match_operand:SI 3 "gpc_reg_operand" ""))
11646          (const_int 0)))
11647    (set (match_operand:SI 0 "gpc_reg_operand" "")
11648         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11649    (clobber (match_scratch:SI 4 ""))]
11650   "! TARGET_POWERPC64 && reload_completed"
11651   [(parallel [(set (match_dup 0)
11652         (plus:SI (leu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11653    (clobber (match_dup 4))])
11654    (set (match_dup 5)
11655         (compare:CC (match_dup 0)
11656                     (const_int 0)))]
11657   "")
11659 (define_insn ""
11660   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11661         (neg:SI (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11662                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
11663   "! TARGET_POWERPC64"
11664   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0"
11665    [(set_attr "length" "12")])
11667 (define_insn ""
11668   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11669         (and:SI (neg:SI
11670                  (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11671                          (match_operand:SI 2 "reg_or_short_operand" "rI")))
11672                 (match_operand:SI 3 "gpc_reg_operand" "r")))
11673    (clobber (match_scratch:SI 4 "=&r"))]
11674   "! TARGET_POWERPC64"
11675   "{sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
11676   [(set_attr "length" "12")])
11678 (define_insn ""
11679   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11680         (compare:CC
11681          (and:SI (neg:SI
11682                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11683                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11684                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11685          (const_int 0)))
11686    (clobber (match_scratch:SI 4 "=&r,&r"))]
11687   "! TARGET_POWERPC64"
11688   "@
11689    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
11690    #"
11691   [(set_attr "type" "compare")
11692    (set_attr "length" "12,16")])
11694 (define_split
11695   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11696         (compare:CC
11697          (and:SI (neg:SI
11698                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11699                           (match_operand:SI 2 "reg_or_short_operand" "")))
11700                  (match_operand:SI 3 "gpc_reg_operand" ""))
11701          (const_int 0)))
11702    (clobber (match_scratch:SI 4 ""))]
11703   "! TARGET_POWERPC64 && reload_completed"
11704   [(set (match_dup 4)
11705         (and:SI (neg:SI (leu:SI (match_dup 1)
11706                           (match_dup 2)))
11707                  (match_dup 3)))
11708    (set (match_dup 0)
11709         (compare:CC (match_dup 4)
11710                     (const_int 0)))]
11711   "")
11713 (define_insn ""
11714   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11715         (compare:CC
11716          (and:SI (neg:SI
11717                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11718                           (match_operand:SI 2 "reg_or_short_operand" "rI,rI")))
11719                  (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11720          (const_int 0)))
11721    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11722         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11723    (clobber (match_scratch:SI 4 "=&r,&r"))]
11724   "! TARGET_POWERPC64"
11725   "@
11726    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
11727    #"
11728   [(set_attr "type" "compare")
11729    (set_attr "length" "12,16")])
11731 (define_split
11732   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11733         (compare:CC
11734          (and:SI (neg:SI
11735                   (leu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11736                           (match_operand:SI 2 "reg_or_short_operand" "")))
11737                  (match_operand:SI 3 "gpc_reg_operand" ""))
11738          (const_int 0)))
11739    (set (match_operand:SI 0 "gpc_reg_operand" "")
11740         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11741    (clobber (match_scratch:SI 4 ""))]
11742   "! TARGET_POWERPC64 && reload_completed"
11743   [(parallel [(set (match_dup 0)
11744         (and:SI (neg:SI (leu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
11745    (clobber (match_dup 4))])
11746    (set (match_dup 5)
11747         (compare:CC (match_dup 0)
11748                     (const_int 0)))]
11749   "")
11751 (define_insn ""
11752   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11753         (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11754                (match_operand:SI 2 "reg_or_short_operand" "rI")))]
11755   "TARGET_POWER"
11756   "doz%I2 %0,%1,%2\;nabs %0,%0\;{sri|srwi} %0,%0,31"
11757    [(set_attr "length" "12")])
11759 (define_insn ""
11760   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
11761         (compare:CC
11762          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11763                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11764          (const_int 0)))
11765    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11766         (lt:SI (match_dup 1) (match_dup 2)))]
11767   "TARGET_POWER"
11768   "@
11769    doz%I2 %0,%1,%2\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
11770    #"
11771   [(set_attr "type" "delayed_compare")
11772    (set_attr "length" "12,16")])
11774 (define_split
11775   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11776         (compare:CC
11777          (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11778                 (match_operand:SI 2 "reg_or_short_operand" ""))
11779          (const_int 0)))
11780    (set (match_operand:SI 0 "gpc_reg_operand" "")
11781         (lt:SI (match_dup 1) (match_dup 2)))]
11782   "TARGET_POWER && reload_completed"
11783   [(set (match_dup 0)
11784         (lt:SI (match_dup 1) (match_dup 2)))
11785    (set (match_dup 3)
11786         (compare:CC (match_dup 0)
11787                     (const_int 0)))]
11788   "")
11790 (define_insn ""
11791   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11792         (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11793                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
11794                  (match_operand:SI 3 "gpc_reg_operand" "r")))
11795    (clobber (match_scratch:SI 4 "=&r"))]
11796   "TARGET_POWER"
11797   "doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
11798   [(set_attr "length" "12")])
11800 (define_insn ""
11801   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
11802         (compare:CC
11803          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11804                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11805                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11806          (const_int 0)))
11807    (clobber (match_scratch:SI 4 "=&r,&r"))]
11808   "TARGET_POWER"
11809   "@
11810    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
11811    #"
11812   [(set_attr "type" "compare")
11813    (set_attr "length" "12,16")])
11815 (define_split
11816   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11817         (compare:CC
11818          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11819                          (match_operand:SI 2 "reg_or_short_operand" ""))
11820                   (match_operand:SI 3 "gpc_reg_operand" ""))
11821          (const_int 0)))
11822    (clobber (match_scratch:SI 4 ""))]
11823   "TARGET_POWER && reload_completed"
11824   [(set (match_dup 4)
11825         (plus:SI (lt:SI (match_dup 1) (match_dup 2))
11826                   (match_dup 3)))
11827    (set (match_dup 0)
11828         (compare:CC (match_dup 4)
11829                     (const_int 0)))]
11830   "")
11832 (define_insn ""
11833   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
11834         (compare:CC
11835          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11836                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
11837                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
11838          (const_int 0)))
11839    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11840         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11841    (clobber (match_scratch:SI 4 "=&r,&r"))]
11842   "TARGET_POWER"
11843   "@
11844    doz%I2 %4,%1,%2\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3
11845    #"
11846   [(set_attr "type" "compare")
11847    (set_attr "length" "12,16")])
11849 (define_split
11850   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11851         (compare:CC
11852          (plus:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "")
11853                          (match_operand:SI 2 "reg_or_short_operand" ""))
11854                   (match_operand:SI 3 "gpc_reg_operand" ""))
11855          (const_int 0)))
11856    (set (match_operand:SI 0 "gpc_reg_operand" "")
11857         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11858    (clobber (match_scratch:SI 4 ""))]
11859   "TARGET_POWER && reload_completed"
11860   [(parallel [(set (match_dup 0)
11861         (plus:SI (lt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11862    (clobber (match_dup 4))])
11863    (set (match_dup 5)
11864         (compare:CC (match_dup 0)
11865                     (const_int 0)))]
11866   "")
11868 (define_insn ""
11869   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
11870         (neg:SI (lt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
11871                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
11872   "TARGET_POWER"
11873   "doz%I2 %0,%1,%2\;nabs %0,%0\;{srai|srawi} %0,%0,31"
11874   [(set_attr "length" "12")])
11876 (define_insn ""
11877   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
11878         (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11879                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
11880   "! TARGET_POWERPC64"
11881   "@
11882    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg %0,%0
11883    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
11884   [(set_attr "length" "12")])
11886 (define_insn ""
11887   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
11888         (compare:CC
11889          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11890                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11891          (const_int 0)))
11892    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11893         (ltu:SI (match_dup 1) (match_dup 2)))]
11894   "! TARGET_POWERPC64"
11895   "@
11896    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
11897    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
11898    #
11899    #"
11900   [(set_attr "type" "compare")
11901    (set_attr "length" "12,12,16,16")])
11903 (define_split
11904   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
11905         (compare:CC
11906          (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11907                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11908          (const_int 0)))
11909    (set (match_operand:SI 0 "gpc_reg_operand" "")
11910         (ltu:SI (match_dup 1) (match_dup 2)))]
11911   "! TARGET_POWERPC64 && reload_completed"
11912   [(set (match_dup 0)
11913         (ltu:SI (match_dup 1) (match_dup 2)))
11914    (set (match_dup 3)
11915         (compare:CC (match_dup 0)
11916                     (const_int 0)))]
11917   "")
11919 (define_insn ""
11920   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
11921         (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
11922                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
11923                  (match_operand:SI 3 "reg_or_short_operand" "rI,rI")))]
11924   "! TARGET_POWERPC64"
11925   "@
11926   {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3
11927   {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
11928  [(set_attr "length" "12")])
11930 (define_insn ""
11931   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
11932         (compare:CC
11933          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11934                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11935                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11936          (const_int 0)))
11937    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11938   "! TARGET_POWERPC64"
11939   "@
11940    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
11941    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
11942    #
11943    #"
11944   [(set_attr "type" "compare")
11945    (set_attr "length" "12,12,16,16")])
11947 (define_split
11948   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
11949         (compare:CC
11950          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11951                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11952                   (match_operand:SI 3 "gpc_reg_operand" ""))
11953          (const_int 0)))
11954    (clobber (match_scratch:SI 4 ""))]
11955   "! TARGET_POWERPC64 && reload_completed"
11956   [(set (match_dup 4)
11957         (plus:SI (ltu:SI (match_dup 1) (match_dup 2))
11958                   (match_dup 3)))
11959    (set (match_dup 0)
11960         (compare:CC (match_dup 4)
11961                     (const_int 0)))]
11962   "")
11964 (define_insn ""
11965   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
11966         (compare:CC
11967          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
11968                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
11969                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
11970          (const_int 0)))
11971    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
11972         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11973    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
11974   "! TARGET_POWERPC64"
11975   "@
11976    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
11977    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
11978    #
11979    #"
11980   [(set_attr "type" "compare")
11981    (set_attr "length" "12,12,16,16")])
11983 (define_split
11984   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
11985         (compare:CC
11986          (plus:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "")
11987                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
11988                   (match_operand:SI 3 "gpc_reg_operand" ""))
11989          (const_int 0)))
11990    (set (match_operand:SI 0 "gpc_reg_operand" "")
11991         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11992    (clobber (match_scratch:SI 4 ""))]
11993   "! TARGET_POWERPC64 && reload_completed"
11994   [(parallel [(set (match_dup 0)
11995         (plus:SI (ltu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
11996    (clobber (match_dup 4))])
11997    (set (match_dup 5)
11998         (compare:CC (match_dup 0)
11999                     (const_int 0)))]
12000   "")
12002 (define_insn ""
12003   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12004         (neg:SI (ltu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12005                         (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))))]
12006   "! TARGET_POWERPC64"
12007   "@
12008    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0
12009    {ai|addic} %0,%1,%n2\;{sfe|subfe} %0,%0,%0"
12010   [(set_attr "length" "8")])
12012 (define_insn ""
12013   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12014         (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12015                (match_operand:SI 2 "reg_or_short_operand" "rI")))
12016    (clobber (match_scratch:SI 3 "=r"))]
12017   "TARGET_POWER"
12018   "doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae|adde} %0,%0,%3"
12019    [(set_attr "length" "12")])
12021 (define_insn ""
12022   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12023         (compare:CC
12024          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12025                 (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12026          (const_int 0)))
12027    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12028         (ge:SI (match_dup 1) (match_dup 2)))
12029    (clobber (match_scratch:SI 3 "=r,r"))]
12030   "TARGET_POWER"
12031   "@
12032    doz%I2 %3,%1,%2\;{sfi|subfic} %0,%3,0\;{ae.|adde.} %0,%0,%3
12033    #"
12034   [(set_attr "type" "compare")
12035    (set_attr "length" "12,16")])
12037 (define_split
12038   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12039         (compare:CC
12040          (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12041                 (match_operand:SI 2 "reg_or_short_operand" ""))
12042          (const_int 0)))
12043    (set (match_operand:SI 0 "gpc_reg_operand" "")
12044         (ge:SI (match_dup 1) (match_dup 2)))
12045    (clobber (match_scratch:SI 3 ""))]
12046   "TARGET_POWER && reload_completed"
12047   [(parallel [(set (match_dup 0)
12048         (ge:SI (match_dup 1) (match_dup 2)))
12049    (clobber (match_dup 3))])
12050    (set (match_dup 4)
12051         (compare:CC (match_dup 0)
12052                     (const_int 0)))]
12053   "")
12055 (define_insn ""
12056   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12057         (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12058                         (match_operand:SI 2 "reg_or_short_operand" "rI"))
12059                  (match_operand:SI 3 "gpc_reg_operand" "r")))
12060    (clobber (match_scratch:SI 4 "=&r"))]
12061   "TARGET_POWER"
12062   "doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze|addze} %0,%3"
12063   [(set_attr "length" "12")])
12065 (define_insn ""
12066   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12067         (compare:CC
12068          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12069                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12070                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12071          (const_int 0)))
12072    (clobber (match_scratch:SI 4 "=&r,&r"))]
12073   "TARGET_POWER"
12074   "@
12075    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %4,%3
12076    #"
12077   [(set_attr "type" "compare")
12078    (set_attr "length" "12,16")])
12080 (define_split
12081   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12082         (compare:CC
12083          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12084                          (match_operand:SI 2 "reg_or_short_operand" ""))
12085                   (match_operand:SI 3 "gpc_reg_operand" ""))
12086          (const_int 0)))
12087    (clobber (match_scratch:SI 4 ""))]
12088   "TARGET_POWER && reload_completed"
12089   [(set (match_dup 4)
12090         (plus:SI (ge:SI (match_dup 1) (match_dup 2))
12091                   (match_dup 3)))
12092    (set (match_dup 0)
12093         (compare:CC (match_dup 4)
12094                     (const_int 0)))]
12095   "")
12097 (define_insn ""
12098   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
12099         (compare:CC
12100          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12101                          (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12102                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12103          (const_int 0)))
12104    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12105         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12106    (clobber (match_scratch:SI 4 "=&r,&r"))]
12107   "TARGET_POWER"
12108   "@
12109    doz%I2 %4,%1,%2\;{sfi|subfic} %4,%4,0\;{aze.|addze.} %0,%3
12110    #"
12111   [(set_attr "type" "compare")
12112    (set_attr "length" "12,16")])
12114 (define_split
12115   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12116         (compare:CC
12117          (plus:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "")
12118                          (match_operand:SI 2 "reg_or_short_operand" ""))
12119                   (match_operand:SI 3 "gpc_reg_operand" ""))
12120          (const_int 0)))
12121    (set (match_operand:SI 0 "gpc_reg_operand" "")
12122         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12123    (clobber (match_scratch:SI 4 ""))]
12124   "TARGET_POWER && reload_completed"
12125   [(parallel [(set (match_dup 0)
12126         (plus:SI (ge:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12127    (clobber (match_dup 4))])
12128    (set (match_dup 5)
12129         (compare:CC (match_dup 0)
12130                     (const_int 0)))]
12131   "")
12133 (define_insn ""
12134   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12135         (neg:SI (ge:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12136                        (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
12137   "TARGET_POWER"
12138   "doz%I2 %0,%1,%2\;{ai|addic} %0,%0,-1\;{sfe|subfe} %0,%0,%0"
12139   [(set_attr "length" "12")])
12141 (define_insn ""
12142   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12143         (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12144                 (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))]
12145   "! TARGET_POWERPC64"
12146   "@
12147    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0
12148    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae|adde} %0,%0,%0"
12149   [(set_attr "length" "12")])
12151 (define_insn ""
12152   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12153         (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12154                 (match_operand:DI 2 "reg_or_neg_short_operand" "r,P")))]
12155   "TARGET_POWERPC64"
12156   "@
12157    subfc %0,%2,%1\;li %0,0\;adde %0,%0,%0
12158    addic %0,%1,%n2\;li %0,0\;adde %0,%0,%0"
12159   [(set_attr "length" "12")])
12161 (define_insn ""
12162   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12163         (compare:CC
12164          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12165                  (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12166          (const_int 0)))
12167    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12168         (geu:SI (match_dup 1) (match_dup 2)))]
12169   "! TARGET_POWERPC64"
12170   "@
12171    {sf|subfc} %0,%2,%1\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12172    {ai|addic} %0,%1,%n2\;{cal %0,0(0)|li %0,0}\;{ae.|adde.} %0,%0,%0
12173    #
12174    #"
12175   [(set_attr "type" "compare")
12176    (set_attr "length" "12,12,16,16")])
12178 (define_split
12179   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12180         (compare:CC
12181          (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12182                  (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12183          (const_int 0)))
12184    (set (match_operand:SI 0 "gpc_reg_operand" "")
12185         (geu:SI (match_dup 1) (match_dup 2)))]
12186   "! TARGET_POWERPC64 && reload_completed"
12187   [(set (match_dup 0)
12188         (geu:SI (match_dup 1) (match_dup 2)))
12189    (set (match_dup 3)
12190         (compare:CC (match_dup 0)
12191                     (const_int 0)))]
12192   "")
12194 (define_insn ""
12195   [(set (match_operand:CC 3 "cc_reg_operand" "=x,x,?y,?y")
12196         (compare:CC
12197          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12198                  (match_operand:DI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12199          (const_int 0)))
12200    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12201         (geu:DI (match_dup 1) (match_dup 2)))]
12202   "TARGET_POWERPC64"
12203   "@
12204    subfc %0,%2,%1\;li %0,0\;adde. %0,%0,%0
12205    addic %0,%1,%n2\;li %0,0\;adde. %0,%0,%0
12206    #
12207    #"
12208   [(set_attr "type" "compare")
12209    (set_attr "length" "12,12,16,16")])
12211 (define_split
12212   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12213         (compare:CC
12214          (geu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12215                  (match_operand:DI 2 "reg_or_neg_short_operand" ""))
12216          (const_int 0)))
12217    (set (match_operand:DI 0 "gpc_reg_operand" "")
12218         (geu:DI (match_dup 1) (match_dup 2)))]
12219   "TARGET_POWERPC64 && reload_completed"
12220   [(set (match_dup 0)
12221         (geu:DI (match_dup 1) (match_dup 2)))
12222    (set (match_dup 3)
12223         (compare:CC (match_dup 0)
12224                     (const_int 0)))]
12225   "")
12227 (define_insn ""
12228   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12229         (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12230                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P"))
12231                  (match_operand:SI 3 "gpc_reg_operand" "r,r")))]
12232   "! TARGET_POWERPC64"
12233   "@
12234    {sf|subfc} %0,%2,%1\;{aze|addze} %0,%3
12235    {ai|addic} %0,%1,%n2\;{aze|addze} %0,%3"
12236   [(set_attr "length" "8")])
12238 (define_insn ""
12239   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12240         (compare:CC
12241          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12242                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12243                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12244          (const_int 0)))
12245    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12246   "! TARGET_POWERPC64"
12247   "@
12248    {sf|subfc} %4,%2,%1\;{aze.|addze.} %4,%3
12249    {ai|addic} %4,%1,%n2\;{aze.|addze.} %4,%3
12250    #
12251    #"
12252   [(set_attr "type" "compare")
12253    (set_attr "length" "8,8,12,12")])
12255 (define_split
12256   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12257         (compare:CC
12258          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12259                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12260                   (match_operand:SI 3 "gpc_reg_operand" ""))
12261          (const_int 0)))
12262    (clobber (match_scratch:SI 4 ""))]
12263   "! TARGET_POWERPC64 && reload_completed"
12264   [(set (match_dup 4)
12265         (plus:SI (geu:SI (match_dup 1) (match_dup 2))
12266                   (match_dup 3)))
12267    (set (match_dup 0)
12268         (compare:CC (match_dup 4)
12269                     (const_int 0)))]
12270   "")
12272 (define_insn ""
12273   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12274         (compare:CC
12275          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12276                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P"))
12277                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12278          (const_int 0)))
12279    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12280         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12281    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12282   "! TARGET_POWERPC64"
12283   "@
12284    {sf|subfc} %4,%2,%1\;{aze.|addze.} %0,%3
12285    {ai|addic} %4,%1,%n2\;{aze.|addze.} %0,%3
12286    #
12287    #"
12288   [(set_attr "type" "compare")
12289    (set_attr "length" "8,8,12,12")])
12291 (define_split
12292   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12293         (compare:CC
12294          (plus:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12295                           (match_operand:SI 2 "reg_or_neg_short_operand" ""))
12296                   (match_operand:SI 3 "gpc_reg_operand" ""))
12297          (const_int 0)))
12298    (set (match_operand:SI 0 "gpc_reg_operand" "")
12299         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12300    (clobber (match_scratch:SI 4 ""))]
12301   "! TARGET_POWERPC64 && reload_completed"
12302   [(parallel [(set (match_dup 0)
12303         (plus:SI (geu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12304    (clobber (match_dup 4))])
12305    (set (match_dup 5)
12306         (compare:CC (match_dup 0)
12307                     (const_int 0)))]
12308   "")
12310 (define_insn ""
12311   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12312         (neg:SI (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12313                         (match_operand:SI 2 "reg_or_short_operand" "r,I"))))]
12314   "! TARGET_POWERPC64"
12315   "@
12316    {sf|subfc} %0,%2,%1\;{sfe|subfe} %0,%0,%0\;nand %0,%0,%0
12317    {sfi|subfic} %0,%1,-1\;{a%I2|add%I2c} %0,%0,%2\;{sfe|subfe} %0,%0,%0"
12318   [(set_attr "length" "12")])
12320 (define_insn ""
12321   [(set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12322         (and:SI (neg:SI
12323                  (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12324                          (match_operand:SI 2 "reg_or_neg_short_operand" "r,P")))
12325                 (match_operand:SI 3 "gpc_reg_operand" "r,r")))
12326    (clobber (match_scratch:SI 4 "=&r,&r"))]
12327   "! TARGET_POWERPC64"
12328   "@
12329    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4
12330    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc %0,%3,%4"
12331   [(set_attr "length" "12")])
12333 (define_insn ""
12334   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12335         (compare:CC
12336          (and:SI (neg:SI
12337                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12338                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12339                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12340          (const_int 0)))
12341    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12342   "! TARGET_POWERPC64"
12343   "@
12344    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12345    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %4,%3,%4
12346    #
12347    #"
12348   [(set_attr "type" "compare")
12349    (set_attr "length" "12,12,16,16")])
12351 (define_split
12352   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12353         (compare:CC
12354          (and:SI (neg:SI
12355                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12356                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12357                  (match_operand:SI 3 "gpc_reg_operand" ""))
12358          (const_int 0)))
12359    (clobber (match_scratch:SI 4 ""))]
12360   "! TARGET_POWERPC64 && reload_completed"
12361   [(set (match_dup 4)
12362         (and:SI (neg:SI (geu:SI (match_dup 1)
12363                           (match_dup 2)))
12364                  (match_dup 3)))
12365    (set (match_dup 0)
12366         (compare:CC (match_dup 4)
12367                     (const_int 0)))]
12368   "")
12370 (define_insn ""
12371   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12372         (compare:CC
12373          (and:SI (neg:SI
12374                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12375                           (match_operand:SI 2 "reg_or_neg_short_operand" "r,P,r,P")))
12376                  (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12377          (const_int 0)))
12378    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12379         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12380    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12381   "! TARGET_POWERPC64"
12382   "@
12383    {sf|subfc} %4,%2,%1\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
12384    {ai|addic} %4,%1,%n2\;{sfe|subfe} %4,%4,%4\;andc. %0,%3,%4
12385    #
12386    #"
12387   [(set_attr "type" "compare")
12388    (set_attr "length" "12,12,16,16")])
12390 (define_split
12391   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12392         (compare:CC
12393          (and:SI (neg:SI
12394                   (geu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12395                           (match_operand:SI 2 "reg_or_neg_short_operand" "")))
12396                  (match_operand:SI 3 "gpc_reg_operand" ""))
12397          (const_int 0)))
12398    (set (match_operand:SI 0 "gpc_reg_operand" "")
12399         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12400    (clobber (match_scratch:SI 4 ""))]
12401   "! TARGET_POWERPC64 && reload_completed"
12402   [(parallel [(set (match_dup 0)
12403         (and:SI (neg:SI (geu:SI (match_dup 1) (match_dup 2))) (match_dup 3)))
12404    (clobber (match_dup 4))])
12405    (set (match_dup 5)
12406         (compare:CC (match_dup 0)
12407                     (const_int 0)))]
12408   "")
12410 (define_insn ""
12411   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12412         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12413                (const_int 0)))]
12414   "! TARGET_POWERPC64"
12415   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri|srwi} %0,%0,31"
12416   [(set_attr "length" "12")])
12418 (define_insn ""
12419   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12420         (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12421                (const_int 0)))]
12422   "TARGET_POWERPC64"
12423   "subfic %0,%1,0\;addme %0,%0\;srdi %0,%0,63"
12424   [(set_attr "length" "12")])
12426 (define_insn ""
12427   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12428         (compare:CC
12429          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12430                 (const_int 0))
12431          (const_int 0)))
12432    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12433         (gt:SI (match_dup 1) (const_int 0)))]
12434   "! TARGET_POWERPC64"
12435   "@
12436    {sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{sri.|srwi.} %0,%0,31
12437    #"
12438   [(set_attr "type" "delayed_compare")
12439    (set_attr "length" "12,16")])
12441 (define_split
12442   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12443         (compare:CC
12444          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12445                 (const_int 0))
12446          (const_int 0)))
12447    (set (match_operand:SI 0 "gpc_reg_operand" "")
12448         (gt:SI (match_dup 1) (const_int 0)))]
12449   "! TARGET_POWERPC64 && reload_completed"
12450   [(set (match_dup 0)
12451         (gt:SI (match_dup 1) (const_int 0)))
12452    (set (match_dup 2)
12453         (compare:CC (match_dup 0)
12454                     (const_int 0)))]
12455   "")
12457 (define_insn ""
12458   [(set (match_operand:CC 2 "cc_reg_operand" "=x,?y")
12459         (compare:CC
12460          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12461                 (const_int 0))
12462          (const_int 0)))
12463    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12464         (gt:DI (match_dup 1) (const_int 0)))]
12465   "TARGET_POWERPC64"
12466   "@
12467    subfic %0,%1,0\;addme %0,%0\;srdi. %0,%0,63
12468    #"
12469   [(set_attr "type" "delayed_compare")
12470    (set_attr "length" "12,16")])
12472 (define_split
12473   [(set (match_operand:CC 2 "cc_reg_not_cr0_operand" "")
12474         (compare:CC
12475          (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12476                 (const_int 0))
12477          (const_int 0)))
12478    (set (match_operand:DI 0 "gpc_reg_operand" "")
12479         (gt:DI (match_dup 1) (const_int 0)))]
12480   "TARGET_POWERPC64 && reload_completed"
12481   [(set (match_dup 0)
12482         (gt:DI (match_dup 1) (const_int 0)))
12483    (set (match_dup 2)
12484         (compare:CC (match_dup 0)
12485                     (const_int 0)))]
12486   "")
12488 (define_insn ""
12489   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12490         (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12491                (match_operand:SI 2 "reg_or_short_operand" "r")))]
12492   "TARGET_POWER"
12493   "doz %0,%2,%1\;nabs %0,%0\;{sri|srwi} %0,%0,31"
12494   [(set_attr "length" "12")])
12496 (define_insn ""
12497   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12498         (compare:CC
12499          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12500                 (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12501          (const_int 0)))
12502    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12503         (gt:SI (match_dup 1) (match_dup 2)))]
12504   "TARGET_POWER"
12505   "@
12506    doz %0,%2,%1\;nabs %0,%0\;{sri.|srwi.} %0,%0,31
12507    #"
12508   [(set_attr "type" "delayed_compare")
12509    (set_attr "length" "12,16")])
12511 (define_split
12512   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12513         (compare:CC
12514          (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12515                 (match_operand:SI 2 "reg_or_short_operand" ""))
12516          (const_int 0)))
12517    (set (match_operand:SI 0 "gpc_reg_operand" "")
12518         (gt:SI (match_dup 1) (match_dup 2)))]
12519   "TARGET_POWER && reload_completed"
12520   [(set (match_dup 0)
12521         (gt:SI (match_dup 1) (match_dup 2)))
12522    (set (match_dup 3)
12523         (compare:CC (match_dup 0)
12524                     (const_int 0)))]
12525   "")
12527 (define_insn ""
12528   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r")
12529         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12530                         (const_int 0))
12531                  (match_operand:SI 2 "gpc_reg_operand" "r")))]
12532   "! TARGET_POWERPC64"
12533   "{a|addc} %0,%1,%1\;{sfe|subfe} %0,%1,%0\;{aze|addze} %0,%2"
12534   [(set_attr "length" "12")])
12536 (define_insn ""
12537   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12538         (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12539                         (const_int 0))
12540                  (match_operand:DI 2 "gpc_reg_operand" "r")))
12541    (clobber (match_scratch:DI 3 "=&r"))]
12542   "TARGET_POWERPC64"
12543   "addc %3,%1,%1\;subfe %3,%1,%3\;addze %0,%2"
12544   [(set_attr "length" "12")])
12546 (define_insn ""
12547   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12548         (compare:CC
12549          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12550                          (const_int 0))
12551                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12552          (const_int 0)))
12553    (clobber (match_scratch:SI 3 "=&r,&r"))]
12554   "! TARGET_POWERPC64"
12555   "@
12556    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %3,%2
12557    #"
12558   [(set_attr "type" "compare")
12559    (set_attr "length" "12,16")])
12561 (define_split
12562   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12563         (compare:CC
12564          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12565                          (const_int 0))
12566                   (match_operand:SI 2 "gpc_reg_operand" ""))
12567          (const_int 0)))
12568    (clobber (match_scratch:SI 3 ""))]
12569   "! TARGET_POWERPC64 && reload_completed"
12570   [(set (match_dup 3)
12571         (plus:SI (gt:SI (match_dup 1) (const_int 0))
12572                   (match_dup 2)))
12573    (set (match_dup 0)
12574         (compare:CC (match_dup 3)
12575                     (const_int 0)))]
12576   "")
12578 (define_insn ""
12579   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12580         (compare:CC
12581          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12582                          (const_int 0))
12583                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12584          (const_int 0)))
12585    (clobber (match_scratch:DI 3 "=&r,&r"))]
12586   "TARGET_POWERPC64"
12587   "@
12588    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %3,%2
12589    #"
12590   [(set_attr "type" "compare")
12591    (set_attr "length" "12,16")])
12593 (define_split
12594   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12595         (compare:CC
12596          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12597                          (const_int 0))
12598                   (match_operand:DI 2 "gpc_reg_operand" ""))
12599          (const_int 0)))
12600    (clobber (match_scratch:DI 3 ""))]
12601   "TARGET_POWERPC64 && reload_completed"
12602   [(set (match_dup 3)
12603         (plus:DI (gt:DI (match_dup 1) (const_int 0))
12604                   (match_dup 2)))
12605    (set (match_dup 0)
12606         (compare:CC (match_dup 3)
12607                     (const_int 0)))]
12608   "")
12610 (define_insn ""
12611   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12612         (compare:CC
12613          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12614                          (const_int 0))
12615                   (match_operand:SI 2 "gpc_reg_operand" "r,r"))
12616          (const_int 0)))
12617    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12618         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12619    (clobber (match_scratch:SI 3 "=&r,&r"))]
12620   "! TARGET_POWERPC64"
12621   "@
12622    {a|addc} %3,%1,%1\;{sfe|subfe} %3,%1,%3\;{aze.|addze.} %0,%2
12623    #"
12624   [(set_attr "type" "compare")
12625    (set_attr "length" "12,16")])
12627 (define_split
12628   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12629         (compare:CC
12630          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12631                          (const_int 0))
12632                   (match_operand:SI 2 "gpc_reg_operand" ""))
12633          (const_int 0)))
12634    (set (match_operand:SI 0 "gpc_reg_operand" "")
12635         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12636    (clobber (match_scratch:SI 3 ""))]
12637   "! TARGET_POWERPC64 && reload_completed"
12638   [(parallel [(set (match_dup 0)
12639         (plus:SI (gt:SI (match_dup 1) (const_int 0)) (match_dup 2)))
12640    (clobber (match_dup 3))])
12641    (set (match_dup 4)
12642         (compare:CC (match_dup 0)
12643                     (const_int 0)))]
12644   "")
12646 (define_insn ""
12647   [(set (match_operand:CC 4 "cc_reg_operand" "=x,?y")
12648         (compare:CC
12649          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12650                          (const_int 0))
12651                   (match_operand:DI 2 "gpc_reg_operand" "r,r"))
12652          (const_int 0)))
12653    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12654         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12655    (clobber (match_scratch:DI 3 "=&r,&r"))]
12656   "TARGET_POWERPC64"
12657   "@
12658    addc %3,%1,%1\;subfe %3,%1,%3\;addze. %0,%2
12659    #"
12660   [(set_attr "type" "compare")
12661    (set_attr "length" "12,16")])
12663 (define_split
12664   [(set (match_operand:CC 4 "cc_reg_not_cr0_operand" "")
12665         (compare:CC
12666          (plus:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "")
12667                          (const_int 0))
12668                   (match_operand:DI 2 "gpc_reg_operand" ""))
12669          (const_int 0)))
12670    (set (match_operand:DI 0 "gpc_reg_operand" "")
12671         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12672    (clobber (match_scratch:DI 3 ""))]
12673   "TARGET_POWERPC64 && reload_completed"
12674   [(parallel [(set (match_dup 0)
12675         (plus:DI (gt:DI (match_dup 1) (const_int 0)) (match_dup 2)))
12676    (clobber (match_dup 3))])
12677    (set (match_dup 4)
12678         (compare:CC (match_dup 0)
12679                     (const_int 0)))]
12680   "")
12682 (define_insn ""
12683   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12684         (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12685                         (match_operand:SI 2 "reg_or_short_operand" "r"))
12686                  (match_operand:SI 3 "gpc_reg_operand" "r")))
12687    (clobber (match_scratch:SI 4 "=&r"))]
12688   "TARGET_POWER"
12689   "doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze|addze} %0,%3"
12690   [(set_attr "length" "12")])
12692 (define_insn ""
12693   [(set (match_operand:CC 0 "cc_reg_operand" "=x,?y")
12694         (compare:CC
12695          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12696                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12697                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12698          (const_int 0)))
12699    (clobber (match_scratch:SI 4 "=&r,&r"))]
12700   "TARGET_POWER"
12701   "@
12702    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %4,%3
12703    #"
12704   [(set_attr "type" "compare")
12705    (set_attr "length" "12,16")])
12707 (define_split
12708   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12709         (compare:CC
12710          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12711                          (match_operand:SI 2 "reg_or_short_operand" ""))
12712                   (match_operand:SI 3 "gpc_reg_operand" ""))
12713          (const_int 0)))
12714    (clobber (match_scratch:SI 4 ""))]
12715   "TARGET_POWER && reload_completed"
12716   [(set (match_dup 4)
12717         (plus:SI (gt:SI (match_dup 1) (match_dup 2))
12718                   (match_dup 3)))
12719    (set (match_dup 0)
12720         (compare:CC (match_dup 4)
12721                     (const_int 0)))]
12722   "")
12724 (define_insn ""
12725   [(set (match_operand:CC 5 "cc_reg_operand" "=x,?y")
12726         (compare:CC
12727          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12728                          (match_operand:SI 2 "reg_or_short_operand" "r,r"))
12729                   (match_operand:SI 3 "gpc_reg_operand" "r,r"))
12730          (const_int 0)))
12731    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12732         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12733    (clobber (match_scratch:SI 4 "=&r,&r"))]
12734   "TARGET_POWER"
12735   "@
12736    doz %4,%2,%1\;{ai|addic} %4,%4,-1\;{aze.|addze.} %0,%3
12737    #"
12738   [(set_attr "type" "compare")
12739    (set_attr "length" "12,16")])
12741 (define_split
12742   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12743         (compare:CC
12744          (plus:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "")
12745                          (match_operand:SI 2 "reg_or_short_operand" ""))
12746                   (match_operand:SI 3 "gpc_reg_operand" ""))
12747          (const_int 0)))
12748    (set (match_operand:SI 0 "gpc_reg_operand" "")
12749         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12750    (clobber (match_scratch:SI 4 ""))]
12751   "TARGET_POWER && reload_completed"
12752   [(parallel [(set (match_dup 0)
12753         (plus:SI (gt:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12754    (clobber (match_dup 4))])
12755    (set (match_dup 5)
12756         (compare:CC (match_dup 0)
12757                     (const_int 0)))]
12758   "")
12760 (define_insn ""
12761   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12762         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12763                        (const_int 0))))]
12764   "! TARGET_POWERPC64"
12765   "{sfi|subfic} %0,%1,0\;{ame|addme} %0,%0\;{srai|srawi} %0,%0,31"
12766   [(set_attr "length" "12")])
12768 (define_insn ""
12769   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12770         (neg:DI (gt:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12771                        (const_int 0))))]
12772   "TARGET_POWERPC64"
12773   "subfic %0,%1,0\;addme %0,%0\;sradi %0,%0,63"
12774   [(set_attr "length" "12")])
12776 (define_insn ""
12777   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12778         (neg:SI (gt:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12779                        (match_operand:SI 2 "reg_or_short_operand" "r"))))]
12780   "TARGET_POWER"
12781   "doz %0,%2,%1\;nabs %0,%0\;{srai|srawi} %0,%0,31"
12782   [(set_attr "length" "12")])
12784 (define_insn ""
12785   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
12786         (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
12787                 (match_operand:SI 2 "reg_or_short_operand" "rI")))]
12788   "! TARGET_POWERPC64"
12789   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg %0,%0"
12790   [(set_attr "length" "12")])
12792 (define_insn ""
12793   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
12794         (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
12795                 (match_operand:DI 2 "reg_or_short_operand" "rI")))]
12796   "TARGET_POWERPC64"
12797   "subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg %0,%0"
12798   [(set_attr "length" "12")])
12800 (define_insn ""
12801   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12802         (compare:CC
12803          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12804                  (match_operand:SI 2 "reg_or_short_operand" "rI,rI"))
12805          (const_int 0)))
12806    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r")
12807         (gtu:SI (match_dup 1) (match_dup 2)))]
12808   "! TARGET_POWERPC64"
12809   "@
12810    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;neg. %0,%0
12811    #"
12812   [(set_attr "type" "compare")
12813    (set_attr "length" "12,16")])
12815 (define_split
12816   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12817         (compare:CC
12818          (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12819                  (match_operand:SI 2 "reg_or_short_operand" ""))
12820          (const_int 0)))
12821    (set (match_operand:SI 0 "gpc_reg_operand" "")
12822         (gtu:SI (match_dup 1) (match_dup 2)))]
12823   "! TARGET_POWERPC64 && reload_completed"
12824   [(set (match_dup 0)
12825         (gtu:SI (match_dup 1) (match_dup 2)))
12826    (set (match_dup 3)
12827         (compare:CC (match_dup 0)
12828                     (const_int 0)))]
12829   "")
12831 (define_insn ""
12832   [(set (match_operand:CC 3 "cc_reg_operand" "=x,?y")
12833         (compare:CC
12834          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12835                  (match_operand:DI 2 "reg_or_short_operand" "rI,rI"))
12836          (const_int 0)))
12837    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12838         (gtu:DI (match_dup 1) (match_dup 2)))]
12839   "TARGET_POWERPC64"
12840   "@
12841    subf%I2c %0,%1,%2\;subfe %0,%0,%0\;neg. %0,%0
12842    #"
12843   [(set_attr "type" "compare")
12844    (set_attr "length" "12,16")])
12846 (define_split
12847   [(set (match_operand:CC 3 "cc_reg_not_cr0_operand" "")
12848         (compare:CC
12849          (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12850                  (match_operand:DI 2 "reg_or_short_operand" ""))
12851          (const_int 0)))
12852    (set (match_operand:DI 0 "gpc_reg_operand" "")
12853         (gtu:DI (match_dup 1) (match_dup 2)))]
12854   "TARGET_POWERPC64 && reload_completed"
12855   [(set (match_dup 0)
12856         (gtu:DI (match_dup 1) (match_dup 2)))
12857    (set (match_dup 3)
12858         (compare:CC (match_dup 0)
12859                     (const_int 0)))]
12860   "")
12862 (define_insn ""
12863   [(set (match_operand:SI 0 "gpc_reg_operand" "=&r,&r")
12864         (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r")
12865                          (match_operand:SI 2 "reg_or_short_operand" "I,rI"))
12866                  (match_operand:SI 3 "reg_or_short_operand" "r,rI")))]
12867   "! TARGET_POWERPC64"
12868   "@
12869    {ai|addic} %0,%1,%k2\;{aze|addze} %0,%3
12870    {sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0\;{sf%I3|subf%I3c} %0,%0,%3"
12871   [(set_attr "length" "8,12")])
12873 (define_insn ""
12874   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
12875         (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r")
12876                          (match_operand:DI 2 "reg_or_short_operand" "I,rI"))
12877                  (match_operand:DI 3 "reg_or_short_operand" "r,rI")))
12878    (clobber (match_scratch:DI 4 "=&r,&r"))]
12879   "TARGET_POWERPC64"
12880   "@
12881    addic %4,%1,%k2\;addze %0,%3
12882    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subf%I3c %0,%4,%3"
12883   [(set_attr "length" "8,12")])
12885 (define_insn ""
12886   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12887         (compare:CC
12888          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12889                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
12890                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12891          (const_int 0)))
12892    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12893   "! TARGET_POWERPC64"
12894   "@
12895    {ai|addic} %4,%1,%k2\;{aze.|addze.} %4,%3
12896    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %4,%4,%3
12897    #
12898    #"
12899   [(set_attr "type" "compare")
12900    (set_attr "length" "8,12,12,16")])
12902 (define_split
12903   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12904         (compare:CC
12905          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12906                           (match_operand:SI 2 "reg_or_short_operand" ""))
12907                   (match_operand:SI 3 "gpc_reg_operand" ""))
12908          (const_int 0)))
12909    (clobber (match_scratch:SI 4 ""))]
12910   "! TARGET_POWERPC64 && reload_completed"
12911   [(set (match_dup 4)
12912         (plus:SI (gtu:SI (match_dup 1) (match_dup 2))
12913                   (match_dup 3)))
12914    (set (match_dup 0)
12915         (compare:CC (match_dup 4)
12916                     (const_int 0)))]
12917   "")
12919 (define_insn ""
12920   [(set (match_operand:CC 0 "cc_reg_operand" "=x,x,?y,?y")
12921         (compare:CC
12922          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12923                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
12924                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
12925          (const_int 0)))
12926    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
12927   "TARGET_POWERPC64"
12928   "@
12929    addic %4,%1,%k2\;addze. %4,%3
12930    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %4,%4,%3
12931    #
12932    #"
12933   [(set_attr "type" "compare")
12934    (set_attr "length" "8,12,12,16")])
12936 (define_split
12937   [(set (match_operand:CC 0 "cc_reg_not_cr0_operand" "")
12938         (compare:CC
12939          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
12940                           (match_operand:DI 2 "reg_or_short_operand" ""))
12941                   (match_operand:DI 3 "gpc_reg_operand" ""))
12942          (const_int 0)))
12943    (clobber (match_scratch:DI 4 ""))]
12944   "TARGET_POWERPC64 && reload_completed"
12945   [(set (match_dup 4)
12946         (plus:DI (gtu:DI (match_dup 1) (match_dup 2))
12947                   (match_dup 3)))
12948    (set (match_dup 0)
12949         (compare:CC (match_dup 4)
12950                     (const_int 0)))]
12951   "")
12953 (define_insn ""
12954   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12955         (compare:CC
12956          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r,r,r,r")
12957                           (match_operand:SI 2 "reg_or_short_operand" "I,r,I,r"))
12958                   (match_operand:SI 3 "gpc_reg_operand" "r,r,r,r"))
12959          (const_int 0)))
12960    (set (match_operand:SI 0 "gpc_reg_operand" "=r,r,r,r")
12961         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12962    (clobber (match_scratch:SI 4 "=&r,&r,&r,&r"))]
12963   "! TARGET_POWERPC64"
12964   "@
12965    {ai|addic} %4,%1,%k2\;{aze.|addze.} %0,%3
12966    {sf%I2|subf%I2c} %4,%1,%2\;{sfe|subfe} %4,%4,%4\;{sf.|subfc.} %0,%4,%3
12967    #
12968    #"
12969   [(set_attr "type" "compare")
12970    (set_attr "length" "8,12,12,16")])
12972 (define_split
12973   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
12974         (compare:CC
12975          (plus:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "")
12976                           (match_operand:SI 2 "reg_or_short_operand" ""))
12977                   (match_operand:SI 3 "gpc_reg_operand" ""))
12978          (const_int 0)))
12979    (set (match_operand:SI 0 "gpc_reg_operand" "")
12980         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12981    (clobber (match_scratch:SI 4 ""))]
12982   "! TARGET_POWERPC64 && reload_completed"
12983   [(parallel [(set (match_dup 0)
12984         (plus:SI (gtu:SI (match_dup 1) (match_dup 2)) (match_dup 3)))
12985    (clobber (match_dup 4))])
12986    (set (match_dup 5)
12987         (compare:CC (match_dup 0)
12988                     (const_int 0)))]
12989   "")
12991 (define_insn ""
12992   [(set (match_operand:CC 5 "cc_reg_operand" "=x,x,?y,?y")
12993         (compare:CC
12994          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r,r,r,r")
12995                           (match_operand:DI 2 "reg_or_short_operand" "I,r,I,r"))
12996                   (match_operand:DI 3 "gpc_reg_operand" "r,r,r,r"))
12997          (const_int 0)))
12998    (set (match_operand:DI 0 "gpc_reg_operand" "=r,r,r,r")
12999         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13000    (clobber (match_scratch:DI 4 "=&r,&r,&r,&r"))]
13001   "TARGET_POWERPC64"
13002   "@
13003    addic %4,%1,%k2\;addze. %0,%3
13004    subf%I2c %4,%1,%2\;subfe %4,%4,%4\;subfc. %0,%4,%3
13005    #
13006    #"
13007   [(set_attr "type" "compare")
13008    (set_attr "length" "8,12,12,16")])
13010 (define_split
13011   [(set (match_operand:CC 5 "cc_reg_not_cr0_operand" "")
13012         (compare:CC
13013          (plus:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "")
13014                           (match_operand:DI 2 "reg_or_short_operand" ""))
13015                   (match_operand:DI 3 "gpc_reg_operand" ""))
13016          (const_int 0)))
13017    (set (match_operand:DI 0 "gpc_reg_operand" "")
13018         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13019    (clobber (match_scratch:DI 4 ""))]
13020   "TARGET_POWERPC64 && reload_completed"
13021   [(parallel [(set (match_dup 0)
13022         (plus:DI (gtu:DI (match_dup 1) (match_dup 2)) (match_dup 3)))
13023    (clobber (match_dup 4))])
13024    (set (match_dup 5)
13025         (compare:CC (match_dup 0)
13026                     (const_int 0)))]
13027   "")
13029 (define_insn ""
13030   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13031         (neg:SI (gtu:SI (match_operand:SI 1 "gpc_reg_operand" "r")
13032                         (match_operand:SI 2 "reg_or_short_operand" "rI"))))]
13033   "! TARGET_POWERPC64"
13034   "{sf%I2|subf%I2c} %0,%1,%2\;{sfe|subfe} %0,%0,%0"
13035   [(set_attr "length" "8")])
13037 (define_insn ""
13038   [(set (match_operand:DI 0 "gpc_reg_operand" "=r")
13039         (neg:DI (gtu:DI (match_operand:DI 1 "gpc_reg_operand" "r")
13040                         (match_operand:DI 2 "reg_or_short_operand" "rI"))))]
13041   "TARGET_POWERPC64"
13042   "subf%I2c %0,%1,%2\;subfe %0,%0,%0"
13043   [(set_attr "length" "8")])
13045 ;; Define both directions of branch and return.  If we need a reload
13046 ;; register, we'd rather use CR0 since it is much easier to copy a
13047 ;; register CC value to there.
13049 (define_insn ""
13050   [(set (pc)
13051         (if_then_else (match_operator 1 "branch_comparison_operator"
13052                                       [(match_operand 2
13053                                                       "cc_reg_operand" "x,?y")
13054                                        (const_int 0)])
13055                       (label_ref (match_operand 0 "" ""))
13056                       (pc)))]
13057   ""
13058   "*
13060   return output_cbranch (operands[1], \"%l0\", 0, insn);
13062   [(set_attr "type" "branch")])
13064 (define_insn ""
13065   [(set (pc)
13066         (if_then_else (match_operator 0 "branch_comparison_operator"
13067                                       [(match_operand 1
13068                                                       "cc_reg_operand" "x,?y")
13069                                        (const_int 0)])
13070                       (return)
13071                       (pc)))]
13072   "direct_return ()"
13073   "*
13075   return output_cbranch (operands[0], NULL, 0, insn);
13077   [(set_attr "type" "branch")
13078    (set_attr "length" "4")])
13080 (define_insn ""
13081   [(set (pc)
13082         (if_then_else (match_operator 1 "branch_comparison_operator"
13083                                       [(match_operand 2
13084                                                       "cc_reg_operand" "x,?y")
13085                                        (const_int 0)])
13086                       (pc)
13087                       (label_ref (match_operand 0 "" ""))))]
13088   ""
13089   "*
13091   return output_cbranch (operands[1], \"%l0\", 1, insn);
13093   [(set_attr "type" "branch")])
13095 (define_insn ""
13096   [(set (pc)
13097         (if_then_else (match_operator 0 "branch_comparison_operator"
13098                                       [(match_operand 1
13099                                                       "cc_reg_operand" "x,?y")
13100                                        (const_int 0)])
13101                       (pc)
13102                       (return)))]
13103   "direct_return ()"
13104   "*
13106   return output_cbranch (operands[0], NULL, 1, insn);
13108   [(set_attr "type" "branch")
13109    (set_attr "length" "4")])
13111 ;; Logic on condition register values.
13113 ; This pattern matches things like
13114 ; (set (reg:CCEQ 68) (compare:CCEQ (ior:SI (gt:SI (reg:CCFP 68) (const_int 0))
13115 ;                                          (eq:SI (reg:CCFP 68) (const_int 0)))
13116 ;                                  (const_int 1)))
13117 ; which are generated by the branch logic.
13119 (define_insn ""
13120   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13121         (compare:CCEQ (match_operator:SI 1 "boolean_operator"
13122                         [(match_operator:SI 2 
13123                                       "branch_positive_comparison_operator"
13124                                       [(match_operand 3
13125                                                       "cc_reg_operand" "y")
13126                                        (const_int 0)])
13127                          (match_operator:SI 4 
13128                                       "branch_positive_comparison_operator"
13129                                       [(match_operand 5
13130                                                       "cc_reg_operand" "y")
13131                                        (const_int 0)])])
13132                       (const_int 1)))]
13133   ""
13134   "cr%q1 %E0,%j2,%j4"
13135   [(set_attr "type" "cr_logical")])
13137 ; Why is the constant -1 here, but 1 in the previous pattern?
13138 ; Because ~1 has all but the low bit set.
13139 (define_insn ""
13140   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13141         (compare:CCEQ (match_operator:SI 1 "boolean_or_operator"
13142                         [(not:SI (match_operator:SI 2 
13143                                       "branch_positive_comparison_operator"
13144                                       [(match_operand 3
13145                                                       "cc_reg_operand" "y")
13146                                        (const_int 0)]))
13147                          (match_operator:SI 4
13148                                 "branch_positive_comparison_operator"
13149                                 [(match_operand 5
13150                                                 "cc_reg_operand" "y")
13151                                  (const_int 0)])])
13152                       (const_int -1)))]
13153   ""
13154   "cr%q1 %E0,%j2,%j4"
13155   [(set_attr "type" "cr_logical")])
13157 (define_insn ""
13158   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13159         (compare:CCEQ (match_operator:SI 1
13160                                       "branch_positive_comparison_operator"
13161                                       [(match_operand 2
13162                                                       "cc_reg_operand" "y")
13163                                        (const_int 0)])
13164                       (const_int 0)))]
13165   ""
13166   "{crnor %E0,%j1,%j1|crnot %E0,%j1}"
13167   [(set_attr "type" "cr_logical")])
13169 ;; If we are comparing the result of two comparisons, this can be done
13170 ;; using creqv or crxor.
13172 (define_insn_and_split ""
13173   [(set (match_operand:CCEQ 0 "cc_reg_operand" "=y")
13174         (compare:CCEQ (match_operator 1 "branch_comparison_operator"
13175                               [(match_operand 2 "cc_reg_operand" "y")
13176                                (const_int 0)])
13177                       (match_operator 3 "branch_comparison_operator"
13178                               [(match_operand 4 "cc_reg_operand" "y")
13179                                (const_int 0)])))]
13180   ""
13181   "#"
13182   ""
13183   [(set (match_dup 0) (compare:CCEQ (xor:SI (match_dup 1) (match_dup 3))
13184                                     (match_dup 5)))]
13185   "
13187   int positive_1, positive_2;
13189   positive_1 = branch_positive_comparison_operator (operands[1], CCEQmode);
13190   positive_2 = branch_positive_comparison_operator (operands[3], CCEQmode);
13192   if (! positive_1)
13193     operands[1] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[2]),
13194                                                      GET_CODE (operands[1])),
13195                            SImode,
13196                            operands[2], const0_rtx);
13197   else if (GET_MODE (operands[1]) != SImode)
13198     operands[1] = gen_rtx (GET_CODE (operands[1]),
13199                            SImode,
13200                            operands[2], const0_rtx);
13202   if (! positive_2)
13203     operands[3] = gen_rtx (rs6000_reverse_condition (GET_MODE (operands[4]),
13204                                                      GET_CODE (operands[3])),
13205                            SImode,
13206                            operands[4], const0_rtx);
13207   else if (GET_MODE (operands[3]) != SImode)
13208     operands[3] = gen_rtx (GET_CODE (operands[3]),
13209                            SImode,
13210                            operands[4], const0_rtx);
13212   if (positive_1 == positive_2)
13213     {
13214       operands[1] = gen_rtx_NOT (SImode, operands[1]);
13215       operands[5] = constm1_rtx;
13216     }
13217   else
13218     {
13219       operands[5] = const1_rtx;
13220     }
13223 ;; Unconditional branch and return.
13225 (define_insn "jump"
13226   [(set (pc)
13227         (label_ref (match_operand 0 "" "")))]
13228   ""
13229   "b %l0"
13230   [(set_attr "type" "branch")])
13232 (define_insn "return"
13233   [(return)]
13234   "direct_return ()"
13235   "{br|blr}"
13236   [(set_attr "type" "jmpreg")])
13238 (define_expand "indirect_jump"
13239   [(set (pc) (match_operand 0 "register_operand" ""))]
13240   ""
13241   "
13243   if (TARGET_32BIT)
13244     emit_jump_insn (gen_indirect_jumpsi (operands[0]));
13245   else
13246     emit_jump_insn (gen_indirect_jumpdi (operands[0]));
13247   DONE;
13250 (define_insn "indirect_jumpsi"
13251   [(set (pc) (match_operand:SI 0 "register_operand" "c,*l"))]
13252   "TARGET_32BIT"
13253   "@
13254    bctr
13255    {br|blr}"
13256   [(set_attr "type" "jmpreg")])
13258 (define_insn "indirect_jumpdi"
13259   [(set (pc) (match_operand:DI 0 "register_operand" "c,*l"))]
13260   "TARGET_64BIT"
13261   "@
13262    bctr
13263    blr"
13264   [(set_attr "type" "jmpreg")])
13266 ;; Table jump for switch statements:
13267 (define_expand "tablejump"
13268   [(use (match_operand 0 "" ""))
13269    (use (label_ref (match_operand 1 "" "")))]
13270   ""
13271   "
13273   if (TARGET_32BIT)
13274     emit_jump_insn (gen_tablejumpsi (operands[0], operands[1]));
13275   else
13276     emit_jump_insn (gen_tablejumpdi (operands[0], operands[1]));
13277   DONE;
13280 (define_expand "tablejumpsi"
13281   [(set (match_dup 3)
13282         (plus:SI (match_operand:SI 0 "" "")
13283                  (match_dup 2)))
13284    (parallel [(set (pc) (match_dup 3))
13285               (use (label_ref (match_operand 1 "" "")))])]
13286   "TARGET_32BIT"
13287   "
13288 { operands[0] = force_reg (SImode, operands[0]);
13289   operands[2] = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[1]));
13290   operands[3] = gen_reg_rtx (SImode);
13293 (define_expand "tablejumpdi"
13294   [(set (match_dup 4) 
13295         (sign_extend:DI (match_operand:SI 0 "lwa_operand" "rm")))
13296    (set (match_dup 3)
13297         (plus:DI (match_dup 4)
13298                  (match_dup 2)))
13299    (parallel [(set (pc) (match_dup 3))
13300               (use (label_ref (match_operand 1 "" "")))])]
13301   "TARGET_64BIT"
13302   "
13303 { operands[2] = force_reg (DImode, gen_rtx_LABEL_REF (DImode, operands[1]));
13304   operands[3] = gen_reg_rtx (DImode);
13305   operands[4] = gen_reg_rtx (DImode);
13308 (define_insn ""
13309   [(set (pc)
13310         (match_operand:SI 0 "register_operand" "c,*l"))
13311    (use (label_ref (match_operand 1 "" "")))]
13312   "TARGET_32BIT"
13313   "@
13314    bctr
13315    {br|blr}"
13316   [(set_attr "type" "jmpreg")])
13318 (define_insn ""
13319   [(set (pc)
13320         (match_operand:DI 0 "register_operand" "c,*l"))
13321    (use (label_ref (match_operand 1 "" "")))]
13322   "TARGET_64BIT"
13323   "@
13324    bctr
13325    blr"
13326   [(set_attr "type" "jmpreg")])
13328 (define_insn "nop"
13329   [(const_int 0)]
13330   ""
13331   "{cror 0,0,0|nop}")
13333 ;; Define the subtract-one-and-jump insns, starting with the template
13334 ;; so loop.c knows what to generate.
13336 (define_expand "doloop_end"
13337   [(use (match_operand 0 "" ""))        ; loop pseudo
13338    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
13339    (use (match_operand 2 "" ""))        ; max iterations
13340    (use (match_operand 3 "" ""))        ; loop level
13341    (use (match_operand 4 "" ""))]       ; label
13342   ""
13343   "
13345   /* Only use this on innermost loops.  */
13346   if (INTVAL (operands[3]) > 1)
13347     FAIL;
13348   if (TARGET_POWERPC64)
13349     {
13350       if (GET_MODE (operands[0]) != DImode)
13351         FAIL;
13352       emit_jump_insn (gen_ctrdi (operands[0], operands[4]));
13353     }
13354   else
13355     {
13356       if (GET_MODE (operands[0]) != SImode)
13357         FAIL;
13358       emit_jump_insn (gen_ctrsi (operands[0], operands[4]));
13359     }
13360   DONE;
13363 (define_expand "ctrsi"
13364   [(parallel [(set (pc)
13365                    (if_then_else (ne (match_operand:SI 0 "register_operand" "")
13366                                      (const_int 1))
13367                                  (label_ref (match_operand 1 "" ""))
13368                                  (pc)))
13369               (set (match_dup 0)
13370                    (plus:SI (match_dup 0)
13371                             (const_int -1)))
13372               (clobber (match_scratch:CC 2 ""))
13373               (clobber (match_scratch:SI 3 ""))])]
13374   "! TARGET_POWERPC64"
13375   "")
13377 (define_expand "ctrdi"
13378   [(parallel [(set (pc)
13379                    (if_then_else (ne (match_operand:DI 0 "register_operand" "")
13380                                      (const_int 1))
13381                                  (label_ref (match_operand 1 "" ""))
13382                                  (pc)))
13383               (set (match_dup 0)
13384                    (plus:DI (match_dup 0)
13385                             (const_int -1)))
13386               (clobber (match_scratch:CC 2 ""))
13387               (clobber (match_scratch:DI 3 ""))])]
13388   "TARGET_POWERPC64"
13389   "")
13391 ;; We need to be able to do this for any operand, including MEM, or we
13392 ;; will cause reload to blow up since we don't allow output reloads on
13393 ;; JUMP_INSNs.
13394 ;; For the length attribute to be calculated correctly, the
13395 ;; label MUST be operand 0.
13397 (define_insn "*ctrsi_internal1"
13398   [(set (pc)
13399         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13400                           (const_int 1))
13401                       (label_ref (match_operand 0 "" ""))
13402                       (pc)))
13403    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13404         (plus:SI (match_dup 1)
13405                  (const_int -1)))
13406    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13407    (clobber (match_scratch:SI 4 "=X,X,r"))]
13408   "! TARGET_POWERPC64"
13409   "*
13411   if (which_alternative != 0)
13412     return \"#\";
13413   else if (get_attr_length (insn) == 4)
13414     return \"{bdn|bdnz} %l0\";
13415   else
13416     return \"bdz $+8\;b %l0\";
13418   [(set_attr "type" "branch")
13419    (set_attr "length" "*,12,16")])
13421 (define_insn "*ctrsi_internal2"
13422   [(set (pc)
13423         (if_then_else (ne (match_operand:SI 1 "register_operand" "c,*r,*r")
13424                           (const_int 1))
13425                       (pc)
13426                       (label_ref (match_operand 0 "" ""))))
13427    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13428         (plus:SI (match_dup 1)
13429                  (const_int -1)))
13430    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13431    (clobber (match_scratch:SI 4 "=X,X,r"))]
13432   "! TARGET_POWERPC64"
13433   "*
13435   if (which_alternative != 0)
13436     return \"#\";
13437   else if (get_attr_length (insn) == 4)
13438     return \"bdz %l0\";
13439   else
13440     return \"{bdn|bdnz} $+8\;b %l0\";
13442   [(set_attr "type" "branch")
13443    (set_attr "length" "*,12,16")])
13445 (define_insn "*ctrdi_internal1"
13446   [(set (pc)
13447         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
13448                           (const_int 1))
13449                       (label_ref (match_operand 0 "" ""))
13450                       (pc)))
13451    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13452         (plus:DI (match_dup 1)
13453                  (const_int -1)))
13454    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13455    (clobber (match_scratch:DI 4 "=X,X,r"))]
13456   "TARGET_POWERPC64"
13457   "*
13459   if (which_alternative != 0)
13460     return \"#\";
13461   else if (get_attr_length (insn) == 4)
13462     return \"{bdn|bdnz} %l0\";
13463   else
13464     return \"bdz $+8\;b %l0\";
13466   [(set_attr "type" "branch")
13467    (set_attr "length" "*,12,16")])
13469 (define_insn "*ctrdi_internal2"
13470   [(set (pc)
13471         (if_then_else (ne (match_operand:DI 1 "register_operand" "c,*r,*r")
13472                           (const_int 1))
13473                       (pc)
13474                       (label_ref (match_operand 0 "" ""))))
13475    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13476         (plus:DI (match_dup 1)
13477                  (const_int -1)))
13478    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13479    (clobber (match_scratch:DI 4 "=X,X,r"))]
13480   "TARGET_POWERPC64"
13481   "*
13483   if (which_alternative != 0)
13484     return \"#\";
13485   else if (get_attr_length (insn) == 4)
13486     return \"bdz %l0\";
13487   else
13488     return \"{bdn|bdnz} $+8\;b %l0\";
13490   [(set_attr "type" "branch")
13491    (set_attr "length" "*,12,16")])
13493 ;; Similar, but we can use GE since we have a REG_NONNEG.
13495 (define_insn "*ctrsi_internal3"
13496   [(set (pc)
13497         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13498                           (const_int 0))
13499                       (label_ref (match_operand 0 "" ""))
13500                       (pc)))
13501    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13502         (plus:SI (match_dup 1)
13503                  (const_int -1)))
13504    (clobber (match_scratch:CC 3 "=X,&x,&X"))
13505    (clobber (match_scratch:SI 4 "=X,X,r"))]
13506   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13507   "*
13509   if (which_alternative != 0)
13510     return \"#\";
13511   else if (get_attr_length (insn) == 4)
13512     return \"{bdn|bdnz} %l0\";
13513   else
13514     return \"bdz $+8\;b %l0\";
13516   [(set_attr "type" "branch")
13517    (set_attr "length" "*,12,16")])
13519 (define_insn "*ctrsi_internal4"
13520   [(set (pc)
13521         (if_then_else (ge (match_operand:SI 1 "register_operand" "c,*r,*r")
13522                           (const_int 0))
13523                       (pc)
13524                       (label_ref (match_operand 0 "" ""))))
13525    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13526         (plus:SI (match_dup 1)
13527                  (const_int -1)))
13528    (clobber (match_scratch:CC 3 "=X,&x,&X"))
13529    (clobber (match_scratch:SI 4 "=X,X,r"))]
13530   "! TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13531   "*
13533   if (which_alternative != 0)
13534     return \"#\";
13535   else if (get_attr_length (insn) == 4)
13536     return \"bdz %l0\";
13537   else
13538     return \"{bdn|bdnz} $+8\;b %l0\";
13540   [(set_attr "type" "branch")
13541    (set_attr "length" "*,12,16")])
13543 (define_insn "*ctrdi_internal3"
13544   [(set (pc)
13545         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
13546                           (const_int 0))
13547                       (label_ref (match_operand 0 "" ""))
13548                       (pc)))
13549    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13550         (plus:DI (match_dup 1)
13551                  (const_int -1)))
13552    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13553    (clobber (match_scratch:DI 4 "=X,X,r"))]
13554   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13555   "*
13557   if (which_alternative != 0)
13558     return \"#\";
13559   else if (get_attr_length (insn) == 4)
13560     return \"{bdn|bdnz} %l0\";
13561   else
13562     return \"bdz $+8\;b %l0\";
13564   [(set_attr "type" "branch")
13565    (set_attr "length" "*,12,16")])
13567 (define_insn "*ctrdi_internal4"
13568   [(set (pc)
13569         (if_then_else (ge (match_operand:DI 1 "register_operand" "c,*r,*r")
13570                           (const_int 0))
13571                       (pc)
13572                       (label_ref (match_operand 0 "" ""))))
13573    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13574         (plus:DI (match_dup 1)
13575                  (const_int -1)))
13576    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13577    (clobber (match_scratch:DI 4 "=X,X,r"))]
13578   "TARGET_POWERPC64 && find_reg_note (insn, REG_NONNEG, 0)"
13579   "*
13581   if (which_alternative != 0)
13582     return \"#\";
13583   else if (get_attr_length (insn) == 4)
13584     return \"bdz %l0\";
13585   else
13586     return \"{bdn|bdnz} $+8\;b %l0\";
13588   [(set_attr "type" "branch")
13589    (set_attr "length" "*,12,16")])
13591 ;; Similar but use EQ
13593 (define_insn "*ctrsi_internal5"
13594   [(set (pc)
13595         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13596                           (const_int 1))
13597                       (label_ref (match_operand 0 "" ""))
13598                       (pc)))
13599    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13600         (plus:SI (match_dup 1)
13601                  (const_int -1)))
13602    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13603    (clobber (match_scratch:SI 4 "=X,X,r"))]
13604   "! TARGET_POWERPC64"
13605   "*
13607   if (which_alternative != 0)
13608     return \"#\";
13609   else if (get_attr_length (insn) == 4)
13610     return \"bdz %l0\";
13611   else
13612     return \"{bdn|bdnz} $+8\;b %l0\";
13614   [(set_attr "type" "branch")
13615    (set_attr "length" "*,12,16")])
13617 (define_insn "*ctrsi_internal6"
13618   [(set (pc)
13619         (if_then_else (eq (match_operand:SI 1 "register_operand" "c,*r,*r")
13620                           (const_int 1))
13621                       (pc)
13622                       (label_ref (match_operand 0 "" ""))))
13623    (set (match_operand:SI 2 "register_operand" "=1,*r,m*q*c*l")
13624         (plus:SI (match_dup 1)
13625                  (const_int -1)))
13626    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13627    (clobber (match_scratch:SI 4 "=X,X,r"))]
13628   "! TARGET_POWERPC64"
13629   "*
13631   if (which_alternative != 0)
13632     return \"#\";
13633   else if (get_attr_length (insn) == 4)
13634     return \"{bdn|bdnz} %l0\";
13635   else
13636     return \"bdz $+8\;b %l0\";
13638   [(set_attr "type" "branch")
13639    (set_attr "length" "*,12,16")])
13641 (define_insn "*ctrdi_internal5"
13642   [(set (pc)
13643         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
13644                           (const_int 1))
13645                       (label_ref (match_operand 0 "" ""))
13646                       (pc)))
13647    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13648         (plus:DI (match_dup 1)
13649                  (const_int -1)))
13650    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13651    (clobber (match_scratch:DI 4 "=X,X,r"))]
13652   "TARGET_POWERPC64"
13653   "*
13655   if (which_alternative != 0)
13656     return \"#\";
13657   else if (get_attr_length (insn) == 4)
13658     return \"bdz %l0\";
13659   else
13660     return \"{bdn|bdnz} $+8\;b %l0\";
13662   [(set_attr "type" "branch")
13663    (set_attr "length" "*,12,16")])
13665 (define_insn "*ctrdi_internal6"
13666   [(set (pc)
13667         (if_then_else (eq (match_operand:DI 1 "register_operand" "c,*r,*r")
13668                           (const_int 1))
13669                       (pc)
13670                       (label_ref (match_operand 0 "" ""))))
13671    (set (match_operand:DI 2 "register_operand" "=1,*r,m*c*l")
13672         (plus:DI (match_dup 1)
13673                  (const_int -1)))
13674    (clobber (match_scratch:CC 3 "=X,&x,&x"))
13675    (clobber (match_scratch:DI 4 "=X,X,r"))]
13676   "TARGET_POWERPC64"
13677   "*
13679   if (which_alternative != 0)
13680     return \"#\";
13681   else if (get_attr_length (insn) == 4)
13682     return \"{bdn|bdnz} %l0\";
13683   else
13684     return \"bdz $+8\;b %l0\";
13686   [(set_attr "type" "branch")
13687    (set_attr "length" "*,12,16")])
13689 ;; Now the splitters if we could not allocate the CTR register
13691 (define_split
13692   [(set (pc)
13693         (if_then_else (match_operator 2 "comparison_operator"
13694                                       [(match_operand:SI 1 "gpc_reg_operand" "")
13695                                        (const_int 1)])
13696                       (match_operand 5 "" "")
13697                       (match_operand 6 "" "")))
13698    (set (match_operand:SI 0 "gpc_reg_operand" "")
13699         (plus:SI (match_dup 1)
13700                  (const_int -1)))
13701    (clobber (match_scratch:CC 3 ""))
13702    (clobber (match_scratch:SI 4 ""))]
13703   "! TARGET_POWERPC64 && reload_completed"
13704   [(parallel [(set (match_dup 3)
13705                    (compare:CC (plus:SI (match_dup 1)
13706                                         (const_int -1))
13707                                (const_int 0)))
13708               (set (match_dup 0)
13709                    (plus:SI (match_dup 1)
13710                             (const_int -1)))])
13711    (set (pc) (if_then_else (match_dup 7)
13712                            (match_dup 5)
13713                            (match_dup 6)))]
13714   "
13715 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13716                          const0_rtx); }")
13718 (define_split
13719   [(set (pc)
13720         (if_then_else (match_operator 2 "comparison_operator"
13721                                       [(match_operand:SI 1 "gpc_reg_operand" "")
13722                                        (const_int 1)])
13723                       (match_operand 5 "" "")
13724                       (match_operand 6 "" "")))
13725    (set (match_operand:SI 0 "nonimmediate_operand" "")
13726         (plus:SI (match_dup 1) (const_int -1)))
13727    (clobber (match_scratch:CC 3 ""))
13728    (clobber (match_scratch:SI 4 ""))]
13729   "! TARGET_POWERPC64 && reload_completed
13730    && ! gpc_reg_operand (operands[0], SImode)"
13731   [(parallel [(set (match_dup 3)
13732                    (compare:CC (plus:SI (match_dup 1)
13733                                         (const_int -1))
13734                                (const_int 0)))
13735               (set (match_dup 4)
13736                    (plus:SI (match_dup 1)
13737                             (const_int -1)))])
13738    (set (match_dup 0)
13739         (match_dup 4))
13740    (set (pc) (if_then_else (match_dup 7)
13741                            (match_dup 5)
13742                            (match_dup 6)))]
13743   "
13744 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13745                          const0_rtx); }")
13746 (define_split
13747   [(set (pc)
13748         (if_then_else (match_operator 2 "comparison_operator"
13749                                       [(match_operand:DI 1 "gpc_reg_operand" "")
13750                                        (const_int 1)])
13751                       (match_operand 5 "" "")
13752                       (match_operand 6 "" "")))
13753    (set (match_operand:DI 0 "gpc_reg_operand" "")
13754         (plus:DI (match_dup 1)
13755                  (const_int -1)))
13756    (clobber (match_scratch:CC 3 ""))
13757    (clobber (match_scratch:DI 4 ""))]
13758   "TARGET_POWERPC64 && reload_completed"
13759   [(parallel [(set (match_dup 3)
13760                    (compare:CC (plus:DI (match_dup 1)
13761                                         (const_int -1))
13762                                (const_int 0)))
13763               (set (match_dup 0)
13764                    (plus:DI (match_dup 1)
13765                             (const_int -1)))])
13766    (set (pc) (if_then_else (match_dup 7)
13767                            (match_dup 5)
13768                            (match_dup 6)))]
13769   "
13770 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13771                          const0_rtx); }")
13773 (define_split
13774   [(set (pc)
13775         (if_then_else (match_operator 2 "comparison_operator"
13776                                       [(match_operand:DI 1 "gpc_reg_operand" "")
13777                                        (const_int 1)])
13778                       (match_operand 5 "" "")
13779                       (match_operand 6 "" "")))
13780    (set (match_operand:DI 0 "nonimmediate_operand" "")
13781         (plus:DI (match_dup 1) (const_int -1)))
13782    (clobber (match_scratch:CC 3 ""))
13783    (clobber (match_scratch:DI 4 ""))]
13784   "TARGET_POWERPC64 && reload_completed
13785    && ! gpc_reg_operand (operands[0], DImode)"
13786   [(parallel [(set (match_dup 3)
13787                    (compare:CC (plus:DI (match_dup 1)
13788                                         (const_int -1))
13789                                (const_int 0)))
13790               (set (match_dup 4)
13791                    (plus:DI (match_dup 1)
13792                             (const_int -1)))])
13793    (set (match_dup 0)
13794         (match_dup 4))
13795    (set (pc) (if_then_else (match_dup 7)
13796                            (match_dup 5)
13797                            (match_dup 6)))]
13798   "
13799 { operands[7] = gen_rtx (GET_CODE (operands[2]), VOIDmode, operands[3],
13800                          const0_rtx); }")
13803 (define_insn "trap"
13804   [(trap_if (const_int 1) (const_int 0))]
13805   ""
13806   "{t 31,0,0|trap}")
13808 (define_expand "conditional_trap"
13809   [(trap_if (match_operator 0 "trap_comparison_operator"
13810                             [(match_dup 2) (match_dup 3)])
13811             (match_operand 1 "const_int_operand" ""))]
13812   ""
13813   "if (rs6000_compare_fp_p || operands[1] != const0_rtx) FAIL;
13814    operands[2] = rs6000_compare_op0;
13815    operands[3] = rs6000_compare_op1;")
13817 (define_insn ""
13818   [(trap_if (match_operator 0 "trap_comparison_operator"
13819                             [(match_operand:SI 1 "register_operand" "r")
13820                              (match_operand:SI 2 "reg_or_short_operand" "rI")])
13821             (const_int 0))]
13822   ""
13823   "{t|tw}%V0%I2 %1,%2")
13825 (define_insn ""
13826   [(trap_if (match_operator 0 "trap_comparison_operator"
13827                             [(match_operand:DI 1 "register_operand" "r")
13828                              (match_operand:DI 2 "reg_or_short_operand" "rI")])
13829             (const_int 0))]
13830   "TARGET_POWERPC64"
13831   "td%V0%I2 %1,%2")
13833 ;; Insns related to generating the function prologue and epilogue.
13835 (define_expand "prologue"
13836   [(use (const_int 0))]
13837   "TARGET_SCHED_PROLOG"
13838   "
13840       rs6000_emit_prologue ();
13841       DONE;
13844 (define_insn "movesi_from_cr"
13845   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
13846         (unspec:SI [(reg:CC 68) (reg:CC 69) (reg:CC 70) (reg:CC 71) 
13847                     (reg:CC 72) (reg:CC 73) (reg:CC 74) (reg:CC 75)] 19))]
13848   ""
13849   "mfcr %0"
13850   [(set_attr "type" "cr_logical")])
13852 (define_insn "*stmw"
13853  [(match_parallel 0 "stmw_operation"
13854                   [(set (match_operand:SI 1 "memory_operand" "=m")
13855                         (match_operand:SI 2 "gpc_reg_operand" "r"))])]
13856  "TARGET_MULTIPLE"
13857  "{stm|stmw} %2,%1")
13859 (define_insn "*save_fpregs_si"
13860  [(match_parallel 0 "any_operand"
13861                   [(clobber (match_operand:SI 1 "register_operand" "=l"))
13862                    (use (match_operand:SI 2 "call_operand" "s"))
13863                    (set (match_operand:DF 3 "memory_operand" "=m")
13864                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13865  "TARGET_32BIT"
13866  "bl %z2")
13868 (define_insn "*save_fpregs_di"
13869  [(match_parallel 0 "any_operand"
13870                   [(clobber (match_operand:DI 1 "register_operand" "=l"))
13871                    (use (match_operand:DI 2 "call_operand" "s"))
13872                    (set (match_operand:DF 3 "memory_operand" "=m")
13873                         (match_operand:DF 4 "gpc_reg_operand" "f"))])]
13874  "TARGET_64BIT"
13875  "bl %z2")
13877 ; These are to explain that changes to the stack pointer should
13878 ; not be moved over stores to stack memory.
13879 (define_insn "stack_tie"
13880   [(set (match_operand:BLK 0 "memory_operand" "+m")
13881         (unspec:BLK [(match_dup 0)] 5))]
13882   ""
13883   ""
13884   [(set_attr "length" "0")])
13887 (define_expand "epilogue"
13888   [(use (const_int 0))]
13889   "TARGET_SCHED_PROLOG"
13890   "
13892       rs6000_emit_epilogue (FALSE);
13893       DONE;
13896 ; On some processors, doing the mtcrf one CC register at a time is
13897 ; faster (like on the 604e).  On others, doing them all at once is
13898 ; faster; for instance, on the 601 and 750.
13900 (define_expand "movsi_to_cr_one"
13901   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13902         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13903                     (match_dup 2)] 20))]
13904   ""
13905   "operands[2] = GEN_INT (1 << (75 - REGNO (operands[0])));")
13907 (define_insn "*movsi_to_cr"
13908   [(match_parallel 0 "mtcrf_operation"
13909                    [(set (match_operand:CC 1 "cc_reg_operand" "=y")
13910                          (unspec:CC [(match_operand:SI 2 "gpc_reg_operand" "r")
13911                                      (match_operand 3 "immediate_operand" "n")]
13912                          20))])]
13913  ""
13914  "*
13916   int mask = 0;
13917   int i;
13918   for (i = 0; i < XVECLEN (operands[0], 0); i++)
13919     mask |= INTVAL (XVECEXP (SET_SRC (XVECEXP (operands[0], 0, i)), 0, 1));
13920   operands[4] = GEN_INT (mask);
13921   return \"mtcrf %4,%2\";
13923   [(set_attr "type" "cr_logical")])
13925 (define_insn ""
13926   [(set (match_operand:CC 0 "cc_reg_operand" "=y")
13927         (unspec:CC [(match_operand:SI 1 "gpc_reg_operand" "r")
13928                     (match_operand 2 "immediate_operand" "n")] 20))]
13929   "GET_CODE (operands[0]) == REG 
13930    && CR_REGNO_P (REGNO (operands[0]))
13931    && GET_CODE (operands[2]) == CONST_INT
13932    && INTVAL (operands[2]) == 1 << (75 - REGNO (operands[0]))"
13933   "mtcrf %R0,%1"
13934   [(set_attr "type" "cr_logical")])
13936 ; The load-multiple instructions have similar properties.
13937 ; Note that "load_multiple" is a name known to the machine-independent
13938 ; code that actually corresponds to the powerpc load-string.
13940 (define_insn "*lmw"
13941   [(match_parallel 0 "lmw_operation"
13942                    [(set (match_operand:SI 1 "gpc_reg_operand" "=r")
13943                          (match_operand:SI 2 "memory_operand" "m"))])]
13944   "TARGET_MULTIPLE"
13945   "{lm|lmw} %1,%2")
13947 (define_insn "*return_internal_si"
13948   [(return)
13949    (use (match_operand:SI 0 "register_operand" "lc"))]
13950   "TARGET_32BIT"
13951   "b%T0"
13952   [(set_attr "type" "jmpreg")])
13954 (define_insn "*return_internal_di"
13955   [(return)
13956    (use (match_operand:DI 0 "register_operand" "lc"))]
13957   "TARGET_64BIT"
13958   "b%T0"
13959   [(set_attr "type" "jmpreg")])
13961 ; FIXME: This would probably be somewhat simpler if the Cygnus sibcall
13962 ; stuff was in GCC.  Oh, and "any_operand" is a bit flexible...
13964 (define_insn "*return_and_restore_fpregs_si"
13965  [(match_parallel 0 "any_operand"
13966                   [(return)
13967                    (use (match_operand:SI 1 "register_operand" "l"))
13968                    (use (match_operand:SI 2 "call_operand" "s"))
13969                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13970                         (match_operand:DF 4 "memory_operand" "m"))])]
13971  "TARGET_32BIT"
13972  "b %z2")
13974 (define_insn "*return_and_restore_fpregs_di"
13975  [(match_parallel 0 "any_operand"
13976                   [(return)
13977                    (use (match_operand:DI 1 "register_operand" "l"))
13978                    (use (match_operand:DI 2 "call_operand" "s"))
13979                    (set (match_operand:DF 3 "gpc_reg_operand" "=f")
13980                         (match_operand:DF 4 "memory_operand" "m"))])]
13981  "TARGET_64BIT"
13982  "b %z2")
13984 ; This is used in compiling the unwind routines.
13985 (define_expand "eh_return"
13986   [(use (match_operand 0 "general_operand" ""))
13987    (use (match_operand 1 "general_operand" ""))]
13988   ""
13989   "
13991 #if TARGET_AIX
13992     rs6000_emit_eh_toc_restore (operands[0]);
13993 #endif
13994   if (TARGET_32BIT)
13995     emit_insn (gen_eh_set_lr_si (operands[1]));
13996   else
13997     emit_insn (gen_eh_set_lr_di (operands[1]));
13998   emit_move_insn (EH_RETURN_STACKADJ_RTX, operands[0]);
13999   DONE;
14002 ; We can't expand this before we know where the link register is stored.
14003 (define_insn "eh_set_lr_si"
14004   [(unspec_volatile [(match_operand:SI 0 "register_operand" "r")] 9)
14005    (clobber (match_scratch:SI 1 "=&b"))]
14006   "TARGET_32BIT"
14007   "#")
14009 (define_insn "eh_set_lr_di"
14010   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")] 9)
14011    (clobber (match_scratch:DI 1 "=&b"))]
14012   "TARGET_64BIT"
14013   "#")
14015 (define_split
14016   [(unspec_volatile [(match_operand 0 "register_operand" "")] 9)
14017    (clobber (match_scratch 1 ""))]
14018   "reload_completed"
14019   [(const_int 0)]
14020   "
14022   rs6000_stack_t *info = rs6000_stack_info ();
14024   if (info->lr_save_p)
14025     {
14026       rtx frame_rtx = stack_pointer_rtx;
14027       int sp_offset = 0;
14028       rtx tmp;
14030       if (frame_pointer_needed
14031           || current_function_calls_alloca
14032           || info->total_size > 32767)
14033         {
14034           emit_move_insn (operands[1], gen_rtx_MEM (Pmode, frame_rtx));
14035           frame_rtx = operands[1];
14036         }
14037       else if (info->push_p)
14038         sp_offset = info->total_size;
14040       tmp = plus_constant (frame_rtx, info->lr_save_offset + sp_offset);
14041       tmp = gen_rtx_MEM (Pmode, tmp);
14042       emit_move_insn (tmp, operands[0]);
14043     }
14044   else
14045     emit_move_insn (gen_rtx_REG (Pmode, LINK_REGISTER_REGNUM), operands[0]);
14046   DONE;
14049 (define_insn "prefetch"
14050   [(prefetch (match_operand:V4SI 0 "address_operand" "p")
14051              (match_operand:SI 1 "const_int_operand" "n")
14052              (match_operand:SI 2 "const_int_operand" "n"))]
14053   "TARGET_POWERPC"
14054   "*
14056   if (GET_CODE (operands[0]) == REG)
14057     return INTVAL (operands[1]) ? \"dcbtst 0,%0\" : \"dcbt 0,%0\";
14058   return INTVAL (operands[1]) ? \"dcbtst %a0\" : \"dcbt %a0\";
14060   [(set_attr "type" "load")])
14062 ;; AltiVec patterns
14064 ;; Generic LVX load instruction.
14065 (define_insn "altivec_lvx_4si"
14066   [(set (match_operand:V4SI 0 "altivec_register_operand" "=v")
14067         (match_operand:V4SI 1 "memory_operand" "m"))]
14068   "TARGET_ALTIVEC"
14069   "lvx %0,%y1"
14070   [(set_attr "type" "vecload")])
14072 (define_insn "altivec_lvx_8hi"
14073   [(set (match_operand:V8HI 0 "altivec_register_operand" "=v")
14074         (match_operand:V8HI 1 "memory_operand" "m"))]
14075   "TARGET_ALTIVEC"
14076   "lvx %0,%y1"
14077   [(set_attr "type" "vecload")])
14079 (define_insn "altivec_lvx_16qi"
14080   [(set (match_operand:V16QI 0 "altivec_register_operand" "=v")
14081         (match_operand:V16QI 1 "memory_operand" "m"))]
14082   "TARGET_ALTIVEC"
14083   "lvx %0,%y1"
14084   [(set_attr "type" "vecload")])
14086 (define_insn "altivec_lvx_4sf"
14087   [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
14088         (match_operand:V4SF 1 "memory_operand" "m"))]
14089   "TARGET_ALTIVEC"
14090   "lvx %0,%y1"
14091   [(set_attr "type" "vecload")])
14093 ;; Generic STVX store instruction.
14094 (define_insn "altivec_stvx_4si"
14095   [(set (match_operand:V4SI 0 "memory_operand" "=m")
14096         (match_operand:V4SI 1 "altivec_register_operand" "v"))]
14097   "TARGET_ALTIVEC"
14098   "stvx %1,%y0"
14099   [(set_attr "type" "vecstore")])
14101 (define_insn "altivec_stvx_8hi"
14102   [(set (match_operand:V8HI 0 "memory_operand" "=m")
14103         (match_operand:V8HI 1 "altivec_register_operand" "v"))]
14104   "TARGET_ALTIVEC"
14105   "stvx %1,%y0"
14106   [(set_attr "type" "vecstore")])
14108 (define_insn "altivec_stvx_16qi"
14109   [(set (match_operand:V16QI 0 "memory_operand" "=m")
14110         (match_operand:V16QI 1 "altivec_register_operand" "v"))]
14111   "TARGET_ALTIVEC"
14112   "stvx %1,%y0"
14113   [(set_attr "type" "vecstore")])
14115 (define_insn "altivec_stvx_4sf"
14116   [(set (match_operand:V4SF 0 "memory_operand" "=m")
14117         (match_operand:V4SF 1 "altivec_register_operand" "v"))]
14118   "TARGET_ALTIVEC"
14119   "stvx %1,%y0"
14120   [(set_attr "type" "vecstore")])
14122 ;; Vector move instructions.
14123 (define_expand "movv4si"
14124   [(set (match_operand:V4SI 0 "nonimmediate_operand" "")
14125         (match_operand:V4SI 1 "any_operand" ""))]
14126   "TARGET_ALTIVEC"
14127   "{ rs6000_emit_move (operands[0], operands[1], V4SImode); DONE; }")
14129 (define_insn "*movv4si_internal"
14130   [(set (match_operand:V4SI 0 "nonimmediate_operand" "=m,v,v,o,r,r")
14131         (match_operand:V4SI 1 "input_operand" "v,m,v,r,o,r"))]
14132   "TARGET_ALTIVEC"
14133   "@
14134    stvx %1,%y0
14135    lvx %0,%y1
14136    vor %0,%1,%1
14137    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14138    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14139    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14140   [(set_attr "type" "altivec")
14141    (set_attr "length" "*,*,*,16,16,16")])
14143 (define_expand "movv8hi"
14144   [(set (match_operand:V8HI 0 "nonimmediate_operand" "")
14145         (match_operand:V8HI 1 "any_operand" ""))]
14146   "TARGET_ALTIVEC"
14147   "{ rs6000_emit_move (operands[0], operands[1], V8HImode); DONE; }")
14149 (define_insn "*movv8hi_internal1"
14150   [(set (match_operand:V8HI 0 "nonimmediate_operand" "=m,v,v,o,r,r")
14151         (match_operand:V8HI 1 "input_operand" "v,m,v,r,o,r"))]
14152   "TARGET_ALTIVEC"
14153   "@
14154    stvx %1,%y0
14155    lvx %0,%y1
14156    vor %0,%1,%1
14157    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14158    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14159    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14160   [(set_attr "type" "altivec")
14161    (set_attr "length" "*,*,*,16,16,16")])
14163 (define_expand "movv16qi"
14164   [(set (match_operand:V16QI 0 "nonimmediate_operand" "")
14165         (match_operand:V16QI 1 "any_operand" ""))]
14166   "TARGET_ALTIVEC"
14167   "{ rs6000_emit_move (operands[0], operands[1], V16QImode); DONE; }")
14169 (define_insn "*movv16qi_internal1"
14170   [(set (match_operand:V16QI 0 "nonimmediate_operand" "=m,v,v,o,r,r")
14171         (match_operand:V16QI 1 "input_operand" "v,m,v,r,o,r"))]
14172   "TARGET_ALTIVEC"
14173   "@
14174    stvx %1,%y0
14175    lvx %0,%y1
14176    vor %0,%1,%1
14177   stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14178   lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14179   mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14180   [(set_attr "type" "altivec")
14181    (set_attr "length" "*,*,*,16,16,16")])
14183 (define_expand "movv4sf"
14184   [(set (match_operand:V4SF 0 "nonimmediate_operand" "")
14185         (match_operand:V4SF 1 "any_operand" ""))]
14186   "TARGET_ALTIVEC"
14187   "{ rs6000_emit_move (operands[0], operands[1], V4SFmode); DONE; }")
14189 (define_insn "*movv4sf_internal1"
14190   [(set (match_operand:V4SF 0 "nonimmediate_operand" "=m,v,v,o,r,r")
14191         (match_operand:V4SF 1 "input_operand" "v,m,v,r,o,r"))]
14192   "TARGET_ALTIVEC"
14193   "@
14194    stvx %1,%y0
14195    lvx %0,%y1
14196    vor %0,%1,%1
14197    stw%U0 %1,%0\;stw %L1,%L0\;stw %Y1,%Y0\;stw %Z1,%Z0
14198    lwz%U1 %0,%1\;lwz %L0,%L1\;lwz %Y0,%Y1\;lwz %Z0,%Z1
14199    mr %0,%1\;mr %L0,%L1\;mr %Y0,%Y1\;mr %Z0,%Z1"
14200   [(set_attr "type" "altivec")
14201    (set_attr "length" "*,*,*,16,16,16")])
14203 (define_insn "get_vrsave_internal"
14204   [(set (match_operand:SI 0 "register_operand" "=r")
14205         (unspec:SI [(reg:SI 109)] 214))]
14206   "TARGET_ALTIVEC"
14207   "*
14209   if (TARGET_MACHO)
14210      return \"mfspr %0,256\";
14211   else
14212      return \"mfvrsave %0\";
14214   [(set_attr "type" "altivec")])
14216 (define_insn "*set_vrsave_internal"
14217   [(match_parallel 0 "vrsave_operation"
14218      [(set (reg:SI 109)
14219            (unspec_volatile:SI [(match_operand:SI 1 "register_operand" "r")
14220                                 (reg:SI 109)] 30))])]
14221   "TARGET_ALTIVEC"
14222   "*
14224   if (TARGET_MACHO)
14225     return \"mtspr 256,%1\";
14226   else
14227     return \"mtvrsave %1\";
14229   [(set_attr "type" "altivec")])
14231 ;; Vector clears
14232 (define_insn "*movv4si_const0"
14233   [(set (match_operand:V4SI 0 "altivec_register_operand" "=v")
14234         (match_operand:V4SI 1 "zero_constant" ""))]
14235   "TARGET_ALTIVEC"
14236   "vxor %0,%0,%0"
14237   [(set_attr "type" "vecsimple")])
14239 (define_insn "*movv4sf_const0"
14240   [(set (match_operand:V4SF 0 "altivec_register_operand" "=v")
14241         (match_operand:V4SF 1 "zero_constant" ""))]
14242                                          
14243   "TARGET_ALTIVEC"
14244   "vxor %0,%0,%0"
14245   [(set_attr "type" "vecsimple")])
14247 (define_insn "*movv8hi_const0"
14248   [(set (match_operand:V8HI 0 "altivec_register_operand" "=v")
14249         (match_operand:V8HI 1 "zero_constant" ""))]
14250   "TARGET_ALTIVEC"
14251   "vxor %0,%0,%0"
14252   [(set_attr "type" "vecsimple")])
14254 (define_insn "*movv16qi_const0"
14255   [(set (match_operand:V16QI 0 "altivec_register_operand" "=v")
14256         (match_operand:V16QI 1 "zero_constant" ""))]
14257   "TARGET_ALTIVEC"
14258   "vxor %0,%0,%0"
14259   [(set_attr "type" "vecsimple")])
14261 ;; Simple binary operations.
14263 (define_insn "addv16qi3"
14264   [(set (match_operand:V16QI 0 "register_operand" "=v")
14265         (plus:V16QI (match_operand:V16QI 1 "register_operand" "v")
14266                     (match_operand:V16QI 2 "register_operand" "v")))]
14267   "TARGET_ALTIVEC"
14268   "vaddubm %0,%1,%2"
14269   [(set_attr "type" "vecsimple")])
14271 (define_insn "addv8hi3"
14272   [(set (match_operand:V8HI 0 "register_operand" "=v")
14273         (plus:V8HI (match_operand:V8HI 1 "register_operand" "v")
14274                    (match_operand:V8HI 2 "register_operand" "v")))]
14275   "TARGET_ALTIVEC"
14276   "vadduhm %0,%1,%2"
14277   [(set_attr "type" "vecsimple")])
14279 (define_insn "addv4si3"
14280   [(set (match_operand:V4SI 0 "register_operand" "=v")
14281         (plus:V4SI (match_operand:V4SI 1 "register_operand" "v")
14282                    (match_operand:V4SI 2 "register_operand" "v")))]
14283   "TARGET_ALTIVEC"
14284   "vadduwm %0,%1,%2"
14285   [(set_attr "type" "vecsimple")])
14287 (define_insn "addv4sf3"
14288   [(set (match_operand:V4SF 0 "register_operand" "=v")
14289         (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
14290                    (match_operand:V4SF 2 "register_operand" "v")))]
14291   "TARGET_ALTIVEC"
14292   "vaddfp %0,%1,%2"
14293   [(set_attr "type" "vecfloat")])
14295 (define_insn "altivec_vaddcuw"
14296   [(set (match_operand:V4SI 0 "register_operand" "=v")
14297         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14298                       (match_operand:V4SI 2 "register_operand" "v")] 35))]
14299   "TARGET_ALTIVEC"
14300   "vaddcuw %0,%1,%2"
14301   [(set_attr "type" "vecsimple")])
14303 (define_insn "altivec_vaddubs"
14304   [(set (match_operand:V16QI 0 "register_operand" "=v")
14305         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14306                        (match_operand:V16QI 2 "register_operand" "v")] 36))
14307    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14308   "TARGET_ALTIVEC"
14309   "vaddubs %0,%1,%2"
14310   [(set_attr "type" "vecsimple")])
14312 (define_insn "altivec_vaddsbs"
14313   [(set (match_operand:V16QI 0 "register_operand" "=v")
14314         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14315                        (match_operand:V16QI 2 "register_operand" "v")] 37))
14316    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14317   "TARGET_ALTIVEC"
14318   "vaddsbs %0,%1,%2"
14319   [(set_attr "type" "vecsimple")])
14321 (define_insn "altivec_vadduhs"
14322   [(set (match_operand:V8HI 0 "register_operand" "=v")
14323         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14324                       (match_operand:V8HI 2 "register_operand" "v")] 38))
14325    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14326   "TARGET_ALTIVEC"
14327   "vadduhs %0,%1,%2"
14328   [(set_attr "type" "vecsimple")])
14330 (define_insn "altivec_vaddshs"
14331   [(set (match_operand:V8HI 0 "register_operand" "=v")
14332         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14333                       (match_operand:V8HI 2 "register_operand" "v")] 39))
14334    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14335   "TARGET_ALTIVEC"
14336   "vaddshs %0,%1,%2"
14337   [(set_attr "type" "vecsimple")])
14339 (define_insn "altivec_vadduws"
14340   [(set (match_operand:V4SI 0 "register_operand" "=v")
14341         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14342                       (match_operand:V4SI 2 "register_operand" "v")] 40))
14343    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14344   "TARGET_ALTIVEC"
14345   "vadduws %0,%1,%2"
14346   [(set_attr "type" "vecsimple")])
14348 (define_insn "altivec_vaddsws"
14349   [(set (match_operand:V4SI 0 "register_operand" "=v")
14350         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14351                       (match_operand:V4SI 2 "register_operand" "v")] 41))
14352    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14353   "TARGET_ALTIVEC"
14354   "vaddsws %0,%1,%2"
14355   [(set_attr "type" "vecsimple")])
14357 (define_insn "andv4si3"
14358   [(set (match_operand:V4SI 0 "register_operand" "=v")
14359         (and:V4SI (match_operand:V4SI 1 "register_operand" "v")
14360                   (match_operand:V4SI 2 "register_operand" "v")))]
14361   "TARGET_ALTIVEC"
14362   "vand %0,%1,%2"
14363   [(set_attr "type" "vecsimple")])
14365 (define_insn "altivec_vandc"
14366   [(set (match_operand:V4SI 0 "register_operand" "=v")
14367         (and:V4SI (match_operand:V4SI 1 "register_operand" "v")
14368                   (not:V4SI (match_operand:V4SI 2 "register_operand" "v"))))]
14369   "TARGET_ALTIVEC"
14370   "vandc %0,%1,%2"
14371   [(set_attr "type" "vecsimple")])
14373 (define_insn "altivec_vavgub"
14374   [(set (match_operand:V16QI 0 "register_operand" "=v")
14375         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14376                        (match_operand:V16QI 2 "register_operand" "v")] 44))]
14377   "TARGET_ALTIVEC"
14378   "vavgub %0,%1,%2"
14379   [(set_attr "type" "vecsimple")])
14381 (define_insn "altivec_vavgsb"
14382   [(set (match_operand:V16QI 0 "register_operand" "=v")
14383         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14384                        (match_operand:V16QI 2 "register_operand" "v")] 45))]
14385   "TARGET_ALTIVEC"
14386   "vavgsb %0,%1,%2"
14387   [(set_attr "type" "vecsimple")])
14389 (define_insn "altivec_vavguh"
14390   [(set (match_operand:V8HI 0 "register_operand" "=v")
14391         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14392                       (match_operand:V8HI 2 "register_operand" "v")] 46))]
14393   "TARGET_ALTIVEC"
14394   "vavguh %0,%1,%2"
14395   [(set_attr "type" "vecsimple")])
14397 (define_insn "altivec_vavgsh"
14398   [(set (match_operand:V8HI 0 "register_operand" "=v")
14399         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14400                       (match_operand:V8HI 2 "register_operand" "v")] 47))]
14401   "TARGET_ALTIVEC"
14402   "vavgsh %0,%1,%2"
14403   [(set_attr "type" "vecsimple")])
14405 (define_insn "altivec_vavguw"
14406   [(set (match_operand:V4SI 0 "register_operand" "=v")
14407         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14408                       (match_operand:V4SI 2 "register_operand" "v")] 48))]
14409   "TARGET_ALTIVEC"
14410   "vavguw %0,%1,%2"
14411   [(set_attr "type" "vecsimple")])
14413 (define_insn "altivec_vavgsw"
14414   [(set (match_operand:V4SI 0 "register_operand" "=v")
14415         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14416                       (match_operand:V4SI 2 "register_operand" "v")] 49))]
14417   "TARGET_ALTIVEC"
14418   "vavgsw %0,%1,%2"
14419   [(set_attr "type" "vecsimple")])
14421 (define_insn "altivec_vcmpbfp"
14422   [(set (match_operand:V4SI 0 "register_operand" "=v")
14423         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14424                       (match_operand:V4SF 2 "register_operand" "v")] 50))]
14425   "TARGET_ALTIVEC"
14426   "vcmpbfp %0,%1,%2"
14427   [(set_attr "type" "veccmp")])
14429 (define_insn "altivec_vcmpequb"
14430   [(set (match_operand:V16QI 0 "register_operand" "=v")
14431         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14432                        (match_operand:V16QI 2 "register_operand" "v")] 51))]
14433   "TARGET_ALTIVEC"
14434   "vcmpequb %0,%1,%2"
14435   [(set_attr "type" "vecsimple")])
14437 (define_insn "altivec_vcmpequh"
14438   [(set (match_operand:V8HI 0 "register_operand" "=v")
14439         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14440                       (match_operand:V8HI 2 "register_operand" "v")] 52))]
14441   "TARGET_ALTIVEC"
14442   "vcmpequh %0,%1,%2"
14443   [(set_attr "type" "vecsimple")])
14445 (define_insn "altivec_vcmpequw"
14446   [(set (match_operand:V4SI 0 "register_operand" "=v")
14447         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14448                       (match_operand:V4SI 2 "register_operand" "v")] 53))]
14449   "TARGET_ALTIVEC"
14450   "vcmpequw %0,%1,%2"
14451   [(set_attr "type" "vecsimple")])
14453 (define_insn "altivec_vcmpeqfp"
14454   [(set (match_operand:V4SI 0 "register_operand" "=v")
14455         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14456                       (match_operand:V4SF 2 "register_operand" "v")] 54))]
14457   "TARGET_ALTIVEC"
14458   "vcmpeqfp %0,%1,%2"
14459   [(set_attr "type" "veccmp")])
14461 (define_insn "altivec_vcmpgefp"
14462   [(set (match_operand:V4SI 0 "register_operand" "=v")
14463         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14464                       (match_operand:V4SF 2 "register_operand" "v")] 55))]
14465   "TARGET_ALTIVEC"
14466   "vcmpgefp %0,%1,%2"
14467   [(set_attr "type" "veccmp")])
14469 (define_insn "altivec_vcmpgtub"
14470   [(set (match_operand:V16QI 0 "register_operand" "=v")
14471         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14472                        (match_operand:V16QI 2 "register_operand" "v")] 56))]
14473   "TARGET_ALTIVEC"
14474   "vcmpgtub %0,%1,%2"
14475   [(set_attr "type" "vecsimple")])
14477 (define_insn "altivec_vcmpgtsb"
14478   [(set (match_operand:V16QI 0 "register_operand" "=v")
14479         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
14480                        (match_operand:V16QI 2 "register_operand" "v")] 57))]
14481   "TARGET_ALTIVEC"
14482   "vcmpgtsb %0,%1,%2"
14483   [(set_attr "type" "vecsimple")])
14485 (define_insn "altivec_vcmpgtuh"
14486   [(set (match_operand:V8HI 0 "register_operand" "=v")
14487         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14488                       (match_operand:V8HI 2 "register_operand" "v")] 58))]
14489   "TARGET_ALTIVEC"
14490   "vcmpgtuh %0,%1,%2"
14491   [(set_attr "type" "vecsimple")])
14493 (define_insn "altivec_vcmpgtsh"
14494   [(set (match_operand:V8HI 0 "register_operand" "=v")
14495         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14496                       (match_operand:V8HI 2 "register_operand" "v")] 59))]
14497   "TARGET_ALTIVEC"
14498   "vcmpgtsh %0,%1,%2"
14499   [(set_attr "type" "vecsimple")])
14501 (define_insn "altivec_vcmpgtuw"
14502   [(set (match_operand:V4SI 0 "register_operand" "=v")
14503         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14504                       (match_operand:V4SI 2 "register_operand" "v")] 60))]
14505   "TARGET_ALTIVEC"
14506   "vcmpgtuw %0,%1,%2"
14507   [(set_attr "type" "vecsimple")])
14509 (define_insn "altivec_vcmpgtsw"
14510   [(set (match_operand:V4SI 0 "register_operand" "=v")
14511         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
14512                       (match_operand:V4SI 2 "register_operand" "v")] 61))]
14513   "TARGET_ALTIVEC"
14514   "vcmpgtsw %0,%1,%2"
14515   [(set_attr "type" "vecsimple")])
14517 (define_insn "altivec_vcmpgtfp"
14518   [(set (match_operand:V4SI 0 "register_operand" "=v")
14519         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
14520                       (match_operand:V4SF 2 "register_operand" "v")] 62))]
14521   "TARGET_ALTIVEC"
14522   "vcmpgtfp %0,%1,%2"
14523   [(set_attr "type" "veccmp")])
14525 ;; Fused multiply add
14526 (define_insn "altivec_vmaddfp"
14527   [(set (match_operand:V4SF 0 "register_operand" "=v")
14528         (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14529                               (match_operand:V4SF 2 "register_operand" "v"))
14530                    (match_operand:V4SF 3 "register_operand" "v")))]
14531   "TARGET_ALTIVEC"
14532   "vmaddfp %0,%1,%2,%3"
14533   [(set_attr "type" "vecfloat")])
14535 ;; The unspec here is a vec splat of 0. We do multiply as a fused
14536 ;; multiply-add with an add of a 0 vector. 
14538 (define_expand "mulv4sf3"
14539   [(set (match_dup 3) (unspec:V4SF [(const_int 0)] 142))
14540    (set (match_operand:V4SF 0 "register_operand" "=v")
14541         (plus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14542                               (match_operand:V4SF 2 "register_operand" "v"))
14543                    (match_dup 3)))]
14544   "TARGET_ALTIVEC && TARGET_FUSED_MADD"
14545   "
14546 { operands[3] = gen_reg_rtx (V4SFmode); }")
14548 ;; Fused multiply subtract 
14549 (define_insn "altivec_vnmsubfp"
14550   [(set (match_operand:V4SF 0 "register_operand" "=v")
14551         (minus:V4SF (mult:V4SF (match_operand:V4SF 1 "register_operand" "v")
14552                                (match_operand:V4SF 2 "register_operand" "v"))
14553                     (match_operand:V4SF 3 "register_operand" "v")))]
14554   "TARGET_ALTIVEC"
14555   "vnmsubfp %0,%1,%2,%3"
14556   [(set_attr "type" "vecfloat")])
14559 (define_insn "altivec_vmsumubm"
14560   [(set (match_operand:V4SI 0 "register_operand" "=v")
14561         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
14562                       (match_operand:V16QI 2 "register_operand" "v")
14563                       (match_operand:V4SI 3 "register_operand" "v")] 65))]
14564   "TARGET_ALTIVEC"
14565   "vmsumubm %0, %1, %2, %3"
14566   [(set_attr "type" "veccomplex")])
14568 (define_insn "altivec_vmsummbm"
14569   [(set (match_operand:V4SI 0 "register_operand" "=v")
14570         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
14571                       (match_operand:V16QI 2 "register_operand" "v")
14572                       (match_operand:V4SI 3 "register_operand" "v")] 66))]
14573   "TARGET_ALTIVEC"
14574   "vmsumubm %0, %1, %2, %3"
14575   [(set_attr "type" "veccomplex")])
14577 (define_insn "altivec_vmsumuhm"
14578   [(set (match_operand:V4SI 0 "register_operand" "=v")
14579         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14580                       (match_operand:V8HI 2 "register_operand" "v")
14581                       (match_operand:V4SI 3 "register_operand" "v")] 67))]
14582   "TARGET_ALTIVEC"
14583   "vmsumuhm %0, %1, %2, %3"
14584   [(set_attr "type" "veccomplex")])
14586 (define_insn "altivec_vmsumshm"
14587   [(set (match_operand:V4SI 0 "register_operand" "=v")
14588         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14589                       (match_operand:V8HI 2 "register_operand" "v")
14590                       (match_operand:V4SI 3 "register_operand" "v")] 68))]
14591   "TARGET_ALTIVEC"
14592   "vmsumshm %0, %1, %2, %3"
14593   [(set_attr "type" "veccomplex")])
14595 (define_insn "altivec_vmsumuhs"
14596   [(set (match_operand:V4SI 0 "register_operand" "=v")
14597         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14598                       (match_operand:V8HI 2 "register_operand" "v")
14599                       (match_operand:V4SI 3 "register_operand" "v")] 69))
14600    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14601   "TARGET_ALTIVEC"
14602   "vmsumuhs %0, %1, %2, %3"
14603   [(set_attr "type" "veccomplex")])
14605 (define_insn "altivec_vmsumshs"
14606   [(set (match_operand:V4SI 0 "register_operand" "=v")
14607         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14608                       (match_operand:V8HI 2 "register_operand" "v")
14609                       (match_operand:V4SI 3 "register_operand" "v")] 70))
14610    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14611   "TARGET_ALTIVEC"
14612   "vmsumshs %0, %1, %2, %3"
14613   [(set_attr "type" "veccomplex")])
14615 (define_insn "umaxv16qi3"
14616   [(set (match_operand:V16QI 0 "register_operand" "=v")
14617         (umax:V16QI (match_operand:V16QI 1 "register_operand" "v")
14618                     (match_operand:V16QI 2 "register_operand" "v")))]
14619   "TARGET_ALTIVEC"
14620   "vmaxub %0,%1,%2"
14621   [(set_attr "type" "vecsimple")])
14623 (define_insn "smaxv16qi3"
14624   [(set (match_operand:V16QI 0 "register_operand" "=v")
14625         (smax:V16QI (match_operand:V16QI 1 "register_operand" "v")
14626                     (match_operand:V16QI 2 "register_operand" "v")))]
14627   "TARGET_ALTIVEC"
14628   "vmaxsb %0,%1,%2"
14629   [(set_attr "type" "vecsimple")])
14631 (define_insn "umaxv8hi3"
14632   [(set (match_operand:V8HI 0 "register_operand" "=v")
14633         (umax:V8HI (match_operand:V8HI 1 "register_operand" "v")
14634                    (match_operand:V8HI 2 "register_operand" "v")))]
14635   "TARGET_ALTIVEC"
14636   "vmaxuh %0,%1,%2"
14637   [(set_attr "type" "vecsimple")])
14639 (define_insn "smaxv8hi3"
14640   [(set (match_operand:V8HI 0 "register_operand" "=v")
14641         (smax:V8HI (match_operand:V8HI 1 "register_operand" "v")
14642                    (match_operand:V8HI 2 "register_operand" "v")))]
14643   "TARGET_ALTIVEC"
14644   "vmaxsh %0,%1,%2"
14645   [(set_attr "type" "vecsimple")])
14647 (define_insn "umaxv4si3"
14648   [(set (match_operand:V4SI 0 "register_operand" "=v")
14649         (umax:V4SI (match_operand:V4SI 1 "register_operand" "v")
14650                    (match_operand:V4SI 2 "register_operand" "v")))]
14651   "TARGET_ALTIVEC"
14652   "vmaxuw %0,%1,%2"
14653   [(set_attr "type" "vecsimple")])
14655 (define_insn "smaxv4si3"
14656   [(set (match_operand:V4SI 0 "register_operand" "=v")
14657         (smax:V4SI (match_operand:V4SI 1 "register_operand" "v")
14658                    (match_operand:V4SI 2 "register_operand" "v")))]
14659   "TARGET_ALTIVEC"
14660   "vmaxsw %0,%1,%2"
14661   [(set_attr "type" "vecsimple")])
14663 (define_insn "smaxv4sf3"
14664   [(set (match_operand:V4SF 0 "register_operand" "=v")
14665         (smax:V4SF (match_operand:V4SF 1 "register_operand" "v")
14666                    (match_operand:V4SF 2 "register_operand" "v")))]
14667   "TARGET_ALTIVEC"
14668   "vmaxfp %0,%1,%2"
14669   [(set_attr "type" "veccmp")])
14671 (define_insn "altivec_vmhaddshs"
14672   [(set (match_operand:V8HI 0 "register_operand" "=v")
14673         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14674                       (match_operand:V8HI 2 "register_operand" "v")
14675                       (match_operand:V8HI 3 "register_operand" "v")] 71))
14676    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14677   "TARGET_ALTIVEC"
14678   "vmhaddshs %0, %1, %2, %3"
14679   [(set_attr "type" "veccomplex")])
14680 (define_insn "altivec_vmhraddshs"
14681   [(set (match_operand:V8HI 0 "register_operand" "=v")
14682         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14683                       (match_operand:V8HI 2 "register_operand" "v")
14684                       (match_operand:V8HI 3 "register_operand" "v")] 72))
14685    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14686   "TARGET_ALTIVEC"
14687   "vmhraddshs %0, %1, %2, %3"
14688   [(set_attr "type" "veccomplex")])
14689 (define_insn "altivec_vmladduhm"
14690   [(set (match_operand:V8HI 0 "register_operand" "=v")
14691         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
14692                       (match_operand:V8HI 2 "register_operand" "v")
14693                       (match_operand:V8HI 3 "register_operand" "v")] 73))]
14694   "TARGET_ALTIVEC"
14695   "vmladduhm %0, %1, %2, %3"
14696   [(set_attr "type" "veccomplex")])
14698 (define_insn "altivec_vmrghb"
14699   [(set (match_operand:V16QI 0 "register_operand" "=v")
14700         (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 "register_operand" "v")
14701                                            (parallel [(const_int 8)
14702                                                       (const_int 9)
14703                                                       (const_int 10)
14704                                                       (const_int 11)
14705                                                       (const_int 12)
14706                                                       (const_int 13)
14707                                                       (const_int 14)
14708                                                       (const_int 15)
14709                                                       (const_int 0)
14710                                                       (const_int 1)
14711                                                       (const_int 2)
14712                                                       (const_int 3)
14713                                                       (const_int 4)
14714                                                       (const_int 5)
14715                                                       (const_int 6)
14716                                                       (const_int 7)]))
14717                       (match_operand:V16QI 2 "register_operand" "v")
14718                       (const_int 255)))]
14719   "TARGET_ALTIVEC"
14720   "vmrghb %0,%1,%2"
14721   [(set_attr "type" "vecperm")])
14723 (define_insn "altivec_vmrghh"
14724   [(set (match_operand:V8HI 0 "register_operand" "=v")
14725         (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 "register_operand" "v")
14726                                            (parallel [(const_int 4)
14727                                                       (const_int 5)
14728                                                       (const_int 6)
14729                                                       (const_int 7)
14730                                                       (const_int 0)
14731                                                       (const_int 1)
14732                                                       (const_int 2)
14733                                                       (const_int 3)]))
14734                       (match_operand:V8HI 2 "register_operand" "v")
14735                       (const_int 15)))]
14736   "TARGET_ALTIVEC"
14737   "vmrghh %0,%1,%2"
14738   [(set_attr "type" "vecperm")])
14740 (define_insn "altivec_vmrghw"
14741   [(set (match_operand:V4SI 0 "register_operand" "=v")
14742         (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 1 "register_operand" "v")
14743                                          (parallel [(const_int 2)
14744                                                     (const_int 3)
14745                                                     (const_int 0)
14746                                                     (const_int 1)]))
14747                       (match_operand:V4SI 2 "register_operand" "v")
14748                       (const_int 12)))]
14749   "TARGET_ALTIVEC"
14750   "vmrghw %0,%1,%2"
14751   [(set_attr "type" "vecperm")])
14753 (define_insn "altivec_vmrglb"
14754   [(set (match_operand:V16QI 0 "register_operand" "=v")
14755         (vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 2 "register_operand" "v")
14756                                            
14757                                            (parallel [(const_int 0)
14758                                                       (const_int 1)
14759                                                       (const_int 2)
14760                                                       (const_int 3)
14761                                                       (const_int 4)
14762                                                       (const_int 5)
14763                                                       (const_int 6)
14764                                                       (const_int 7)
14765                                                       (const_int 8)
14766                                                       (const_int 9)
14767                                                       (const_int 10)
14768                                                       (const_int 11)
14769                                                       (const_int 12)
14770                                                       (const_int 13)
14771                                                       (const_int 14)
14772                                                       (const_int 15)]))
14773                       (match_operand:V16QI 1 "register_operand" "v")
14774                       (const_int 255)))]
14775   "TARGET_ALTIVEC"
14776   "vmrglb %0,%1,%2"
14777   [(set_attr "type" "vecperm")])
14779 (define_insn "altivec_vmrglh"
14780   [(set (match_operand:V8HI 0 "register_operand" "=v")
14781         (vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 2 "register_operand" "v")
14782                                            (parallel [(const_int 0)
14783                                                       (const_int 1)
14784                                                       (const_int 2)
14785                                                       (const_int 3)
14786                                                       (const_int 4)
14787                                                       (const_int 5)
14788                                                       (const_int 6)
14789                                                       (const_int 7)]))
14790                       (match_operand:V8HI 1 "register_operand" "v")
14791                       (const_int 15)))]
14792   "TARGET_ALTIVEC"
14793   "vmrglh %0,%1,%2"
14794   [(set_attr "type" "vecperm")])
14796 (define_insn "altivec_vmrglw"
14797   [(set (match_operand:V4SI 0 "register_operand" "=v")
14798         (vec_merge:V4SI (vec_select:V4SI (match_operand:V4SI 2 "register_operand" "v")
14799                                          (parallel [(const_int 0)
14800                                                     (const_int 1)
14801                                                     (const_int 2)
14802                                                     (const_int 3)]))
14803                       (match_operand:V4SI 1 "register_operand" "v")
14804                       (const_int 12)))]
14805   "TARGET_ALTIVEC"
14806   "vmrglw %0,%1,%2"
14807   [(set_attr "type" "vecperm")])
14809 (define_insn "uminv16qi3"
14810   [(set (match_operand:V16QI 0 "register_operand" "=v")
14811         (umin:V16QI (match_operand:V16QI 1 "register_operand" "v")
14812                     (match_operand:V16QI 2 "register_operand" "v")))]
14813   "TARGET_ALTIVEC"
14814   "vminub %0,%1,%2"
14815   [(set_attr "type" "vecsimple")])
14817 (define_insn "sminv16qi3"
14818   [(set (match_operand:V16QI 0 "register_operand" "=v")
14819         (smin:V16QI (match_operand:V16QI 1 "register_operand" "v")
14820                     (match_operand:V16QI 2 "register_operand" "v")))]
14821   "TARGET_ALTIVEC"
14822   "vminsb %0,%1,%2"
14823   [(set_attr "type" "vecsimple")])
14825 (define_insn "uminv8hi3"
14826   [(set (match_operand:V8HI 0 "register_operand" "=v")
14827         (umin:V8HI (match_operand:V8HI 1 "register_operand" "v")
14828                    (match_operand:V8HI 2 "register_operand" "v")))]
14829   "TARGET_ALTIVEC"
14830   "vminuh %0,%1,%2"
14831   [(set_attr "type" "vecsimple")])
14833 (define_insn "sminv8hi3"
14834   [(set (match_operand:V8HI 0 "register_operand" "=v")
14835         (smin:V8HI (match_operand:V8HI 1 "register_operand" "v")
14836                    (match_operand:V8HI 2 "register_operand" "v")))]
14837   "TARGET_ALTIVEC"
14838   "vminsh %0,%1,%2"
14839   [(set_attr "type" "vecsimple")])
14841 (define_insn "uminv4si3"
14842   [(set (match_operand:V4SI 0 "register_operand" "=v")
14843         (umin:V4SI (match_operand:V4SI 1 "register_operand" "v")
14844                    (match_operand:V4SI 2 "register_operand" "v")))]
14845   "TARGET_ALTIVEC"
14846   "vminuw %0,%1,%2"
14847   [(set_attr "type" "vecsimple")])
14849 (define_insn "sminv4si3"
14850   [(set (match_operand:V4SI 0 "register_operand" "=v")
14851         (smin:V4SI (match_operand:V4SI 1 "register_operand" "v")
14852                    (match_operand:V4SI 2 "register_operand" "v")))]
14853   "TARGET_ALTIVEC"
14854   "vminsw %0,%1,%2"
14855   [(set_attr "type" "vecsimple")])
14857 (define_insn "sminv4sf3"
14858   [(set (match_operand:V4SF 0 "register_operand" "=v")
14859         (smin:V4SF (match_operand:V4SF 1 "register_operand" "v")
14860                    (match_operand:V4SF 2 "register_operand" "v")))]
14861   "TARGET_ALTIVEC"
14862   "vminfp %0,%1,%2"
14863   [(set_attr "type" "veccmp")])
14865 (define_insn "altivec_vmuleub"
14866   [(set (match_operand:V8HI 0 "register_operand" "=v")
14867         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14868                       (match_operand:V16QI 2 "register_operand" "v")] 83))]
14869   "TARGET_ALTIVEC"
14870   "vmuleub %0,%1,%2"
14871   [(set_attr "type" "veccomplex")])
14873 (define_insn "altivec_vmulesb"
14874   [(set (match_operand:V8HI 0 "register_operand" "=v")
14875         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14876                       (match_operand:V16QI 2 "register_operand" "v")] 84))]
14877   "TARGET_ALTIVEC"
14878   "vmulesb %0,%1,%2"
14879   [(set_attr "type" "veccomplex")])
14881 (define_insn "altivec_vmuleuh"
14882   [(set (match_operand:V4SI 0 "register_operand" "=v")
14883         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14884                       (match_operand:V8HI 2 "register_operand" "v")] 85))]
14885   "TARGET_ALTIVEC"
14886   "vmuleuh %0,%1,%2"
14887   [(set_attr "type" "veccomplex")])
14889 (define_insn "altivec_vmulesh"
14890   [(set (match_operand:V4SI 0 "register_operand" "=v")
14891         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14892                       (match_operand:V8HI 2 "register_operand" "v")] 86))]
14893   "TARGET_ALTIVEC"
14894   "vmulesh %0,%1,%2"
14895   [(set_attr "type" "veccomplex")])
14897 (define_insn "altivec_vmuloub"
14898   [(set (match_operand:V8HI 0 "register_operand" "=v")
14899         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14900                       (match_operand:V16QI 2 "register_operand" "v")] 87))]
14901   "TARGET_ALTIVEC"
14902   "vmuloub %0,%1,%2"
14903   [(set_attr "type" "veccomplex")])
14905 (define_insn "altivec_vmulosb"
14906   [(set (match_operand:V8HI 0 "register_operand" "=v")
14907         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")
14908                       (match_operand:V16QI 2 "register_operand" "v")] 88))]
14909   "TARGET_ALTIVEC"
14910   "vmulosb %0,%1,%2"
14911   [(set_attr "type" "veccomplex")])
14913 (define_insn "altivec_vmulouh"
14914   [(set (match_operand:V4SI 0 "register_operand" "=v")
14915         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14916                       (match_operand:V8HI 2 "register_operand" "v")] 89))]
14917   "TARGET_ALTIVEC"
14918   "vmulouh %0,%1,%2"
14919   [(set_attr "type" "veccomplex")])
14921 (define_insn "altivec_vmulosh"
14922   [(set (match_operand:V4SI 0 "register_operand" "=v")
14923         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
14924                       (match_operand:V8HI 2 "register_operand" "v")] 90))]
14925   "TARGET_ALTIVEC"
14926   "vmulosh %0,%1,%2"
14927   [(set_attr "type" "veccomplex")])
14929 (define_insn "altivec_vnor"
14930   [(set (match_operand:V4SI 0 "register_operand" "=v")
14931         (not:V4SI (ior:V4SI (match_operand:V4SI 1 "register_operand" "v")
14932                             (match_operand:V4SI 2 "register_operand" "v"))))]
14933   "TARGET_ALTIVEC"
14934   "vnor %0,%1,%2"
14935   [(set_attr "type" "vecsimple")])
14937 (define_insn "iorv4si3"
14938   [(set (match_operand:V4SI 0 "register_operand" "=v")
14939         (ior:V4SI (match_operand:V4SI 1 "register_operand" "v")
14940                   (match_operand:V4SI 2 "register_operand" "v")))]
14941   "TARGET_ALTIVEC"
14942   "vor %0,%1,%2"
14943   [(set_attr "type" "vecsimple")])
14945 (define_insn "altivec_vpkuhum"
14946   [(set (match_operand:V16QI 0 "register_operand" "=v")
14947         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14948                        (match_operand:V8HI 2 "register_operand" "v")] 93))]
14949   "TARGET_ALTIVEC"
14950   "vpkuhum %0,%1,%2"
14951   [(set_attr "type" "vecperm")])
14953 (define_insn "altivec_vpkuwum"
14954   [(set (match_operand:V8HI 0 "register_operand" "=v")
14955         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14956                       (match_operand:V4SI 2 "register_operand" "v")] 94))]
14957   "TARGET_ALTIVEC"
14958   "vpkuwum %0,%1,%2"
14959   [(set_attr "type" "vecperm")])
14961 (define_insn "altivec_vpkpx"
14962   [(set (match_operand:V8HI 0 "register_operand" "=v")
14963         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14964                       (match_operand:V4SI 2 "register_operand" "v")] 95))]
14965   "TARGET_ALTIVEC"
14966   "vpkpx %0,%1,%2"
14967   [(set_attr "type" "vecperm")])
14969 (define_insn "altivec_vpkuhss"
14970   [(set (match_operand:V16QI 0 "register_operand" "=v")
14971         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14972                        (match_operand:V8HI 2 "register_operand" "v")] 96))
14973    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14974   "TARGET_ALTIVEC"
14975   "vpkuhss %0,%1,%2"
14976   [(set_attr "type" "vecperm")])
14978 (define_insn "altivec_vpkshss"
14979   [(set (match_operand:V16QI 0 "register_operand" "=v")
14980         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
14981                        (match_operand:V8HI 2 "register_operand" "v")] 97))
14982    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14983   "TARGET_ALTIVEC"
14984   "vpkshss %0,%1,%2"
14985   [(set_attr "type" "vecperm")])
14987 (define_insn "altivec_vpkuwss"
14988   [(set (match_operand:V8HI 0 "register_operand" "=v")
14989         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14990                       (match_operand:V4SI 2 "register_operand" "v")] 98))
14991    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
14992   "TARGET_ALTIVEC"
14993   "vpkuwss %0,%1,%2"
14994   [(set_attr "type" "vecperm")])
14996 (define_insn "altivec_vpkswss"
14997   [(set (match_operand:V8HI 0 "register_operand" "=v")
14998         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
14999                       (match_operand:V4SI 2 "register_operand" "v")] 99))
15000    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15001   "TARGET_ALTIVEC"
15002   "vpkswss %0,%1,%2"
15003   [(set_attr "type" "vecperm")])
15005 (define_insn "altivec_vpkuhus"
15006   [(set (match_operand:V16QI 0 "register_operand" "=v")
15007         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
15008                        (match_operand:V8HI 2 "register_operand" "v")] 100))
15009    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15010   "TARGET_ALTIVEC"
15011   "vpkuhus %0,%1,%2"
15012   [(set_attr "type" "vecperm")])
15014 (define_insn "altivec_vpkshus"
15015   [(set (match_operand:V16QI 0 "register_operand" "=v")
15016         (unspec:V16QI [(match_operand:V8HI 1 "register_operand" "v")
15017                        (match_operand:V8HI 2 "register_operand" "v")] 101))
15018    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15019   "TARGET_ALTIVEC"
15020   "vpkshus %0,%1,%2"
15021   [(set_attr "type" "vecperm")])
15023 (define_insn "altivec_vpkuwus"
15024   [(set (match_operand:V8HI 0 "register_operand" "=v")
15025         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
15026                       (match_operand:V4SI 2 "register_operand" "v")] 102))
15027    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15028   "TARGET_ALTIVEC"
15029   "vpkuwus %0,%1,%2"
15030   [(set_attr "type" "vecperm")])
15032 (define_insn "altivec_vpkswus"
15033   [(set (match_operand:V8HI 0 "register_operand" "=v")
15034         (unspec:V8HI [(match_operand:V4SI 1 "register_operand" "v")
15035                       (match_operand:V4SI 2 "register_operand" "v")] 103))
15036    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15037   "TARGET_ALTIVEC"
15038   "vpkswus %0,%1,%2"
15039   [(set_attr "type" "vecperm")])
15041 (define_insn "altivec_vrlb"
15042   [(set (match_operand:V16QI 0 "register_operand" "=v")
15043         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15044                        (match_operand:V16QI 2 "register_operand" "v")] 104))]
15045   "TARGET_ALTIVEC"
15046   "vrlb %0,%1,%2"
15047   [(set_attr "type" "vecsimple")])
15049 (define_insn "altivec_vrlh"
15050   [(set (match_operand:V8HI 0 "register_operand" "=v")
15051         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15052                       (match_operand:V8HI 2 "register_operand" "v")] 105))]
15053   "TARGET_ALTIVEC"
15054   "vrlh %0,%1,%2"
15055   [(set_attr "type" "vecsimple")])
15057 (define_insn "altivec_vrlw"
15058   [(set (match_operand:V4SI 0 "register_operand" "=v")
15059         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15060                       (match_operand:V4SI 2 "register_operand" "v")] 106))]
15061   "TARGET_ALTIVEC"
15062   "vrlw %0,%1,%2"
15063   [(set_attr "type" "vecsimple")])
15065 (define_insn "altivec_vslb"
15066   [(set (match_operand:V16QI 0 "register_operand" "=v")
15067         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15068                        (match_operand:V16QI 2 "register_operand" "v")] 107))]
15069   "TARGET_ALTIVEC"
15070   "vslb %0,%1,%2"
15071   [(set_attr "type" "vecsimple")])
15073 (define_insn "altivec_vslh"
15074   [(set (match_operand:V8HI 0 "register_operand" "=v")
15075         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15076                       (match_operand:V8HI 2 "register_operand" "v")] 108))]
15077   "TARGET_ALTIVEC"
15078   "vslh %0,%1,%2"
15079   [(set_attr "type" "vecsimple")])
15081 (define_insn "altivec_vslw"
15082   [(set (match_operand:V4SI 0 "register_operand" "=v")
15083         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15084                       (match_operand:V4SI 2 "register_operand" "v")] 109))]
15085   "TARGET_ALTIVEC"
15086   "vslw %0,%1,%2"
15087   [(set_attr "type" "vecsimple")])
15089 (define_insn "altivec_vsl"
15090   [(set (match_operand:V4SI 0 "register_operand" "=v")
15091         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15092                       (match_operand:V4SI 2 "register_operand" "v")] 110))]
15093   "TARGET_ALTIVEC"
15094   "vsl %0,%1,%2"
15095   [(set_attr "type" "vecperm")])
15097 (define_insn "altivec_vslo"
15098   [(set (match_operand:V4SI 0 "register_operand" "=v")
15099         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15100                       (match_operand:V4SI 2 "register_operand" "v")] 111))]
15101   "TARGET_ALTIVEC"
15102   "vslo %0,%1,%2"
15103   [(set_attr "type" "vecperm")])
15105 (define_insn "altivec_vsrb"
15106   [(set (match_operand:V16QI 0 "register_operand" "=v")
15107         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15108                        (match_operand:V16QI 2 "register_operand" "v")] 112))]
15109   "TARGET_ALTIVEC"
15110   "vsrb %0,%1,%2"
15111   [(set_attr "type" "vecsimple")])
15113 (define_insn "altivec_vsrh"
15114   [(set (match_operand:V8HI 0 "register_operand" "=v")
15115         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15116                       (match_operand:V8HI 2 "register_operand" "v")] 113))]
15117   "TARGET_ALTIVEC"
15118   "vsrh %0,%1,%2"
15119   [(set_attr "type" "vecsimple")])
15121 (define_insn "altivec_vsrw"
15122   [(set (match_operand:V4SI 0 "register_operand" "=v")
15123         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15124                       (match_operand:V4SI 2 "register_operand" "v")] 114))]
15125   "TARGET_ALTIVEC"
15126   "vsrw %0,%1,%2"
15127   [(set_attr "type" "vecsimple")])
15129 (define_insn "altivec_vsrab"
15130   [(set (match_operand:V16QI 0 "register_operand" "=v")
15131         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15132                        (match_operand:V16QI 2 "register_operand" "v")] 115))]
15133   "TARGET_ALTIVEC"
15134   "vsrab %0,%1,%2"
15135   [(set_attr "type" "vecsimple")])
15137 (define_insn "altivec_vsrah"
15138   [(set (match_operand:V8HI 0 "register_operand" "=v")
15139         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15140                       (match_operand:V8HI 2 "register_operand" "v")] 116))]
15141   "TARGET_ALTIVEC"
15142   "vsrah %0,%1,%2"
15143   [(set_attr "type" "vecsimple")])
15145 (define_insn "altivec_vsraw"
15146   [(set (match_operand:V4SI 0 "register_operand" "=v")
15147         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15148                       (match_operand:V4SI 2 "register_operand" "v")] 117))]
15149   "TARGET_ALTIVEC"
15150   "vsraw %0,%1,%2"
15151   [(set_attr "type" "vecsimple")])
15153 (define_insn "altivec_vsr"
15154   [(set (match_operand:V4SI 0 "register_operand" "=v")
15155         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15156                       (match_operand:V4SI 2 "register_operand" "v")] 118))]
15157   "TARGET_ALTIVEC"
15158   "vsr %0,%1,%2"
15159   [(set_attr "type" "vecperm")])
15161 (define_insn "altivec_vsro"
15162   [(set (match_operand:V4SI 0 "register_operand" "=v")
15163         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15164                       (match_operand:V4SI 2 "register_operand" "v")] 119))]
15165   "TARGET_ALTIVEC"
15166   "vsro %0,%1,%2"
15167   [(set_attr "type" "vecperm")])
15169 (define_insn "subv16qi3"
15170   [(set (match_operand:V16QI 0 "register_operand" "=v")
15171         (minus:V16QI (match_operand:V16QI 1 "register_operand" "v")
15172                      (match_operand:V16QI 2 "register_operand" "v")))]
15173   "TARGET_ALTIVEC"
15174   "vsububm %0,%1,%2"
15175   [(set_attr "type" "vecsimple")])
15177 (define_insn "subv8hi3"
15178   [(set (match_operand:V8HI 0 "register_operand" "=v")
15179         (minus:V8HI (match_operand:V8HI 1 "register_operand" "v")
15180                     (match_operand:V8HI 2 "register_operand" "v")))]
15181   "TARGET_ALTIVEC"
15182   "vsubuhm %0,%1,%2"
15183   [(set_attr "type" "vecsimple")])
15185 (define_insn "subv4si3"
15186   [(set (match_operand:V4SI 0 "register_operand" "=v")
15187         (minus:V4SI (match_operand:V4SI 1 "register_operand" "v")
15188                     (match_operand:V4SI 2 "register_operand" "v")))]
15189   "TARGET_ALTIVEC"
15190   "vsubuwm %0,%1,%2"
15191   [(set_attr "type" "vecsimple")])
15193 (define_insn "subv4sf3"
15194   [(set (match_operand:V4SF 0 "register_operand" "=v")
15195         (minus:V4SF (match_operand:V4SF 1 "register_operand" "v")
15196                     (match_operand:V4SF 2 "register_operand" "v")))]
15197   "TARGET_ALTIVEC"
15198   "vsubfp %0,%1,%2"
15199   [(set_attr "type" "vecfloat")])
15201 (define_insn "altivec_vsubcuw"
15202   [(set (match_operand:V4SI 0 "register_operand" "=v")
15203         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15204                       (match_operand:V4SI 2 "register_operand" "v")] 124))]
15205   "TARGET_ALTIVEC"
15206   "vsubcuw %0,%1,%2"
15207   [(set_attr "type" "vecsimple")])
15209 (define_insn "altivec_vsububs"
15210   [(set (match_operand:V16QI 0 "register_operand" "=v")
15211         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15212                        (match_operand:V16QI 2 "register_operand" "v")] 125))
15213    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15214   "TARGET_ALTIVEC"
15215   "vsububs %0,%1,%2"
15216   [(set_attr "type" "vecsimple")])
15218 (define_insn "altivec_vsubsbs"
15219   [(set (match_operand:V16QI 0 "register_operand" "=v")
15220         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15221                        (match_operand:V16QI 2 "register_operand" "v")] 126))
15222    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15223   "TARGET_ALTIVEC"
15224   "vsubsbs %0,%1,%2"
15225   [(set_attr "type" "vecsimple")])
15227 (define_insn "altivec_vsubuhs"
15228   [(set (match_operand:V8HI 0 "register_operand" "=v")
15229         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15230                       (match_operand:V8HI 2 "register_operand" "v")] 127))
15231    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15232   "TARGET_ALTIVEC"
15233   "vsubuhs %0,%1,%2"
15234   [(set_attr "type" "vecsimple")])
15236 (define_insn "altivec_vsubshs"
15237   [(set (match_operand:V8HI 0 "register_operand" "=v")
15238         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15239                       (match_operand:V8HI 2 "register_operand" "v")] 128))
15240    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15241   "TARGET_ALTIVEC"
15242   "vsubshs %0,%1,%2"
15243   [(set_attr "type" "vecsimple")])
15245 (define_insn "altivec_vsubuws"
15246   [(set (match_operand:V4SI 0 "register_operand" "=v")
15247         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15248                       (match_operand:V4SI 2 "register_operand" "v")] 129))
15249    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15250   "TARGET_ALTIVEC"
15251   "vsubuws %0,%1,%2"
15252   [(set_attr "type" "vecsimple")])
15254 (define_insn "altivec_vsubsws"
15255   [(set (match_operand:V4SI 0 "register_operand" "=v")
15256         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15257                       (match_operand:V4SI 2 "register_operand" "v")] 130))
15258    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15259   "TARGET_ALTIVEC"
15260   "vsubsws %0,%1,%2"
15261   [(set_attr "type" "vecsimple")])
15263 (define_insn "altivec_vsum4ubs"
15264   [(set (match_operand:V4SI 0 "register_operand" "=v")
15265         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
15266                       (match_operand:V4SI 2 "register_operand" "v")] 131))
15267    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15268   "TARGET_ALTIVEC"
15269   "vsum4ubs %0,%1,%2"
15270   [(set_attr "type" "veccomplex")])
15272 (define_insn "altivec_vsum4sbs"
15273   [(set (match_operand:V4SI 0 "register_operand" "=v")
15274         (unspec:V4SI [(match_operand:V16QI 1 "register_operand" "v")
15275                       (match_operand:V4SI 2 "register_operand" "v")] 132))
15276    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15277   "TARGET_ALTIVEC"
15278   "vsum4sbs %0,%1,%2"
15279   [(set_attr "type" "veccomplex")])
15281 (define_insn "altivec_vsum4shs"
15282   [(set (match_operand:V4SI 0 "register_operand" "=v")
15283         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")
15284                       (match_operand:V4SI 2 "register_operand" "v")] 133))
15285    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15286   "TARGET_ALTIVEC"
15287   "vsum4shs %0,%1,%2"
15288   [(set_attr "type" "veccomplex")])
15290 (define_insn "altivec_vsum2sws"
15291   [(set (match_operand:V4SI 0 "register_operand" "=v")
15292         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15293                       (match_operand:V4SI 2 "register_operand" "v")] 134))
15294    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15295   "TARGET_ALTIVEC"
15296   "vsum2sws %0,%1,%2"
15297   [(set_attr "type" "veccomplex")])
15299 (define_insn "altivec_vsumsws"
15300   [(set (match_operand:V4SI 0 "register_operand" "=v")
15301         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15302                       (match_operand:V4SI 2 "register_operand" "v")] 135))
15303    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15304   "TARGET_ALTIVEC"
15305   "vsumsws %0,%1,%2"
15306   [(set_attr "type" "veccomplex")])
15308 (define_insn "xorv4si3"
15309   [(set (match_operand:V4SI 0 "register_operand" "=v")
15310         (xor:V4SI (match_operand:V4SI 1 "register_operand" "v")
15311                   (match_operand:V4SI 2 "register_operand" "v")))]
15312   "TARGET_ALTIVEC"
15313   "vxor %0,%1,%2"
15314   [(set_attr "type" "vecsimple")])
15316 (define_insn "altivec_vspltb"
15317   [(set (match_operand:V16QI 0 "register_operand" "=v")
15318         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15319                        (match_operand:QI 2 "immediate_operand" "i")] 136))]
15320   "TARGET_ALTIVEC"
15321   "vspltb %0,%1,%2"
15322   [(set_attr "type" "vecperm")])
15324 (define_insn "altivec_vsplth"
15325   [(set (match_operand:V8HI 0 "register_operand" "=v")
15326         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15327                       (match_operand:QI 2 "immediate_operand" "i")] 137))]
15328   "TARGET_ALTIVEC"
15329   "vsplth %0,%1,%2"
15330   [(set_attr "type" "vecperm")])
15332 (define_insn "altivec_vspltw"
15333   [(set (match_operand:V4SI 0 "register_operand" "=v")
15334         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15335                       (match_operand:QI 2 "immediate_operand" "i")] 138))]
15336   "TARGET_ALTIVEC"
15337   "vspltw %0,%1,%2"
15338   [(set_attr "type" "vecperm")])
15340 (define_insn "altivec_vspltisb"
15341   [(set (match_operand:V16QI 0 "register_operand" "=v")
15342         (unspec:V16QI [(match_operand:QI 1 "immediate_operand" "i")] 139))]
15343   "TARGET_ALTIVEC"
15344   "vspltisb %0, %1"
15345   [(set_attr "type" "vecsimple")])
15348 (define_insn "altivec_vspltish"
15349   [(set (match_operand:V8HI 0 "register_operand" "=v")
15350         (unspec:V8HI [(match_operand:QI 1 "immediate_operand" "i")] 140))]
15351   "TARGET_ALTIVEC"
15352   "vspltish %0, %1"
15353   [(set_attr "type" "vecsimple")])
15355 (define_insn "altivec_vspltisw"
15356   [(set (match_operand:V4SI 0 "register_operand" "=v")
15357         (unspec:V4SI [(match_operand:QI 1 "immediate_operand" "i")] 141))]
15358   "TARGET_ALTIVEC"
15359   "vspltisw %0, %1"
15360   [(set_attr "type" "vecsimple")])
15362 (define_insn ""
15363   [(set (match_operand:V4SF 0 "register_operand" "=v")
15364         (unspec:V4SF [(match_operand:QI 1 "immediate_operand" "i")] 142))]
15365   "TARGET_ALTIVEC"
15366   "vspltisw %0, %1"
15367   [(set_attr "type" "vecsimple")])
15369 (define_insn "ftruncv4sf2"
15370   [(set (match_operand:V4SF 0 "register_operand" "=v")
15371         (fix:V4SF (match_operand:V4SF 1 "register_operand" "v")))]
15372   "TARGET_ALTIVEC"
15373   "vrfiz %0, %1"
15374   [(set_attr "type" "vecfloat")])
15376 (define_insn "altivec_vperm_4si"
15377   [(set (match_operand:V4SI 0 "register_operand" "=v")
15378         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15379                       (match_operand:V4SI 2 "register_operand" "v")
15380                       (match_operand:V16QI 3 "register_operand" "v")] 144))]
15381   "TARGET_ALTIVEC"
15382   "vperm %0,%1,%2,%3"
15383   [(set_attr "type" "vecperm")])
15385 (define_insn "altivec_vperm_4sf"
15386   [(set (match_operand:V4SF 0 "register_operand" "=v")
15387         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15388                       (match_operand:V4SF 2 "register_operand" "v")
15389                       (match_operand:V16QI 3 "register_operand" "v")] 145))]
15390   "TARGET_ALTIVEC"
15391   "vperm %0,%1,%2,%3"
15392   [(set_attr "type" "vecperm")])
15394 (define_insn "altivec_vperm_8hi"
15395   [(set (match_operand:V8HI 0 "register_operand" "=v")
15396         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15397                       (match_operand:V8HI 2 "register_operand" "v")
15398                       (match_operand:V16QI 3 "register_operand" "v")] 146))]
15399   "TARGET_ALTIVEC"
15400   "vperm %0,%1,%2,%3"
15401   [(set_attr "type" "vecperm")])
15403 (define_insn "altivec_vperm_16qi"
15404   [(set (match_operand:V16QI 0 "register_operand" "=v")
15405         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15406                        (match_operand:V16QI 2 "register_operand" "v")
15407                        (match_operand:V16QI 3 "register_operand" "v")] 147))]
15408   "TARGET_ALTIVEC"
15409   "vperm %0,%1,%2,%3"
15410   [(set_attr "type" "vecperm")])
15412 (define_insn "altivec_vrfip"
15413   [(set (match_operand:V4SF 0 "register_operand" "=v")
15414         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 148))]
15415   "TARGET_ALTIVEC"
15416   "vrfip %0, %1"
15417   [(set_attr "type" "vecfloat")])
15419 (define_insn "altivec_vrfin"
15420   [(set (match_operand:V4SF 0 "register_operand" "=v")
15421         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 149))]
15422   "TARGET_ALTIVEC"
15423   "vrfin %0, %1"
15424   [(set_attr "type" "vecfloat")])
15426 (define_insn "altivec_vrfim"
15427   [(set (match_operand:V4SF 0 "register_operand" "=v")
15428         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 150))]
15429   "TARGET_ALTIVEC"
15430   "vrfim %0, %1"
15431   [(set_attr "type" "vecfloat")])
15433 (define_insn "altivec_vcfux"
15434   [(set (match_operand:V4SF 0 "register_operand" "=v")
15435         (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
15436                       (match_operand:QI 2 "immediate_operand" "i")] 151))]
15437   "TARGET_ALTIVEC"
15438   "vcfux %0, %1, %2"
15439   [(set_attr "type" "vecfloat")])
15441 (define_insn "altivec_vcfsx"
15442   [(set (match_operand:V4SF 0 "register_operand" "=v")
15443         (unspec:V4SF [(match_operand:V4SI 1 "register_operand" "v")
15444                       (match_operand:QI 2 "immediate_operand" "i")] 152))]
15445   "TARGET_ALTIVEC"
15446   "vcfsx %0, %1, %2"
15447   [(set_attr "type" "vecfloat")])
15449 (define_insn "altivec_vctuxs"
15450   [(set (match_operand:V4SI 0 "register_operand" "=v")
15451         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
15452                       (match_operand:QI 2 "immediate_operand" "i")] 153))
15453    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15454   "TARGET_ALTIVEC"
15455   "vctuxs %0, %1, %2"
15456   [(set_attr "type" "vecfloat")])
15458 (define_insn "altivec_vctsxs"
15459   [(set (match_operand:V4SI 0 "register_operand" "=v")
15460         (unspec:V4SI [(match_operand:V4SF 1 "register_operand" "v")
15461                       (match_operand:QI 2 "immediate_operand" "i")] 154))
15462    (set (reg:SI 110) (unspec:SI [(const_int 0)] 213))]
15463   "TARGET_ALTIVEC"
15464   "vctsxs %0, %1, %2"
15465   [(set_attr "type" "vecfloat")])
15467 (define_insn "altivec_vlogefp"
15468   [(set (match_operand:V4SF 0 "register_operand" "=v")
15469         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 155))]
15470   "TARGET_ALTIVEC"
15471   "vlogefp %0, %1"
15472   [(set_attr "type" "vecfloat")])
15474 (define_insn "altivec_vexptefp"
15475   [(set (match_operand:V4SF 0 "register_operand" "=v")
15476         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 156))]
15477   "TARGET_ALTIVEC"
15478   "vexptefp %0, %1"
15479   [(set_attr "type" "vecfloat")])
15481 (define_insn "altivec_vrsqrtefp"
15482   [(set (match_operand:V4SF 0 "register_operand" "=v")
15483         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 157))]
15484   "TARGET_ALTIVEC"
15485   "vrsqrtefp %0, %1"
15486   [(set_attr "type" "vecfloat")])
15488 (define_insn "altivec_vrefp"
15489   [(set (match_operand:V4SF 0 "register_operand" "=v")
15490         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")] 158))]
15491   "TARGET_ALTIVEC"
15492   "vrefp %0, %1"
15493   [(set_attr "type" "vecfloat")])
15495 (define_insn "altivec_vsel_4si"
15496   [(set (match_operand:V4SI 0 "register_operand" "=v")
15497         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15498                       (match_operand:V4SI 2 "register_operand" "v")
15499                       (match_operand:V4SI 3 "register_operand" "v")] 159))]
15500   "TARGET_ALTIVEC"
15501   "vsel %0,%1,%2,%3"
15502   [(set_attr "type" "vecperm")])
15504 (define_insn "altivec_vsel_4sf"
15505   [(set (match_operand:V4SF 0 "register_operand" "=v")
15506         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15507                       (match_operand:V4SF 2 "register_operand" "v")
15508                       (match_operand:V4SI 3 "register_operand" "v")] 160))]
15509   "TARGET_ALTIVEC"
15510   "vsel %0,%1,%2,%3"
15511   [(set_attr "type" "vecperm")])
15513 (define_insn "altivec_vsel_8hi"
15514   [(set (match_operand:V8HI 0 "register_operand" "=v")
15515         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15516                       (match_operand:V8HI 2 "register_operand" "v")
15517                       (match_operand:V8HI 3 "register_operand" "v")] 161))]
15518   "TARGET_ALTIVEC"
15519   "vsel %0,%1,%2,%3"
15520   [(set_attr "type" "vecperm")])
15522 (define_insn "altivec_vsel_16qi"
15523   [(set (match_operand:V16QI 0 "register_operand" "=v")
15524         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15525                        (match_operand:V16QI 2 "register_operand" "v")
15526                        (match_operand:V16QI 3 "register_operand" "v")] 162))]
15527   "TARGET_ALTIVEC"
15528   "vsel %0,%1,%2,%3"
15529   [(set_attr "type" "vecperm")])
15531 (define_insn "altivec_vsldoi_4si"
15532   [(set (match_operand:V4SI 0 "register_operand" "=v")
15533         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")
15534                       (match_operand:V4SI 2 "register_operand" "v")
15535                       (match_operand:QI 3 "immediate_operand" "i")] 163))]
15536   "TARGET_ALTIVEC"
15537   "vsldoi %0, %1, %2, %3"
15538   [(set_attr "type" "vecperm")])
15540 (define_insn "altivec_vsldoi_4sf"
15541   [(set (match_operand:V4SF 0 "register_operand" "=v")
15542         (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")
15543                       (match_operand:V4SF 2 "register_operand" "v")
15544                       (match_operand:QI 3 "immediate_operand" "i")] 164))]
15545   "TARGET_ALTIVEC"
15546   "vsldoi %0, %1, %2, %3"
15547   [(set_attr "type" "vecperm")])
15549 (define_insn "altivec_vsldoi_8hi"
15550   [(set (match_operand:V8HI 0 "register_operand" "=v")
15551         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")
15552                       (match_operand:V8HI 2 "register_operand" "v")
15553                       (match_operand:QI 3 "immediate_operand" "i")] 165))]
15554   "TARGET_ALTIVEC"
15555   "vsldoi %0, %1, %2, %3"
15556   [(set_attr "type" "vecperm")])
15558 (define_insn "altivec_vsldoi_16qi"
15559   [(set (match_operand:V16QI 0 "register_operand" "=v")
15560         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")
15561                        (match_operand:V16QI 2 "register_operand" "v")
15562                        (match_operand:QI 3 "immediate_operand" "i")] 166))]
15563   "TARGET_ALTIVEC"
15564   "vsldoi %0, %1, %2, %3"
15565   [(set_attr "type" "vecperm")])
15567 (define_insn "altivec_vupkhsb"
15568   [(set (match_operand:V8HI 0 "register_operand" "=v")
15569         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")] 167))]
15570   "TARGET_ALTIVEC"
15571   "vupkhsb %0, %1"
15572   [(set_attr "type" "vecperm")])
15574 (define_insn "altivec_vupkhpx"
15575   [(set (match_operand:V4SI 0 "register_operand" "=v")
15576         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 168))]
15577   "TARGET_ALTIVEC"
15578   "vupkhpx %0, %1"
15579   [(set_attr "type" "vecperm")])
15581 (define_insn "altivec_vupkhsh"
15582   [(set (match_operand:V4SI 0 "register_operand" "=v")
15583         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 169))]
15584   "TARGET_ALTIVEC"
15585   "vupkhsh %0, %1"
15586   [(set_attr "type" "vecperm")])
15588 (define_insn "altivec_vupklsb"
15589   [(set (match_operand:V8HI 0 "register_operand" "=v")
15590         (unspec:V8HI [(match_operand:V16QI 1 "register_operand" "v")] 170))]
15591   "TARGET_ALTIVEC"
15592   "vupklsb %0, %1"
15593   [(set_attr "type" "vecperm")])
15595 (define_insn "altivec_vupklpx"
15596   [(set (match_operand:V4SI 0 "register_operand" "=v")
15597         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 171))]
15598   "TARGET_ALTIVEC"
15599   "vupklpx %0, %1"
15600   [(set_attr "type" "vecperm")])
15602 (define_insn "altivec_vupklsh"
15603   [(set (match_operand:V4SI 0 "register_operand" "=v")
15604         (unspec:V4SI [(match_operand:V8HI 1 "register_operand" "v")] 172))]
15605   "TARGET_ALTIVEC"
15606   "vupklsh %0, %1"
15607   [(set_attr "type" "vecperm")])
15609 ;; AltiVec predicates.
15611 (define_expand "cr6_test_for_zero"
15612   [(set (match_operand:SI 0 "register_operand" "=r")
15613         (eq:SI (reg:CC 74)
15614                (const_int 0)))]
15615   "TARGET_ALTIVEC"
15616   "")   
15618 (define_expand "cr6_test_for_zero_reverse"
15619   [(set (match_operand:SI 0 "register_operand" "=r")
15620         (eq:SI (reg:CC 74)
15621                (const_int 0)))
15622    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
15623   "TARGET_ALTIVEC"
15624   "")
15626 (define_expand "cr6_test_for_lt"
15627   [(set (match_operand:SI 0 "register_operand" "=r")
15628         (lt:SI (reg:CC 74)
15629                (const_int 0)))]
15630   "TARGET_ALTIVEC"
15631   "")
15633 (define_expand "cr6_test_for_lt_reverse"
15634   [(set (match_operand:SI 0 "register_operand" "=r")
15635         (lt:SI (reg:CC 74)
15636                (const_int 0)))
15637    (set (match_dup 0) (minus:SI (const_int 1) (match_dup 0)))]
15638   "TARGET_ALTIVEC"
15639   "")
15641 ;; We can get away with generating the opcode on the fly (%3 below)
15642 ;; because all the predicates have the same scheduling parameters.
15644 (define_insn "altivec_predicate_v4si"
15645   [(set (reg:CC 74)
15646         (unspec:CC [(match_operand:V4SI 1 "register_operand" "v")
15647                     (match_operand:V4SI 2 "register_operand" "v")
15648                     (match_operand 3 "any_operand" "")] 173))
15649    (clobber (match_scratch:V4SI 0 "=v"))]
15650   "TARGET_ALTIVEC"
15651   "%3 %0,%1,%2"
15652 [(set_attr "type" "veccmp")])
15654 (define_insn "altivec_predicate_v4sf"
15655   [(set (reg:CC 74)
15656         (unspec:CC [(match_operand:V4SF 1 "register_operand" "v")
15657                     (match_operand:V4SF 2 "register_operand" "v")
15658                     (match_operand 3 "any_operand" "")] 174))
15659    (clobber (match_scratch:V4SF 0 "=v"))]
15660   "TARGET_ALTIVEC"
15661   "%3 %0,%1,%2"
15662 [(set_attr "type" "veccmp")])
15664 (define_insn "altivec_predicate_v8hi"
15665   [(set (reg:CC 74)
15666         (unspec:CC [(match_operand:V8HI 1 "register_operand" "v")
15667                     (match_operand:V8HI 2 "register_operand" "v")
15668                     (match_operand 3 "any_operand" "")] 175))
15669    (clobber (match_scratch:V8HI 0 "=v"))]
15670   "TARGET_ALTIVEC"
15671   "%3 %0,%1,%2"
15672 [(set_attr "type" "veccmp")])
15674 (define_insn "altivec_predicate_v16qi"
15675   [(set (reg:CC 74)
15676         (unspec:CC [(match_operand:V16QI 1 "register_operand" "v")
15677                     (match_operand:V16QI 2 "register_operand" "v")
15678                     (match_operand 3 "any_operand" "")] 175))
15679    (clobber (match_scratch:V16QI 0 "=v"))]
15680   "TARGET_ALTIVEC"
15681   "%3 %0,%1,%2"
15682 [(set_attr "type" "veccmp")])
15684 (define_insn "altivec_mtvscr"
15685   [(set (reg:SI 110)
15686         (unspec_volatile:SI
15687          [(match_operand:V4SI 0 "register_operand" "v")] 186))]
15688   "TARGET_ALTIVEC"
15689   "mtvscr %0"
15690   [(set_attr "type" "vecsimple")])
15692 (define_insn "altivec_mfvscr"
15693   [(set (match_operand:V8HI 0 "register_operand" "=v")
15694         (unspec_volatile:V8HI [(reg:SI 110)] 187))]
15695   "TARGET_ALTIVEC"
15696   "mfvscr %0"
15697   [(set_attr "type" "vecsimple")])
15699 (define_insn "altivec_dssall"
15700   [(unspec [(const_int 0)] 188)]
15701   "TARGET_ALTIVEC"
15702   "dssall"
15703   [(set_attr "type" "vecsimple")])
15705 (define_insn "altivec_dss"
15706   [(unspec [(match_operand:QI 0 "immediate_operand" "i")] 189)]
15707   "TARGET_ALTIVEC"
15708   "dss %0"
15709   [(set_attr "type" "vecsimple")])
15711 (define_insn "altivec_dst"
15712   [(unspec [(match_operand:SI 0 "register_operand" "b")
15713             (match_operand:SI 1 "register_operand" "r")
15714             (match_operand:QI 2 "immediate_operand" "i")] 190)]
15715   "TARGET_ALTIVEC"
15716   "dst %0,%1,%2"
15717   [(set_attr "type" "vecsimple")])
15719 (define_insn "altivec_dstt"
15720   [(unspec [(match_operand:SI 0 "register_operand" "b")
15721             (match_operand:SI 1 "register_operand" "r")
15722             (match_operand:QI 2 "immediate_operand" "i")] 191)]
15723   "TARGET_ALTIVEC"
15724   "dstt %0,%1,%2"
15725   [(set_attr "type" "vecsimple")])
15727 (define_insn "altivec_dstst"
15728   [(unspec [(match_operand:SI 0 "register_operand" "b")
15729             (match_operand:SI 1 "register_operand" "r")
15730             (match_operand:QI 2 "immediate_operand" "i")] 192)]
15731   "TARGET_ALTIVEC"
15732   "dstst %0,%1,%2"
15733   [(set_attr "type" "vecsimple")])
15735 (define_insn "altivec_dststt"
15736   [(unspec [(match_operand:SI 0 "register_operand" "b")
15737             (match_operand:SI 1 "register_operand" "r")
15738             (match_operand:QI 2 "immediate_operand" "i")] 193)]
15739   "TARGET_ALTIVEC"
15740   "dststt %0,%1,%2"
15741   [(set_attr "type" "vecsimple")])
15743 (define_insn "altivec_lvsl"
15744   [(set (match_operand:V16QI 0 "register_operand" "=v")
15745         (unspec:V16QI [(match_operand:SI 1 "register_operand" "b")
15746                        (match_operand:SI 2 "register_operand" "r")] 194))]
15747   "TARGET_ALTIVEC"
15748   "lvsl %0,%1,%2"
15749   [(set_attr "type" "vecload")])
15751 (define_insn "altivec_lvsr"
15752   [(set (match_operand:V16QI 0 "register_operand" "=v")
15753         (unspec:V16QI [(match_operand:SI 1 "register_operand" "b")
15754                        (match_operand:SI 2 "register_operand" "r")] 195))]
15755   "TARGET_ALTIVEC"
15756   "lvsr %0,%1,%2"
15757   [(set_attr "type" "vecload")])
15759 ;; Parallel some of the LVE* and STV*'s with unspecs because some have
15760 ;; identical rtl but different instructions-- and gcc gets confused.
15762 (define_insn "altivec_lvebx"
15763   [(parallel
15764     [(set (match_operand:V16QI 0 "register_operand" "=v")
15765           (mem:V16QI (plus:SI (match_operand:SI 1 "register_operand" "b")
15766                               (match_operand:SI 2 "register_operand" "r"))))
15767      (unspec [(const_int 0)] 196)])]
15768   "TARGET_ALTIVEC"
15769   "lvebx %0,%1,%2"
15770   [(set_attr "type" "vecload")])
15772 (define_insn "altivec_lvehx"
15773   [(parallel
15774     [(set (match_operand:V8HI 0 "register_operand" "=v")
15775           (mem:V8HI
15776            (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15777                             (match_operand:SI 2 "register_operand" "r"))
15778                    (const_int -2))))
15779      (unspec [(const_int 0)] 197)])]
15780   "TARGET_ALTIVEC"
15781   "lvehx %0,%1,%2"
15782   [(set_attr "type" "vecload")])
15784 (define_insn "altivec_lvewx"
15785   [(parallel
15786     [(set (match_operand:V4SI 0 "register_operand" "=v")
15787           (mem:V4SI
15788            (and:SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15789                             (match_operand:SI 2 "register_operand" "r"))
15790                    (const_int -4))))
15791      (unspec [(const_int 0)] 198)])]
15792   "TARGET_ALTIVEC"
15793   "lvewx %0,%1,%2"
15794   [(set_attr "type" "vecload")])
15796 (define_insn "altivec_lvxl"
15797   [(parallel
15798     [(set (match_operand:V4SI 0 "register_operand" "=v")
15799           (mem:V4SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15800                              (match_operand:SI 2 "register_operand" "r"))))
15801      (unspec [(const_int 0)] 213)])]
15802   "TARGET_ALTIVEC"
15803   "lvxl %0,%1,%2"
15804   [(set_attr "type" "vecload")])
15806 (define_insn "altivec_lvx"
15807   [(set (match_operand:V4SI 0 "register_operand" "=v")
15808         (mem:V4SI (plus:SI (match_operand:SI 1 "register_operand" "b")
15809                            (match_operand:SI 2 "register_operand" "r"))))]
15810   "TARGET_ALTIVEC"
15811   "lvx %0,%1,%2"
15812   [(set_attr "type" "vecload")])
15814 (define_insn "altivec_stvx"
15815   [(parallel
15816     [(set (mem:V4SI
15817            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15818                             (match_operand:SI 1 "register_operand" "r"))
15819                    (const_int -16)))
15820           (match_operand:V4SI 2 "register_operand" "v"))
15821      (unspec [(const_int 0)] 201)])]
15822   "TARGET_ALTIVEC"
15823   "stvx %2,%0,%1"
15824   [(set_attr "type" "vecstore")])
15826 (define_insn "altivec_stvxl"
15827   [(parallel
15828     [(set (mem:V4SI
15829            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15830                             (match_operand:SI 1 "register_operand" "r"))
15831                    (const_int -16)))
15832           (match_operand:V4SI 2 "register_operand" "v"))
15833      (unspec [(const_int 0)] 202)])]
15834   "TARGET_ALTIVEC"
15835   "stvxl %2,%0,%1"
15836   [(set_attr "type" "vecstore")])
15838 (define_insn "altivec_stvebx"
15839   [(parallel
15840     [(set (mem:V16QI
15841            (plus:SI (match_operand:SI 0 "register_operand" "b")
15842                     (match_operand:SI 1 "register_operand" "r")))
15843           (match_operand:V16QI 2 "register_operand" "v"))
15844      (unspec [(const_int 0)] 203)])]
15845   "TARGET_ALTIVEC"
15846   "stvebx %2,%0,%1"
15847   [(set_attr "type" "vecstore")])
15849 (define_insn "altivec_stvehx"
15850   [(parallel
15851     [(set (mem:V8HI
15852            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15853                             (match_operand:SI 1 "register_operand" "r"))
15854                    (const_int -2)))
15855           (match_operand:V8HI 2 "register_operand" "v"))
15856      (unspec [(const_int 0)] 204)])]
15857   "TARGET_ALTIVEC"
15858   "stvehx %2,%0,%1"
15859   [(set_attr "type" "vecstore")])
15861 (define_insn "altivec_stvewx"
15862   [(parallel
15863     [(set (mem:V4SI
15864            (and:SI (plus:SI (match_operand:SI 0 "register_operand" "b")
15865                             (match_operand:SI 1 "register_operand" "r"))
15866                    (const_int -4)))
15867           (match_operand:V4SI 2 "register_operand" "v"))
15868      (unspec [(const_int 0)] 205)])]
15869   "TARGET_ALTIVEC"
15870   "stvewx %2,%0,%1"
15871   [(set_attr "type" "vecstore")])
15873 (define_insn "absv16qi2"
15874   [(set (match_operand:V16QI 0 "register_operand" "=v")
15875         (abs:V16QI (match_operand:V16QI 1 "register_operand" "v")))
15876    (clobber (match_scratch:V16QI 2 "=v"))
15877    (clobber (match_scratch:V16QI 3 "=v"))]
15878   "TARGET_ALTIVEC"
15879   "vspltisb %2,0\;vsububm %3,%2,%1\;vmaxsb %0,%1,%3"
15880   [(set_attr "type" "altivec")
15881    (set_attr "length" "12")])
15883 (define_insn "absv8hi2"
15884   [(set (match_operand:V8HI 0 "register_operand" "=v")
15885         (abs:V8HI (match_operand:V8HI 1 "register_operand" "v")))
15886    (clobber (match_scratch:V8HI 2 "=v"))
15887    (clobber (match_scratch:V8HI 3 "=v"))]
15888   "TARGET_ALTIVEC"
15889   "vspltisb %2,0\;vsubuhm %3,%2,%1\;vmaxsh %0,%1,%3"
15890   [(set_attr "type" "altivec")
15891    (set_attr "length" "12")])
15893 (define_insn "absv4si2"
15894   [(set (match_operand:V4SI 0 "register_operand" "=v")
15895         (abs:V4SI (match_operand:V4SI 1 "register_operand" "v")))
15896    (clobber (match_scratch:V4SI 2 "=v"))
15897    (clobber (match_scratch:V4SI 3 "=v"))]
15898   "TARGET_ALTIVEC"
15899   "vspltisb %2,0\;vsubuwm %3,%2,%1\;vmaxsw %0,%1,%3"
15900   [(set_attr "type" "altivec")
15901    (set_attr "length" "12")])
15903 (define_insn "absv4sf2"
15904   [(set (match_operand:V4SF 0 "register_operand" "=v")
15905         (abs:V4SF (match_operand:V4SF 1 "register_operand" "v")))
15906    (clobber (match_scratch:V4SF 2 "=v"))
15907    (clobber (match_scratch:V4SF 3 "=v"))]
15908   "TARGET_ALTIVEC"
15909   "vspltisw %2, -1\;vslw %3,%2,%2\;vandc %0,%1,%3"
15910   [(set_attr "type" "altivec")
15911    (set_attr "length" "12")])
15913 (define_insn "altivec_abss_v16qi"
15914   [(set (match_operand:V16QI 0 "register_operand" "=v")
15915         (unspec:V16QI [(match_operand:V16QI 1 "register_operand" "v")] 210))
15916    (clobber (match_scratch:V16QI 2 "=v"))
15917    (clobber (match_scratch:V16QI 3 "=v"))]
15918   "TARGET_ALTIVEC"
15919   "vspltisb %2,0\;vsubsbs %3,%2,%1\;vmaxsb %0,%1,%3"
15920   [(set_attr "type" "altivec")
15921    (set_attr "length" "12")])
15923 (define_insn "altivec_abss_v8hi"
15924   [(set (match_operand:V8HI 0 "register_operand" "=v")
15925         (unspec:V8HI [(match_operand:V8HI 1 "register_operand" "v")] 211))
15926    (clobber (match_scratch:V8HI 2 "=v"))
15927    (clobber (match_scratch:V8HI 3 "=v"))]
15928   "TARGET_ALTIVEC"
15929   "vspltisb %2,0\;vsubshs %3,%2,%1\;vmaxsh %0,%1,%3"
15930   [(set_attr "type" "altivec")
15931    (set_attr "length" "12")])
15933 (define_insn "altivec_abss_v4si"
15934   [(set (match_operand:V4SI 0 "register_operand" "=v")
15935         (unspec:V4SI [(match_operand:V4SI 1 "register_operand" "v")] 212))
15936    (clobber (match_scratch:V4SI 2 "=v"))
15937    (clobber (match_scratch:V4SI 3 "=v"))]
15938   "TARGET_ALTIVEC"
15939   "vspltisb %2,0\;vsubsws %3,%2,%1\;vmaxsw %0,%1,%3"
15940   [(set_attr "type" "altivec")
15941    (set_attr "length" "12")])